CN109697127A - The method and apparatus that the access operation of a kind of pair of shared resource locks - Google Patents
The method and apparatus that the access operation of a kind of pair of shared resource locks Download PDFInfo
- Publication number
- CN109697127A CN109697127A CN201711003058.1A CN201711003058A CN109697127A CN 109697127 A CN109697127 A CN 109697127A CN 201711003058 A CN201711003058 A CN 201711003058A CN 109697127 A CN109697127 A CN 109697127A
- Authority
- CN
- China
- Prior art keywords
- node
- shared resource
- permission
- lock permission
- lock
- 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.)
- Granted
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/52—Program synchronisation; Mutual exclusion, e.g. by means of semaphores
- G06F9/526—Mutual exclusion algorithms
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Storage Device Security (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
This application discloses the method and apparatus that the access operation of a kind of pair of shared resource locks, it is related to field of computer technology, largely to derive from a node in distributed system in locking request, a certain locking request is triggered by remaining node, and it is promoted scene that locking request is usually triggered by the node again under next time and locks the speed of response.Method is applied to the management node of the lock permission for managing at least two node visit shared resources in distributed system, and the node for obtaining lock permission executes operation indicated by lock permission to shared resource;Method includes: to receive the lock authority request for the first lock permission for requesting access to shared resource that first node is sent;The first lock permission is authorized to first node;Determine that the number of connected reference shared resource at least two nodes is greater than or equal to preset threshold, and the time gap current time nearest node of connected reference, as hot node;It is recycled to first node and authorizes the first lock permission to hot node.
Description
Technical field
The method that is locked this application involves the access operation of field of computer technology more particularly to a kind of pair of shared resource and
Device.
Background technique
In a distributed system, node usually passes through distributed lock and accesses to shared resource.Currently, distributed lock tube
The deployment way of (distributed locks management, the DLM) system of managing is as shown in Figure 1.With reference to Fig. 1, in the system
Including multiple nodes (in Fig. 1 by taking 4 node, that is, nodes 1~4 as an example), one is disposed on one of node (such as node 1)
DLM arbitrates (DLM_Master) module, disposes DLM local agent (DLM_Proxy) module on each node.It is deployed with
The node of DLM_Master module is properly termed as management node, and the node for not disposing DLM_Master module is properly termed as non-pipe
Manage node.DLM_Master module is responsible for managing the locking request that the DLM_Proxy of each node is sent, and locking request is for requesting
Permission is locked, the node for obtaining the lock permission for accessing a certain shared resource executes the behaviour of lock permission lock instruction to the shared resource
Make.DLM_Proxy module is responsible for the processing of local locking request, and carries out information exchange with DLM_Master module.
Currently, the lock is weighed after obtaining accessing the node visit of the lock permission of a certain shared resource shared resource
Limit is stored in local.If locking request is triggered by this node next time, it is directly performed locally locking process.If add next time
Lock request is triggered by other nodes, then when the node is management node, which directly authorizes the lock permission to other sections
Point;When the node is non-management node, management node, which is first passed through, carries out information exchange, recycling and the lock permission institute with the node
Operation indicated by the lock permission of the operation mutual exclusion of instruction weighs the lock then by carrying out information exchange with other nodes
Limit authorizes other nodes.Wherein, lock permission includes read right and write permission, and the lock permission with read right mutual exclusion is write permission,
Lock permission with write permission mutual exclusion is read right and write permission.In other words, a node is carrying out reading behaviour to a shared resource
When making, other nodes cannot carry out write operation to the shared resource;One node to a shared resource carry out write operation when,
He cannot carry out read operation and write operation to the shared resource by node.
Due under most of scene, for example, in Corporation Distributed storage system, to the locking request of a certain shared resource
Most of one of node in distributed system.Remaining node is sporadic or periodic triggering to this
The locking request of shared resource.Therefore, when certain locking request by remaining node a node trigger, next time plus
Lock request is usually triggered by the node again, if according to the technical solution of above-mentioned offer, to the locking request progress next time
During processing, need to carry out information interaction between nodes, this can reduce the locking speed of response.
Summary of the invention
The application provides the method and apparatus that the access operation of a kind of pair of shared resource locks, and facilitates big in locking request
A node being derived partly from distributed system, a certain locking request is triggered by remaining node, and locking request next time
The scene usually triggered by the node again under, information interaction between nodes number is reduced, to promote the locking speed of response.
In order to achieve the above objectives, the embodiment of the present application adopts the following technical scheme that
In a first aspect, the method that the access operation for providing a kind of pair of shared resource locks, applied in distributed system
Management node, lock permission of the management node at least two node visit shared resources in managing distributing type system, obtains
The node for locking permission executes operation indicated by lock permission to shared resource;Method includes: the received at least two nodes
The lock authority request that one node is sent, lock authority request are used to request access to the first lock permission of shared resource, the first lock permission
It is one of lock permission lock permission;The first lock permission of access shared resource is authorized to first node;Determine hot node,
In, hot node is that the number of connected reference shared resource at least two nodes is greater than or equal to preset threshold, and continuous visit
The time gap current time asked nearest node;The first lock permission of access shared resource is recycled to first node, and to heat
Point node authorizes the first lock permission of access shared resource.In the technical solution, after execution locking process flow terminates, hot spot
Node is stored with the first lock permission of shared resource.In this way, largely be derived from distributed system in locking request
One node (hot node such as defined herein), a certain locking request are touched by remaining node (such as above-mentioned first node)
Hair, and next time locking request usually again by the node (i.e. hot node) triggering scene under, can be directly in the hot spot section
Point locally executes locking process, so as to reduce information interaction between nodes number, improves the locking speed of response.In addition, right
It is locked for process in this, i.e., in the technical program, for the locking process of first node triggering, in above-mentioned second step
In, it can be obtained the first lock permission of shared resource, therefore have no effect on the speed of response of the locking process.
The accessed historical record of shared resource is stored in a kind of possible design, in management node, is accessed history
Record is determined hot node, be may include: in shared resource quilt by the node of access time journal access shared resource
The number of connected reference shared resource is selected to be greater than or equal to preset threshold in the historical record of access, and access time distance is worked as
Nearest node of preceding moment, as hot node.The possible design gives a kind of implementation of determining hot node.
In a kind of possible design, before authorizing the first lock permission of access shared resource to first node, the party
Method can also include: the historical record for receiving the second node access shared resource that second node reports;Wherein, second node is
The node of second lock permission of storage access shared resource at least two nodes, second locks operation and first indicated by permission
Lock operation mutual exclusion indicated by permission.For example, the second lock permission is write permission if the first lock permission is read right;If first
Locking permission is write permission, then the second lock permission is read right and write permission.Second node is accessed to the historical record of shared resource,
It is added in the accessed historical record of shared resource.
In a kind of possible design, in the historical record for receiving the second node access shared resource that second node reports
Before, this method can also include: to send lock permission recycling order to second node, wherein lock permission recycling order is for referring to
Show the second lock permission of second node release shared resource;The historical record that second node accesses shared resource is that second node exists
Management node is sent to after second lock permission of release access shared resource.The possible design gives a kind of second node
It is reported to access the implementation of the historical record of shared resource, certain the application is without being limited thereto, specifically refers in detail below
Embodiment.
In a kind of possible design, after determining hot node, this method can also include: to receive first node hair
The historical record for the first node access shared resource sent;Then, by the historical record of first node access shared resource, addition
In the historical record being accessed to shared resource.The accessed historical record of updated shared resource can be used for subsequent locking
Hot node is determined in process.
In a kind of possible design, this method can also include: to delete in the accessed historical record of shared resource
Invalidation history record, invalidation history record are visited before being hot node currently determining in the accessed historical record of shared resource
Ask the node of shared resource.In this way, which memory space can be saved.
Second aspect provides a kind of management node, which can be used for executing described in above-mentioned first aspect pair
The method that the access operation of shared resource locks.The management node can specifically include: execute side described in above-mentioned first aspect
The corresponding each functional module of method can also integrate two or more functions therein.
The third aspect provides a kind of management node, which can be used for executing described in above-mentioned first aspect pair
The method that the access operation of shared resource locks.The management node can specifically include: memory and processor, wherein storage
Device is for storing computer program, when which is executed by processor, so that either first aspect offer method quilt
It executes.Wherein, memory can be memory and/or storage chip etc..Processor can be CPU and/or control memory etc..
Fourth aspect provides a kind of distributed system, comprising: any pipe that above-mentioned second aspect or the third aspect provide
Node is managed, lock permission of the management node at least two node visit shared resources in managing distributing type system obtains
The nodes sharing resource for locking permission executes operation indicated by lock permission.
Present invention also provides a kind of computer readable storage mediums, store computer program thereon, when the program exists
When being run on computer, so that computer executes method described in above-mentioned first aspect.
Present invention also provides a kind of computer program products, when run on a computer, so that computer executes
Method described in above-mentioned first aspect.
Present invention also provides a kind of communication chips, wherein it is stored with instruction, when it runs in management node, so that
Management node executes method described in above-mentioned first aspect.
It is to be appreciated that any device or computer storage medium of above-mentioned offer or computer program product etc. are used
In executing corresponding method presented above, therefore, attainable beneficial effect can refer to having in corresponding method
Beneficial effect, details are not described herein again.
Detailed description of the invention
A kind of applicable system architecture of the method that the access operation to shared resource that Fig. 1 is provided by the prior art locks
Schematic diagram;
Fig. 2 is the interaction signal for the method that the access operation of a kind of pair of shared resource provided by the embodiments of the present application locks
Figure;
Fig. 3 is that the interaction for the method that another access operation to shared resource provided by the embodiments of the present application locks is illustrated
Figure;
A kind of applicable system of the method that Fig. 4 is locked by the access operation provided by the embodiments of the present application to shared resource
The schematic diagram of framework;
Fig. 5 is that the interaction for the method that another access operation to shared resource provided by the embodiments of the present application locks is illustrated
Figure;
Fig. 6 is that the interaction for the method that another access operation to shared resource provided by the embodiments of the present application locks is illustrated
Figure;
Fig. 7 is a kind of structural schematic diagram of management node provided by the embodiments of the present application;
Fig. 8 is the structural schematic diagram of another management node provided by the embodiments of the present application.
Specific embodiment
The relational language and technology that are related in the embodiment of the present application are explained first below.
Shared resource refers to the resource that multiple nodes are accessible in distributed system.The resource, which specifically can be, deposits
Store up hard disk, the corresponding memory space in hard disk domain of virtualization, storage pool etc..Shared resource can dispose in a distributed system
On one or more nodes, it can also be deployed in an equipment except distributed system.
Business module refers to the module to access in the node of distributed system to shared resource.In other words, node
It accesses to shared resource, specifically the business module in node accesses to shared resource.Each of distributed system
Node may each comprise one or more business modules.Different shared resources can be carried out for different nodes/business module
Access.Such as shared resource 1 can access for node 1 and node 2, i.e., shared resource 1 is the shared of node 1 and node 2
Resource;Shared resource 2 can access for node 2 and node 3, i.e. the shared resource that is node 2 and node 3 of shared resource 2.
It accesses to shared resource, including read operation is carried out to shared resource, and write operation is carried out to shared resource.
Wherein, read operation is carried out to shared resource, refers to the operation for reading the data in shared resource.Shared resource is carried out to write behaviour
Make, is directed to write the operation of data in shared resource.One business module when carrying out read operation to shared resource, other
Business module can with but not necessarily to the shared resource carry out read operation, it is not possible to the sharing module carry out write operation.One
For business module when carrying out write operation to a shared resource, other business modules cannot carry out reading behaviour to the shared resource
Make, cannot also carry out write operation to the shared resource.Wherein, other business modules and the business module can be same section
Different business module in point, the business module being also possible in different nodes.
Permission is locked, refers to the accessed permission of locked share resource, the i.e. permission of the operation of locking access shared resource.Lock
Permission may include read right and write permission.The node for obtaining lock permission executes behaviour indicated by the lock permission to shared resource
Make;Wherein, operation indicated by read right is read operation, and operation indicated by write permission is write operation.Only have to one
The node for the lock permission (hereinafter referred to accessing the lock permission of the shared resource) that shared resource accesses, it is just accessible to be somebody's turn to do
Shared resource.Specifically, the node of the read right with a shared resource, just can carry out read operation to the shared resource;
The node of write permission with a shared resource just can carry out write operation to the shared resource.In general, having one to share
The node of the read right of resource not necessarily has the write permission to the shared resource;Write permission with a shared resource
Node, while there is the read right to the shared resource.One node can also not have the reading to a shared resource simultaneously
Permission and write permission.In general, if node has a read right of a shared resource, other nodes can with but not necessarily can
There is the read right of the shared resource simultaneously, it is not possible to while there is the write permission of the shared resource.If a node has one
The write permission of a shared resource, then other nodes cannot have the read right and write permission of the shared resource simultaneously.
The state of permission is locked, the lock permission for having to node is marked.As described above, due to total with one
The node for enjoying the read right of resource not necessarily has the write permission to the shared resource;Write permission with a shared resource
Node, while there is the read right to the shared resource.One node can also not have simultaneously to shared resource
Read right and write permission.Therefore, the state of usually lock permission may include: None state, read states and write state.Wherein, if
The state for accessing the lock permission of a certain shared resource is None state, then shows the read right without the shared resource and write power
Limit.If the state for accessing the lock permission of a certain shared resource is read states, show read right only with the shared resource, no
Write permission with the shared resource.If the state for accessing the lock permission of a certain shared resource is write state, shows to have and be somebody's turn to do
The read right and write permission of shared resource.It is generally thought that the rank for being superior to read states of write state, the rank of read states is high
In the rank of None state.
Global record sheet refers to the DLM_Master module maintenance of management node, for recording in distributed system
Access the table for authorizing situation of the lock permission of each shared resource.Certainly, each shared for recording the access in distributed system
The mode for authorizing situation of the lock permission of resource can be not limited to table.The information recorded in global record sheet is with distribution
Each node updates the variation of the access situation of shared resource in system.For example, it is assumed that distributed system include node 1,2,
3 and shared resource A, B, C, then, a certain moment, it is assumed that node 1, node 3 do not have the read right of access shared resource A
And write permission, node 2 have the read right and write permission of access shared resource A.Node 3 does not have the reading of access shared resource B
Permission and write permission, node 1, node 2 have the read right of access shared resource B and write power without access shared resource B
Limit.Node 1, node 2, node 3 do not have the read right and write permission of access shared resource C.So, DLM_Master module is tieed up
The information recorded in the global record sheet of shield can be as shown in table 1.
Table 1
Local record's table refers to the DLM_Proxy module maintenance of each node, for recording the DLM_Proxy module
The table of the currently used situation of lock permission and these lock permissions that affiliated node currently has.For example, a DLM_Proxy
The information recorded in local record's table of module record may include: that node belonging to the DLM_Proxy module currently has
The information etc. of which lock permission is being currently used in the lock permission and which business module for accessing each shared resource.Certainly, it uses
In the side for the currently used situation for recording lock permission and these lock permissions that node belonging to the DLM_Proxy module currently has
Formula can be not limited to table.For example, it is assumed that distributed system includes shared resource A, B, C, a node includes business module
1,2,3, and the node currently has the read right and write permission of access shared resource A, has the read right of access shared resource B
And do not have the write permission of access shared resource B, read right and write permission without access shared resource C.Also, currently should
The lock permission of access shared resource 1 is used in the business module 1 of node, and it is shared that access is used currently without business module
The lock permission of resource 2, then, local record's table of the DLM_Proxy module maintenance of the node can be as shown in table 2:
Table 2
Local record's table of one DLM_Proxy module maintenance obtain with node belonging to the DLM_Proxy module or
It loses lock permission and updates.Updating local record's table can specifically include: buffer lock permission and release lock permission.
Buffer lock permission, refer to node (the DLM_Proxy module specifically in node) to obtain lock this event of permission
It is marked.Specifically lock the process of the state upgrading of permission.For example, one shared resource of DLM_Proxy module cache access
Read right, refer to the state that the lock permission of the shared resource is accessed in local record's table that DLM_Proxy module is safeguarded
Read states are updated to by None state.The write permission of one shared resource of cache access, the lock of the shared resource will be accessed by referring to
The state of permission is updated to write state by None state or read states.
Release lock permission, refer to node (the DLM_Proxy module specifically in node) to lose lock this event of permission
It is marked.Specifically lock the process that the state of permission degrades.For example, DLM_Proxy module release one shared resource of access
Read right, refer to the state that the lock permission of the shared resource is accessed in local record's table that DLM_Proxy module is safeguarded
None state is updated to by read states.The write permission of release one shared resource of access, the lock of the shared resource will be accessed by referring to
The state of permission is updated to read states or None state by write state.
In addition, term "and/or" in the application, only a kind of incidence relation for describing affiliated partner, expression can be deposited
In three kinds of relationships, for example, A and/or B, can indicate: individualism A exists simultaneously A and B, these three situations of individualism B.
Symbol "/" herein indicates that affiliated partner is relationship such as A/B expression A or B perhaps.Term " first " in the application,
" second " etc. is rather than to be used for the particular order of description object for distinguishing different objects.For example, first node and second
Node is the particular order for distinguishing different nodes, rather than for describing node.Unless otherwise indicated, " multiple " contain
Justice refers to two or more.For example, multiple nodes refer to two or more nodes.
Referring to fig. 2, the schematic diagram of the method locked for the access operation of a kind of pair of shared resource.Wherein, Fig. 2 is based on figure
It is illustrated for system architecture shown in 1.It can specifically include following steps:
S101: some business module of node 3 sends a locking request to the DLM_Proxy module of the node.Node 3
DLM_Proxy module first parse the lock authority information of locking request carrying, then determined according to the lock authority information shared
Resource and the lock permission to access to shared resource (i.e. the first lock permission of access shared resource).
For any one business module, when it has the requirements for access to some shared resource (i.e. shared resource)
When, it generates and sends a locking request to the DLM_Proxy module of the node where the business module.Wherein, which asks
Lock authority information can be carried in asking, lock authority information can be the packaging body that multiple Information encapsulations are constituted together, should
Multiple information can such as, but not limited to include: the mark of shared resource, the mark of the first lock permission, the mark of business module
Deng.Wherein, which can be any one shared resource in distributed system.First lock permission can be reading power
Limit, is also possible to write permission.Specifically, the first lock permission is to read power if the business module has reading demand to shared resource
Limit;If the business module has demand of writing to shared resource, the first lock permission is write permission.
S102: local record's table that the DLM_Proxy module of node 3 is safeguarded by inquiring the DLM_Proxy module obtains
The state of the lock permission of the access shared resource recorded in local record's table.Judge to record in the first lock permission and local record's table
The state of lock permission of access shared resource whether match.
If it is not, then executing S103;If so, executing S106.
Specifically, if the first lock permission is read right, the lock permission of the access shared resource recorded in local record's table
State is read states, then is judged to matching;Alternatively, the access recorded in local record's table is total if the first lock permission is write permission
The state for enjoying the lock permission of resource is write state, then is judged to matching.Otherwise, it is determined that mismatch.For example, it is assumed that the first lock power
Limit is read right, then, reference table 2, if shared resource is shared resource B, due to the shape of the lock permission of access shared resource B
State is read states, therefore, it is determined that for matching;If shared resource is shared resource A, due to the lock permission of access shared resource A
State is write state, therefore, it is determined that mismatch.
S103: the DLM_Proxy module of node 3 sends lock authority request to the DLM_Master module of node 1, wherein
Lock authority request is used to request access to the first lock permission of shared resource.
S104: the type (i.e. read right or write permission) that the DLM_Master module of node 1 locks permission according to first, really
Surely the second lock permission of shared resource is accessed.Operation indicated by second lock permission and operation indicated by the first lock permission are mutual
Reprimand in section Example hereinafter, is described as the second lock permission and the first lock permission mutual exclusion for ease of description.Wherein, if
First lock permission is read right, then the second lock permission is write permission;If the first lock permission is write permission, the second lock permission is to read
Permission and write permission.Then, it by the global record sheet of inquiry DLM_Master module maintenance, determines and stores the shared money of access
The node of the second lock permission in source.And according to the node for the second lock permission for storing access shared resource, judgement it is current whether
Meet the condition that the first lock permission of access shared resource is directly authorized to node 3.
If it is not, then executing S105.If so, executing S106.
Specifically, that is, second lock permission is write permission, then DLM_Master module passes through if the first lock permission is read right
Global record sheet is inquired, node (the i.e. corresponding lock power of the write state of shared resource that the write permission of shared resource is awarded is obtained
Limit the node being awarded).If the node that the write permission of shared resource is awarded is sky, i.e., each node in current distributed system
Do not have the write permission of shared resource, then determines current the first lock power for meeting and directly authorizing access shared resource to node 3
The condition of limit;Otherwise, it is determined that being currently unsatisfactory for directly authorizing the condition of the first lock permission of access shared resource to node 3.Example
Such as, reference table 1 is awarded if shared resource is shared resource B due to the corresponding lock permission of the write state of shared resource B
Node is sky, therefore, it is determined that current meet the condition for directly authorizing the first lock permission of access shared resource to node 3;If shared
Resource is shared resource A, then since the node that the corresponding lock permission of the write state of shared resource A is awarded is not sky, sentences
It is unsatisfactory for directly authorizing the condition of the first lock permission of access shared resource to node 3 before settled.
If the first lock permission is write permission, i.e., the second lock permission is read right and write permission, then DLM_Master module is logical
The global record sheet of inquiry is crossed, the node that the read right of shared resource is awarded is obtained and the node that write permission is awarded is (i.e. shared
The node that the node and the corresponding lock permission of write state that the corresponding lock permission of the read states of resource is awarded are awarded).If shared
The node that the node and write permission that the read right of resource is awarded are awarded is sky, i.e., each node in current distributed system
Do not have the read right of shared resource, do not have the write permission of shared resource yet, then determines that current satisfaction is directly awarded to node 3
Give the condition of the first lock permission of access shared resource;Otherwise, it is determined that being currently unsatisfactory for directly authorizing shared resource to node 3
The condition of first lock permission.For example, reference table 1, if shared resource is shared resource C, due to the read states pair of shared resource C
The node that the corresponding lock permission of the node and write state that the lock permission answered is awarded is awarded is sky, therefore, it is determined that current full
Foot directly authorizes the condition of the first lock permission of access shared resource to node 3;If shared resource is shared resource A, due to
The node that the corresponding lock permission of the write state of shared resource A is awarded is not sky, therefore, it is determined that being currently unsatisfactory for directly to node 3
Authorize the condition of the first lock permission of access shared resource.
S105: the node of the DLM_Master module of node 1 to the second lock permission for storing access shared resource
Second lock permission of DLM_Proxy module recycling access shared resource.
For example, it is assumed that the second lock permission includes write permission, and the node of the currently stored write permission of shared resource is section
Point 2, then the DLM_Master module of node 1 sends lock permission recycling order to the DLM_Proxy module of node 2, wherein lock power
Limit recycling order is for the write permission to the DLM_Proxy module of node 2 recycling shared resource.The DLM_Proxy module of node 2
After receiving lock permission recycling order, by the local record's table for inquiring its maintenance, however, it is determined that have business module in present node 2
The lock permission (including write permission and read right) of access shared resource is used, then waits the business module after use, releases
The write permission of shared resource is put, and replys lock permission recycling response to DLM_Master module;If it is determined that not having in present node 2
The lock permission (including write permission and read right) of access shared resource is used in business module, then discharge shared resource writes power
Limit, and lock permission recycling response is replied to DLM_Master module.
Assuming that the second lock permission includes read right, then the DLM_Master module of node 1 is to storing access shared resource
The second lock permission node recycling the second lock permission process and the difference of the above process be: business module is currently in use
The lock permission for accessing shared resource is read right, other processes can refer to the above process, and details are not described herein again.
S106: the DLM_Master module of node 1 authorizes the of access shared resource to the DLM_Proxy module of node 3
One lock permission.Specifically, the DLM_Master module of node 1, which sends lock permission to the DLM_Proxy module of node 3, authorizes life
It enables.Wherein, lock permission authorizes order and is used to indicate the first lock permission for authorizing access shared resource to node 3.The DLM_ of node 3
Proxy module receives after lock permission authorizes order, the first lock permission of cache access shared resource, and to the DLM_ of node 1
Master module replys lock permission and authorizes response.
S107: the DLM_Proxy module of node 3 authorizes the first lock permission of access shared resource to the business module.Tool
Body, the DLM_Proxy module of node 3 sends lock permission to the business module and authorizes order.Wherein, lock permission authorizes order use
The first lock permission of access shared resource is authorized to the business module in instruction.The business module receives lock permission and authorizes order
Afterwards, lock permission is replied to the DLM_Proxy module authorize response.
S108: the business module accesses to shared resource, and visiting according to the first lock permission of access shared resource
After the completion of asking that operation executes, the DLM_Proxy module of Xiang Jiedian 3 sends release information.The DLM_Proxy module of node 3 receives
To after release information, local record's table is updated.Wherein, updating local record's table is specifically: access is being currently used altogether in deletion
Enjoy the mark of the business module of the first lock permission of resource.
So far, locking process terminates.In this case, lock permission is stored in the DLM_Proxy module of node 3.
Due under most of scene, for example, in Corporation Distributed storage system, to the locking request of a certain shared resource
Most of one of node in distributed system.Remaining node is sporadic or periodic triggering to this
The locking request of shared resource.Therefore, when certain locking request by remaining node a node trigger, next time plus
Lock request is usually triggered by the node again, if according to the technical solution of above-mentioned offer, to the locking request progress next time
It during processing, needs to carry out multiple information interaction between nodes, this causes communication to take a long time.Below by an example into
Row explanation:
For example, it is assumed that the node of continuous 5 triggerings locking request (being respectively labeled as locking request 1~5) is successively are as follows: node
3, node 3, node 3, node 2, node 3, then, the 5 locking process such as Fig. 3 executed according to technical solution as shown in Figure 2
It is shown.Fig. 3 is based on being illustrated for system architecture shown in FIG. 1.The explanation of related content in embodiment shown in Fig. 3
It can refer to above, details are not described herein again.In this example, it is illustrated so that the first lock permission is write permission as an example.
It is specific as follows referring to Fig. 3:
1), for locking request 1, it is as follows to lock process:
A. the DLM_Proxy module of node 3 receives the locking request 1 that a business module is sent, and is due to distributed at this time
System is in original state, and the write permission and read right of shared resource are not stored in the DLM_Proxy module dimension of any node
In local record's table of shield, therefore, the DLM_Proxy module of node 3 determines local without the storage requested visit of locking request 1
It asks the write permission of shared resource, then, sends lock authority request to the DLM_Master module of management node (i.e. node 1), with
Request access to the write permission of shared resource.
B. after the DLM_Master module of node 1 receives the lock authority request, determine current meet directly to node 3
DLM_Proxy module authorizes the condition of the write permission of access shared resource.Then, the DLM_Proxy module of Xiang Jiedian 3 authorizes visit
Ask the write permission of shared resource.
C. the DLM_Proxy module of node 3 authorizes the write permission of access shared resource to the business module.The business module
After having executed the access to shared resource, the write permission for accessing shared resource is released to the DLM_Proxy module of node 3.
During being somebody's turn to do, locks process and executed between node.Node 3 directly authorizes access shared resource to node 1 and writes power
It limits, the write permission that shared resource is accessed after this process is stored in node 3.
2), for locking request 2, it is as follows to lock process:
The DLM_Proxy module of node 3 receives the locking request 2 of business module transmission, and determining be locally stored adds
The write permission of the requested access shared resource of lock request 2, then authorize the write permission of access shared resource to the business module, should
After business module has executed the access to shared resource, the write permission for accessing shared resource is released to the DLM_Proxy of node 3
Module.
During being somebody's turn to do, locks process and be performed locally.The write permission that shared resource is accessed after this process is stored in section
Point 3.
3), for locking request 3, it is as follows to lock process:
The DLM_Proxy module of node 3 receives the locking request 3 of business module transmission, and determining be locally stored adds
The write permission of the requested access shared resource of lock request 3, then authorize the write permission of access shared resource to the business module, should
After business module has executed the access to shared resource, the write permission for accessing shared resource is released to the DLM_Proxy of node 3
Module.
During being somebody's turn to do, locks process and be performed locally.The write permission that shared resource is accessed after this process is stored in section
Point 3.
4), for locking request 4, it is as follows to lock process:
A. the DLM_Proxy module of node 2 receives the locking request 4 of business module transmission, determines and does not deposit locally
The write permission of the requested access shared resource of locking request 4 is stored up, then sends lock permission to the DLM_Master module of node 1 and asks
It asks, to request access to the write permission of shared resource.
B. after the DLM_Master module of node 1 receives the lock authority request, to storing and access shared resource
The node of the lock permission of write permission mutual exclusion recycles the lock permission of the mutual exclusion, specifically, recycling to the DLM_Proxy module of node 3
Access the write permission of shared resource.The process includes 2 minor node information interactions, specifically can be with reference to above.
It should be noted that in the present embodiment, it is illustrated so that the first lock permission is write permission as an example, therefore, with the
Second lock permission of one lock permission mutual exclusion is write permission and read right, and in the present embodiment, due to the reading power of shared resource at this time
Limit is not stored in any node, and the write permission of shared resource is stored on node 3, and therefore, which embodies are as follows: section
Point 1 recycles the write permission of shared resource to node 3.
C. the DLM_Proxy module of node 1 authorizes the write permission of access shared resource to the DLM_Proxy module of node 2.
The process includes 2 minor node information interactions, specifically can be with reference to above.It should be noted that the processing for locking request 4
For process, through step b and c totally 4 minor node information interaction, node 2 can be made to obtain the write permission of access shared resource.
D. the DLM_Proxy module of node 2 authorizes the write permission of access shared resource, the business module to the business module
After having executed the access to shared resource, the write permission for accessing shared resource is released to the DLM_Proxy module of node 2.
During being somebody's turn to do, locks process and executed between node.Node 1 first recycles the write permission of access shared resource to node 3,
The write permission for authorizing access shared resource to node 2 again, with reference to step b, c it is found that executing 4 minor node information interactions altogether.This
The write permission that shared resource is accessed after process is stored in node 2.
5), for locking request 5, it is as follows to lock process:
A. the DLM_Proxy module of node 3 receives the locking request 5 of business module transmission, determines local without slow
The write permission of the requested access shared resource of locking request 5 is deposited, then sends lock permission to the DLM_Master module of node 1 and asks
It asks, to request access to the write permission of shared resource.
B. after the DLM_Master module of node 1 receives the lock authority request, the DLM_Proxy module of Xiang Jiedian 2 is returned
Receive the write permission of access shared resource.The process includes 2 information exchanges, specifically can be with reference to above.In the step mutually inside the Pass
The explanation of appearance can refer to it is above-mentioned 4) in step b in explanation, details are not described herein again.
C. the DLM_Proxy module of node 1 authorizes the write permission of access shared resource to the DLM_Proxy module of node 3.
The process includes 2 information exchanges, specifically can be with reference to above.
D. the DLM_Proxy module of node 3 authorizes the write permission of access shared resource, the business module to the business module
After having executed the access to shared resource, the write permission for accessing shared resource is released to the DLM_Proxy module of node 3
During being somebody's turn to do, locks process and executed between node.Node 1 first recycles the write permission of access shared resource to node 2,
The write permission of access shared resource is authorized to node 3 again, and with reference to step b, c it is found that executing 4 minor node information interactions altogether.
The write permission that shared resource is accessed after this process is stored in node 3.
Example according to Fig.3, it is believed that node 3 is largely derived to the locking request of shared resource, also,
In the case where triggering a locking request by node 2 sporadicly and locking request being triggered by node 3 again next time, right
In the process of processing, (shown in Figure 3 shows the information exchange for needing to be implemented between 4 minor nodes locking request next time for this
To the process flow of locking request 5 in example), this will lead to communication and takes a long time.
Based on this, this application provides the method and apparatus that the access operation of a kind of pair of shared resource locks.It is substantially former
Reason are as follows: after locking process every time and having executed, this locks the heat that the requested lock permission of process is stored in shared resource
Point node, wherein the hot node is node of the number more than or equal to preset threshold of connected reference shared resource, and continuous
The time gap current time of access nearest node.In this way, even if certain locking request sporadic ground or periodical
Ground is triggered by other nodes except hot node, is usually triggered again by the hot node due to locking process next time,
This can be directly performed locally and lock process next time, it is time-consuming so as to reduce communication.Below by an example, explanation
The determination method of hot node.Assuming that according to chronological order access shared resource node successively are as follows: node 1, node 1,
Node 1, node 2, node 3, node 3, node 4, it follows that the node of current accessed shared resource is node 4.So, if
Preset threshold is 2, then hot node is node 3.If preset threshold is 3, hot node is node 1.
As shown in figure 4, being that the framework of distributed system that technical solution provided by the embodiments of the present application is applicable in a kind of shows
It is intended to.The distributed system includes multiple nodes (in Fig. 4 by taking 4 nodes i.e. node 1~4 as an example).It is disposed in each node
One DLM_Proxy module 100.A DLM_Master module 200 is disposed on one of node (such as node 1).Wherein
A distributed lock management is disposed on one node (such as node 1) counts (DLM_Statistic) module 300.
DLM_Proxy module 100 is responsible for the processing of local locking request, and with DLM_Master module 200 and DLM_
Statistic module 300 carries out information exchange etc..
DLM_Master module 200 is responsible for the locking request etc. that the DLM_Proxy of each node of management is sent.
DLM_Statistic module 300 is responsible for the historical record that each shared resource is accessed in statistical cloth system,
And the historical record being accessed according to a certain shared resource, determine the hot node etc. of the shared resource.Wherein, shared resource quilt
The historical record record of access is accessed the node of shared resource by access time journal.Hereinafter, DLM_ will be recorded
The table of the accessed historical record of each shared resource, referred to as global in the distributed system that Statistic module 300 counts
History table.In actual implementation, for recording the mode for the historical record that each shared resource is accessed in distributed system
It can be not limited to table.For example, it is assumed that including node 1,2,3 and shared resource A, B, C in distributed system, then, certain
At one moment, the information that records can be as shown in table 3 in the global history table that DLM_Statistic module 300 is safeguarded.
Table 3
Shared resource | The accessed historical record of shared resource |
Shared resource A | Node 3, node 3, node 2, node 3 |
Shared resource B | Node 2, node 1, node 2, node 2, node 2 |
Shared resource C | Node 1, node 1, node 1 |
It should be noted that the DLM_Proxy module 100 of each node can also be responsible for safeguarding local history record sheet.One
The local history record sheet that DLM_Proxy module 100 is safeguarded, for recording node visit belonging to the DLM_Proxy module 100
The historical record of each shared resource.A node shared resource of every access, the DLM_Proxy module 100 of the node can be
The historical record of the primary shared resource is recorded in the local history record sheet of the DLM_Proxy module 100 maintenance, it specifically can be with
It is the mark for recording the primary node.The DLM_Proxy module 100 of each node can be under certain trigger condition to DLM_
Statistic module 300 some or all of reports in the local history record sheet of self maintained information, so that DLM_
The historical record that Statistic module 300 is accessed shared resource each in distributed system counts.About the triggering
The description of condition, can refer to hereafter.
It should be noted that the node of deployment DLM_Master module 200 is management node.It is deployed with DLM_Master module
200 node and the node for being deployed with DLM_Statistic module 300 can be same node, be also possible to different nodes.For
Reduction information interaction times, are usually deployed in same section for DLM_Master module 200 and DLM_Statistic module 300
On point, hereafter and in attached drawing it is illustrated as example.DLM_Master module 200 and DLM_Statistic module 300
It can be independent two modules, also can integrate together.In order to more clearly describe, hereafter and in attached drawing, with
DLM_Master module 200 and DLM_Statistic module 300 is illustrated for independent two modules.
It should be noted that example shown in Fig. 4, the system architecture that technical solution only provided by the embodiments of the present application is applicable in
One example, does not constitute the restriction for the system architecture being applicable in technical solution provided by the embodiments of the present application.For example, every
It is disposed on one node on multiple DLM_Proxy modules 100 or at least two nodes and is deployed with DLM_Master module 200, or extremely
DLM_Statistic module 300 etc. is deployed on few two nodes.
With reference to the accompanying drawing, technical solution provided by the present application is illustrated.
As shown in figure 5, the interaction signal of the method for the access operation locking of a kind of pair of shared resource provided by the present application
Figure is specifically based on what system architecture shown in Fig. 4 provided.It can specifically include following steps:
S201~S203: can refer to S101~S103, and certain the application is without being limited thereto.
S204: the DLM_Master module of node 1 determines the second of access shared resource according to the type of the first lock permission
Lock permission.Then, by inquiring global record sheet, the node for storing the second lock permission of access shared resource is determined.And root
According to the node for the second lock permission for storing access shared resource, whether judgement, which currently meets, is directly authorized access altogether to node 3
Enjoy the condition of the first lock permission of resource.
If it is not, then executing S205;If so, executing S207.
The specific implementation process and related description of the step can refer to above, and details are not described herein again.
S205: node (such as node 2) the recycling access of node 1 to the second lock permission for storing access shared resource is shared
Second lock permission of resource.The specific implementation process of S205 can refer to above, and details are not described herein again.
S206: the DLM_Proxy module of node 2 reports the part of self maintained to the DLM_Statistic module of node 1
The accessed historical record of the shared resource recorded in history table.Can be for specifically reporting is visited according to chronological order
Ask the mark of the node of resource to be shared.
Exemplary, S206 can be such as, but not limited to achieved by the steps of: the DLM_Master module of node 1 is to section
The DLM_Proxy module of point 2 sends an instruction information, wherein the instruction information may include the mark of shared resource, be used for
Indicate the history note that the DLM_Proxy module of node 2 reports shared resource accessed to the DLM_Statistic module of node 1
Record.After receiving the instruction information, the local history by inquiring self maintained records the DLM_Proxy module of node 2
Table obtains the accessed historical record of shared resource, then reports shared resource quilt to the DLM_Statistic module of node 1
The historical record of access.In this case, the application is to the sequencing of execution S205 and S206 without limiting.
Exemplary, S206 can be such as, but not limited to achieved by the steps of: the DLM_Proxy module of node 2 is being released
It puts under the trigger condition of the second lock permission of access shared resource, the DLM_Statistic module of Xiang Jiedian 1 reports the DLM_
The accessed historical record of the shared resource of Proxy module maintenance.Specifically, the historical record that shared resource is accessed can be taken
Band is in lock permission recycling response, alternatively, the historical record that shared resource is accessed can be carried with lock permission recycling response
In same message, alternatively, historical record and lock permission recycling response that shared resource is accessed can be independent two message,
Then, the DLM_Statistic module of node 1 is sent to by the DLM_Proxy module of node 2.Compared to above-mentioned example, originally showing
In example, since node 1 does not need to send instruction information to node 2, to indicate that the history that node 2 reports shared resource accessed is remembered
Record, therefore can reduce signaling overheads.
It should be noted that in some implementations, the DLM_ of the DLM_Proxy module of each node to management node
After the historical record that Statistic module reports a certain shared resource accessed, DLM_Proxy module maintenance can be deleted
Historical record in local history record sheet, to save storage resource.
S207~S209: can refer to above-mentioned S106~S108, and certain the application is without being limited thereto.
S210: the DLM_Statistic module of node 1 is accessed according to the shared resource that the node 2 received is sent
Historical record updates the global history table of DLM_Statistic module maintenance, specifically sends the node 2 received
The accessed historical record of shared resource, be added in global history table;And it is interviewed according to updated shared resource
The historical record asked determines the hot node of shared resource.
For example, reference table 3, it is assumed that shared resource is shared resource A, i.e. current shared resource A accessed historical record
It is: [node 3, node 3, node 2, node 3];Also, what the shared resource that the DLM_Proxy module of node 2 is sent was accessed
Historical record is: [node 3, node 3], then the shared resource A recorded in updated global history table is accessed to be gone through
Records of the Historian record is: [node 3, node 3, node 2, node 3, node 3, node 3].
It should be noted that the number being accessed with node increases, the content meeting recorded in global history table
Increase therewith, this can occupy very big memory space.In order to save memory space, also, when in view of specific implementation, Ke Nengyin
The reasons such as certain nodes or the device fails for disposing shared resource, cause in a distributed system in distributed system
The distribution situation of node visit shared resource changes, and updates so as to cause the hot node of shared resource.In some of the application
In embodiment, DLM_Statistic module 300 can delete the record of the invalidation history in global history table, wherein invalid
Historical record accesses shared resource before being hot node currently determining in the historical record being accessed for shared resource
Node.For example, being based on above-mentioned example, i.e. shared resource A accessed historical record is: [node 3, node 3, node 2, node
3, node 3, node 3], if hot node is defined as continuously being accessed number more than or equal to 2, and the time interval of connected reference
The node nearest from current time, that is to say, that the accessed historical information of shared resource is that [node 3, node 3] can indicate
Currently determining hot node is node 3, then historical record [node 3, node 3, node that can be accessed shared resource A
2, node 3, node 3, node 3] it is updated to [node 3, node 3], to save memory space.
S211: the DLM_Master module of node 1 judges whether the hot node of identified shared resource is that this adds
The node (i.e. node 3) of the first lock permission of shared resource is requested access to during lock.
If so, this, which locks process, terminates.At this point, the first lock permission of access shared resource is stored in shared resource
Hot node.If it is not, then executing S212.
It should be noted that the application do not limit S207~S209 and S210~S211 execute sequence.
S212: the DLM_Master module of node 1 recycles the of access shared resource to the DLM_Proxy module of node 3
One lock permission, and the DLM_Proxy module that permission authorizes hot node is locked by accessing the first of shared resource.Wherein, the hot spot
Node can be node 2, may not be node 2, be to be illustrated in Fig. 5 by taking hot node is not node 2 as an example.
Optionally, shared to the recycling access of the DLM_Proxy module of node 3 in the DLM_Master module for executing node 1
During or after first lock permission of resource, following S213~S214 can also be performed:
S213: the DLM_Proxy module of node 3 reports the part of self maintained to the DLM_Statistic module of node 1
The accessed historical record of the shared resource recorded in history table.Can be for specifically reporting is visited according to chronological order
Ask the mark of the node of resource to be shared.
S214: the DLM_Statistic module of node 1 is accessed according to the shared resource that the node 3 received is sent
After historical record, the global history table of DLM_Statistic module maintenance is updated, specifically sends out the node 3 received
The accessed historical record of the shared resource sent, is added in global history table;Think that next time locks and determines heat in process
Point node is prepared.
Wherein, the specific implementation process of S213 can refer to above-mentioned S206, and the specific implementation process of S214 can refer to above-mentioned
S209.Details are not described herein again.
So far, this locking operation terminates.At this point, the first lock permission of access shared resource is buffered in the heat of shared resource
Point node.
It should be noted that the sequencing between step in embodiment shown in fig. 5 is only a kind of example.It is practical
On, under the premise of not influencing the main thought and basic logic of the technical program, the sequencing between step can be carried out
Adjustment.For example, in some implementations, the execution sequence of S205 and S206 can be in no particular order.
Hereinafter, illustrating technical solution provided by the present application by a specific example compared with prior art, section can be reduced
Point information interaction number.
For example, it is assumed that the node of continuous 5 triggerings locking request (being respectively labeled as locking request 1~5) is successively are as follows: node
3, node 3, node 3, node 2, node 3, also, hot node is continuous 2 times accessed, and the time gap of connected reference is worked as
Nearest node of preceding moment, then, the 5 locking processes executed according to technical solution as shown in Figure 5 are as shown in Figure 6.Fig. 6 is
It is illustrated for system architecture based on shown in Fig. 4.The explanation of related content can refer in embodiment shown in fig. 6
Text, details are not described herein again.In this example, it is illustrated so that the first lock permission is write permission as an example.
It is specific as follows referring to Fig. 6:
1)~3), for locking request 1~3, it can refer to the processing in technical solution shown in Fig. 3 to locking request 1~3
Process.
In the present embodiment, execute 1)~3) after, in the local history record sheet of the DLM_Proxy module maintenance of node 3
The accessed historical record of the shared resource of record can mark are as follows: [node 3, node 3, node 3].
4), for locking request 4, it is as follows to lock process:
A. the DLM_Proxy module of node 2 receives the locking request 4 of business module transmission, determines and does not deposit locally
The write permission of the requested access shared resource of locking request 4 is stored up, then sends lock permission to the DLM_Master module of node 1 and asks
It asks, to request access to the write permission of shared resource.
B. after the DLM_Master module of node 1 receives the lock authority request, the DLM_Proxy module of Xiang Jiedian 3 is returned
Receive the write permission of access shared resource.The process includes 2 minor node information interactions, specifically can be with reference to above.
C. the DLM_Proxy module of node 3 reports the part of self maintained to go through to the DLM_Statistic module of node 1
The accessed historical record (i.e. [node 3, node 3, node 3]) of the access shared resource recorded in history record sheet.Wherein, it refers to
The specific implementation of above-mentioned S206 is it is found that the message of interaction can be to hand between the node in de-multiplexing steps b between the step interior joint
Mutual message.
D. the DLM_Proxy module of node 1 authorizes the write permission of access shared resource to the DLM_Proxy module of node 2.
The process includes 2 minor node information interactions, specifically can be with reference to above.It should be noted that the processing for locking request 4
For process, through step b and d totally 4 minor node information interaction, node 2 can be made to obtain the write permission of access shared resource.
E. the DLM_Proxy module of node 2 authorizes the write permission of access shared resource, the business module to the business module
After having executed the access to access shared resource, the write permission that resource is enjoyed in total access is released to the DLM_Proxy mould of node 2
Block.
F. the DLM_Statistic module of node 1 is according to receiving [node 3, node 3, node 3], Yi Jire in step c
Point node is continuous accessed 2 times, and time gap current time nearest node this concept of connected reference, is updated global
History table.Wherein, the accessed historical record of updated shared resource can be [node 3, node 3].Then, according to
The accessed historical record of updated shared resource determines that the hot node of shared resource is node 3.
G. the DLM_Master module of node 1 determines that the hot node (i.e. node 3) of shared resource is not that this locks stream
The node (i.e. node 2) that locking request is triggered in journey, then executes following step h.
H. the DLM_Master module of node 1 writes power to the DLM_Proxy module of node 2 recycling access shared resource
It limits, and the write permission for accessing shared resource is authorized to the DLM_Proxy module of hot node (i.e. node 3).
I. the DLM_Proxy module of node 2 reports shared resource to be accessed to the DLM_Statistic module of node 1
Historical record (i.e. [node 2]).Wherein, with reference to the specific implementation of above-mentioned S206 it is found that interaction between the step interior joint
Message can be with the message of interaction between the node in de-multiplexing steps h.
J. the DLM_Statistic module of node 1 will be recorded according to [node 2] received in global history table
[node 3, node 3] be updated to [node 3, node 3, node 2], with for next time lock process in determine hot node it is valid
It is standby.
During being somebody's turn to do, locks process and executed between node.Node 1, which first recycles to node 3 and authorizes access to node 2, to be shared
The write permission of resource, then recycled to node 2 and authorize the write permission for accessing shared resource to node 3.After this process, access
The write permission of shared resource is stored in node 3.
5), for locking request 5, it is as follows to lock process:
The DLM_Proxy module of node 3 receives the locking request 5 of business module transmission, and determining be locally stored adds
The write permission of the requested access shared resource of lock request 5, then authorize the write permission of access shared resource to the business module, should
After business module has executed the access to shared resource, the write permission for accessing shared resource is released to the DLM_Proxy of node 5
Module.
During being somebody's turn to do, locks process and be performed locally.The write permission that shared resource is accessed after this process is stored in section
Point 3.
Example shown in Fig. 3 and example shown in fig. 6 are compared it is found that being hot node in node 3, and sporadic by saving
2 locking request (i.e. locking request 4) of triggering of point, locking request (i.e. locking request 5) is touched by the hot node again next time
In the case where hair, in example shown in Fig. 3, to this, locking request in the process of processing, needs to be implemented 4 partial nodes next time
Between point information exchange (for details, reference can be made in example shown in Fig. 3 to the process flow of locking request 5).However, shown in fig. 6
In example, do not need to execute the information exchange between node, for details, reference can be made to the processing in example shown in fig. 6 to locking request 5
Process, therefore, example shown in fig. 6, it is possible to reduce the information interaction times between node, thus solve communication take a long time ask
Topic, improves the locking speed of response.In addition, from the point of view of the process handled locking request 4, method shown in Fig. 3 and Fig. 6
Shown in method pass through 4 minor node information interactions so that the node 2 of triggering locking request 4 obtains locking request and is requested
Lock permission, therefore, example shown in fig. 6 will not influence the locking speed of response for locking request 4.To sum up, compared to figure
Example shown in 3, in technical solution provided by the present application, the instant messaging between node is fulfiled ahead of schedule by pre-granted (as plus
Communicate between part of nodes in the process flow of lock request 5 and completed in the process flow of locking request 4 in advance), be to reduce
Shi Tongxin, to promote the locking speed of response.
It is above-mentioned that mainly scheme provided by the embodiments of the present application is described from the angle of interaction between each node.It can
With understanding, each node, such as management node or non-management node.In order to realize the above functions, it comprises execution
The corresponding hardware configuration of each function and/or software module.Those skilled in the art should be readily appreciated that, in conjunction with herein
Each exemplary unit and algorithm steps of the disclosed embodiments description, the application can be with hardware or hardware and computer software
Combining form realize.Some functions is executed in a manner of hardware or computer software driving hardware actually, is depended on
The specific application and design constraint of technical solution.Professional technician can use not Tongfang to each specific application
Method realizes described function, but this realizes it is not considered that exceeding scope of the present application.
The embodiment of the present application can carry out the division of functional module according to above method example to management node, for example, can
With each functional module of each function division of correspondence, two or more functions can also be integrated in a processing module
In.Above-mentioned integrated module both can take the form of hardware realization, can also be realized in the form of software function module.It needs
It is noted that be schematical, only a kind of logical function partition to the division of module in the embodiment of the present application, it is practical real
It is current that there may be another division manner.It is illustrated for using corresponding each each functional module of function division below:
Fig. 7 gives a kind of structural schematic diagram of management node 70.The management node 70 can be above involved in pipe
It manages node (such as node 1 in Fig. 4).Access of the management node 70 at least two nodes in managing distributing type system is total
The lock permission for enjoying resource, the node for obtaining lock permission execute operation indicated by lock permission to shared resource;Management node 70 can
To include: receiving unit 701, granting unit 702, determination unit 703 and recovery unit 704.Receiving unit 701, for connecing
Receive the lock authority request that first node at least two nodes is sent, lock authority request is used to request access to the of shared resource
One lock permission, the first lock permission are one of lock permission lock permissions.Granting unit 702, for authorizing access to first node
First lock permission of shared resource.Determination unit 703, for determining hot node, wherein hot node is at least two nodes
The number of middle connected reference shared resource is greater than or equal to preset threshold, and the time gap current time of connected reference is nearest
Node.Recovery unit 704, for recycling the first lock permission of access shared resource to first node.Granting unit 702 is also used
In authorize access shared resource to hot node first locks permission.For example, first node can be in Fig. 5 in conjunction with Fig. 5
Node 3, management node 70 can be the node 1 in Fig. 5.Receiving unit 701 can be used for executing the movement of the reception in S203.It awards
Giving unit 702 can be used for executing S207.Determination unit 703 can be used for executing S210.Recovery unit 704 can be used for executing
Recycling step in S212.Granting unit 702, which can be also used for executing in S212, authorizes step.
In a kind of possible design, management node 70 further include: storage unit 705, it is interviewed for storing shared resource
The historical record asked is accessed historical record by the node of access time journal access shared resource.Determination unit 703
It specifically can be used for: selecting the number of connected reference shared resource to be greater than or equal in the historical record that shared resource is accessed
Preset threshold, and the node that access time is nearest apart from current time, as hot node.For example, in conjunction with Fig. 5, determination unit
703 can be used for executing S210.
In a kind of possible design, receiving unit 701 is also used to, and it is total to receive the second node access that second node reports
Enjoy the historical record of resource;Wherein, second node is the second lock permission of storage access shared resource at least two nodes
Node, second locks operation indicated by permission and operation mutual exclusion indicated by the first lock permission;Management node 70 can also include:
Adding unit 706, for being added to the accessed history note of shared resource for the historical record of second node access shared resource
In record.For example, second node can be node 2 in conjunction with Fig. 5.Receiving unit 701 can be used for executing the step of the reception in S206
Suddenly.Adding unit 706 can be used for executing the update step in S210.
In a kind of possible design, management node 70 can also include: transmission unit 707, in receiving unit 701
Before the historical record for receiving the second node access shared resource that second node reports, lock permission recycling is sent to second node
Order, wherein lock permission recycling order is used to indicate the second lock permission of second node release shared resource;Second node access
The historical record of shared resource is that second node is sent to management node after the second lock permission of release access shared resource.
For example, in conjunction with Fig. 5, transmission unit 707, for the step of executing the lock permission recycling order of the transmission in S205.
In a kind of possible design, receiving unit 701 is also used to, and after determination unit 703 determines hot node, is connect
Receive the historical record for the first node access shared resource that first node is sent;Management node 70 further include: adding unit 706,
For being added to the historical record of first node access shared resource in the accessed historical record of shared resource.For example, knot
Fig. 5 is closed, receiving unit 701 is used to execute the receiving step in S213.Adding unit 706 is for executing S214.
In a kind of possible design, management node 7 can also include: to delete unit 708, for deleting shared resource quilt
Invalidation history record in the historical record of access, invalidation history record are current true in the accessed historical record of shared resource
The node of shared resource is accessed before fixed hot node.
It should be noted that the above-mentioned each unit illustrated by way of example in management node 70 and illustrated above
The connection between some steps in embodiment of the method, in fact, each unit of management node 70 can also be performed it is illustrated above
Embodiment of the method in other correlation steps, will not enumerate herein.
In addition, another structural schematic diagram of management node 70, it can be with reference to the structural schematic diagram of the node 1 in Fig. 4.
A kind of hardware implementation mode of management node can refer to Fig. 8.As shown in figure 8, management node 80 may include: place
Manage device 801, Memory Controller Hub 802, memory 803, transceiver 804 and bus 805;Wherein, processor 801, Memory Controller Hub
802, memory 803, transceiver 805 are connected with each other by bus 805.Wherein, above-mentioned processing unit 701 can pass through processor
801 and/or Memory Controller Hub 802 realize.Transmit-Receive Unit 702 can be realized by transceiver 804.
Processor 801 can be CPU, general processor, digital signal processor (digital signal
Processor, DSP), specific integrated circuit (application-specific integrated circuit, ASIC) is existing
Field programmable gate array (field programmable gate array, FPGA) or other programmable logic device, crystal
Pipe logical device, hardware component or any combination thereof.It, which may be implemented or executes, combines described in present disclosure
Various illustrative logic blocks, module and circuit.The processor be also possible to realize computing function combination, such as comprising
One or more microprocessors combination, DSP and the combination of microprocessor etc..Bus 805 can be Peripheral Component Interconnect standard
(peripheral component interconnect, PCI) bus or expanding the industrial standard structure (extended
Industry standard architecture, EISA) bus etc..The bus can be divided into address bus, data/address bus,
Control bus etc..Only to be indicated with a thick line in Fig. 8, it is not intended that an only bus or a seed type convenient for indicating
Bus.
Since management node provided by the embodiments of the present application can be used for executing the access to shared resource of above-mentioned offer
The locking method of operation, therefore it can be obtained technical effect can refer to above method embodiment, the embodiment of the present application is herein
It repeats no more.
The step of method in conjunction with described in present disclosure or algorithm can realize in a manner of hardware, can also
It is realized in a manner of being to execute software instruction by processing module.Software instruction can be made of corresponding software module, software
Module can be stored on random access memory (random access memory, RAM), flash memory, read-only memory (read
Only memory, ROM), Erasable Programmable Read Only Memory EPROM (erasable programmable ROM, EPROM), electricity can
Erasable programmable read-only memory (electrically EPROM, EEPROM), register, hard disk, mobile hard disk, CD-ROM
(CD-ROM) or in the storage medium of any other form well known in the art.A kind of illustrative storage medium is coupled to place
Device is managed, to enable a processor to from the read information, and information can be written to the storage medium.Certainly, it stores
Medium is also possible to the component part of processor.Pocessor and storage media can be located in ASIC.
Those skilled in the art are it will be appreciated that in said one or multiple examples, function described herein
It can be realized with hardware, software, firmware or their any combination.It when implemented in software, can be by these functions
Storage in computer-readable medium or as on computer-readable medium one or more instructions or code transmitted.
Computer-readable medium includes computer storage media and communication media, and wherein communication media includes convenient for from a place to another
Any medium of one place transmission computer program.Storage medium can be general or specialized computer can access it is any
Usable medium.
The above specific embodiment has carried out further specifically the purpose of the application, technical scheme and beneficial effects
It is bright, it should be understood that being not used to limit the protection of the application the foregoing is merely the specific embodiment of the application
Range.
Claims (14)
1. the method that the access operation of a kind of pair of shared resource locks, which is characterized in that applied to the management in distributed system
Node, the management node are used to manage the lock permission of at least two node visit shared resources in the distributed system,
The node for obtaining the lock permission executes operation indicated by the lock permission to the shared resource;The described method includes:
The lock authority request that the first node at least two node is sent is received, the lock authority request is visited for requesting
Ask that the first lock permission of the shared resource, the first lock permission are one of described lock permission lock permissions;
The first lock permission of the access shared resource is authorized to the first node;
Determine hot node, wherein the hot node is shared resource described in connected reference at least two node
Number is greater than or equal to preset threshold, and the time gap current time nearest node of connected reference;
The first lock permission of the shared resource is accessed to first node recycling, and authorizes visit to the hot node
Ask the first lock permission of the shared resource.
2. the method according to claim 1, wherein it is accessed to store the shared resource in the management node
Historical record, the accessed historical record is by the access time journal node of the access shared resource, institute
State determining hot node, comprising:
The number of shared resource described in connected reference is selected to be greater than or equal in the historical record that the shared resource is accessed
The preset threshold, and the node that access time is nearest apart from current time, as the hot node.
3. according to the method described in claim 2, it is characterized in that, authorizing access the shared resource to the first node
First lock permission before, the method also includes:
Receive the historical record that the second node that second node reports accesses the shared resource;Wherein, second section
Point is the node for the second lock permission that storage accesses the shared resource at least two node, second lock permission institute
The operation of instruction and operation mutual exclusion indicated by the first lock permission;
The historical record that the second node is accessed to the shared resource is added to the accessed history note of the shared resource
In record.
4. according to the method described in claim 3, it is characterized in that, the second node reported in the reception second node
Before the historical record for accessing the shared resource, the method also includes:
Lock permission recycling order is sent to the second node, wherein the lock permission recycling order is used to indicate described second
Node discharges the second lock permission of the shared resource;The historical record that the second node accesses the shared resource is
The second node is sent to the management node after the second lock permission that release accesses the shared resource.
5. method according to any one of claims 1 to 4, which is characterized in that described after the determining hot node
Method further include:
Receive the historical record that the first node that the first node is sent accesses the shared resource;
The historical record that the first node is accessed to the shared resource is added to the accessed history note of the shared resource
In record.
6. method according to any one of claims 2 to 5, which is characterized in that the method also includes:
The invalidation history record in the accessed historical record of the shared resource is deleted, the invalidation history record is described total
The node of the shared resource is accessed before enjoying hot node currently determining in the accessed historical record of resource.
7. a kind of management node, which is characterized in that the management node is at least two nodes in managing distributing type system
The lock permission for accessing shared resource, the node for obtaining the lock permission execute indicated by the lock permission shared resource
Operation;The management node includes:
Receiving unit, for receiving the lock authority request of the transmission of the first node at least two node, the lock permission
The first lock permission for requesting access to the shared resource is requested, the first lock permission is one of described lock permission lock
Permission;
Granting unit, for authorizing the first lock permission of the access shared resource to the first node;
Determination unit, for determining hot node, wherein the hot node is connected reference institute at least two node
The number for stating shared resource is greater than or equal to preset threshold, and the time gap current time nearest node of connected reference;
Recovery unit, for accessing the first lock permission of the shared resource to first node recycling;
The granting unit is also used to, and Xiang Suoshu hot node authorizes the first lock permission of the access shared resource.
8. management node according to claim 7, which is characterized in that the management node further include:
Storage unit, for storing the accessed historical record of the shared resource, when the accessed historical record is by access
Between the journal node of the access shared resource;
The determination unit is specifically used for, and selects to share described in connected reference in the historical record that the shared resource is accessed
The number of resource is greater than or equal to the preset threshold, and the node that access time is nearest apart from current time, as the heat
Point node.
9. management node according to claim 8, which is characterized in that
The receiving unit is also used to, and receives the history note that the second node that second node reports accesses the shared resource
Record;Wherein, the second node is the section for the second lock permission that storage accesses the shared resource at least two node
Point, described second locks operation indicated by permission and operation mutual exclusion indicated by the first lock permission;
The management node further include: adding unit, for the second node to be accessed to the historical record of the shared resource,
It is added in the accessed historical record of the shared resource.
10. management node according to claim 9, which is characterized in that the management node further include:
Transmission unit, it is described shared for receiving the second node access that the second node reports in the receiving unit
Before the historical record of resource, Xiang Suoshu second node sends lock permission recycling order, wherein the lock permission recycling order is used
The second lock permission of the shared resource is discharged in the instruction second node;The second node accesses the shared money
The historical record in source is described in the second node is sent to after the second lock permission that release accesses the shared resource
Management node.
11. according to the described in any item management nodes of claim 7 to 10, which is characterized in that
The receiving unit is also used to, and after the determination unit determines the hot node, receives the first node hair
The first node sent accesses the historical record of the shared resource;
The management node further include: adding unit, for the first node to be accessed to the historical record of the shared resource,
It is added in the accessed historical record of the shared resource.
12. management node according to any one of claims 8 to 11, which is characterized in that the management node further include:
Unit is deleted, it is described to go through in vain for deleting the invalidation history record in the accessed historical record of the shared resource
Records of the Historian record accesses the shared resource before being hot node currently determining in the accessed historical record of the shared resource
Node.
13. a kind of distributed system characterized by comprising such as the described in any item management nodes of claim 7 to 12, institute
Management node is stated for managing the lock permission of at least two node visit shared resources in the distributed system, is obtained described
The node of lock permission executes operation indicated by the lock permission to the shared resource.
14. a kind of computer readable storage medium, is stored thereon with computer program, which is characterized in that described program is calculating
When being run on machine, so that as method as claimed in any one of claims 1 to 6 is performed.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201711003058.1A CN109697127B (en) | 2017-10-24 | 2017-10-24 | Method and device for locking access operation of shared resource |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201711003058.1A CN109697127B (en) | 2017-10-24 | 2017-10-24 | Method and device for locking access operation of shared resource |
Publications (2)
Publication Number | Publication Date |
---|---|
CN109697127A true CN109697127A (en) | 2019-04-30 |
CN109697127B CN109697127B (en) | 2020-12-01 |
Family
ID=66227887
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201711003058.1A Active CN109697127B (en) | 2017-10-24 | 2017-10-24 | Method and device for locking access operation of shared resource |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN109697127B (en) |
Cited By (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110287665A (en) * | 2019-05-08 | 2019-09-27 | 口碑(上海)信息技术有限公司 | Equipment uses distribution method, device and storage medium, the electronic device of equity |
CN110659303A (en) * | 2019-10-10 | 2020-01-07 | 北京优炫软件股份有限公司 | Read-write control method and device for database nodes |
CN112463757A (en) * | 2020-12-17 | 2021-03-09 | 北京浪潮数据技术有限公司 | Resource access method of distributed system and related device |
CN113296904A (en) * | 2021-02-10 | 2021-08-24 | 阿里巴巴集团控股有限公司 | Distributed lock scheduling method and device in distributed system |
CN113535415A (en) * | 2021-06-21 | 2021-10-22 | 福建天泉教育科技有限公司 | Resource acquisition method and terminal |
Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102298539A (en) * | 2011-06-07 | 2011-12-28 | 华东师范大学 | Method and system for scheduling shared resources subjected to distributed parallel treatment |
US20120144138A1 (en) * | 2010-12-02 | 2012-06-07 | International Business Machines Corporation | Locking Access To Data Storage Shared By A Plurality Of Compute Nodes |
CN103297456A (en) * | 2012-02-24 | 2013-09-11 | 阿里巴巴集团控股有限公司 | Method for accessing sharing resources in distributed system and distributed system |
CN103716383A (en) * | 2013-12-13 | 2014-04-09 | 华为技术有限公司 | Method and device for accessing shared resources |
CN104702655A (en) * | 2014-03-21 | 2015-06-10 | 杭州海康威视系统技术有限公司 | Cloud storage resource distribution method and system |
CN104750562A (en) * | 2013-12-30 | 2015-07-01 | 中国银联股份有限公司 | Lock processing system and method in distributed system |
CN106302825A (en) * | 2016-10-31 | 2017-01-04 | 杭州华为数字技术有限公司 | File access control method and device |
-
2017
- 2017-10-24 CN CN201711003058.1A patent/CN109697127B/en active Active
Patent Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20120144138A1 (en) * | 2010-12-02 | 2012-06-07 | International Business Machines Corporation | Locking Access To Data Storage Shared By A Plurality Of Compute Nodes |
CN102298539A (en) * | 2011-06-07 | 2011-12-28 | 华东师范大学 | Method and system for scheduling shared resources subjected to distributed parallel treatment |
CN103297456A (en) * | 2012-02-24 | 2013-09-11 | 阿里巴巴集团控股有限公司 | Method for accessing sharing resources in distributed system and distributed system |
CN103716383A (en) * | 2013-12-13 | 2014-04-09 | 华为技术有限公司 | Method and device for accessing shared resources |
CN104750562A (en) * | 2013-12-30 | 2015-07-01 | 中国银联股份有限公司 | Lock processing system and method in distributed system |
CN104702655A (en) * | 2014-03-21 | 2015-06-10 | 杭州海康威视系统技术有限公司 | Cloud storage resource distribution method and system |
CN106302825A (en) * | 2016-10-31 | 2017-01-04 | 杭州华为数字技术有限公司 | File access control method and device |
Cited By (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110287665A (en) * | 2019-05-08 | 2019-09-27 | 口碑(上海)信息技术有限公司 | Equipment uses distribution method, device and storage medium, the electronic device of equity |
CN110287665B (en) * | 2019-05-08 | 2020-09-15 | 口碑(上海)信息技术有限公司 | Method and device for allocating device use rights, storage medium and electronic device |
CN110659303A (en) * | 2019-10-10 | 2020-01-07 | 北京优炫软件股份有限公司 | Read-write control method and device for database nodes |
CN112463757A (en) * | 2020-12-17 | 2021-03-09 | 北京浪潮数据技术有限公司 | Resource access method of distributed system and related device |
CN113296904A (en) * | 2021-02-10 | 2021-08-24 | 阿里巴巴集团控股有限公司 | Distributed lock scheduling method and device in distributed system |
CN113535415A (en) * | 2021-06-21 | 2021-10-22 | 福建天泉教育科技有限公司 | Resource acquisition method and terminal |
CN113535415B (en) * | 2021-06-21 | 2023-08-04 | 福建天泉教育科技有限公司 | Resource acquisition method and terminal |
Also Published As
Publication number | Publication date |
---|---|
CN109697127B (en) | 2020-12-01 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN109697127A (en) | The method and apparatus that the access operation of a kind of pair of shared resource locks | |
CN106575238B (en) | Concurrency control in shared storage architectures supporting page implicit locks | |
US6976131B2 (en) | Method and apparatus for shared cache coherency for a chip multiprocessor or multiprocessor system | |
US6678799B2 (en) | Aggregation of cache-updates in a multi-processor, shared-memory system | |
US7249152B2 (en) | Dynamic disk space management by multiple database server instances in a cluster configuration | |
CN105872040B (en) | A method of write performance is stored using gateway node cache optimization distributed block | |
US8818942B2 (en) | Database system with multiple layer distribution | |
US20170177484A1 (en) | Region probe filter for distributed memory system | |
US20150067269A1 (en) | Method for building multi-processor system with nodes having multiple cache coherency domains | |
CN103744799B (en) | A kind of internal storage data access method, device and system | |
CN107038123A (en) | Snoop filter for the buffer consistency in data handling system | |
US20180336076A1 (en) | Parameter-sharing apparatus and method | |
CN107577678A (en) | The method of processing data storehouse affairs, client and server | |
JPH0628250A (en) | Method for continuation of data movement from memory and method for control of data movement | |
CN103559319B (en) | The cache synchronization method and equipment of distributed cluster file system | |
JP2011511989A (en) | An adaptive cache organization method for chip multiprocessors. | |
CN103716383B (en) | A kind of method and device for accessing shared resource | |
CN106201980A (en) | Processing unit and processing method thereof | |
KR20110066940A (en) | System accessing shared data by a plurality of application servers | |
CN107229593A (en) | The buffer consistency operating method and multi-disc polycaryon processor of multi-disc polycaryon processor | |
JP2004531005A (en) | Partitioning database ownership between different database servers to control access to the database | |
US10540283B2 (en) | Coherence de-coupling buffer | |
CN103970678B (en) | Catalogue designing method and device | |
CN106227674B (en) | Cache coherence controller and method | |
US7080213B2 (en) | System and method for reducing shared memory write overhead in multiprocessor systems |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |