WO2015085826A1 - Method and apparatus for accessing shared resource - Google Patents

Method and apparatus for accessing shared resource Download PDF

Info

Publication number
WO2015085826A1
WO2015085826A1 PCT/CN2014/088928 CN2014088928W WO2015085826A1 WO 2015085826 A1 WO2015085826 A1 WO 2015085826A1 CN 2014088928 W CN2014088928 W CN 2014088928W WO 2015085826 A1 WO2015085826 A1 WO 2015085826A1
Authority
WO
WIPO (PCT)
Prior art keywords
lock
node
identifier
client
shared resource
Prior art date
Application number
PCT/CN2014/088928
Other languages
French (fr)
Chinese (zh)
Inventor
邹蛟同
Original Assignee
华为技术有限公司
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Publication of WO2015085826A1 publication Critical patent/WO2015085826A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements 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/46Multiprogramming arrangements
    • G06F9/52Program synchronisation; Mutual exclusion, e.g. by means of semaphores
    • G06F9/526Mutual exclusion algorithms

Definitions

  • the present invention relates to the field of data communication technologies, and in particular, to a method and an apparatus for accessing shared resources.
  • the storage array is the storage carrier of the storage device.
  • the storage array provides virtualized shared resources for the host application.
  • data is simultaneously written to the storage arrays of the two storage devices.
  • the other storage device can still provide external services to implement data disaster recovery.
  • a mutual exclusion mechanism needs to be provided between two storage devices to prevent concurrent access of shared resources (each storage device includes multiple nodes, and each node includes multiple clients) As shown in FIG.
  • the client refers to a process in which a node accesses a shared resource
  • the client refers to a process in which a node accesses a shared resource
  • the lock manager is a commonly used mutual exclusion protection mechanism between nodes. It allows a shared resource to be accessed by only one client at a time.
  • the process of accessing shared resources through the lock manager is as follows (as shown in the figure). 1C):
  • node 1 node 1
  • node 2 node 3
  • Step a assign a lock manager to the shared resource A;
  • Step b When the node 2 needs to access the shared resource A, apply to the lock manager for the lock authority corresponding to the shared resource A;
  • Step c After obtaining the lock permission corresponding to the shared resource A, the node 2 accesses the shared resource A;
  • Step d Node 3 applies to the lock manager for the lock permission corresponding to the shared resource A. Since the lock has been authorized, the lock manager suspends the authorization of the lock request of other rights conflicts, and only the lock holder of the conflict releases the lock permission. After that, the new lock request will be authorized.
  • the lock manager is used to achieve the orderly access of the same shared resource by multiple clients, and the consistency of the accessed data is ensured.
  • the current lock manager has the following drawbacks: when some nodes are not the same node as the lock manager node, when acquiring the lock identifier corresponding to the lock authority of any shared resource, the other node is required to acquire the lock permission. A problem that takes a long time.
  • the embodiment of the invention provides a method and a device for accessing a shared resource, which are used to solve the problem that the current method for accessing the shared resource has a long time.
  • a method of accessing a shared resource including:
  • the lock permission request is forwarded when the first node sends the lock identifier that is sent by the client of the first node and does not find the identifier of the shared resource in the first node;
  • the first node is configured to cache a lock identifier corresponding to a lock authority occupied by each client in the first node, or an occupied idle time The lock identifier corresponding to the lock authority that is smaller than the delete threshold.
  • the receiving, by the first node, the lock permission request that carries the identifier of the shared resource specifically includes:
  • the lock permission request is forwarded by the second node when receiving the lock identifier sent by the first node and not finding the identifier of the shared resource in the first node.
  • the second node is configured to cache a lock identifier corresponding to the occupied lock authority in the specified lock authority, or The lock identifier corresponding to the lock authority that is occupied by the lock authority and whose idle time is less than the deletion threshold.
  • the determining, by the first node, the lock identifier is Client, specifically:
  • the determining, by the first node, the lock identifier is Client, specifically:
  • the lock permission recall instruction is sent to the client occupying the lock permission, so that the client occupying the lock authority completes accessing the shared resource and then releases The lock authority;
  • an apparatus for accessing a shared resource including:
  • a receiving unit configured to receive a lock permission request that is forwarded by the first node and that carries the identifier of the shared resource, where the lock permission request is sent by the first node at the client that receives the first node, and is in the first Forwarded when the lock identifier of the identifier of the shared resource is not found in the node;
  • a determining unit configured to determine, from the stored lock identifier, a lock label including an identifier of the shared resource knowledge
  • An allocating unit configured to allocate the determined lock identifier to the client by using the first node, and give the client a lock right corresponding to the lock identifier of the shared resource, for the client Access to the shared resource.
  • the lock permission request received by the receiving unit is sent by the first node, and the first node is used to cache the first node.
  • the receiving unit is specifically configured to:
  • the lock permission request is forwarded by the second node when receiving the lock identifier sent by the first node and not finding the identifier of the shared resource in the first node.
  • the lock permission request received by the receiving unit is sent by the second node, and the second node is used by the second node.
  • the allocation unit is specifically configured to:
  • the allocation unit is specifically configured to:
  • the lock permission recall instruction is sent to the client occupying the lock permission, so that the client occupying the lock authority completes accessing the total Release the lock permission after enjoying the resource;
  • the lock permission request that carries the identifier of the shared resource forwarded by the first node is received, where the lock permission request is sent by the first node to the client that receives the first node.
  • the lock identifier including the identifier of the shared resource is not found in the first node, and then determining a lock identifier including the identifier of the shared resource from the stored lock identifier, and finally, determining The lock identifier is allocated to the client by the first node, and the client is given a lock right corresponding to the lock identifier of the shared resource, and is used by the client to access the shared resource.
  • the first node after receiving the lock permission request sent by the client of the first node, the first node does not find the target including the shared resource in the first node. The lock is only forwarded when the lock is identified.
  • the lock identifier of the identifier of the shared resource is first searched in the first node, and only when it does not exist, the forwarding is performed, and when it exists, the direct assignment is performed.
  • FIG. 1A is a schematic structural diagram of a dual active data center in the prior art
  • 1B is a schematic structural diagram of a node and a client in the prior art
  • 1C is a schematic diagram of accessing shared resources in a dual-active data center in the prior art
  • FIG. 2 is a schematic diagram of accessing a shared resource according to an embodiment of the present invention.
  • FIG. 3 is a first embodiment of accessing a shared resource according to an embodiment of the present invention.
  • FIG. 5 is a schematic structural diagram of a device for accessing a shared resource according to an embodiment of the present invention.
  • system and “network” are used interchangeably herein.
  • the term “and/or” in this context is merely an association describing the associated object, indicating that there may be three relationships, for example, A and / or B, which may indicate that A exists separately, and both A and B exist, respectively. B these three situations.
  • the letter “/” in this article generally indicates that the contextual object is an "or" relationship.
  • the lock permission request that carries the identifier of the shared resource forwarded by the first node is received, where the lock permission request is received by the first node. And forwarding, when the lock identifier sent by the client of the first node and not identifying the identifier of the shared resource is found in the first node, and then determining the lock identifier including the identifier of the shared resource from the stored lock identifier, Finally, the determined lock identifier is assigned to the client through the first node, and the lock permission corresponding to the lock identifier of the shared resource is given to the client for accessing the shared resource by the client.
  • the first node is receiving After the lock permission request sent by the client of the first node is forwarded, the lock identifier including the identifier of the shared resource is not found in the first node, that is, the first node is first searched for whether to include the share.
  • the lock identifier of the identifier of the resource when it exists, directly allocates it, and only forwards when it does not exist, and the client obtains the lock identifier from the first node. To identify the other nodes to acquire the lock takes less time, therefore, to solve the long time-consuming problems of current methods to access shared resources.
  • Step 200 Receive a lock permission request that carries the identifier of the shared resource forwarded by the first node, where the lock permission request is sent by the first node after receiving the client of the first node, and is not found in the first node. Forwarded when the lock identifier of the shared resource identifier is used;
  • Step 210 Determine, from the stored lock identifier, a lock identifier that includes an identifier of the shared resource.
  • Step 220 Assign the determined lock identifier to the client through the first node, and give the client the lock permission corresponding to the lock identifier of the shared resource, and use the client to access the shared resource.
  • the lock identifier includes the following information, the identifier of the protected shared resource, and the manner of accessing the shared resource.
  • other information than the above two types of information may also be included, and details are not further described herein. Said.
  • a shared resource for example, a method of reading a shared resource.
  • the client acquires the permission to read the shared resource, and, for example, writes the shared resource.
  • the permission obtained by the client to write the shared resource wherein if the acquired permission to read the shared resource is obtained, the client can only perform the read operation on the shared resource, and cannot perform the write operation; if the obtained write share is obtained.
  • the permission of the resource the client can not only read the shared resource, but also perform the write operation.
  • there are other ways to access the shared resource and the details are not detailed here. .
  • the first node has multiple forms, for example, may be used to cache a lock identifier corresponding to the lock authority occupied by each client in the first node, or the occupied idle time is less than the deletion threshold.
  • the lock identifier corresponding to the lock authority may also be used to cache other information, which is not detailed here.
  • the client may send a lock permission request for accessing the shared resource to the first node where the client is located, If the lock identifier of the identifier of the shared resource to be accessed is currently stored in the first node, the first node allocates the corresponding lock identifier to the client, if the first node does not currently store the shared resource to be accessed.
  • the lock identifier of the identifier the first node sends a lock permission request for accessing the shared resource to the lock manager that manages the lock authority of the shared resource of the different node, and then assigns the lock identifier returned by the received lock manager to The client, and stores the lock identifier, then the first node receives the lock permission for accessing the shared resource sent by the client again. While, if the lock identifier is not allocated, then the lock identification assigned to clients, thereby avoiding a longer acquire the lock identified problems exist in the process time-consuming.
  • the node where the client 1 is located is in the first storage device, and the lock manager is located in the second storage device, wherein the lock manager manages the lock permission of the first storage device and the second storage device to access the shared resource, and the client 1
  • the lock identifier of the first shared resource is obtained, that is, the lock permission
  • the lock permission request for accessing the first shared resource may be directly sent to the lock manager located at the second storage device, and at this time, because it is between the two storage devices Communication interaction, therefore, there is a problem that takes a long time.
  • the client 1 can send the client to the client.
  • the first node that is located at 1 sends a lock permission request for accessing the first shared resource. If the lock identifier of the first shared resource is cached in the first node, and the lock identifier is not allocated, the first node sends the lock identifier. To the client 1, that is, to assign the lock permission to the first shared resource to the client 1; if the lock of the first shared resource is not cached in the first node The first node sends a lock permission request for accessing the first shared resource to the lock manager, sends the lock identifier returned by the received lock manager to the client, and caches the lock identifier, so as to receive the client again. 1 or when the client sends a lock permission request to access the first shared resource, if the lock identifier is not If it is assigned, the lock ID is sent to the client.
  • the request for the lock permission to carry the identifier of the shared resource forwarded by the first node may be received by the first node, for example, the lock permission request of the identifier of the shared resource that is forwarded by the first node by the second node may be received, where The lock permission request is forwarded by the second node when receiving the lock identifier sent by the first node and not identifying the identifier of the shared resource in the first node, where the foregoing is only receiving the shared resource carried by the first node.
  • An implementation manner of the identified lock permission request in actual application, there are other implementation manners, which are not described in detail herein.
  • the implementation of the lock permission request for receiving the identifier of the shared resource forwarded by the first node by the second node is as follows:
  • the first storage device and the second storage device share 10 shared resources: shared resource 1, shared resource 2, ..., each shared resource corresponds to a lock identifier, and the second node located at the first storage device can store 10 The lock identifier corresponding to the shared resource, that is, the lock permission for accessing the 10 shared resources.
  • the second node sends a lock permission request for accessing the shared resource 1, and acquires a lock identifier corresponding to the shared resource 1 from the second node; in order to improve efficiency, the client 1 may also first send the access shared resource 1 to the first node where it is located.
  • the lock permission request if the first node caches a lock identifier corresponding to the shared resource 1, the first node sends the lock identifier to the client 1, and assigns the lock permission to the client 1, if the first node is not cached
  • the lock identifier corresponding to the shared resource 1 is forwarded by the first node to the second node to access the lock permission request of the shared resource 1, and the received second node sends the shared resource 1 corresponding to the client ID to the lock 1, the lock authority to assign a client.
  • the second node has multiple forms, optionally, used to cache the lock identifier corresponding to the occupied lock authority in the specified lock authority, or the idle time occupied by the specified lock authority is less than Delete the lock identifier corresponding to the lock permission of the threshold.
  • a storage device may further include a plurality of second nodes, where the second node is configured to cache a lock identifier corresponding to the occupied lock authority in the specified lock authority, or is occupied by the specified lock authority.
  • the lock identifier corresponding to the lock authority whose idle time is less than the deletion threshold. At this time, the second node is different. You can manage lock identifiers for different shared resources.
  • the first storage device and the second storage device share 10 shared resources: shared resource 1, shared resource 2, ..., each shared resource corresponds to a lock identifier, and the second node 1 located at the first storage device manages sharing.
  • the identifier that is, the lock permission for accessing 10 shared resources. If the client 1 located at the first storage device wants to access the shared resource 1, the client 1 can directly send the access shared resource to the lock manager located at the second storage device.
  • the lock permission request acquires the lock identifier corresponding to the shared resource 1 from the lock manager; in order to improve the efficiency, the client 1 may first send a lock permission request for accessing the shared resource 1 to the first node where the first node is located, if the first node
  • the cache has a lock identifier corresponding to the shared resource 1, and the first node sends the lock identifier to the client 1, and assigns the lock permission to the client 1, if the first node is not cached
  • the lock identifier corresponding to the shared resource 1 is forwarded to the second node 1 by the first node to access the lock permission request of the shared resource 1. If the lock identifier of the identifier including the shared resource is not found in the second node 1, the switch forwards to the lock.
  • the manager sends the lock identifier corresponding to the shared resource 1 sent by the received lock manager to the client 1 through the first node, and assigns the lock authority to the client 1.
  • the client 2 located at the first storage device wants to access the shared resource 10
  • the client 2 can directly send a lock permission request for accessing the shared resource 10 to the lock manager located at the second storage device, from the lock manager.
  • the lock identifier is sent by the third node to the client 2, and the lock authority is assigned to the client 2.
  • the third node is The second node 2 forwards the lock permission request for accessing the shared resource 10. If the lock identifier corresponding to the shared resource 10 is not cached in the second node 2, the second node 2 forwards the lock permission request for accessing the shared resource 10 to the lock manager. And the lock identifier corresponding to the shared resource 10 sent by the received lock manager is sent to the client 2 through the third node, and the lock authority is allocated to the client 2.
  • the above embodiment only enumerates the case where only one second node exists in one storage device, in practice. In an application, there may also be a case where a storage device has multiple second nodes. If a storage device has multiple second nodes, when the client sends a lock permission request for accessing the shared resource, the client first sends a lock permission request for accessing the shared resource to the first node where the client is located, if the client is located at the first node.
  • a lock identifier corresponding to the shared resource to be accessed is cached in a node, and the first node where the client is located sends a lock identifier corresponding to the shared resource to be accessed to the client, if the first node where the client is located is not If the lock identifier corresponding to the shared resource to be accessed is cached, the lock permission request for accessing the shared resource is forwarded to the corresponding second node, and if the lock identifier corresponding to the shared resource to be accessed is cached in the second node, The two nodes send the lock identifier corresponding to the shared resource to be accessed to the client. If the lock identifier corresponding to the shared resource to be accessed is not cached in the second node, the lock permission request for accessing the shared resource is forwarded to the lock management. Device.
  • the first node may directly receive the lock permission request of the identifier of the shared resource that is forwarded by the first node.
  • the second node may receive a lock permission request that receives the identifier of the shared resource forwarded by the first node.
  • the determined lock identifier is allocated to the client through the first node.
  • the determined lock identifier may be directly allocated to the client through the first node; or, The determined lock identifier is sent to the first node by the second node such that the first node assigns the lock identifier to the client.
  • the client sends a lock permission request for accessing the shared resource to the first node or the second node, whether the lock permission request for accessing the shared resource is directly sent to the lock manager, and the lock for receiving the request is received.
  • the lock identifier corresponding to the accessed shared resource may be stored in the manager or the node, but the lock identifier is sent to the client, that is, the lock authority corresponding to the lock identifier is occupied. At this time, the lock corresponding to the determined lock identifier is used.
  • the lock permission recall instruction is sent to the client occupying the lock permission, so that the client occupying the lock privilege releases the lock privilege after accessing the shared resource; and the lock privilege released by the client occupying the lock privilege corresponds to
  • the lock identifier is assigned to the client through the first node.
  • the determined lock identifier there are multiple ways to assign the determined lock identifier to the client through the first node. For example, if the lock permission corresponding to the determined lock identifier is occupied by other clients, the lock permission is sent to the client occupying the lock permission.
  • the recall indication is such that the client occupying the lock authority releases the lock permission after accessing the shared resource, and the lock identifier corresponding to the lock authority released by the client occupying the lock authority is allocated to the client through the first node.
  • the client 1 sends a lock permission request for accessing the shared resource 1 to the second node, and if the lock identifier corresponding to the shared resource 1 cached in the second node is assigned to another node, that is, the lock corresponding to the lock identifier
  • the lock privilege recall instruction is sent to the client 2 occupying the lock privilege, so that the client 2 occupying the lock privilege releases the lock privilege when accessing the shared resource, and then the second node occupies the lock privilege again.
  • the lock identifier corresponding to the lock permission released by the client 2 is assigned to the client 1.
  • the lock identifier corresponding to the shared resource to be accessed in the second node is allocated to the other client as an example.
  • the first node where the client is located may be used, or The lock identifier corresponding to the shared resource to be accessed cached in the lock manager is allocated to other clients.
  • the first node or the lock manager sends a lock permission recall instruction to the client occupying the lock authority, and the process is as follows. The embodiments are the same and will not be described in detail herein.
  • An embodiment of obtaining a lock identifier by a primary lock authority agent node An embodiment of obtaining a lock identifier by a primary lock authority agent node.
  • Embodiment 1 (shown in Figure 3):
  • Step 300 The client 1 sends a lock permission request for accessing the shared resource 1 to the first node where the client 1 is located;
  • Step 310 The first node determines whether the lock identifier corresponding to the shared resource 1 is stored in the first node, and the lock identifier is not allocated, and if so, step 350 is performed; otherwise, step 320 is performed;
  • Step 320 The first node sends a lock permission request for accessing the shared resource 1 to the lock manager.
  • the lock manager is located at the second storage device.
  • Step 330 The lock manager determines whether a lock label corresponding to the shared resource 1 is stored in the first node. Knowledge, and the lock identifier is not assigned; if yes, step 340 is performed, otherwise, step 360 is performed;
  • Step 340 The lock manager sends the lock identifier corresponding to the shared resource 1 to the first node;
  • Step 350 The first node sends a lock identifier corresponding to the shared resource 1 to the client 1;
  • Step 360 The lock manager sends a lock permission recall indication to the client 2 occupying the lock authority, and sends the lock identifier corresponding to the lock authority released by the client 2 occupying the lock authority to the client 1 through the first node.
  • Embodiment 2 (as shown in Figure 4):
  • Step 400 The client 1 sends a lock permission request for accessing the shared resource 1 to the first node where the client 1 is located;
  • Step 410 The first node determines whether the lock identifier corresponding to the shared resource 1 is stored in the first node, and the lock identifier is not allocated, and if so, step 480 is performed; otherwise, step 420 is performed;
  • Step 420 The first node sends a lock permission request for accessing the shared resource 1 to the second node.
  • the client 1 and the second node are located at the first storage device.
  • Step 430 The second node determines whether the lock identifier corresponding to the shared resource 1 is stored in the first node, and the lock identifier is not allocated, and if so, step 470 is performed; otherwise, step 440 is performed;
  • Step 440 The second node sends a lock permission request for accessing the shared resource 1 to the lock manager.
  • the lock manager is located at the second storage device.
  • Step 450 The lock manager determines whether the lock identifier corresponding to the shared resource 1 is stored in the first node, and the lock identifier is not allocated; if yes, step 460 is performed; otherwise, step 490 is performed;
  • Step 460 The lock manager sends the lock identifier corresponding to the shared resource 1 to the second node;
  • Step 470 The second node sends the lock identifier corresponding to the shared resource 1 to the first node.
  • Step 480 The first node sends a lock identifier corresponding to the shared resource 1 to the client 1;
  • Step 490 The lock manager sends a lock permission recall indication to the client 2 that occupies the lock authority, and forwards the lock identifier corresponding to the lock authority released by the client 2 that occupies the lock authority to the first node through the second node, so that the first The node sends to client 1.
  • an embodiment of the present invention further provides an apparatus for accessing a shared resource, where the apparatus includes a receiving unit 500, a determining unit 510, and an allocating unit 520, where:
  • the receiving unit 500 is configured to receive, by the first node, a lock permission request that carries the identifier of the shared resource, where the lock permission request is sent by the first node on the client that receives the first node, and is not in the first node. Forwarded when a lock identifier including the identity of the shared resource is found;
  • a determining unit 510 configured to determine, from the stored lock identifier, a lock identifier that includes an identifier of the shared resource
  • the allocating unit 520 is configured to allocate the determined lock identifier to the client by using the first node, and give the client a lock right corresponding to the lock identifier of the shared resource, for the client to access the shared resource.
  • the lock permission request received by the receiving unit 500 is sent by the first node, and the first node is configured to cache a lock identifier corresponding to the lock authority occupied by each client in the first node. Or the lock identifier corresponding to the lock authority whose idle time is less than the deletion threshold.
  • the receiving unit 500 is specifically configured to:
  • the lock permission request is forwarded by the second node when receiving the lock identifier sent by the first node and not identifying the identifier including the shared resource in the first node.
  • the lock permission request received by the receiving unit 500 is sent by the second node, and the second node is configured to cache the lock identifier corresponding to the occupied lock authority in the specified lock authority, or specify The lock identifier corresponding to the lock authority that is occupied by the lock authority and whose idle time is less than the delete threshold.
  • the allocating unit 520 is specifically configured to:
  • the determined lock identifier is sent to the first node through the second node such that the first node assigns the lock identifier to the client.
  • the allocating unit 520 is specifically configured to:
  • the lock permission recall instruction is sent to the client occupying the lock permission, so that the client occupying the lock permission releases the lock right after accessing the shared resource;
  • the lock identifier corresponding to the lock authority released by the client occupying the lock authority is allocated to the client through the first node.
  • the lock permission request that carries the identifier of the shared resource forwarded by the first node is received, where the lock permission request is sent by the first node on the client that receives the first node, and And forwarding, when the lock identifier of the identifier of the shared resource is not found in the first node, and then determining a lock identifier including the identifier of the shared resource from the stored lock identifier, and finally, determining the determined lock identifier by using the first node Assigned to the client, giving the client the lock permission corresponding to the lock identifier of the shared resource, for the client to access the shared resource, in the scheme, the first node receives the lock permission sent by the client of the first node After the request, the lock identifier of the identifier including the shared resource is not found in the first node, that is, the lock identifier of the identifier of the shared resource is first searched in the first node, and only exists in the absence of the lock identifier of the
  • the forwarding when it exists, the direct allocation is performed, and the client obtains the lock identifier from the first node than when the other node acquires the lock identifier. Less, therefore, to solve the problem of a longer time-consuming methods currently exist to access shared resources.
  • the computer program instructions can also be stored in a computer readable memory that can direct a computer or other programmable data processing device to operate in a particular manner, such that the instructions stored in the computer readable memory produce an article of manufacture comprising the instruction device.
  • the apparatus functions in one or more blocks of a flow or a flow diagram and/or block diagram of a flowchart.
  • These computer program instructions can also be loaded onto a computer or other programmable data processing device such that a series of operational steps are performed on a computer or other programmable device to produce computer-implemented processing for execution on a computer or other programmable device.
  • the instructions provide steps for implementing the functions in one or more blocks of the flowchart or in a flow or block of the flowchart.

Abstract

The present invention relates to the technical field of data communications, and disclosed are a method and an apparatus for accessing a shared resource. In a scheme described in embodiments of the present invention, after receiving a lock permission request sent by a client of a first node, the first node forwards the lock permission request only when a lock identifier comprising an identifier of a shared resource is not found in the first node, that is, the first node is searched first to determine whether the lock identifier comprising the identifier of the shared resource exists in the first node; the lock permission request is forwarded only when the lock identifier comprising the identifier of the shared resource does not exist in the first node, and when the lock identifier comprising the identifier of the shared resource exists in the first node, the lock permission request is directly allocated. It takes less time for the client to acquire the lock identifier from the first node than from other nodes. Therefore, the problem that an existing method for accessing a shared resource is time-consuming is solved.

Description

一种访问共享资源的方法及装置Method and device for accessing shared resources
本申请要求于2013年12月13日提交中国专利局、申请号201310689369.3、发明名称为“一种访问共享资源的方法及装置”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。The present application claims priority to Chinese Patent Application No. 201310689369.3, entitled "A Method and Apparatus for Accessing Shared Resources" on December 13, 2013, the entire contents of which are incorporated herein by reference. in.
技术领域Technical field
本发明涉及数据通信技术领域,特别涉及一种访问共享资源的方法及装置。The present invention relates to the field of data communication technologies, and in particular, to a method and an apparatus for accessing shared resources.
背景技术Background technique
随着存储技术的发展,各种数据信息呈爆炸式的增长,人们正在寻找一种强大的数据中心架构。双活数据中心就是其中一种重要的解决方案,通过双活技术,可以在多个跨地域的数据中心(存储设备)之间实现业务容灾和负载分担,进而整合存储设备的存储资源,如图1A所示。With the development of storage technology, various data information is exploding, and people are looking for a powerful data center architecture. The active-active data center is one of the most important solutions. Through the dual-active technology, service disaster recovery and load sharing can be implemented between multiple data centers (storage devices) across multiple regions, thereby consolidating the storage resources of storage devices. Figure 1A shows.
存储阵列为存储设备的存储载体,在双活数据中心的解决方案中,存储阵列为主机应用提供虚拟化的共享资源。在系统运行时,数据会被同时写入到两个存储设备的存储阵列中,当其中一个存储设备发生故障时,另一个存储设备仍可以对外提供服务,进而实现数据容灾。为了实现存储资源的虚拟化整合和数据容灾,两个存储设备间需要提供一种互斥机制,防止共享资源的并发访问(每个存储设备包括多个节点,每个节点包括多个客户端,如图1B所示,其中,客户端是指节点访问共享资源的进程),因为如果多个客户端同时访问和操作数据,就有可能发生各客户端之间相互覆盖共享资源的情况,造成被访问的共享资源处于不一致的状态。The storage array is the storage carrier of the storage device. In the dual-active data center solution, the storage array provides virtualized shared resources for the host application. When the system is running, data is simultaneously written to the storage arrays of the two storage devices. When one of the storage devices fails, the other storage device can still provide external services to implement data disaster recovery. In order to achieve virtualization integration and data disaster recovery of storage resources, a mutual exclusion mechanism needs to be provided between two storage devices to prevent concurrent access of shared resources (each storage device includes multiple nodes, and each node includes multiple clients) As shown in FIG. 1B, where the client refers to a process in which a node accesses a shared resource, because if multiple clients access and manipulate data at the same time, it may happen that each client overlaps the shared resource, resulting in The shared resources being accessed are in an inconsistent state.
在集群系统中,锁管理器是一种常用的节点间互斥保护机制,它使得某一共享资源每一次只能被一个客户端访问,通过锁管理器实现共享资源访问的过程如下(如图1C所示):In the cluster system, the lock manager is a commonly used mutual exclusion protection mechanism between nodes. It allows a shared resource to be accessed by only one client at a time. The process of accessing shared resources through the lock manager is as follows (as shown in the figure). 1C):
假设存储设备1中具有三个节点:节点1、节点2、节点3Assume that there are three nodes in storage device 1: node 1, node 2, node 3
步骤a:为共享资源A分配一个锁管理器; Step a: assign a lock manager to the shared resource A;
步骤b:节点2需要访问共享资源A时,向锁管理器申请与共享资源A对应的锁权限;Step b: When the node 2 needs to access the shared resource A, apply to the lock manager for the lock authority corresponding to the shared resource A;
步骤c:节点2在获取与共享资源A对应的锁权限后,访问共享资源A;Step c: After obtaining the lock permission corresponding to the shared resource A, the node 2 accesses the shared resource A;
步骤d:节点3向锁管理器申请与共享资源A对应的锁权限,由于锁已经被授权,锁管理器会暂缓其它权限冲突的锁请求的授权,只有等冲突的锁持有者释放锁权限后,新的锁请求才会被授权。Step d: Node 3 applies to the lock manager for the lock permission corresponding to the shared resource A. Since the lock has been authorized, the lock manager suspends the authorization of the lock request of other rights conflicts, and only the lock holder of the conflict releases the lock permission. After that, the new lock request will be authorized.
通过上述过程可以看出,同一时刻有多个客户端访问某一共享资源时,通过锁管理器达到多个客户端对同一共享资源的有序化访问的目的,保证访问的数据的一致性。但是,目前的锁管理器存在如下缺陷:有些节点与锁管理器节点不是同一个节点时,在获取针对任意一共享资源的锁权限对应的锁标识时,要去其他节点去获取锁权限,存在耗费时间较长的问题。Through the above process, it can be seen that when multiple clients access a certain shared resource at the same time, the lock manager is used to achieve the orderly access of the same shared resource by multiple clients, and the consistency of the accessed data is ensured. However, the current lock manager has the following drawbacks: when some nodes are not the same node as the lock manager node, when acquiring the lock identifier corresponding to the lock authority of any shared resource, the other node is required to acquire the lock permission. A problem that takes a long time.
综上所述,目前的访问共享资源的方法存在耗时较长的问题。In summary, the current method of accessing shared resources has a long time-consuming problem.
发明内容Summary of the invention
本发明实施例提供一种访问共享资源的方法及装置,用以解决目前的访问共享资源的方法存在的耗时较长的问题。The embodiment of the invention provides a method and a device for accessing a shared resource, which are used to solve the problem that the current method for accessing the shared resource has a long time.
第一方面,提供一种访问共享资源的方法,包括:In a first aspect, a method of accessing a shared resource is provided, including:
接收第一节点转发的携带共享资源的标识的锁权限请求;Receiving a lock permission request for carrying the identifier of the shared resource forwarded by the first node;
其中,所述锁权限请求是所述第一节点在接收到第一节点的客户端发送的、且在第一节点中未查找到包括所述共享资源的标识的锁标识时转发的;The lock permission request is forwarded when the first node sends the lock identifier that is sent by the client of the first node and does not find the identifier of the shared resource in the first node;
从存储的锁标识中确定出包括所述共享资源的标识的锁标识;Determining, from the stored lock identifier, a lock identifier including an identifier of the shared resource;
将确定的所述锁标识通过所述第一节点分配至所述客户端,给予所述客户端对所述共享资源的所述锁标识对应的锁权限,用于所述客户端对所述共享资源的访问。Assigning the determined lock identifier to the client by using the first node, and giving the client a lock right corresponding to the lock identifier of the shared resource, where the client uses the share for the share Access to resources.
结合第一方面,在第一种可能的实现方式中,所述第一节点用于缓存所述第一节点中的每一个客户端占用的锁权限对应的锁标识,或者占用过的、空闲时间小于删除阈值的锁权限对应的锁标识。 With reference to the first aspect, in a first possible implementation, the first node is configured to cache a lock identifier corresponding to a lock authority occupied by each client in the first node, or an occupied idle time The lock identifier corresponding to the lock authority that is smaller than the delete threshold.
结合第一方面,或者第一方面的第一种可能的实现方式,在第二种可能的实现方式中,所述接收第一节点转发的携带共享资源的标识的锁权限请求,具体包括:With reference to the first aspect, or the first possible implementation manner of the first aspect, in a second possible implementation manner, the receiving, by the first node, the lock permission request that carries the identifier of the shared resource, specifically includes:
接收所述第一节点通过第二节点转发的携带所述共享资源的标识的锁权限请求;Receiving, by the first node, a lock permission request that carries the identifier of the shared resource that is forwarded by the second node;
其中,所述锁权限请求是所述第二节点在接收到所述第一节点发送的、且在第一节点中未查找到包括所述共享资源的标识的锁标识时转发的。The lock permission request is forwarded by the second node when receiving the lock identifier sent by the first node and not finding the identifier of the shared resource in the first node.
结合第一方面的第二种可能的实现方式,在第三种可能的实现方式中,所述第二节点用于缓存指定的锁权限中被占用的锁权限对应的锁标识,或者,指定的锁权限中占用过的、空闲时间小于删除阈值的锁权限对应的锁标识。In conjunction with the second possible implementation of the first aspect, in a third possible implementation, the second node is configured to cache a lock identifier corresponding to the occupied lock authority in the specified lock authority, or The lock identifier corresponding to the lock authority that is occupied by the lock authority and whose idle time is less than the deletion threshold.
结合第一方面,或者第一方面的第二至第三种可能的实现方式,在第四种可能的实现方式中,所述将确定的所述锁标识通过所述第一节点分配至所述客户端,具体包括:With reference to the first aspect, or the second to third possible implementation manners of the first aspect, in a fourth possible implementation, the determining, by the first node, the lock identifier is Client, specifically:
将确定的所述锁标识通过所述第二节点发送至所述第一节点,以使得所述第一节点将所述锁标识分配至所述客户端。And transmitting the determined lock identifier to the first node by the second node, so that the first node assigns the lock identifier to the client.
结合第一方面,或者第一方面的第一至第四种可能的实现方式,在第五种可能的实现方式中,所述将确定的所述锁标识通过所述第一节点分配至所述客户端,具体包括:With reference to the first aspect, or the first to fourth possible implementation manners of the first aspect, in a fifth possible implementation, the determining, by the first node, the lock identifier is Client, specifically:
若确定的所述锁标识对应的锁权限被其他客户端占用时,向占用所述锁权限的客户端发送锁权限召回指示,令占用所述锁权限的客户端完成访问所述共享资源后释放所述锁权限;If the lock permission corresponding to the lock identifier is occupied by another client, the lock permission recall instruction is sent to the client occupying the lock permission, so that the client occupying the lock authority completes accessing the shared resource and then releases The lock authority;
第二方面,提供一种访问共享资源的装置,包括:In a second aspect, an apparatus for accessing a shared resource is provided, including:
接收单元,用于接收第一节点转发的携带共享资源的标识的锁权限请求;其中,所述锁权限请求是所述第一节点在接收到第一节点的客户端发送的、且在第一节点中未查找到包括所述共享资源的标识的锁标识时转发的;a receiving unit, configured to receive a lock permission request that is forwarded by the first node and that carries the identifier of the shared resource, where the lock permission request is sent by the first node at the client that receives the first node, and is in the first Forwarded when the lock identifier of the identifier of the shared resource is not found in the node;
确定单元,用于从存储的锁标识中确定出包括所述共享资源的标识的锁标 识;a determining unit, configured to determine, from the stored lock identifier, a lock label including an identifier of the shared resource knowledge;
分配单元,用于将确定的所述锁标识通过所述第一节点分配至所述客户端,给予所述客户端对所述共享资源的所述锁标识对应的锁权限,用于所述客户端对所述共享资源的访问。An allocating unit, configured to allocate the determined lock identifier to the client by using the first node, and give the client a lock right corresponding to the lock identifier of the shared resource, for the client Access to the shared resource.
结合第二方面,在第一种可能的实现方式中,所所述接收单元接收到的所述锁权限请求是所述第一节点发送的,所述第一节点用于缓存所述第一节点中的每一个客户端占用的锁权限对应的锁标识,或者占用过的、空闲时间小于删除阈值的锁权限对应的锁标识。With reference to the second aspect, in a first possible implementation, the lock permission request received by the receiving unit is sent by the first node, and the first node is used to cache the first node. The lock identifier corresponding to the lock authority occupied by each client in the account, or the lock identifier corresponding to the lock authority whose idle time is less than the deletion threshold.
结合第二方面,或者第二方面的第一种可能的实现方式,在第二种可能的实现方式中,所述接收单元具体用于:With reference to the second aspect, or the first possible implementation manner of the second aspect, in a second possible implementation manner, the receiving unit is specifically configured to:
接收所述第一节点通过第二节点转发的携带所述共享资源的标识的锁权限请求;Receiving, by the first node, a lock permission request that carries the identifier of the shared resource that is forwarded by the second node;
其中,所述锁权限请求是所述第二节点在接收到所述第一节点发送的、且在第一节点中未查找到包括所述共享资源的标识的锁标识时转发的。The lock permission request is forwarded by the second node when receiving the lock identifier sent by the first node and not finding the identifier of the shared resource in the first node.
结合第二方面的第二种可能的实现方式,在第三种可能的实现方式中,所述接收单元接收到的所述锁权限请求是所述第二节点发送的,所述第二节点用于缓存指定的锁权限中被占用的锁权限对应的锁标识,或者,指定的锁权限中占用过的、空闲时间小于删除阈值的锁权限对应的锁标识。With reference to the second possible implementation of the second aspect, in a third possible implementation, the lock permission request received by the receiving unit is sent by the second node, and the second node is used by the second node. The lock identifier corresponding to the lock permission that is occupied in the specified lock permission, or the lock identifier corresponding to the lock authority that is occupied by the specified lock authority and whose idle time is less than the delete threshold.
结合第二方面,或者第二方面的第二至第三种可能的实现方式,在第四种可能的实现方式中,所述分配单元具体用于:With reference to the second aspect, or the second to third possible implementation manners of the second aspect, in a fourth possible implementation, the allocation unit is specifically configured to:
将确定的所述锁标识通过所述第二节点发送至所述第一节点,以使得所述第一节点将所述锁标识分配至所述客户端。And transmitting the determined lock identifier to the first node by the second node, so that the first node assigns the lock identifier to the client.
结合第二方面,或者第二方面的第一至第四种可能的实现方式,在第五种可能的实现方式中,所述分配单元具体用于:With reference to the second aspect, or the first to fourth possible implementation manners of the second aspect, in a fifth possible implementation manner, the allocation unit is specifically configured to:
若确定的所述锁标识对应的锁权限被其他客户端占用时,向占用所述锁权限的客户端发送锁权限召回指示,令占用所述锁权限的客户端完成访问所述共 享资源后释放所述锁权限;If the lock permission corresponding to the lock identifier is occupied by another client, the lock permission recall instruction is sent to the client occupying the lock permission, so that the client occupying the lock authority completes accessing the total Release the lock permission after enjoying the resource;
将占用所述锁权限的客户端释放的锁权限对应的锁标识通过所述第一节点分配至所述客户端。And assigning, by the first node, the lock identifier corresponding to the lock authority released by the client occupying the lock authority to the client.
本发明有益效果如下:The beneficial effects of the present invention are as follows:
现有的技术中,有些节点与锁管理器节点不是同一个节点时,在获取针对任意一共享资源的锁权限对应的锁标识时,要去其他节点去获取锁权限,存在耗费时间较长的问题,而本发明实施例为,先接收第一节点转发的携带共享资源的标识的锁权限请求,其中,所述锁权限请求是所述第一节点在接收到第一节点的客户端发送的、且在第一节点中未查找到包括所述共享资源的标识的锁标识时转发的,然后,从存储的锁标识中确定出包括所述共享资源的标识的锁标识,最后,将确定的所述锁标识通过所述第一节点分配至所述客户端,给予所述客户端对所述共享资源的所述锁标识对应的锁权限,用于所述客户端对所述共享资源的访问,在该方案中,第一节点在接收到第一节点的客户端发送的所述锁权限请求后,在第一节点中未查找到包括所述共享资源的标识的锁标识时才进行转发,也就是说,要先在第一节点中查找是否包括所述共享资源的标识的锁标识,只有在不存在时,才进行转发,而存在时,直接分配就行,而客户端从第一节点中获取锁标识要比去其他节点获取锁标识耗费的时间少,因此,解决了目前的访问共享资源的方法存在的耗时较长的问题。In the prior art, when some nodes are not the same node as the lock manager node, when acquiring the lock identifier corresponding to the lock authority of any shared resource, it is necessary to go to other nodes to acquire the lock permission, which takes a long time. The problem is that, in the embodiment of the present invention, the lock permission request that carries the identifier of the shared resource forwarded by the first node is received, where the lock permission request is sent by the first node to the client that receives the first node. And forwarding, when the lock identifier including the identifier of the shared resource is not found in the first node, and then determining a lock identifier including the identifier of the shared resource from the stored lock identifier, and finally, determining The lock identifier is allocated to the client by the first node, and the client is given a lock right corresponding to the lock identifier of the shared resource, and is used by the client to access the shared resource. In the solution, after receiving the lock permission request sent by the client of the first node, the first node does not find the target including the shared resource in the first node. The lock is only forwarded when the lock is identified. That is, the lock identifier of the identifier of the shared resource is first searched in the first node, and only when it does not exist, the forwarding is performed, and when it exists, the direct assignment is performed. However, it takes less time for the client to obtain the lock identifier from the first node than to obtain the lock identifier from other nodes. Therefore, the problem of the current method of accessing the shared resource is long.
附图说明DRAWINGS
附图用来提供对本发明的进一步理解,并且构成说明书的一部分,与本发明实施例一起用于解释本发明,并不构成对本发明的限制。在附图中:The drawings are intended to provide a further understanding of the invention, and are intended to be a In the drawing:
图1A为现有技术中双活数据中心的结构示意图;1A is a schematic structural diagram of a dual active data center in the prior art;
图1B为现有技术中节点与客户端的结构示意图;1B is a schematic structural diagram of a node and a client in the prior art;
图1C为现有技术中双活数据中心访问共享资源的示意图;1C is a schematic diagram of accessing shared resources in a dual-active data center in the prior art;
图2为本发明实施例中访问共享资源的示意图; 2 is a schematic diagram of accessing a shared resource according to an embodiment of the present invention;
图3为本发明实施例中访问共享资源的第一实施例;FIG. 3 is a first embodiment of accessing a shared resource according to an embodiment of the present invention;
图4为本发明实施例中访问共享资源的第二实施例;4 is a second embodiment of accessing a shared resource according to an embodiment of the present invention;
图5为本发明实施例中访问共享资源的装置的功能结构示意图。FIG. 5 is a schematic structural diagram of a device for accessing a shared resource according to an embodiment of the present invention.
具体实施方式detailed description
为使本发明实施例的目的、技术方案和优点更加清楚,下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。The technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the drawings in the embodiments of the present invention. It is a partial embodiment of the invention, and not all of the embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative efforts are within the scope of the present invention.
另外,本文中术语“系统”和“网络”在本文中常被可互换使用。本文中术语“和/或”,仅仅是一种描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B这三种情况。另外,本文中字母“/”,一般表示前后关联对象是一种“或”的关系。Additionally, the terms "system" and "network" are used interchangeably herein. The term "and/or" in this context is merely an association describing the associated object, indicating that there may be three relationships, for example, A and / or B, which may indicate that A exists separately, and both A and B exist, respectively. B these three situations. In addition, the letter "/" in this article generally indicates that the contextual object is an "or" relationship.
为了解决现有技术中存在的耗时较长的问题,本发明实施例中,要先接收第一节点转发的携带共享资源的标识的锁权限请求,其中,锁权限请求是第一节点在接收到第一节点的客户端发送的、且在第一节点中未查找到包括共享资源的标识的锁标识时转发的,然后,从存储的锁标识中确定出包括共享资源的标识的锁标识,最后,将确定的锁标识通过第一节点分配至客户端,给予客户端对共享资源的锁标识对应的锁权限,用于客户端对共享资源的访问,在该方案中,第一节点在接收到第一节点的客户端发送的锁权限请求后,在第一节点中未查找到包括共享资源的标识的锁标识时进行转发的,也就是说,要先在第一节点中查找是否包括共享资源的标识的锁标识,存在时,直接进行分配,只有在不存在时,才进行转发,而客户端从第一节点中获取锁标识要比去其他节点获取锁标识耗费的时间少,因此,解决了目前的访问共享资源的方法存在的耗时较长的问题。In order to solve the problem that the time-consuming problem exists in the prior art, in the embodiment of the present invention, the lock permission request that carries the identifier of the shared resource forwarded by the first node is received, where the lock permission request is received by the first node. And forwarding, when the lock identifier sent by the client of the first node and not identifying the identifier of the shared resource is found in the first node, and then determining the lock identifier including the identifier of the shared resource from the stored lock identifier, Finally, the determined lock identifier is assigned to the client through the first node, and the lock permission corresponding to the lock identifier of the shared resource is given to the client for accessing the shared resource by the client. In the solution, the first node is receiving After the lock permission request sent by the client of the first node is forwarded, the lock identifier including the identifier of the shared resource is not found in the first node, that is, the first node is first searched for whether to include the share. The lock identifier of the identifier of the resource, when it exists, directly allocates it, and only forwards when it does not exist, and the client obtains the lock identifier from the first node. To identify the other nodes to acquire the lock takes less time, therefore, to solve the long time-consuming problems of current methods to access shared resources.
下面结合说明书附图对本发明优选的实施方式进行详细说明,应当理解, 此处所描述的优选实施例仅用于说明和解释本发明,并不用于限定本发明,并且在不冲突的情况下,本申请中的实施例及实施例中的特征可以相互组合。The preferred embodiments of the present invention are described in detail below with reference to the accompanying drawings, and it should be understood that The preferred embodiments described herein are only illustrative of the invention and are not intended to limit the invention, and the features of the embodiments and embodiments of the present application can be combined with each other without conflict.
下面结合附图对本发明优选的实施方式进行详细说明。Preferred embodiments of the present invention will be described in detail below with reference to the accompanying drawings.
参阅图2所示,本发明实施例中,访问共享资源的详细流程如下:Referring to FIG. 2, in the embodiment of the present invention, the detailed process of accessing the shared resource is as follows:
步骤200:接收第一节点转发的携带共享资源的标识的锁权限请求,其中,锁权限请求是第一节点在接收到第一节点的客户端发送的、且在第一节点中未查找到包括共享资源的标识的锁标识时转发的;Step 200: Receive a lock permission request that carries the identifier of the shared resource forwarded by the first node, where the lock permission request is sent by the first node after receiving the client of the first node, and is not found in the first node. Forwarded when the lock identifier of the shared resource identifier is used;
步骤210:从存储的锁标识中确定出包括共享资源的标识的锁标识;Step 210: Determine, from the stored lock identifier, a lock identifier that includes an identifier of the shared resource.
步骤220:将确定的锁标识通过第一节点分配至客户端,给予客户端对共享资源的锁标识对应的锁权限,用于客户端对共享资源的访问。Step 220: Assign the determined lock identifier to the client through the first node, and give the client the lock permission corresponding to the lock identifier of the shared resource, and use the client to access the shared resource.
本发明实施例中,锁标识中包括如下信息,保护的共享资源的标识、访问共享资源的方式,在实际应用中,还可以包括除上述两种信息外的其他信息,在此不再进行详述。In the embodiment of the present invention, the lock identifier includes the following information, the identifier of the protected shared resource, and the manner of accessing the shared resource. In actual applications, other information than the above two types of information may also be included, and details are not further described herein. Said.
本发明实施例中,访问共享资源的方式有多种,如,读共享资源的方式,此时,客户端获取的读取该共享资源的权限,又如,写共享资源的方式,此时,客户端获取的写入该共享资源的权限,其中,若获取的读取共享资源的权限,则客户端只能对该共享资源进行读取操作,不能进行写入操作;若获取的写入共享资源的权限,则客户端不仅能对该共享资源进行读取操作,还能进行写入操作,当然,在实际应用中,还有其他访问共享资源的方式,在此不再进行一一详述。In the embodiment of the present invention, there are multiple ways to access a shared resource, for example, a method of reading a shared resource. At this time, the client acquires the permission to read the shared resource, and, for example, writes the shared resource. The permission obtained by the client to write the shared resource, wherein if the acquired permission to read the shared resource is obtained, the client can only perform the read operation on the shared resource, and cannot perform the write operation; if the obtained write share is obtained The permission of the resource, the client can not only read the shared resource, but also perform the write operation. Of course, in the actual application, there are other ways to access the shared resource, and the details are not detailed here. .
本发明实施例中,第一节点的形式有多种,例如,可以用于缓存第一节点中的每一个客户端占用的锁权限对应的锁标识,或者占用过的、空闲时间小于删除阈值的锁权限对应的锁标识,当然,在实际应用中,第一节点还可以用于缓存其他信息,在此不再进行一一详述。In the embodiment of the present invention, the first node has multiple forms, for example, may be used to cache a lock identifier corresponding to the lock authority occupied by each client in the first node, or the occupied idle time is less than the deletion threshold. The lock identifier corresponding to the lock authority. Of course, in practical applications, the first node may also be used to cache other information, which is not detailed here.
步骤200-220的执行主体有多种,下面以锁管理器为例进行说明,需要说明的是,锁管理器只是执行主体的一个实施例,在实际应用中,执行主体还可 以是其他,在此不再进行一一详述。There are a plurality of execution entities of the steps 200-220. The following describes the lock manager as an example. It should be noted that the lock manager is only an embodiment of the execution subject. In practical applications, the execution entity may also be used. Therefore, other details are not repeated here.
在实际应用中,若客户端向其他节点发送访问共享资源的锁权限请求,由于是不同节点间的交互,因此,存在耗时较长的问题,本发明实施例中,为了缩短客户端发送访问共享资源的锁权限请求,或者接收锁标识的所消耗的时间,客户端在发送访问共享资源的锁权限请求时,可以向与客户端所处的第一节点发送访问共享资源的锁权限请求,若第一节点中当前存储了包括待访问的共享资源的标识的锁标识,则该第一节点将对应的锁标识分配至客户端,若该第一节点中当前未存储包括待访问的共享资源的标识的锁标识,则该第一节点将访问共享资源的锁权限请求发送至管理不同节点的访问共享资源的锁权限的锁管理器,再将接收到的锁管理器返回的锁标识分配至客户端,且存储该锁标识,那么第一节点再次接收到客户端发送的访问共享资源的锁权限请求时,若该锁标识未被分配,则将该锁标识分配至客户端,从而避免了获取锁标识的过程中存在的耗时较长的问题。In an actual application, if the client sends a lock permission request to the other node to access the shared resource, the interaction between the different nodes is a problem that takes a long time. In the embodiment of the present invention, in order to shorten the client sending access The lock permission request of the shared resource, or the time taken to receive the lock identifier, when the client sends a lock permission request for accessing the shared resource, the client may send a lock permission request for accessing the shared resource to the first node where the client is located, If the lock identifier of the identifier of the shared resource to be accessed is currently stored in the first node, the first node allocates the corresponding lock identifier to the client, if the first node does not currently store the shared resource to be accessed. The lock identifier of the identifier, the first node sends a lock permission request for accessing the shared resource to the lock manager that manages the lock authority of the shared resource of the different node, and then assigns the lock identifier returned by the received lock manager to The client, and stores the lock identifier, then the first node receives the lock permission for accessing the shared resource sent by the client again. While, if the lock identifier is not allocated, then the lock identification assigned to clients, thereby avoiding a longer acquire the lock identified problems exist in the process time-consuming.
例如,客户端1所在的节点处于第一存储设备,锁管理器位于第二存储设备,其中,锁管理器管理第一存储设备和第二存储设备访问共享资源的锁权限,则客户端1要获取访问第一共享资源的锁标识,即锁权限时,可以直接向位于第二存储设备的锁管理器发送访问第一共享资源的锁权限请求,此时,由于是两个存储设备之间的通信交互,因此,存在耗时较长的问题,为了缩短客户端1发送访问第一共享资源的锁权限请求,或者,获取访问第一共享资源的锁标识的时间,客户端1可以向客户端1所在的第一节点发送访问第一共享资源的锁权限请求,若第一节点中缓存了访问第一共享资源的锁标识,且该锁标识未被分配,则第一节点将该锁标识发送至客户端1,也就是说,向客户端1分配访问第一共享资源的锁权限;若第一节点中未缓存访问第一共享资源的锁标识,则第一节点将访问第一共享资源的锁权限请求发送至锁管理器,将接收到的锁管理器返回的锁标识发送至客户端,并缓存该锁标识,以便再接收到客户端1或者其他客户端发送的访问第一共享资源的锁权限请求时,若该锁标识未 被分配,则将该锁标识发送至客户端。For example, the node where the client 1 is located is in the first storage device, and the lock manager is located in the second storage device, wherein the lock manager manages the lock permission of the first storage device and the second storage device to access the shared resource, and the client 1 When the lock identifier of the first shared resource is obtained, that is, the lock permission, the lock permission request for accessing the first shared resource may be directly sent to the lock manager located at the second storage device, and at this time, because it is between the two storage devices Communication interaction, therefore, there is a problem that takes a long time. In order to shorten the time when the client 1 sends a lock permission request to access the first shared resource, or obtains the lock identifier of the first shared resource, the client 1 can send the client to the client. The first node that is located at 1 sends a lock permission request for accessing the first shared resource. If the lock identifier of the first shared resource is cached in the first node, and the lock identifier is not allocated, the first node sends the lock identifier. To the client 1, that is, to assign the lock permission to the first shared resource to the client 1; if the lock of the first shared resource is not cached in the first node The first node sends a lock permission request for accessing the first shared resource to the lock manager, sends the lock identifier returned by the received lock manager to the client, and caches the lock identifier, so as to receive the client again. 1 or when the client sends a lock permission request to access the first shared resource, if the lock identifier is not If it is assigned, the lock ID is sent to the client.
本发明实施例中,接收第一节点转发的携带共享资源的标识的锁权限请求有多种方式,例如,可以接收第一节点通过第二节点转发的携带共享资源的标识的锁权限请求,其中,锁权限请求是第二节点在接收到第一节点发送的、且在第一节点中未查找到包括共享资源的标识的锁标识时转发的,上述只是接收第一节点转发的携带共享资源的标识的锁权限请求的一种实现方式,在实际应用中,还有其他实现方式,在此不再进行详述。In the embodiment of the present invention, the request for the lock permission to carry the identifier of the shared resource forwarded by the first node may be received by the first node, for example, the lock permission request of the identifier of the shared resource that is forwarded by the first node by the second node may be received, where The lock permission request is forwarded by the second node when receiving the lock identifier sent by the first node and not identifying the identifier of the shared resource in the first node, where the foregoing is only receiving the shared resource carried by the first node. An implementation manner of the identified lock permission request, in actual application, there are other implementation manners, which are not described in detail herein.
接收第一节点通过第二节点转发的携带共享资源的标识的锁权限请求的实施例如下:The implementation of the lock permission request for receiving the identifier of the shared resource forwarded by the first node by the second node is as follows:
例如,第一存储设备和第二存储设备共有10个共享资源:共享资源1、共享资源2,……,则每一个共享资源对应一个锁标识,位于第一存储设备的第二节点可以存储10个共享资源分别对应的锁标识,也就是访问10个共享资源的锁权限,若位于第二存储设备的客户端1要访问共享资源1,则客户端1可以直接向位于第一存储设备的第二节点发送访问共享资源1的锁权限请求,从第二节点中获取与共享资源1对应的锁标识;为了提高效率,客户端1也可以先向所处的第一节点发送访问共享资源1的锁权限请求,若第一节点缓存有与共享资源1对应的锁标识,则第一节点将该锁标识发送至客户端1,将锁权限分配至客户端1,若第一节点中未缓存有与共享资源1对应的锁标识,则第一节点向第二节点转发访问共享资源1的锁权限请求,并将接收到的第二节点发送的与共享资源1对应的锁标识发送至客户端1,将锁权限分配至客户端1。For example, the first storage device and the second storage device share 10 shared resources: shared resource 1, shared resource 2, ..., each shared resource corresponds to a lock identifier, and the second node located at the first storage device can store 10 The lock identifier corresponding to the shared resource, that is, the lock permission for accessing the 10 shared resources. If the client 1 located in the second storage device wants to access the shared resource 1, the client 1 can directly access the first storage device. The second node sends a lock permission request for accessing the shared resource 1, and acquires a lock identifier corresponding to the shared resource 1 from the second node; in order to improve efficiency, the client 1 may also first send the access shared resource 1 to the first node where it is located. The lock permission request, if the first node caches a lock identifier corresponding to the shared resource 1, the first node sends the lock identifier to the client 1, and assigns the lock permission to the client 1, if the first node is not cached The lock identifier corresponding to the shared resource 1 is forwarded by the first node to the second node to access the lock permission request of the shared resource 1, and the received second node sends the shared resource 1 corresponding to the client ID to the lock 1, the lock authority to assign a client.
本发明实施例中,第二节点有多种形式,可选的,用于缓存指定的锁权限中被占用的锁权限对应的锁标识,或者,指定的锁权限中占用过的、空闲时间小于删除阈值的锁权限对应的锁标识。In the embodiment of the present invention, the second node has multiple forms, optionally, used to cache the lock identifier corresponding to the occupied lock authority in the specified lock authority, or the idle time occupied by the specified lock authority is less than Delete the lock identifier corresponding to the lock permission of the threshold.
本发明实施例中,一个存储设备中还可以有多个第二节点,第二节点用于缓存指定的锁权限中被占用的锁权限对应的锁标识,或者,指定的锁权限中占用过的、空闲时间小于删除阈值的锁权限对应的锁标识,此时,不同第二节点 可以管理不同的共享资源对应的锁标识。In the embodiment of the present invention, a storage device may further include a plurality of second nodes, where the second node is configured to cache a lock identifier corresponding to the occupied lock authority in the specified lock authority, or is occupied by the specified lock authority. The lock identifier corresponding to the lock authority whose idle time is less than the deletion threshold. At this time, the second node is different. You can manage lock identifiers for different shared resources.
例如,第一存储设备和第二存储设备共有10个共享资源:共享资源1、共享资源2,……,则每一个共享资源对应一个锁标识,位于第一存储设备的第二节点1管理共享资源1-5分别对应的锁标识、位于第一存储设备的第二节点2管理共享资源6-10分别对应的锁标识,位于第二存储设备的锁管理器管理10个共享资源分别对应的锁标识,也就是访问10个共享资源的锁权限,若位于第一存储设备的客户端1要访问共享资源1,则客户端1可以直接向位于第二存储设备的锁管理器发送访问共享资源1的锁权限请求,从锁管理器中获取与共享资源1对应的锁标识;为了提高效率,客户端1可以先向所处的第一节点发送访问共享资源1的锁权限请求,若第一节点缓存有与共享资源1对应的锁标识,则第一节点将该锁标识发送至客户端1,将锁权限分配至客户端1,若第一节点中未缓存有与共享资源1对应的锁标识,则第一节点向第二节点1转发访问共享资源1的锁权限请求,若第二节点1中未查找到包括共享资源的标识的锁标识时,转发至锁管理器,并将接收到的锁管理器发送的与共享资源1对应的锁标识通过第一节点发送至客户端1,将锁权限分配至客户端1。For example, the first storage device and the second storage device share 10 shared resources: shared resource 1, shared resource 2, ..., each shared resource corresponds to a lock identifier, and the second node 1 located at the first storage device manages sharing. The lock identifiers corresponding to the resources 1-5 and the lock identifiers corresponding to the shared resources 6-10 of the second node 2 of the first storage device respectively, and the lock manager of the second storage device manages the locks corresponding to the 10 shared resources respectively. The identifier, that is, the lock permission for accessing 10 shared resources. If the client 1 located at the first storage device wants to access the shared resource 1, the client 1 can directly send the access shared resource to the lock manager located at the second storage device. The lock permission request acquires the lock identifier corresponding to the shared resource 1 from the lock manager; in order to improve the efficiency, the client 1 may first send a lock permission request for accessing the shared resource 1 to the first node where the first node is located, if the first node The cache has a lock identifier corresponding to the shared resource 1, and the first node sends the lock identifier to the client 1, and assigns the lock permission to the client 1, if the first node is not cached The lock identifier corresponding to the shared resource 1 is forwarded to the second node 1 by the first node to access the lock permission request of the shared resource 1. If the lock identifier of the identifier including the shared resource is not found in the second node 1, the switch forwards to the lock. The manager sends the lock identifier corresponding to the shared resource 1 sent by the received lock manager to the client 1 through the first node, and assigns the lock authority to the client 1.
同理,若位于第一存储设备的客户端2要访问共享资源10,则客户端2可以直接向位于第二存储设备的锁管理器发送访问共享资源10的锁权限请求,从锁管理器中获取与共享资源10对应的锁标识;为了提高访问效率,客户端2也可以先向所处的第三节点发送访问共享资源10的锁权限请求,若第三节点中缓存有与共享资源10对应的锁标识,则第三节点将该锁标识发送至客户端2,将锁权限分配至客户端2,若第三节点中未缓存有与共享资源10对应的锁标识,则第三节点向第二节点2转发访问共享资源10的锁权限请求,若第二节点2中未缓存有与共享资源10对应的锁标识,则第二节点2向锁管理器转发访问共享资源10的锁权限请求,并将接收到的锁管理器发送的与共享资源10对应的锁标识通过第三节点发送至客户端2,将锁权限分配至客户端2。Similarly, if the client 2 located at the first storage device wants to access the shared resource 10, the client 2 can directly send a lock permission request for accessing the shared resource 10 to the lock manager located at the second storage device, from the lock manager. Obtaining a lock identifier corresponding to the shared resource 10; in order to improve the access efficiency, the client 2 may first send a lock permission request for accessing the shared resource 10 to the third node where the third node is located, and if the third node caches the cached resource corresponding to the shared resource 10 The lock identifier is sent by the third node to the client 2, and the lock authority is assigned to the client 2. If the lock identifier corresponding to the shared resource 10 is not cached in the third node, the third node is The second node 2 forwards the lock permission request for accessing the shared resource 10. If the lock identifier corresponding to the shared resource 10 is not cached in the second node 2, the second node 2 forwards the lock permission request for accessing the shared resource 10 to the lock manager. And the lock identifier corresponding to the shared resource 10 sent by the received lock manager is sent to the client 2 through the third node, and the lock authority is allocated to the client 2.
上述实施例只是列举了一个存储设备只存在两个第二节点的情况,在实际 应用中,还可能有一个存储设备存在多个第二节点的情况。若一个存储设备存在多个第二节点,则客户端在发送访问共享资源的锁权限请求时,先将访问共享资源的锁权限请求发送至客户端所在的第一节点,若客户端所在的第一节点中缓存有与待访问的共享资源对应的锁标识,则客户端所在的第一节点将与待访问的共享资源对应的锁标识发送至客户端,若客户端所在的第一节点中未缓存有与待访问的共享资源对应的锁标识,则将访问共享资源的锁权限请求转发至相应的第二节点,若第二节点中缓存有与待访问的共享资源对应的锁标识,则第二节点将与待访问的共享资源对应的锁标识发送至客户端,若第二节点中未缓存有与待访问的共享资源对应的锁标识,则将访问共享资源的锁权限请求转发至锁管理器。The above embodiment only enumerates the case where only one second node exists in one storage device, in practice. In an application, there may also be a case where a storage device has multiple second nodes. If a storage device has multiple second nodes, when the client sends a lock permission request for accessing the shared resource, the client first sends a lock permission request for accessing the shared resource to the first node where the client is located, if the client is located at the first node. A lock identifier corresponding to the shared resource to be accessed is cached in a node, and the first node where the client is located sends a lock identifier corresponding to the shared resource to be accessed to the client, if the first node where the client is located is not If the lock identifier corresponding to the shared resource to be accessed is cached, the lock permission request for accessing the shared resource is forwarded to the corresponding second node, and if the lock identifier corresponding to the shared resource to be accessed is cached in the second node, The two nodes send the lock identifier corresponding to the shared resource to be accessed to the client. If the lock identifier corresponding to the shared resource to be accessed is not cached in the second node, the lock permission request for accessing the shared resource is forwarded to the lock management. Device.
本发明实施例中,接收第一节点转发的携带共享资源的标识的锁权限请求的方式有多种,例如,可以直接通过第一节点接收第一节点转发的携带共享资源的标识的锁权限请求;也可以为,通过第二节点接收接收第一节点转发的携带共享资源的标识的锁权限请求。In the embodiment of the present invention, there are multiple ways to receive the lock permission request of the identifier of the shared resource that is forwarded by the first node. For example, the first node may directly receive the lock permission request of the identifier of the shared resource that is forwarded by the first node. Alternatively, the second node may receive a lock permission request that receives the identifier of the shared resource forwarded by the first node.
那么,同理,将确定的锁标识通过第一节点分配至客户端的方式也有多种,例如,可以为,将确定的锁标识直接通过第一节点分配至客户端;或者,也可以为,将确定的锁标识通过第二节点发送至第一节点,以使得第一节点将锁标识分配至客户端。Then, in the same way, the determined lock identifier is allocated to the client through the first node. For example, the determined lock identifier may be directly allocated to the client through the first node; or, The determined lock identifier is sent to the first node by the second node such that the first node assigns the lock identifier to the client.
本发明实施例中,客户端无论是向直接向锁管理器发送访问共享资源的锁权限请求,还是向第一节点,或者是第二节点发送访问共享资源的锁权限请求,接收该请求的锁管理器或者节点中可能存储有与访问的共享资源对应的锁标识,但是该锁标识被发送至客户端,也就是该锁标识对应的锁权限被占用,此时,确定的锁标识对应的锁权限被其他客户端占用时,向占用锁权限的客户端发送锁权限召回指示,令占用锁权限的客户端完成访问共享资源后释放锁权限;将占用锁权限的客户端释放的锁权限对应的锁标识通过第一节点分配至客户端。 In the embodiment of the present invention, the client sends a lock permission request for accessing the shared resource to the first node or the second node, whether the lock permission request for accessing the shared resource is directly sent to the lock manager, and the lock for receiving the request is received. The lock identifier corresponding to the accessed shared resource may be stored in the manager or the node, but the lock identifier is sent to the client, that is, the lock authority corresponding to the lock identifier is occupied. At this time, the lock corresponding to the determined lock identifier is used. When the privilege is occupied by other clients, the lock permission recall instruction is sent to the client occupying the lock permission, so that the client occupying the lock privilege releases the lock privilege after accessing the shared resource; and the lock privilege released by the client occupying the lock privilege corresponds to The lock identifier is assigned to the client through the first node.
也就是说,将确定的锁标识通过第一节点分配至客户端的方式有多种,例如:若确定的锁标识对应的锁权限被其他客户端占用时,向占用锁权限的客户端发送锁权限召回指示,令占用锁权限的客户端完成访问共享资源后释放锁权限,将占用锁权限的客户端释放的锁权限对应的锁标识通过第一节点分配至客户端。That is to say, there are multiple ways to assign the determined lock identifier to the client through the first node. For example, if the lock permission corresponding to the determined lock identifier is occupied by other clients, the lock permission is sent to the client occupying the lock permission. The recall indication is such that the client occupying the lock authority releases the lock permission after accessing the shared resource, and the lock identifier corresponding to the lock authority released by the client occupying the lock authority is allocated to the client through the first node.
例如,客户端1向第二节点发送访问共享资源1的锁权限请求,若第二节点中缓存的与共享资源1对应的锁标识被分配至其他节点,也就是说,该锁标识对应的锁权限被分配至客户端2,则向占用锁权限的客户端2发送锁权限召回指示,令占用锁权限的客户端2完成访问共享资源时释放锁权限,然后,第二节点再将占用锁权限的客户端2释放的锁权限对应的锁标识分配至客户端1。For example, the client 1 sends a lock permission request for accessing the shared resource 1 to the second node, and if the lock identifier corresponding to the shared resource 1 cached in the second node is assigned to another node, that is, the lock corresponding to the lock identifier When the privilege is assigned to the client 2, the lock privilege recall instruction is sent to the client 2 occupying the lock privilege, so that the client 2 occupying the lock privilege releases the lock privilege when accessing the shared resource, and then the second node occupies the lock privilege again. The lock identifier corresponding to the lock permission released by the client 2 is assigned to the client 1.
上述实施例,只是以第二节点中缓存的与待访问的共享资源对应的锁标识被分配至其他客户端为例,在实际应用中,也可能是客户端所在的第一节点中,或者,锁管理器中缓存的与待访问的共享资源对应的锁标识被分配至其他客户端,此时,则第一节点或者锁管理器向占用锁权限的客户端发送锁权限召回指示,过程与上述实施例相同,在此不再进行详述。In the above embodiment, the lock identifier corresponding to the shared resource to be accessed in the second node is allocated to the other client as an example. In the actual application, the first node where the client is located may be used, or The lock identifier corresponding to the shared resource to be accessed cached in the lock manager is allocated to other clients. At this time, the first node or the lock manager sends a lock permission recall instruction to the client occupying the lock authority, and the process is as follows. The embodiments are the same and will not be described in detail herein.
为了更好地理解本发明实施例,以下给出具体应用场景,针对访问共享资源的过程,作出进一步详细描述:In order to better understand the embodiments of the present invention, a specific application scenario is given below, and a process for accessing shared resources is further described in detail:
通过一级锁权限代理节点获取锁标识的实施例。An embodiment of obtaining a lock identifier by a primary lock authority agent node.
实施例一(如图3所示):Embodiment 1 (shown in Figure 3):
步骤300:客户端1向所在的第一节点发送访问共享资源1的锁权限请求;Step 300: The client 1 sends a lock permission request for accessing the shared resource 1 to the first node where the client 1 is located;
步骤310:第一节点判断第一节点中是否存储有与共享资源1对应的锁标识、且该锁标识未被分配,若是,执行步骤350,否则,执行步骤320;Step 310: The first node determines whether the lock identifier corresponding to the shared resource 1 is stored in the first node, and the lock identifier is not allocated, and if so, step 350 is performed; otherwise, step 320 is performed;
步骤320:第一节点将访问共享资源1的锁权限请求发送至锁管理器;Step 320: The first node sends a lock permission request for accessing the shared resource 1 to the lock manager.
其中,锁管理器位于第二存储设备。The lock manager is located at the second storage device.
步骤330:锁管理器判断第一节点中是否存储有与共享资源1对应的锁标 识、且该锁标识未被分配;若是,执行步骤340,否则,执行步骤360;Step 330: The lock manager determines whether a lock label corresponding to the shared resource 1 is stored in the first node. Knowledge, and the lock identifier is not assigned; if yes, step 340 is performed, otherwise, step 360 is performed;
步骤340:锁管理器将与共享资源1对应的锁标识发送至第一节点;Step 340: The lock manager sends the lock identifier corresponding to the shared resource 1 to the first node;
步骤350:第一节点将与共享资源1对应的锁标识发送至客户端1;Step 350: The first node sends a lock identifier corresponding to the shared resource 1 to the client 1;
步骤360:锁管理器向占用锁权限的客户端2发送锁权限召回指示,并将占用锁权限的客户端2释放的锁权限对应的锁标识通过第一节点发送至客户端1。Step 360: The lock manager sends a lock permission recall indication to the client 2 occupying the lock authority, and sends the lock identifier corresponding to the lock authority released by the client 2 occupying the lock authority to the client 1 through the first node.
实施例二(如图4所示):Embodiment 2 (as shown in Figure 4):
步骤400:客户端1向所在的第一节点发送访问共享资源1的锁权限请求;Step 400: The client 1 sends a lock permission request for accessing the shared resource 1 to the first node where the client 1 is located;
步骤410:第一节点判断第一节点中是否存储有与共享资源1对应的锁标识、且该锁标识未被分配,若是,执行步骤480,否则,执行步骤420;Step 410: The first node determines whether the lock identifier corresponding to the shared resource 1 is stored in the first node, and the lock identifier is not allocated, and if so, step 480 is performed; otherwise, step 420 is performed;
步骤420:第一节点将访问共享资源1的锁权限请求发送至第二节点;Step 420: The first node sends a lock permission request for accessing the shared resource 1 to the second node.
在该步骤中,客户端1与第二节点位于第一存储设备。In this step, the client 1 and the second node are located at the first storage device.
步骤430:第二节点判断第一节点中是否存储有与共享资源1对应的锁标识、且该锁标识未被分配,若是,执行步骤470,否则,执行步骤440;Step 430: The second node determines whether the lock identifier corresponding to the shared resource 1 is stored in the first node, and the lock identifier is not allocated, and if so, step 470 is performed; otherwise, step 440 is performed;
步骤440:第二节点将访问共享资源1的锁权限请求发送至锁管理器;Step 440: The second node sends a lock permission request for accessing the shared resource 1 to the lock manager.
其中,锁管理器位于第二存储设备。The lock manager is located at the second storage device.
步骤450:锁管理器判断第一节点中是否存储有与共享资源1对应的锁标识、且该锁标识未被分配;若是,执行步骤460,否则,执行步骤490;Step 450: The lock manager determines whether the lock identifier corresponding to the shared resource 1 is stored in the first node, and the lock identifier is not allocated; if yes, step 460 is performed; otherwise, step 490 is performed;
步骤460:锁管理器将与共享资源1对应的锁标识发送至第二节点;Step 460: The lock manager sends the lock identifier corresponding to the shared resource 1 to the second node;
步骤470:第二节点将与共享资源1对应的锁标识发送至第一节点;Step 470: The second node sends the lock identifier corresponding to the shared resource 1 to the first node.
步骤480:第一节点将与共享资源1对应的锁标识发送至客户端1;Step 480: The first node sends a lock identifier corresponding to the shared resource 1 to the client 1;
步骤490:锁管理器向占用锁权限的客户端2发送锁权限召回指示,并将占用锁权限的客户端2释放的锁权限对应的锁标识通过第二节点转发至第一节点,使得第一节点发送至客户端1。Step 490: The lock manager sends a lock permission recall indication to the client 2 that occupies the lock authority, and forwards the lock identifier corresponding to the lock authority released by the client 2 that occupies the lock authority to the first node through the second node, so that the first The node sends to client 1.
参阅图5所示,本发明实施例还提供一种访问共享资源的装置,该装置包括接收单元500、确定单元510、分配单元520,其中: Referring to FIG. 5, an embodiment of the present invention further provides an apparatus for accessing a shared resource, where the apparatus includes a receiving unit 500, a determining unit 510, and an allocating unit 520, where:
接收单元500,用于接收第一节点转发的携带共享资源的标识的锁权限请求;其中,锁权限请求是第一节点在接收到第一节点的客户端发送的、且在第一节点中未查找到包括共享资源的标识的锁标识时转发的;The receiving unit 500 is configured to receive, by the first node, a lock permission request that carries the identifier of the shared resource, where the lock permission request is sent by the first node on the client that receives the first node, and is not in the first node. Forwarded when a lock identifier including the identity of the shared resource is found;
确定单元510,用于从存储的锁标识中确定出包括共享资源的标识的锁标识;a determining unit 510, configured to determine, from the stored lock identifier, a lock identifier that includes an identifier of the shared resource;
分配单元520,用于将确定的锁标识通过第一节点分配至客户端,给予客户端对共享资源的锁标识对应的锁权限,用于客户端对共享资源的访问。The allocating unit 520 is configured to allocate the determined lock identifier to the client by using the first node, and give the client a lock right corresponding to the lock identifier of the shared resource, for the client to access the shared resource.
本发明实施例中,可选的,接收单元500接收到的锁权限请求是第一节点发送的,第一节点用于缓存第一节点中的每一个客户端占用的锁权限对应的锁标识,或者占用过的、空闲时间小于删除阈值的锁权限对应的锁标识。In the embodiment of the present invention, optionally, the lock permission request received by the receiving unit 500 is sent by the first node, and the first node is configured to cache a lock identifier corresponding to the lock authority occupied by each client in the first node. Or the lock identifier corresponding to the lock authority whose idle time is less than the deletion threshold.
本发明实施例中,可选的,接收单元500具体用于:In the embodiment of the present invention, optionally, the receiving unit 500 is specifically configured to:
接收第一节点通过第二节点转发的携带共享资源的标识的锁权限请求;Receiving a lock permission request that carries the identifier of the shared resource forwarded by the first node by using the second node;
其中,锁权限请求是第二节点在接收到第一节点发送的、且在第一节点中未查找到包括共享资源的标识的锁标识时转发的。The lock permission request is forwarded by the second node when receiving the lock identifier sent by the first node and not identifying the identifier including the shared resource in the first node.
本发明实施例中,可选的,接收单元500接收到的锁权限请求是第二节点发送的,第二节点用于缓存指定的锁权限中被占用的锁权限对应的锁标识,或者,指定的锁权限中占用过的、空闲时间小于删除阈值的锁权限对应的锁标识。In the embodiment of the present invention, optionally, the lock permission request received by the receiving unit 500 is sent by the second node, and the second node is configured to cache the lock identifier corresponding to the occupied lock authority in the specified lock authority, or specify The lock identifier corresponding to the lock authority that is occupied by the lock authority and whose idle time is less than the delete threshold.
本发明实施例中,可选的,分配单元520具体用于:In the embodiment of the present invention, optionally, the allocating unit 520 is specifically configured to:
将确定的锁标识通过第二节点发送至第一节点,以使得第一节点将锁标识分配至客户端。The determined lock identifier is sent to the first node through the second node such that the first node assigns the lock identifier to the client.
本发明实施例中,可选的,分配单元520具体用于:In the embodiment of the present invention, optionally, the allocating unit 520 is specifically configured to:
若确定的锁标识对应的锁权限被其他客户端占用时,向占用锁权限的客户端发送锁权限召回指示,令占用锁权限的客户端完成访问共享资源后释放锁权限;If the lock permission corresponding to the determined lock identifier is occupied by another client, the lock permission recall instruction is sent to the client occupying the lock permission, so that the client occupying the lock permission releases the lock right after accessing the shared resource;
将占用锁权限的客户端释放的锁权限对应的锁标识通过第一节点分配至客户端。 The lock identifier corresponding to the lock authority released by the client occupying the lock authority is allocated to the client through the first node.
综上所述,本发明实施例中,先接收第一节点转发的携带共享资源的标识的锁权限请求,其中,锁权限请求是第一节点在接收到第一节点的客户端发送的、且在第一节点中未查找到包括共享资源的标识的锁标识时转发的,然后,从存储的锁标识中确定出包括共享资源的标识的锁标识,最后,将确定的锁标识通过第一节点分配至客户端,给予客户端对共享资源的锁标识对应的锁权限,用于客户端对共享资源的访问,在该方案中,第一节点在接收到第一节点的客户端发送的锁权限请求后,在第一节点中未查找到包括共享资源的标识的锁标识时才进行转发,也就是说,要先在第一节点中查找是否包括共享资源的标识的锁标识,只有在不存在时,才进行转发,而存在时,直接分配就行,而客户端从第一节点中获取锁标识要比去其他节点获取锁标识耗费的时间少,因此,解决了目前的访问共享资源的方法存在的耗时较长的问题。In summary, in the embodiment of the present invention, the lock permission request that carries the identifier of the shared resource forwarded by the first node is received, where the lock permission request is sent by the first node on the client that receives the first node, and And forwarding, when the lock identifier of the identifier of the shared resource is not found in the first node, and then determining a lock identifier including the identifier of the shared resource from the stored lock identifier, and finally, determining the determined lock identifier by using the first node Assigned to the client, giving the client the lock permission corresponding to the lock identifier of the shared resource, for the client to access the shared resource, in the scheme, the first node receives the lock permission sent by the client of the first node After the request, the lock identifier of the identifier including the shared resource is not found in the first node, that is, the lock identifier of the identifier of the shared resource is first searched in the first node, and only exists in the absence of the lock identifier of the identifier of the shared resource. When the forwarding is performed, when it exists, the direct allocation is performed, and the client obtains the lock identifier from the first node than when the other node acquires the lock identifier. Less, therefore, to solve the problem of a longer time-consuming methods currently exist to access shared resources.
本发明是参照根据本发明实施例的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中的功能的装置。The present invention has been described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (system), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flowchart illustrations and/or FIG. These computer program instructions can be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing device to produce a machine for the execution of instructions for execution by a processor of a computer or other programmable data processing device. Means for implementing the functions in one or more of the flow or in a block or blocks of the flowchart.
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中的功能。The computer program instructions can also be stored in a computer readable memory that can direct a computer or other programmable data processing device to operate in a particular manner, such that the instructions stored in the computer readable memory produce an article of manufacture comprising the instruction device. The apparatus functions in one or more blocks of a flow or a flow diagram and/or block diagram of a flowchart.
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中的功能的步骤。 These computer program instructions can also be loaded onto a computer or other programmable data processing device such that a series of operational steps are performed on a computer or other programmable device to produce computer-implemented processing for execution on a computer or other programmable device. The instructions provide steps for implementing the functions in one or more blocks of the flowchart or in a flow or block of the flowchart.
尽管已描述了本发明的优选实施例,但本领域内的技术人员一旦得知了基本创造性概念,则可对这些实施例作出另外的变更和修改。所以,所附权利要求意欲解释为包括优选实施例以及落入本发明范围的所有变更和修改。While the preferred embodiment of the invention has been described, it will be understood that Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and the modifications and
显然,本领域的技术人员可以对本发明实施例进行各种改动和变型而不脱离本发明实施例的精神和范围。这样,倘若本发明实施例的这些修改和变型属于本发明权利要求及其等同技术的范围之内,则本发明也意图包含这些改动和变型在内。 It is apparent that those skilled in the art can make various modifications and variations to the embodiments of the invention without departing from the spirit and scope of the embodiments of the invention. Thus, it is intended that the present invention cover the modifications and modifications of the embodiments of the invention.

Claims (12)

  1. 一种访问共享资源的方法,其特征在于,包括:A method for accessing a shared resource, comprising:
    接收第一节点转发的携带共享资源的标识的锁权限请求;Receiving a lock permission request for carrying the identifier of the shared resource forwarded by the first node;
    其中,所述锁权限请求是所述第一节点在接收到第一节点的客户端发送的、且在第一节点中未查找到包括所述共享资源的标识的锁标识时转发的;The lock permission request is forwarded when the first node sends the lock identifier that is sent by the client of the first node and does not find the identifier of the shared resource in the first node;
    从存储的锁标识中确定出包括所述共享资源的标识的锁标识;Determining, from the stored lock identifier, a lock identifier including an identifier of the shared resource;
    将确定的所述锁标识通过所述第一节点分配至所述客户端,给予所述客户端对所述共享资源的所述锁标识对应的锁权限,用于所述客户端对所述共享资源的访问。Assigning the determined lock identifier to the client by using the first node, and giving the client a lock right corresponding to the lock identifier of the shared resource, where the client uses the share for the share Access to resources.
  2. 如权利要求1所述的方法,其特征在于,所述第一节点用于缓存所述第一节点中的每一个客户端占用的锁权限对应的锁标识,或者占用过的、空闲时间小于删除阈值的锁权限对应的锁标识。The method according to claim 1, wherein the first node is configured to cache a lock identifier corresponding to a lock authority occupied by each client in the first node, or the occupied idle time is less than the deletion. The lock identifier corresponding to the lock permission of the threshold.
  3. 如权利要求1或2所述的方法,其特征在于,所述接收第一节点转发的携带共享资源的标识的锁权限请求,具体包括:The method according to claim 1 or 2, wherein the receiving the lock permission request that carries the identifier of the shared resource forwarded by the first node includes:
    接收所述第一节点通过第二节点转发的携带所述共享资源的标识的锁权限请求;Receiving, by the first node, a lock permission request that carries the identifier of the shared resource that is forwarded by the second node;
    其中,所述锁权限请求是所述第二节点在接收到所述第一节点发送的、且在第一节点中未查找到包括所述共享资源的标识的锁标识时转发的。The lock permission request is forwarded by the second node when receiving the lock identifier sent by the first node and not finding the identifier of the shared resource in the first node.
  4. 如权利要求3所述的方法,其特征在于,所述第二节点用于缓存指定的锁权限中被占用的锁权限对应的锁标识,或者,指定的锁权限中占用过的、空闲时间小于删除阈值的锁权限对应的锁标识。The method according to claim 3, wherein the second node is configured to cache a lock identifier corresponding to the occupied lock authority in the specified lock authority, or the idle time occupied by the specified lock authority is less than Delete the lock identifier corresponding to the lock permission of the threshold.
  5. 如权利要求3或4所述的方法,其特征在于,所述将确定的所述锁标识通过所述第一节点分配至所述客户端,具体包括:The method of claim 3 or 4, wherein the assigning the determined lock identifier to the client by using the first node comprises:
    将确定的所述锁标识通过所述第二节点发送至所述第一节点,以使得所述第一节点将所述锁标识分配至所述客户端。 And transmitting the determined lock identifier to the first node by the second node, so that the first node assigns the lock identifier to the client.
  6. 如权利要求1-5任一项所述的方法,其特征在于,所述将确定的所述锁标识通过所述第一节点分配至所述客户端,具体包括:The method according to any one of claims 1-5, wherein the assigning the determined lock identifier to the client by using the first node comprises:
    若确定的所述锁标识对应的锁权限被其他客户端占用时,向占用所述锁权限的客户端发送锁权限召回指示,令占用所述锁权限的客户端完成访问所述共享资源后释放所述锁权限;If the lock permission corresponding to the lock identifier is occupied by another client, the lock permission recall instruction is sent to the client occupying the lock permission, so that the client occupying the lock authority completes accessing the shared resource and then releases The lock authority;
    将占用所述锁权限的客户端释放的锁权限对应的锁标识通过所述第一节点分配至所述客户端。And assigning, by the first node, the lock identifier corresponding to the lock authority released by the client occupying the lock authority to the client.
  7. 一种访问共享资源的装置,其特征在于,包括:An apparatus for accessing a shared resource, comprising:
    接收单元,用于接收第一节点转发的携带共享资源的标识的锁权限请求;其中,所述锁权限请求是所述第一节点在接收到第一节点的客户端发送的、且在第一节点中未查找到包括所述共享资源的标识的锁标识时转发的;a receiving unit, configured to receive a lock permission request that is forwarded by the first node and that carries the identifier of the shared resource, where the lock permission request is sent by the first node at the client that receives the first node, and is in the first Forwarded when the lock identifier of the identifier of the shared resource is not found in the node;
    确定单元,用于从存储的锁标识中确定出包括所述共享资源的标识的锁标识;a determining unit, configured to determine, from the stored lock identifier, a lock identifier including an identifier of the shared resource;
    分配单元,用于将确定的所述锁标识通过所述第一节点分配至所述客户端,给予所述客户端对所述共享资源的所述锁标识对应的锁权限,用于所述客户端对所述共享资源的访问。An allocating unit, configured to allocate the determined lock identifier to the client by using the first node, and give the client a lock right corresponding to the lock identifier of the shared resource, for the client Access to the shared resource.
  8. 如权利要求7所述的装置,其特征在于,所述接收单元接收到的所述锁权限请求是所述第一节点发送的,所述第一节点用于缓存所述第一节点中的每一个客户端占用的锁权限对应的锁标识,或者占用过的、空闲时间小于删除阈值的锁权限对应的锁标识。The device according to claim 7, wherein the lock permission request received by the receiving unit is sent by the first node, and the first node is configured to cache each of the first nodes. The lock identifier corresponding to the lock authority occupied by the client, or the lock identifier corresponding to the lock authority whose idle time is less than the deletion threshold.
  9. 如权利要求7或8所述的装置,其特征在于,所述接收单元具体用于:The device according to claim 7 or 8, wherein the receiving unit is specifically configured to:
    接收所述第一节点通过第二节点转发的携带所述共享资源的标识的锁权限请求;Receiving, by the first node, a lock permission request that carries the identifier of the shared resource that is forwarded by the second node;
    其中,所述锁权限请求是所述第二节点在接收到所述第一节点发送的、 且在第一节点中未查找到包括所述共享资源的标识的锁标识时转发的。The lock permission request is sent by the second node after receiving the first node, And forwarding when the lock identifier including the identifier of the shared resource is not found in the first node.
  10. 如权利要求9所述的装置,其特征在于,所述接收单元接收到的所述锁权限请求是所述第二节点发送的,所述第二节点用于缓存指定的锁权限中被占用的锁权限对应的锁标识,或者,指定的锁权限中占用过的、空闲时间小于删除阈值的锁权限对应的锁标识。The apparatus according to claim 9, wherein the lock authority request received by the receiving unit is sent by the second node, and the second node is configured to cache an occupied one of the specified lock rights. The lock identifier corresponding to the lock authority, or the lock identifier corresponding to the lock authority that is occupied by the specified lock authority and whose idle time is less than the deletion threshold.
  11. 如权利要求9或10所述的装置,其特征在于,所述分配单元具体用于:The device according to claim 9 or 10, wherein the allocating unit is specifically configured to:
    将确定的所述锁标识通过所述第二节点发送至所述第一节点,以使得所述第一节点将所述锁标识分配至所述客户端。And transmitting the determined lock identifier to the first node by the second node, so that the first node assigns the lock identifier to the client.
  12. 如权利要求7-11任一项所述的装置,其特征在于,所述分配单元具体用于:The device according to any one of claims 7 to 11, wherein the allocating unit is specifically configured to:
    若确定的所述锁标识对应的锁权限被其他客户端占用时,向占用所述锁权限的客户端发送锁权限召回指示,令占用所述锁权限的客户端完成访问所述共享资源后释放所述锁权限;If the lock permission corresponding to the lock identifier is occupied by another client, the lock permission recall instruction is sent to the client occupying the lock permission, so that the client occupying the lock authority completes accessing the shared resource and then releases The lock authority;
    将占用所述锁权限的客户端释放的锁权限对应的锁标识通过所述第一节点分配至所述客户端。 And assigning, by the first node, the lock identifier corresponding to the lock authority released by the client occupying the lock authority to the client.
PCT/CN2014/088928 2013-12-13 2014-10-20 Method and apparatus for accessing shared resource WO2015085826A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201310689369.3A CN103716383B (en) 2013-12-13 2013-12-13 A kind of method and device for accessing shared resource
CN201310689369.3 2013-12-13

Publications (1)

Publication Number Publication Date
WO2015085826A1 true WO2015085826A1 (en) 2015-06-18

Family

ID=50408953

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2014/088928 WO2015085826A1 (en) 2013-12-13 2014-10-20 Method and apparatus for accessing shared resource

Country Status (2)

Country Link
CN (1) CN103716383B (en)
WO (1) WO2015085826A1 (en)

Families Citing this family (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103716383B (en) * 2013-12-13 2017-12-15 华为技术有限公司 A kind of method and device for accessing shared resource
CN106202074B (en) * 2015-04-29 2021-02-23 中兴通讯股份有限公司 Method and device for processing shared file
CN107402821B (en) * 2017-07-03 2020-06-30 阿里巴巴集团控股有限公司 Access control method, device and equipment for shared resources
CN109697127B (en) * 2017-10-24 2020-12-01 华为技术有限公司 Method and device for locking access operation of shared resource
CN108038005A (en) * 2017-12-28 2018-05-15 广东蜂助手网络技术股份有限公司 Shared resource access method, client, server-side, system based on zookeeper
CN109063132B (en) * 2018-08-02 2020-08-25 上海达梦数据库有限公司 Latch request method, latch authorization method, device and terminal equipment
CN109947575B (en) * 2019-03-21 2021-08-24 恒生电子股份有限公司 Locking and releasing method of read-write lock and related system
CN110879743B (en) * 2019-11-20 2023-07-18 深圳市网心科技有限公司 Task eliminating method, device, system and medium based on edge computing environment
CN114500390B (en) * 2021-12-29 2024-01-19 中国航空工业集团公司西安航空计算技术研究所 rapidIO network flow control method

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20120072763A1 (en) * 2010-08-17 2012-03-22 Emc Corporation System and method of file locking in a network file system federated namespace
CN103248667A (en) * 2012-02-14 2013-08-14 阿里巴巴集团控股有限公司 Resource access method and system for distributed system
CN103297268A (en) * 2013-05-13 2013-09-11 北京邮电大学 P2P (peer to peer) technology based distributed data consistency maintaining system and method
CN103716383A (en) * 2013-12-13 2014-04-09 华为技术有限公司 Method and device for accessing shared resources

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN100576848C (en) * 2005-12-09 2009-12-30 英业达股份有限公司 Distribution-type data dynamic program agent method
US8078622B2 (en) * 2008-10-30 2011-12-13 Network Appliance, Inc. Remote volume access and migration via a clustered server namespace

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20120072763A1 (en) * 2010-08-17 2012-03-22 Emc Corporation System and method of file locking in a network file system federated namespace
CN103248667A (en) * 2012-02-14 2013-08-14 阿里巴巴集团控股有限公司 Resource access method and system for distributed system
CN103297268A (en) * 2013-05-13 2013-09-11 北京邮电大学 P2P (peer to peer) technology based distributed data consistency maintaining system and method
CN103716383A (en) * 2013-12-13 2014-04-09 华为技术有限公司 Method and device for accessing shared resources

Also Published As

Publication number Publication date
CN103716383B (en) 2017-12-15
CN103716383A (en) 2014-04-09

Similar Documents

Publication Publication Date Title
WO2015085826A1 (en) Method and apparatus for accessing shared resource
US11366768B2 (en) Data write method, apparatus, and system
US8782323B2 (en) Data storage management using a distributed cache scheme
EP2985702B1 (en) Data processing method and device, and computer system
US10228737B2 (en) Affinity-aware parallel zeroing of memory for initialization of large pages in non-uniform memory access (NUMA) servers
WO2015169145A1 (en) Memory management method and device
US20100257331A1 (en) Reducing storage expansion of a virtual machine operating system
US11741022B2 (en) Fine grained memory and heap management for sharable entities across coordinating participants in database environment
US9654582B2 (en) Enhanced shared memory based communication driver for improved performance and scalability
CN109144406B (en) Metadata storage method, system and storage medium in distributed storage system
US10310986B1 (en) Memory management unit for shared memory allocation
US20120066191A1 (en) Optimized concurrent file input/output in a clustered file system
WO2022000799A1 (en) Memory management method and device
WO2022120522A1 (en) Memory space allocation method and device, and storage medium
US9250977B2 (en) Tiered locking of resources
CN114041119A (en) Memory deallocation across trust boundaries
KR20220085831A (en) Competency Management Methods and Computer Devices
US9251101B2 (en) Bitmap locking using a nodal lock
WO2023236629A1 (en) Data access method and apparatus, and storage system and storage medium
US11573719B2 (en) PMEM cache RDMA security
CN116303128A (en) Memory cache pool maintenance method, equipment, system and storage medium
KR20190010508A (en) Message scheduling method

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 14869724

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 14869724

Country of ref document: EP

Kind code of ref document: A1