CN106293946B - The method and server of resource acquisition - Google Patents
The method and server of resource acquisition Download PDFInfo
- Publication number
- CN106293946B CN106293946B CN201610681245.4A CN201610681245A CN106293946B CN 106293946 B CN106293946 B CN 106293946B CN 201610681245 A CN201610681245 A CN 201610681245A CN 106293946 B CN106293946 B CN 106293946B
- Authority
- CN
- China
- Prior art keywords
- resource
- server
- files
- blocks
- request message
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/50—Allocation of resources, e.g. of the central processing unit [CPU]
- G06F9/5005—Allocation of resources, e.g. of the central processing unit [CPU] to service a request
- G06F9/5011—Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
- G06F9/5016—Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals the resource being the memory
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/50—Allocation of resources, e.g. of the central processing unit [CPU]
- G06F9/5005—Allocation of resources, e.g. of the central processing unit [CPU] to service a request
- G06F9/5027—Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The invention discloses a kind of method of resource acquisition and servers, to solve existing resource database too small technical problem of handling capacity when concurrently accessing shared resource.This method comprises: server receives at least one resource request message that client is sent;The server carries out locking processing at least one described resource request message according to procedure lock, wherein described program lock allows the server only to handle a resource request message in synchronization;The server obtains the resource in memory queue according to first resource request message;Wherein, the first resource request message is any resource request message at least one described resource request message, and the resource that the server obtains in batches from resource database is stored in the memory queue;The resource got according to the first resource request message is returned to the client by the server.
Description
Technical field
The present invention relates to field of computer technology, and in particular, to a kind of method and server of resource acquisition.
Background technique
Database resource is locked currently, the resource-sharing under cluster environment generallys use optimistic locking, is avoided concurrent
Thread generates conflict when obtaining same resource.Wherein, the same resource in the database of resource-sharing can only be visited by a thread
It asks.
The realization mechanism to be accessed using optimistic locking to resource is as follows: firstly, the resource pool in database is got wait lock
Resource, then lock resource is treated using optimistic locking and is locked, wherein if locking is unsuccessful, relock, until being successfully
Only.After optimistic locking locks successfully, server takes resource away from database and resource is returned to client, and client is to resource
Processing after the completion of resource is removed from resource pool, if client returns to data to the processing failure of resource, by resource
In base resource pond.After optimistic locking locking, other threads cannot access to the resource, so as to avoid conflict.
From the foregoing, it will be observed that optimistic locking is locked for each resource of database, expense is excessive, and using optimistic
After lock locks resource, thread can only obtain a resource from database every time, cause the handling capacity of database too small.
Summary of the invention
The object of the present invention is to provide a kind of method of resource acquisition and servers, to solve existing resource database
The too small technical problem of handling capacity when concurrently accessing shared resource.
To achieve the goals above, the present invention provides a kind of method of resource acquisition, and the method is applied to server, institute
Server is stated to be connected with resource database, which comprises
Server receives at least one resource request message that client is sent, and the resource request message is for obtaining institute
State the resource in resource database;
The server carries out locking processing at least one described resource request message according to procedure lock, wherein described
Procedure lock allows the server only to handle a resource request message in synchronization, wherein in the resource database
Same resource can only be accessed by a resource request message;
The server obtains the resource in memory queue according to first resource request message;Wherein, the first resource
Request message is any resource request message at least one described resource request message, is stored in the memory queue
State the resource that server obtains in batches from the resource database;
The resource got according to the first resource request message is returned to the client by the server.
Optionally, the method also includes:
The server records the resource taken away by the client in the first blocks of files of lock queue;
The server receives the processing success message that the client is sent, and the processing success message is used to indicate institute
State the processing that client has completed the resource of the lock queue described to deposit;
The server is by the resource record of the lock queue into the second blocks of files for completing queue.
Optionally, the method also includes:
The server determines the recorded full resource of second blocks of files in the completion queue;
The server deletes the resource recorded in second blocks of files in the resource database.
Optionally, the server records the resource taken away by the client in the first blocks of files of lock queue
Later, the method also includes:
The server starts a timer;
The server determines the timer expiry, by the resource in second blocks of files and first blocks of files
It is compared;
The server is deleted recording in second blocks of files with first file in the resource database
Identical resource in block;
The resources different from second blocks of files recorded in first blocks of files are back to by the server
The resource database.
Optionally, the method also includes:
The server records the resource taken away by the client in the first blocks of files of lock queue;
The server receives the processing failure message that the client is sent, and the processing failure message is used to indicate institute
Client is stated to the processing failure of the resource;
The resource recorded in first blocks of files is back to the resource database by the server.
Optionally, the method also includes:
The server obtains resource in batches from the resource database, and the resource is stored in the memory team
Column.
The present invention also provides a kind of server, the server is connected with resource database, and the server includes:
Receiving unit, for receiving at least one resource request message of client transmission, the resource request message is used
Resource in the acquisition resource database;
Program lock unit carries out locking processing at least one described resource request message according to procedure lock, wherein described
Procedure lock allows the server only to handle a resource request message in synchronization, wherein in the resource database
Same resource can only be accessed by a resource request message;
First acquisition unit, for obtaining the resource in memory queue according to first resource request message;Wherein, described
One resource request message is any resource request message at least one described resource request message, is deposited in the memory queue
Contain the resource that the server obtains in batches from the resource database;
Response unit, for the resource got according to the first resource request message to be returned to the client.
Optionally, the server further includes recording unit, for lock queue the first blocks of files in record by
The resource that the client is taken away;
The receiving unit is also used to, and receives the processing success message that the client is sent, the processing success message
It is used to indicate the processing that the client has completed the resource of the lock queue described to deposit;
The recording unit is also used to, by the resource record of the lock queue into the second blocks of files for completing queue.
Optionally, the server further includes determination unit, for determining second file in the completion queue
The recorded full resource of block;
Unit is deleted, for deleting the resource recorded in second blocks of files in the resource database.
Optionally, the server further includes timing unit, for the recording unit lock queue the first file
After recording the resource taken away by the client in block, start a timer;
Comparing unit will be in second blocks of files and first blocks of files for determining the timer expiry
Resource be compared;
Delete unit, for deleted in the resource database recorded in second blocks of files with it is described first text
Identical resource in part block;
Resource return unit, the resources different from second blocks of files for will be recorded in first blocks of files
It is back to the resource database.
Optionally, the server further includes recording unit, for lock queue the first blocks of files in record by
The resource that the client is taken away;
The receiving unit is also used to, and receives the processing failure message that the client is sent, the processing failure message
The client is used to indicate to the processing failure of the resource;
Resource return unit, for the resource recorded in first blocks of files to be back to the resource database.
Optionally, the server further includes second acquisition unit, for obtaining money in batches from the resource database
Source, and the resource is stored in the memory queue.
Through the above technical solutions, the resource that server obtains in batches from resource database is stored in memory queue,
And thread is locked using procedure lock.Compared with prior art, lock mode of the invention is transferred to memory team by database
In column, the expense of lock resource is reduced.Also, resource can only be obtained from database by single every time compared to the prior art, this
Invention can obtain resource in batches from database, improve the data throughout in database resource pond.
Other features and advantages of the present invention will the following detailed description will be given in the detailed implementation section.
Detailed description of the invention
The drawings are intended to provide a further understanding of the invention, and constitutes part of specification, with following tool
Body embodiment is used to explain the present invention together, but is not construed as limiting the invention.In the accompanying drawings:
Fig. 1 is a kind of system architecture diagram in the prior art;
Fig. 2 is a kind of flow diagram of the method for resource acquisition provided in an embodiment of the present invention;
Fig. 3 is a kind of system architecture diagram provided in an embodiment of the present invention;
Fig. 4 is a kind of flow diagram of the method for resource acquisition based on system architecture shown in Fig. 3;
Fig. 5 A is a kind of structural schematic diagram of server provided in an embodiment of the present invention;
Fig. 5 B is the structural schematic diagram of another server provided in an embodiment of the present invention.
Specific embodiment
Below in conjunction with attached drawing, detailed description of the preferred embodiments.It should be understood that this place is retouched
The specific embodiment stated is merely to illustrate and explain the present invention, and is not intended to restrict the invention.
It is right first below in order to make those skilled in the art be easier to understand technical solution provided in an embodiment of the present invention
The relevant technical terms being related to simply are introduced.
Server cluster: with the development of e-commerce, people can easily utilize a website to buy various
Commodity.Incident is the continuous growth of the pageview of website and order volume, to the oncurrent processing ability of website operation system
It is required that higher and higher.No matter how powerful performance is for individual server, always has bottleneck, and there are problems that Single Point of Faliure.In such feelings
Under condition, occurs carrying out parallel computation using multiple computers in the prior art to obtain very high calculating speed, and lead to
It crosses multiple computers to backup, so that the technical side that whole system still can operate normally when any one machine breaks down
Case.Wherein, the combination of multiple computers is server cluster.
As shown in Figure 1, resource database is connected with each server in server cluster, each server be can receive
The resource request message that client is sent, each server, can be from resource database after receiving resource request message
It obtains resource and returns to client.Wherein, the same resource in the resource database can only be by one in server cluster
Node is accessed.The database of system, in this case, data for example, the resource database can be engaged in for train ticket
Base resource follows the principle for arriving first and first obtaining, and the user first accessed can first take train ticket away, in processing of the user to train ticket
Before completion, other users cannot get the train ticket again.
However, server cluster also brings the problem of access competition therewith.In the prior art, data access thread is without area
The optimistic locking in other competition data library brings greatly lock competition, reduces the handling capacity of entire cluster.
In order to solve the above-mentioned technical problem the embodiment of the present invention, provides a kind of method of resource acquisition, the execution of this method
Main body is server, which is connected with resource database.As shown in Fig. 2, this method comprises:
S201, server receive at least one resource request message that client is sent, and the resource request message is for obtaining
Take the resource in the resource database.
Wherein, the same resource in the resource database can only be accessed by a resource request message.
Illustratively, which is the database of train ticketing system, includes that each column train is not sold in resource pool
Train ticket.In this way, the lower single operation that each user is bought tickets using client sends first resource acquisition request to server.
Above-mentioned to be merely illustrative, the embodiment of the present invention can be also used for other resource databases, for example, shopping website
Merchandising database etc., which is not limited by the present invention.
S202, the server carry out locking processing at least one described resource request message according to procedure lock.
Wherein, described program lock allows the server only to handle a resource request message in synchronization.
Illustratively, the realization mechanism of procedure lock can be such that server is stored with lock configuration index, lock configuration index packet
Include lock resource and the status information of the lock resource.After the server receives resource request message, the server is according to the lock
The status information of resource determines whether the lock resource is in unused state, if the lock resource is in unused state, obtains
The lock resource, and the status information of the lock resource in the lock configuration index of the server is changed to use state.Get this
After locking resource, which obtains resource from memory queue according to the resource request message.And after getting resource, lock is matched
The status information for setting the lock resource in index is changed to unused state.
S203, the server obtain the resource in memory queue according to first resource request message.
Wherein, which is that any resource request at least one described resource request message disappears
It ceases, is stored with the resource that the server obtains in batches from the resource database in the memory queue.
That is, the server is in advance from a collection of resource of acquisition is stored in memory queue in batches in resource database.
In this way, the server after receiving resource request message, can directly get resource from memory queue.
The resource got according to the first resource request message is returned to the client by S204, the server.
By adopting the above technical scheme, the resource that server obtains in batches from resource database is stored in memory queue,
And thread is locked using procedure lock.Compared with prior art, lock mode of the invention is transferred to memory team by database
In column, the expense of lock resource is reduced.Also, resource can only be obtained from database by single every time compared to the prior art, this
Invention can obtain resource in batches from database, improve the data throughout in database resource pond.
In order to make those skilled in the art more understand technical solution provided in an embodiment of the present invention, below to above-mentioned money
The method that source obtains is described in detail.
Specifically, which independently can obtain resource from the resource database using a thread execution in batches,
And the step of resource is stored in the memory queue.Illustratively, which can be according to a fixed cycle from the resource data
Resource is obtained in library in batches, can also be triggered when detecting the resource in the memory queue lower than preset water level from number of resources
According to the resource deposit memory queue that obtains resource in library, and will acquire.
Further, in the embodiment of the present invention, which, can also be in lock queue after resource is returned to client
The first blocks of files in record the resource taken away by the client.Also, the server is receiving the client
It, can be by the resource record of the lock queue into the second blocks of files for completing queue after the processing success message of transmission.Wherein,
The processing success message is used to indicate the processing that the client has completed the resource of the lock queue described to deposit.
Further, it may be implemented based on second blocks of files and first blocks of files, the embodiment of the present invention to resource
Resource carries out batch removal in database.Specifically, including the following two kinds mode:
Mode one, the server when determining the recorded full resource of second blocks of files in the completion queue,
The resource recorded in second blocks of files is deleted in the resource database.
Specifically, whether which can be using recorded in second blocks of files of separate threads periodic test
Full resource, if so, the server from removing the resource recorded in second blocks of files in batches in the resource pool of resource database.
Compared to the prior art, client is every has handled a resource, and server is required to remove single resource, the present invention in database
Embodiment batch removes the handling capacity for improving database when concurrently accessing shared resource.
It is worth noting that may include multiple blocks of files in the completion queue in the specific implementation, server uses one
Whether a each blocks of files of thread poll records full resource, which is any file in the multiple blocks of files
Block.
With the database of train ticketing service net system for example, the resource request that the server receives client transmission disappears
After breath, the resource of first train ticket in memory queue is back to client according to sequencing, and by the train ticket
Information is recorded in the first blocks of files of lock queue.Client sends processing success message after payment confirmation, to the server,
After the server receives the processing success message, the information of the train ticket is recorded in the second blocks of files for completing queue.
The server handles every train ticket as procedure described above, in this way, the server is filled in detecting the second blocks of files
When the record of train ticket, the train ticket for having handled completion is removed in batches from the database.Wherein, in the resource pool of database
In, if a certain resource is put into memory queue by server acquisition, which can be marked the resource, refer to
Show that the resource is obtained by server, when server being avoided to obtain resource in batches next time, repetition gets the resource.If should
Resource is not by client process, then the resource is back to database by the server, i.e. deletion resource pool to the label of the resource,
When so that server obtaining resource in batches next time, the resource can be got again.
That is, the server records the resource taken away by the client in the first blocks of files of lock queue
Afterwards, if receiving the processing failure message of client transmission, the resource recorded in first blocks of files is back to described
Resource database.Wherein, the processing failure message is used to indicate the client to the processing failure of the resource.
Mode two, the server recorded in the first blocks of files of lock queue the resource taken away by the client it
Afterwards, start a timer;The server determines the timer expiry, will be in second blocks of files and first blocks of files
Resource be compared;The server deleted in the resource database recorded in second blocks of files with described first
Identical resource in blocks of files;The moneys different from second blocks of files that the server will record in first blocks of files
Source is back to the resource database.
Still with the database of train ticketing service net system for example, after train ticket information returns to client by server,
Start timing.If not receiving the processing success message of client return in 40 minutes, i.e., client is receiving clothes
It is engaged in after the train ticket information that device returns, does not pay the bill in 40 minutes, then the server needs the train ticket being back to data
Library.At this point, the information of the train ticket is recorded in the first blocks of files, it is not recorded in the second blocks of files, that is to say, that lock queue
The first blocks of files and complete in the second blocks of files of queue that the resource that records may be inconsistent, in this case, the first text
The resource recorded in part block and the second blocks of files is to have handled the resource of completion, and for this part resource, server can
It is removed with batch in the database;It is recorded in first blocks of files and Unrecorded resource is in the given time in the second blocks of files
The resource of untreated completion, for this part resource, which can be back to database in batches.Compared to the prior art
Single to remove and individually return, the embodiment of the present invention improves handling capacity of the database when concurrently accessing shared resource.
Above two mode is merely illustrative of, and in the specific implementation, can also delete mode, example using other batches
Such as, in the finish time of scheduled duration, directly batch deletes the resource that records in the second blocks of files in the database, without to the
One blocks of files is verified with the second blocks of files.Which is not limited by the present invention.
A kind of resource acquiring method provided in an embodiment of the present invention is illustrated below with reference to specific application scenarios.
Firstly, the connection framework of server and database is as shown in Figure 3.Server includes memory queue, lock queue and
Complete queue, wherein lock queue includes blocks of files 1 and blocks of files 2, and completing queue includes blocks of files 3 and blocks of files 4.Wherein, should
Server of the server as resource-sharing, upper layer are also connected with server cluster, and the server cluster is for receiving client
The resource request message sent is held, server described in the embodiment of the present invention receives the message that client is sent, Ke Yili
It solves to be that server cluster receives client message, then sends a message to the server of resource-sharing.In addition, resource-sharing
Server is also possible to a cluster, and server shown in Fig. 3 can be the primary server in resource sharing service device cluster.
It is worth noting that there was only primary server in the cluster of resource sharing service device for serve upper layers device, other servers are used
It backs up, is not shown one by one in Fig. 3 in order to facilitate understanding.
As shown in figure 4, in the case where the database of resource database shown in Fig. 3 for train ticketing system, the present invention
A kind of process of method for resource acquisition that embodiment provides includes:
S401, server obtain train ticket resource from resource database batch, and the train ticket resource write-in that will acquire
Memory queue.
Illustratively, if the capacity of memory queue is 2000, which can disposably be obtained from resource database
The resource of 2000 train tickets.
S402, the server receive at least one resource request message that client is sent.
It is worth noting that the server, which can be, obtains multiple resource request messages that different clients is sent, institute
Stating at least one resource request message can be the message that multiple client synchronization is sent to the server.The resource request
Message user obtains train ticket resource.
S403, the server determine the first resource request message of this processing based on program lock mechanism.
Specifically, for the resource request message on concurrent thread, which is based on procedure lock can be every time only to one
A resource request message is handled.Avoid conflict.The first resource request message is that at least one described resource request disappears
Any one resource request message in breath.
S404, the server obtain first train ticket according to the resource request message from memory queue, and by this
One train ticket is back to client.
It is worth noting that first train ticket in memory queue after taking out, which stores first fire
The data block of ticket is marked as invalid or is wiped, and server is avoided to repeat to obtain from the database next time to provide
Source.
First train ticket is recorded in the blocks of files 1 of lock queue by S405, the server.
S406, the server start a timer.
S407, the server judge whether the timer is overtime.
Further, if having not timed out, S408 and S409 are thened follow the steps;If overtime, S410 is thened follow the steps to S412.
First train ticket is recorded in by S408, the server when receiving the processing success message of client transmission
In the blocks of files 3 for completing queue.
S409, the server are deleted in the resource database when determining that this document block 3 is recorded expires train ticket information
All train tickets recorded except this document block 3.
Illustratively, the capacity of this document block 3 is 1000, then the server can be deleted disposably in resource database
1000 have handled successful train ticket.
This document block 1 is compared by S410, the server with the train ticket information in this document block 3.
S411, the server deleted in the resource database recorded in this document block 3 it is identical with this document block 1
Train ticket.
The train tickets different from this document block 3 recorded in this document block 1 are back to the resource by S412, the server
Database.
Using the above method, the resource that server obtains in batches from resource database is stored in memory queue, and adopt
Thread is locked with procedure lock.Compared with prior art, lock mode of the invention is transferred in memory queue by database,
Reduce the expense of lock resource.It, compared to the prior art can only be single every time also, referring to above-mentioned steps S401 and step S409
Item obtains resource from database, and the present invention can obtain resource in batches from database and batch removes resource, to mention
The data throughout in high database resource pond.
For above method embodiment, for simple description, therefore, it is stated as a series of action combinations, but this
Field technical staff should be aware of, and the present invention is not limited by the sequence of acts described.Secondly, those skilled in the art
It should be aware of, the embodiments described in the specification are all preferred embodiments, and related movement is not necessarily of the invention
It is necessary.
The embodiment of the present invention also provides a kind of server 50, and a kind of resource for implementing above method embodiment offer obtains
The method taken, wherein the server 50 is connected with resource database, and as shown in Figure 5A, which includes:
Receiving unit 501, for receiving at least one resource request message of client transmission, the resource request message
For obtaining the resource in the resource database.
Wherein, the same resource in the resource database can only be accessed by a resource request message.
Program lock unit 502 carries out locking processing at least one described resource request message according to procedure lock, wherein
Described program lock allows the server only to handle a resource request message in synchronization.
First acquisition unit 503, for obtaining the resource in memory queue according to first resource request message.Wherein, institute
Stating first resource request message is any resource request message at least one described resource request message, the memory queue
In be stored with the resource that the server obtains in batches from the resource database.
Response unit 504, for the resource got according to the first resource request message to be returned to the client
End.
Optionally, as shown in Figure 5 B, which further includes recording unit 505, for the first file in lock queue
The resource taken away by the client is recorded in block;The receiving unit 501 is also used to, and receives what the client was sent
Success message is handled, the processing success message is used to indicate the client and has completed to the resource for being stored in the lock queue
Processing;The recording unit 505 is also used to, by the resource record of the lock queue into the second blocks of files for completing queue.
Optionally, as shown in Figure 5 B, which further includes determination unit 506, for determining in the completion queue
The recorded full resource of second blocks of files;Unit 507 is deleted, for deleting described second in the resource database
The resource recorded in blocks of files.
Optionally, as shown in Figure 5 B, which further includes timing unit 508, for locking in the recording unit
After recording the resource taken away by the client in first blocks of files of queue, start a timer;Comparing unit
509, for determining the timer expiry, second blocks of files and the resource in first blocks of files are compared
Compared with;It is described delete unit 507 be used to delete in the resource database recorded in second blocks of files with described first
Identical resource in blocks of files;Resource return unit 510, for by being recorded in first blocks of files with second file
Different resources is back to the resource database in block.
Optionally, the recording unit 505 is used in the first blocks of files of lock queue record by the client
The resource taken away;The receiving unit 501 is also used to, and receives the processing failure message that the client is sent, and the processing is lost
It loses message and is used to indicate the client to the processing failure of the resource;The resource return unit 510 is also used to will be described
The resource recorded in first blocks of files is back to the resource database.
Optionally, as shown in Figure 5 B, which further includes second acquisition unit 511, is used for from the resource data
Resource is obtained in library in batches, and the resource is stored in the memory queue.
It is worth noting that the above dividing elements to server 50, only a kind of logical function partition, in actual implementation
There may be another division manner.Also, the physics realization of above-mentioned each functional unit may also be there are many implementation, the present invention
It does not limit this.
In addition, affiliated, it will be apparent to those skilled in the art ground to recognize, for convenience and simplicity of description, foregoing description
Server each unit specific work process, can refer to corresponding processes in the foregoing method embodiment, it is no longer superfluous herein
It states.
In embodiment provided herein, it should be understood that disclosed device and method can pass through others
Mode is realized.It, can also be with for example, the functional units in various embodiments of the present invention may be integrated into one processing unit
It is that each unit physically exists alone, can also be integrated in one unit with two or more units.Above-mentioned integrated list
Member both can take the form of hardware realization, can also realize in the form of hardware adds SFU software functional unit.
The above-mentioned integrated unit being realized in the form of SFU software functional unit can store and computer-readable deposit at one
In storage media.Above-mentioned SFU software functional unit is stored in a storage medium, including some instructions are used so that a computer
Equipment (can be personal computer, server or the network equipment etc.) executes the portion of each embodiment the method for the present invention
Step by step.And storage medium above-mentioned includes: USB flash disk, mobile hard disk, RAM (deposit by Random Access Memory, arbitrary access
Reservoir), the various media that can store data such as magnetic or disk.
The above description is merely a specific embodiment, but scope of protection of the present invention is not limited thereto, any
In the technical scope disclosed by the present invention, any changes or substitutions that can be easily thought of by those familiar with the art, all answers
It is included within the scope of the present invention.Therefore, protection scope of the present invention should be subject to the protection scope in claims.
Claims (8)
1. a kind of method of resource acquisition, which is characterized in that the method is applied to server, the server and resource data
Library is connected, which comprises
Server receives at least one resource request message that client is sent, and the resource request message is for obtaining the money
Resource in source database, wherein the same resource in the resource database can only be accessed by a resource request message;
The server carries out locking processing at least one described resource request message according to procedure lock, wherein described program
Lock allows the server only to handle a resource request message in synchronization;
The server obtains the resource in memory queue according to first resource request message;Wherein, the first resource request
Message is any resource request message at least one described resource request message, is stored with the clothes in the memory queue
The resource that business device obtains in batches from the resource database;
The resource got according to the first resource request message is returned to the client by the server;
The method also includes:
The server records the resource taken away by the client in the first blocks of files of lock queue;
The server receives the processing success message that the client is sent, and the processing success message is used to indicate the visitor
The processing to the resource for being stored in the lock queue is completed in family end;
The server is by the resource record of the lock queue into the second blocks of files for completing queue;
The server determines the recorded full resource of second blocks of files in the completion queue;
The server deletes the resource recorded in second blocks of files in the resource database.
2. the method according to claim 1, wherein the server records in the first blocks of files of lock queue
After the resource taken away by the client, the method also includes:
The server starts a timer;
The server determines the timer expiry, and the resource in second blocks of files and first blocks of files is carried out
Compare;
The server deleted in the resource database recorded in second blocks of files in first blocks of files
Identical resource;
The resources different from second blocks of files recorded in first blocks of files are back to described by the server
Resource database.
3. the method according to claim 1, wherein the method also includes:
The server records the resource taken away by the client in the first blocks of files of lock queue;
The server receives the processing failure message that the client is sent, and the processing failure message is used to indicate the visitor
Processing failure of the family end to the resource;
The resource recorded in first blocks of files is back to the resource database by the server.
4. method according to any one of claims 1 to 3, which is characterized in that the method also includes:
The server obtains resource in batches from the resource database, and the resource is stored in the memory queue.
5. a kind of server, which is characterized in that the server is connected with resource database, and the server includes:
Receiving unit, for receiving at least one resource request message of client transmission, the resource request message is for obtaining
Take the resource in the resource database;
Program lock unit carries out locking processing at least one described resource request message according to procedure lock, wherein described program
Lock allows the server only to handle a resource request message in synchronization, wherein same in the resource database
Resource can only be accessed by a resource request message;
First acquisition unit, for obtaining the resource in memory queue according to first resource request message;Wherein, first money
Source request message is any resource request message at least one described resource request message, is stored in the memory queue
The resource that the server obtains in batches from the resource database;
Response unit, for the resource got according to the first resource request message to be returned to the client;
The server further includes recording unit, is taken by the client for recording in the first blocks of files of lock queue
The resource walked;
The receiving unit is also used to, and receives the processing success message that the client is sent, and the processing success message is used for
Indicate that the client has completed the processing to the resource for being stored in the lock queue;
The recording unit is also used to, by the resource record of the lock queue into the second blocks of files for completing queue;
The server further includes determination unit, for determining that second blocks of files in the completion queue is recorded full
Resource;
Unit is deleted, for deleting the resource recorded in second blocks of files in the resource database.
6. server according to claim 5, which is characterized in that further include timing unit, in the recording unit
After recording the resource taken away by the client in the first blocks of files of lock queue, start a timer;
Comparing unit, for determining the timer expiry, by the money in second blocks of files and first blocks of files
Source is compared;
Unit is deleted, it is being recorded in second blocks of files with first blocks of files for being deleted in the resource database
In identical resource;
Resource return unit, for returning to the resources different from second blocks of files recorded in first blocks of files
To the resource database.
7. server according to claim 5, which is characterized in that further include recording unit, for the first of lock queue
The resource taken away by the client is recorded in blocks of files;
The receiving unit is also used to, and receives the processing failure message that the client is sent, and the processing failure message is used for
Indicate the client to the processing failure of the resource;
Resource return unit, for the resource recorded in first blocks of files to be back to the resource database.
8. according to the described in any item servers of claim 5 to 7, which is characterized in that further include second acquisition unit, for from
Resource is obtained in the resource database in batches, and the resource is stored in the memory queue.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201610681245.4A CN106293946B (en) | 2016-08-16 | 2016-08-16 | The method and server of resource acquisition |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201610681245.4A CN106293946B (en) | 2016-08-16 | 2016-08-16 | The method and server of resource acquisition |
Publications (2)
Publication Number | Publication Date |
---|---|
CN106293946A CN106293946A (en) | 2017-01-04 |
CN106293946B true CN106293946B (en) | 2019-11-08 |
Family
ID=57679584
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201610681245.4A Active CN106293946B (en) | 2016-08-16 | 2016-08-16 | The method and server of resource acquisition |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN106293946B (en) |
Families Citing this family (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN108182599A (en) * | 2017-12-27 | 2018-06-19 | 五八有限公司 | One kind is registered bonusing method, equipment and computer readable storage medium |
CN110515706B (en) * | 2019-08-16 | 2022-07-08 | 苏州浪潮智能科技有限公司 | Request processing method, device, equipment and readable storage medium |
CN110716936B (en) * | 2019-10-12 | 2022-04-05 | 浪潮云信息技术股份公司 | Database optimistic lock implementation method and system based on SpringBoot + JPA |
CN113207012A (en) * | 2021-04-30 | 2021-08-03 | 北京奇艺世纪科技有限公司 | Resource acquisition method and device, electronic equipment and readable storage medium |
CN114006946B (en) * | 2021-10-29 | 2023-08-29 | 中国平安人寿保险股份有限公司 | Method, device, equipment and storage medium for processing homogeneous resource request |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1773481A (en) * | 2004-11-12 | 2006-05-17 | 国际商业机器公司 | Method and system for processing complexes to access shared devices |
CN1808389A (en) * | 2006-02-20 | 2006-07-26 | 南京联创科技股份有限公司 | Autonomous locking method based on shared memory for account background memory database |
CN104008100A (en) * | 2013-02-21 | 2014-08-27 | 纽海信息技术(上海)有限公司 | Cluster environment concurrent processing method |
-
2016
- 2016-08-16 CN CN201610681245.4A patent/CN106293946B/en active Active
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1773481A (en) * | 2004-11-12 | 2006-05-17 | 国际商业机器公司 | Method and system for processing complexes to access shared devices |
CN1808389A (en) * | 2006-02-20 | 2006-07-26 | 南京联创科技股份有限公司 | Autonomous locking method based on shared memory for account background memory database |
CN104008100A (en) * | 2013-02-21 | 2014-08-27 | 纽海信息技术(上海)有限公司 | Cluster environment concurrent processing method |
Also Published As
Publication number | Publication date |
---|---|
CN106293946A (en) | 2017-01-04 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN106293946B (en) | The method and server of resource acquisition | |
CN103186554B (en) | Distributed data mirror method and storage back end | |
JP5677298B2 (en) | Parallel data processing and electronic bookkeeping | |
CN110400612A (en) | Managing user information | |
CN108520307A (en) | Data processing method and relevant apparatus | |
CN106657228A (en) | Crawler realizing method using cloud terminal for concurrent acquisition | |
CN103116634A (en) | System for supporting high concurrent cache task queue and asynchronous batch operation method thereof | |
CN107783842B (en) | Distributed lock implementation method, device and storage device | |
CN109271115A (en) | Store sharing method, device, block chain distributed network topology | |
CN110188110A (en) | A kind of method and device constructing distributed lock | |
CN104657435B (en) | A kind of memory management method and Network Management System using data | |
CN107148617A (en) | Automatically configuring for storage group is coordinated in daily record | |
CN108809855A (en) | Information management method, device and electronic equipment | |
CN111815454B (en) | Data uplink method and device, electronic equipment and storage medium | |
CN109634974A (en) | A kind of data processing method, system and associated component | |
CN107656815A (en) | Method and apparatus for controlling distributed lock | |
CN107807797A (en) | The method, apparatus and server of data write-in | |
CN110377854A (en) | User access activity information monitoring method and device, computer equipment | |
CN106708608A (en) | Distributed lock service method and acquisition method, and corresponding device | |
CN107872517A (en) | A kind of data processing method and device | |
CN112256776B (en) | Form repeated submission detection method and device, computer equipment and storage medium | |
CN113760513A (en) | Distributed task scheduling method, device, equipment and medium | |
CN111385294B (en) | Data processing method, system, computer device and storage medium | |
CN109542612A (en) | A kind of hot spot keyword acquisition methods, device and server | |
CN108090056A (en) | Data query method, apparatus and system |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |