CN110515911B - Resource processing method and device - Google Patents

Resource processing method and device Download PDF

Info

Publication number
CN110515911B
CN110515911B CN201910736626.1A CN201910736626A CN110515911B CN 110515911 B CN110515911 B CN 110515911B CN 201910736626 A CN201910736626 A CN 201910736626A CN 110515911 B CN110515911 B CN 110515911B
Authority
CN
China
Prior art keywords
node
space
space block
lock
block
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201910736626.1A
Other languages
Chinese (zh)
Other versions
CN110515911A (en
Inventor
马怀旭
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Jinan Inspur Data Technology Co Ltd
Original Assignee
Jinan Inspur Data Technology Co Ltd
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 Jinan Inspur Data Technology Co Ltd filed Critical Jinan Inspur Data Technology Co Ltd
Priority to CN201910736626.1A priority Critical patent/CN110515911B/en
Publication of CN110515911A publication Critical patent/CN110515911A/en
Application granted granted Critical
Publication of CN110515911B publication Critical patent/CN110515911B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/17Details of further file system functions
    • G06F16/176Support for shared access to files; File sharing support
    • G06F16/1767Concurrency control, e.g. optimistic or pessimistic approaches
    • G06F16/1774Locking methods, e.g. locking methods for file systems allowing shared and concurrent access to files
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/18File system types
    • G06F16/182Distributed file systems
    • 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

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Software Systems (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application discloses a resource processing method and a device, wherein the resource processing method is implemented by acquiring a lock space request; wherein the lock space request carries an identifier of the node; reading the information of the lock space; wherein the information of the lock space includes: identifiers of space blocks in the lock space and occupation condition information of the space blocks in the lock space; according to the read information in the lock space, determining a space block in the lock space which is currently in an idle state; and taking one space block in the space blocks in the idle state at present as a space block corresponding to the node to be distributed to the node. According to the method and the device, the information in the lock space can be read, the space block in the lock space in the idle state at present can be further determined, and then one space block in the idle state at present is allocated to the node, so that the space block is automatically allocated to the node, the workload of manual operation is reduced, and the condition of error caused by the manual operation is reduced.

Description

Resource processing method and device
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a resource processing method and apparatus.
Background
Distributed locks (sanlocks) are one way to control the synchronous access to shared resources between distributed systems. In distributed systems, it is often necessary to coordinate their actions. If one or a group of resources are shared between different systems or different hosts of the same system, mutual exclusion is often required to prevent interference with each other when accessing the resources to ensure consistency, and in this case, a distributed lock is required to ensure consistency.
sanlock achieves consistency according to the disk paxos algorithm. In the prior art, the disk paxos algorithm needs to manually designate a node to occupy a space block corresponding to the node. When the number of the nodes is large, the workload of manual operation is large, and errors are easy to occur, so that the disk paxos algorithm is abnormal and exits.
Disclosure of Invention
Based on the defects of the prior art, the application provides a resource processing method and device to realize automatic allocation of space blocks for nodes.
The first aspect of the invention discloses a resource processing method, which comprises the following steps:
acquiring a lock space request; wherein the lock space request carries an identifier of a node;
reading the information of the lock space; wherein the information of the lock space includes: identifiers of space blocks in the lock space and occupation condition information of the space blocks in the lock space;
according to the read information in the lock space, determining a space block in the lock space which is currently in an idle state;
and taking one space block in the space blocks in the idle state at present as a space block corresponding to the node to be distributed to the node.
Optionally, in the method for processing resources, the allocating a space block corresponding to the node includes:
writing the information of the node into a space block corresponding to the node; wherein the information of the node comprises an identifier of the node.
Optionally, in the method for processing resources, the allocating a space block in the space blocks currently in the idle state to the node as a space block corresponding to the node includes:
judging whether a space block occupied by the node exists in the space blocks in the idle state currently;
if the space block occupied by the node exists, the space block occupied by the node is taken as the space block corresponding to the node and is distributed to the node;
if the space blocks occupied by the nodes do not exist, judging whether unoccupied space blocks exist in the space blocks in the current idle state or not;
if the unoccupied space blocks exist, the unoccupied space blocks are taken as the space blocks corresponding to the nodes and are distributed to the nodes;
if the identifier of the unoccupied space block does not exist, judging whether the space block occupying the failed node exists or not;
and if the space block occupying the failed node exists, distributing the space block occupying the failed node to the node as the space block corresponding to the node.
Optionally, in the method for processing resources, if there is a space block occupied by the node, allocating the space block occupied by the node to the node as a space block corresponding to the node, includes:
if the space block occupied by the node exists, judging whether the space block occupied by the node is updated in a preset period;
and if the space block occupied by the node is not updated in the preset period, distributing the space block occupied by the node to the node as the space block corresponding to the node.
Optionally, in the method for processing resources, after determining whether the space block occupied by the node is updated in a preset period, the method further includes:
and if the space block occupied by the node is updated in the preset period, modifying the identifier of the node, and returning to the step of reading the information of the lock space.
Optionally, in the method for processing resources, if there is a space block occupying a failed node, allocating the space block occupying the failed node to the node as an identifier of the space block corresponding to the node, including:
if the space block occupying the failed node exists, judging whether the space block occupying the failed node is updated or not after waiting for a preset period;
and if the space block occupying the failed node is not updated, allocating the space block occupying the failed node to the node as the identifier of the space block corresponding to the node.
The second aspect of the present invention discloses a resource processing apparatus, including:
an obtaining unit, configured to obtain a lock space request; wherein the lock space request carries an identifier of a node;
a reading unit for reading information of the lock space; wherein the information of the lock space includes: identifiers of space blocks in the lock space and occupation condition information of the space blocks in the lock space;
the determining unit is used for determining a space block which is in a free state currently in the lock space according to the read information in the lock space;
and the allocation unit is used for allocating one space block in the space blocks in the idle state as the space block corresponding to the node.
Optionally, in the device for processing resources, the allocating unit includes:
a writing unit, configured to write information of the node into a space block corresponding to the node; wherein the information of the node comprises an identifier of the node.
Optionally, in the device for processing resources, the allocating unit includes:
a first judging unit, configured to judge whether a space block occupied by the node exists in the space blocks currently in the idle state;
a first allocating subunit, configured to, if there is a space block occupied by the node, allocate the space block occupied by the node to the node as a space block corresponding to the node;
a second judging unit, configured to judge whether an unoccupied space block exists in the space blocks currently in the idle state if the space block occupied by the node does not exist;
the second allocation subunit is used for allocating the unoccupied space blocks to the nodes as the space blocks corresponding to the nodes if the unoccupied space blocks exist;
a third judging unit, configured to judge whether there is a space block in which an occupied node has failed if there is no identifier of an unoccupied space block;
and the third allocating subunit is used for allocating the space block occupying the failed node to the node as the space block corresponding to the node if the space block occupying the failed node exists.
Optionally, in the processing apparatus of the resource, the first allocation subunit includes:
the first judging subunit is used for judging whether the space block occupied by the node is updated in a preset period or not if the space block occupied by the node exists;
and the fourth sub-unit is used for distributing the space block occupied by the node to the node as the space block corresponding to the node if the space block occupied by the node is not updated in the preset period.
Optionally, in the processing apparatus for resources, the method further includes:
and the returning unit is used for modifying the identifier of the node and returning the identifier to the reading unit if the space block occupied by the node is updated in the preset period.
Optionally, in the apparatus for processing the resource, the third sub-subunit includes:
the second judgment subunit is configured to, if there is a space block occupying the failed node, judge whether the space block occupying the failed node has been updated after waiting for a preset period;
and the fifth allocating subunit is used for allocating the space block which occupies the node with the failure as the identifier of the space block corresponding to the node if the space block which occupies the node with the failure is not updated.
According to the technical scheme, the method for processing the resources provided by the application obtains the lock space request. Wherein the lock space request carries an identifier of the node. The information of the lock space is read. Wherein the information of the lock space includes: an identifier of a space block in the lock space, and occupancy information of the space block in the lock space. And according to the read information in the lock space, determining the space block in the lock space which is currently in the idle state. And taking one space block in the space blocks in the idle state at present as a space block corresponding to the node to be distributed to the node. According to the method and the device, the information in the lock space can be read, the space block in the lock space in the idle state at present can be further determined, and then one space block in the idle state at present is allocated to the node, so that the space block is automatically allocated to the node, the workload of manual operation is reduced, and the condition of error caused by the manual operation is reduced.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the provided drawings without creative efforts.
FIG. 1 is a flowchart illustrating a resource processing method according to an embodiment of the present invention;
FIG. 2 is a flow chart illustrating another resource processing method according to an embodiment of the present invention;
fig. 3 is a schematic flowchart of a method for allocating a space block occupied by a node to the node according to an embodiment of the present invention;
FIG. 4 is a flowchart illustrating a method for allocating unoccupied space blocks to nodes according to an embodiment of the present invention;
fig. 5 is a schematic flowchart of a method for allocating a space block occupying a failed node to a node according to an embodiment of the present invention;
fig. 6 is a schematic structural diagram of a resource processing apparatus 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 below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Referring to fig. 1, an embodiment of the present application discloses a resource processing method, where the resource processing method is executed by a control unit in sanlock, where the control unit may be a host, a terminal, and other devices, and the control unit is configured to allocate a space block in a lock space for a node. Specifically, the method shown in fig. 1 includes the following steps:
s101, obtaining a lock space request.
Wherein the lock space request carries an identifier of the node. The lock space is made up of a number of Lease (Delta Lease) space blocks. In a distributed environment, both nodes and processes may crash or otherwise fail the network, and thus the lock has a lease period so that the lock can be automatically released upon a crash of the node holding the lock. After a process requests a lock from sanlock, sanlock will automatically renew the lock at intervals, so the term Lease (Delta Lease) used in sanlock's documents is used to refer to the lock. Each node acquires a Delta Lease space block in a lock space to acquire a Lease. Here, a node refers to a device having a communication function, such as a host or a terminal.
It should be noted that the lock space request is a request for allocating a space block to a node, and specifically, which node is to be allocated with a space block may be known by an identifier of the node carried in the lock space request. The lock space request may be sent by a node, or may be directly input to the control unit by a user. When a node wants to add a lock space, the control unit needs to allocate a space block to the node, and thus generates a lock space request.
It should be further noted that the Identifier of the node may be a Universal Unique Identifier (UUID), the Identifier of the node is Unique to each node, and when a node Identifier conflict occurs, the control unit needs to modify the Identifier of the node to ensure the uniqueness of the Identifier of each node.
And S102, reading the information of the lock space.
Wherein the information of the lock space includes: an identifier of a space block in the lock space, and occupancy information of the space block in the lock space. The lock space is composed of a plurality of space blocks, and the information of the lock space includes identifier information of each space block and occupation information of each space block. The occupation information of each space block includes the current occupation and the historical occupation. For example, the information in the space block with identifier 001 may show that the space block 001 does not currently have any node occupied, but has been occupied by the a node. The information in the space block of identifier 002 indicates that it is currently occupied by a node B. It should be noted that the information in the lock space may include other information contents besides those provided in the embodiments of the present application.
S103, according to the read information in the lock space, determining the space block in the lock space which is in the idle state at present.
Since the information of the lock space includes the occupation information of each space block, it can be determined which space block is currently in the free state in the lock space. The space block currently in the idle state refers to a space block currently not occupied by a node. The space block currently in the idle state mainly includes: occupied space blocks of a node, unoccupied space blocks, and occupied space blocks in which the node has failed.
The space block occupied by the node refers to the space block once occupied by the node identifier carried in the lock space request in step S101. Specifically, the historical occupation information of each space block is read when step S102 is executed, and whether there is an identifier of a node is checked from the historical occupation information, so that the space block occupied by the node can be found.
An unoccupied space block refers to a space block that has never been occupied by any node. Specifically, after the information of the lock space is read, the found space block with empty historical occupation information and no occupied space currently is an unoccupied space block.
The space block occupied by the failed node refers to a space block without continuous update information, that is, the node occupying the space block does not renew the space block or the node crashes due to an exception. Specifically, when the control unit detects that none of the space blocks has updated information in more than n update cycles, it is determined that the occupied node of the space block has failed. Wherein n is a preset integer, and the update period is set by disk paxos algorithm. Every other update period, the lease in the lock space is updated by the disk paxos algorithm.
And S104, allocating one space block in the space blocks in the idle state to the node as a space block corresponding to the node.
From the empty space blocks determined in step S103, one of the space blocks can be selected according to a preset allocation rule, and is allocated to the node as the space block corresponding to the node. For example, a priority may be set for a space block occupied by a node, a space block unoccupied, and a space block occupied by a node that has failed, and the priority may be assigned to the node according to a preset priority. For example, it may be set that an unoccupied space block is preferentially selected as a space block corresponding to a node, and if there is no unoccupied space block, a space block occupied by the node is then selected as a space block corresponding to the node, and if there is no space block occupied by the node, a space block occupied by the node that has failed is selected as a space block corresponding to the node. The preset allocation rule can be in various forms, including but not limited to the content provided by the embodiment of the application.
Alternatively, one of the space blocks determined in step S103 in the idle state may be arbitrarily selected and allocated to the node.
Optionally, in a specific embodiment of the present application, one way of executing step S104 includes:
and writing the information of the node into a space block corresponding to the node.
Wherein the information of the node comprises an identifier of the node. After the information of the node is written into the space block corresponding to the node, the occupation of the node on the space block can be completed, and the lease of the space block is obtained.
Specifically, for example, the a node writes the information of the a node into the space block numbered 001, and if a node B wants to add a lock space later, the control center finds that the information of the a node has been written into the space block number 001 when reading the lock space information, that is, the space block number 001 has been occupied by the a node, and therefore the space block number 001 is not allocated to the node B, and it is ensured that a situation that a plurality of nodes, which occur when the space block is manually specified in the prior art, are allocated to the same space block does not occur.
According to the resource processing method, the lock space request is acquired. Wherein the lock space request carries an identifier of the node. The information of the lock space is read. Wherein the information of the lock space includes: an identifier of a space block in the lock space, and occupancy information of the space block in the lock space. And according to the read information in the lock space, determining the space block in the lock space which is currently in the idle state. And taking one space block in the space blocks in the idle state at present as a space block corresponding to the node to be distributed to the node. According to the method and the device, the information in the lock space can be read, the space block in the lock space in the idle state at present can be further determined, and then one space block in the idle state at present is allocated to the node, so that the space block is automatically allocated to the node, the workload of manual operation is reduced, and the condition of error caused by the manual operation is reduced.
Referring to fig. 2, an embodiment of the present application provides another resource processing method, which specifically includes the following steps:
s201, obtaining a lock space request.
The principle and the execution process of step S201 are the same as those of step S101 shown in fig. 1, and reference may be made to these steps, which are not described herein again.
And S202, reading the information of the lock space.
The principle and the execution process of step S202 are the same as those of step S102 shown in fig. 1, and reference may be made to these steps, which are not described herein again.
S203, according to the read information in the lock space, determining the space block in the lock space which is currently in the idle state.
The principle and the execution process of step S203 are the same as those of step S103 shown in fig. 1, and reference may be made to these steps, which are not described herein again.
And S204, judging whether a space block occupied by the node exists in the space blocks in the idle state at present.
After determining the space block currently in the idle state in step S203, checking whether the historical occupation records of the space blocks have the identifier of the node, if the identifier of the node is written in the historical occupation record of one space block, it may be determined that the space block currently in the idle state has the space block occupied by the node, and then step S205 is executed. If the historical occupation records of the space block currently in the free state do not have the identifier of the node, it indicates that the space block occupied by the node does not exist in the space block currently in the free state, and step S206 is executed.
And S205, allocating the space blocks occupied by the nodes to the nodes as the space blocks corresponding to the nodes.
Generally, a node occupies the same space block as much as possible, so that the node is less likely to collide when being allocated. Therefore, if a space block occupied by a node exists in the currently free space block, the space block occupied by the node can be allocated to the node as a space block corresponding to the node.
Optionally, referring to fig. 3, in an embodiment of the present application, an implementation manner of performing step S205 includes:
s301, judging whether the space block occupied by the node is updated in a preset period.
In order to avoid the situation that two nodes occupy the same space block, the nodes may wait for a preset period from the current time, the disk paxos algorithm updates the information in the lock space after the preset period, and if the space block occupied by the node is still unoccupied, that is, the space block occupied by the node is not updated in the preset period, the space block may be allocated to the node, that is, step S302 is executed. The preset period can be set according to actual conditions.
And if the space block occupied by the node is updated in a preset period, finishing the distribution of the space block to the node.
Optionally, in a specific embodiment of the present application, after the step S301 is executed, the method further includes:
if the space block occupied by the node is updated within a preset period, the identifier of the node is modified, and the step S202 is executed.
In the embodiment of the application, the space block occupied by the node is used as the space block preferentially selected and allocated, so that if the space block occupied by the node is updated in a preset period, it is indicated that the lease of the space block is acquired by other nodes, and according to the priority set by the application, the space block is acquired by other nodes having the same identifier as the identifier of the node, that is, the identifier conflicts, and two nodes use the same identifier. It is therefore necessary to modify the identifier of the node and then re-read the information of the lock space, i.e. return to performing step S202 shown in fig. 2.
S302, the space blocks occupied by the nodes are used as space blocks corresponding to the nodes to be distributed to the nodes.
If the space block occupied by the node is not updated within a preset period, the space block can be considered as belonging to the node, and therefore the space block can be allocated to the node. In particular, a node may write its own identifier into a space block.
S206, judging whether unoccupied space blocks exist in the space blocks in the idle state at present.
The unoccupied space block refers to a space block in which both the historical occupation information and the current occupation information are empty. Specifically, the historical occupation information in the space block currently in the idle state determined in step S203 is checked, and if the historical occupation information is a blank space block, it is determined that an unoccupied space block exists in the space block currently in the idle state, and step S207 is executed. If there is no unoccupied space block, step S208 is executed.
And S207, allocating the unoccupied space blocks to the nodes as the space blocks corresponding to the nodes.
If the unoccupied space block is more than one, one unoccupied space block can be arbitrarily selected as the space block corresponding to the node and distributed to the node.
Optionally, when step S207 is executed, the identifier of the node may be written into the unoccupied space block, so that the node successfully acquires the lock resource of the space block and obtains a lease.
Optionally, referring to fig. 4, in an embodiment of the present application, an implementation manner of executing step S207 includes:
s401, judging whether the unoccupied space blocks are updated in a preset period.
In order to avoid the situation that other nodes have already joined the unoccupied space block at this time, but the information in the lock space has not been updated yet by the disk paxos algorithm, it needs to be determined whether the unoccupied space block has been updated within a preset period.
If the unoccupied space block is not updated within a preset period, the unoccupied space block is allocated to the node as the space block corresponding to the node, i.e., step S402 is executed. If the unoccupied space block is updated within a predetermined period, it indicates that the unoccupied space block is occupied after waiting for a predetermined period, and therefore, it is necessary to continue to execute step S208 shown in fig. 2.
S402, distributing the unoccupied space blocks to the nodes as the space blocks corresponding to the nodes.
Because the space block is not updated within a preset period, no other node and the node select the space block at the same time, and the condition of node conflict does not occur, so that the unoccupied space block can be used as the space block corresponding to the node to be allocated to the node.
And S208, judging whether the space block occupying the failed node exists or not.
A failed node refers to a node that has no longer been able to reconcile a previously occupied block of space. The non-continuation condition may occur because the abnormal condition of the node itself is broken down, or the node adds another space block and does not continue the continuation of the originally occupied space block.
Specifically, when step S208 is executed, it is checked whether there is a space block that has not been updated for more than a preset period from the information of the space block currently in the free state determined in step S203. The preset period can be set according to actual conditions. The update cycle of the 6 disk paxos algorithms can be used as a preset cycle duration, that is, if the space block is still not rented after the 6 update cycles, the occupied node corresponding to the space block is invalid.
If it is determined that there is a space block occupying the node that has failed, step S209 is performed. If the space block occupying the node and having failed does not exist, the distribution of the node is finished, and the current free space block is considered to have no space block capable of being distributed to the node. Alternatively, step S209 determines that there is no space block occupying the failed node, and may return to step S202 again to continue reading the information of the lock space until a space block that can be allocated to the node is found.
S209, allocating the space block occupying the failed node to the node as the space block corresponding to the node.
And if the space block occupying the failed node exists, taking the space block as the space block corresponding to the node and distributing the space block to the node. Specifically, the identifier of the node may be written into the space block, and the occupation of the space block is completed.
It should be noted that, if the corresponding failed node before the space block is a node crashed due to an abnormal condition, the failed node will not actively release the lock resource of the space block, and therefore the node needs to actively release the lock resource occupied by the previous failed node after the step S209 is executed.
Optionally, referring to fig. 5, in an embodiment of the present application, an implementation manner of executing step S209 includes:
s501, after waiting for a preset period, judging whether the space block occupying the failed node is updated or not.
Step S501 may also be regarded as determining whether the space block occupying the failed node is updated in a waiting period. Waiting for a predetermined period is started from the current time. Step S501 is performed to avoid that other nodes also want to occupy the space block, and to avoid collision, it is necessary to wait for a predetermined period before deciding whether to allocate the space block to the node.
If the space block occupying the node with the failure is not updated after waiting for a predetermined period, step S502 is executed. And if the occupied space blocks which have failed the node are updated after waiting for a preset period, determining that no space block which can be distributed to the node exists in the space blocks which are in the idle state currently, and therefore finishing distributing the space blocks to the node.
S502, allocating the space block occupying the failed node to the node as the identifier of the space block corresponding to the node.
Specifically, the identifier of the node may be written into a space block occupying the failed space block, and the lease of the space block is successfully acquired.
Referring to fig. 6, based on the method for processing resources disclosed in the embodiment of the present application, the embodiment of the present application correspondingly discloses a device 600 for processing resources, which includes: an acquisition unit 601, a reading unit 602, a determination unit 603, and an assignment unit 604.
An obtaining unit 601, configured to obtain a lock space request.
Wherein the lock space request carries an identifier of the node.
A reading unit 602, configured to read information of the lock space.
Wherein the information of the lock space includes: an identifier of a space block in the lock space, and occupancy information of the space block in the lock space.
A determining unit 603, configured to determine, according to the read information in the lock space, a space block currently in a free state in the lock space.
An allocating unit 604, configured to allocate one of the space blocks currently in the idle state to a node as a space block corresponding to the node.
Optionally, in a specific embodiment of the present application, the allocating unit 604 includes:
and the writing unit is used for writing the information of the nodes into the space blocks corresponding to the nodes.
Wherein the information of the node comprises an identifier of the node.
Optionally, in a specific embodiment of the present application, the allocating unit 604 includes: the device comprises a first judgment unit, a first assignment subunit, a second judgment unit, a second assignment subunit, a third judgment unit and a third assignment subunit.
And the first judgment unit is used for judging whether a space block occupied by the node exists in the space blocks in the idle state at present.
And the first allocation subunit is used for allocating the space block occupied by the node to the node as the space block corresponding to the node if the space block occupied by the node exists.
Optionally, in a specific embodiment of the present application, the first allocating subunit includes: a first judgment subunit and a fourth judgment subunit.
And the first judgment subunit is used for judging whether the space block occupied by the node is updated in a preset period or not if the space block occupied by the node exists.
And the fourth sub-unit is used for distributing the space blocks occupied by the nodes to the nodes as the space blocks corresponding to the nodes if the space blocks occupied by the nodes are not updated in a preset period.
And the second judging unit is used for judging whether unoccupied space blocks exist in the space blocks in the idle state at present or not if the space blocks occupied by the nodes do not exist.
And the second allocation subunit is used for allocating the unoccupied space blocks to the nodes as the space blocks corresponding to the nodes if the unoccupied space blocks exist.
And the third judging unit is used for judging whether the space block with the failed occupied node exists or not if the identifier of the unoccupied space block does not exist.
And the third allocating subunit is used for allocating the space block occupying the failed node to the node as the space block corresponding to the node if the space block occupying the failed node exists.
Optionally, in a specific embodiment of the present application, the third subunit includes: a second judging subunit and a fifth allocating subunit.
And the second judging subunit is used for judging whether the space block occupying the failed node is updated or not after waiting for a preset period if the space block occupying the failed node exists.
And the fifth allocating subunit is used for allocating the space block which occupies the node with the failure as the identifier of the space block corresponding to the node if the space block which occupies the node with the failure is not updated.
Optionally, in a specific embodiment of the present application, the apparatus 600 for processing a resource further includes:
a returning unit, configured to modify the identifier of the node if the space block occupied by the node is updated within a preset period, and return to the reading unit 602.
The specific principle and the execution process of each unit in the resource processing apparatus 600 disclosed in the embodiment of the present application are the same as the resource processing method disclosed in the embodiment of the present application, and reference may be made to corresponding parts in the resource processing method disclosed in the embodiment of the present application, which are not described herein again.
In the resource processing apparatus 600 provided by the present application, the lock space request is acquired by the acquisition unit 601. Wherein the lock space request carries an identifier of the node. And the information of the lock space is read by the reading unit 602. Wherein the information of the lock space includes: an identifier of a space block in the lock space, and occupancy information of the space block in the lock space. The determining unit 603 determines a space block currently in a free state in the lock space according to the read information in the lock space. The allocating unit 604 allocates one of the space blocks currently in the idle state to the node as a space block corresponding to the node. According to the method and the device, the information in the lock space can be read through the reading unit 602, the space block currently in the idle state in the lock space can be determined through the determining unit 603, and then the space block currently in the idle state is allocated to the node through the allocating unit 604, so that the space block is automatically allocated to the node, the workload of manual operation is reduced, and the error caused by the manual operation is reduced.
The previous description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the present invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the invention. Thus, the present invention is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims (10)

1. A method for processing resources, comprising:
acquiring a lock space request; wherein the lock space request carries an identifier of a node;
reading the information of the lock space; wherein the information of the lock space includes: identifiers of space blocks in the lock space and occupation condition information of the space blocks in the lock space;
according to the read information in the lock space, determining a space block in the lock space which is currently in an idle state;
taking one space block in the space blocks in the idle state at present as a space block corresponding to the node and distributing the space block to the node;
the allocating a space block of the space blocks currently in the idle state to the node as a space block corresponding to the node includes:
judging whether a space block occupied by the node exists in the space blocks in the idle state currently;
if the space block occupied by the node exists, the space block occupied by the node is taken as the space block corresponding to the node and is distributed to the node;
if the space blocks occupied by the nodes do not exist, judging whether unoccupied space blocks exist in the space blocks in the current idle state or not;
if the unoccupied space blocks exist, the unoccupied space blocks are taken as the space blocks corresponding to the nodes and are distributed to the nodes;
if the identifier of the unoccupied space block does not exist, judging whether the space block occupying the failed node exists or not;
and if the space block occupying the failed node exists, distributing the space block occupying the failed node to the node as the space block corresponding to the node.
2. The method according to claim 1, wherein the space block corresponding to the node is allocated to the node, and comprises:
writing the information of the node into a space block corresponding to the node; wherein the information of the node comprises an identifier of the node.
3. The method according to claim 1, wherein if there is a space block occupied by the node, allocating the space block occupied by the node to the node as a space block corresponding to the node, comprises:
if the space block occupied by the node exists, judging whether the space block occupied by the node is updated in a preset period;
and if the space block occupied by the node is not updated in the preset period, distributing the space block occupied by the node to the node as the space block corresponding to the node.
4. The method of claim 3, wherein after determining whether the space block occupied by the node has been updated within a preset period, the method further comprises:
and if the space block occupied by the node is updated in the preset period, modifying the identifier of the node, and returning to the step of reading the information of the lock space.
5. The method according to claim 1, wherein if there is a space block that occupies the node with a failure, assigning the space block that occupies the node with the failure as an identifier of the space block corresponding to the node, comprises:
if the space block occupying the failed node exists, judging whether the space block occupying the failed node is updated or not after waiting for a preset period;
and if the space block occupying the failed node is not updated, allocating the space block occupying the failed node to the node as the identifier of the space block corresponding to the node.
6. An apparatus for processing a resource, comprising:
an obtaining unit, configured to obtain a lock space request; wherein the lock space request carries an identifier of a node;
a reading unit for reading information of the lock space; wherein the information of the lock space includes: identifiers of space blocks in the lock space and occupation condition information of the space blocks in the lock space;
the determining unit is used for determining a space block which is in a free state currently in the lock space according to the read information in the lock space;
the allocation unit is used for allocating one space block in the space blocks in the idle state as a space block corresponding to the node;
the distribution unit includes:
a first judging unit, configured to judge whether a space block occupied by the node exists in the space blocks currently in the idle state;
a first allocating subunit, configured to, if there is a space block occupied by the node, allocate the space block occupied by the node to the node as a space block corresponding to the node;
a second judging unit, configured to judge whether an unoccupied space block exists in the space blocks currently in the idle state if the space block occupied by the node does not exist;
the second allocation subunit is used for allocating the unoccupied space blocks to the nodes as the space blocks corresponding to the nodes if the unoccupied space blocks exist;
a third judging unit, configured to judge whether there is a space block in which an occupied node has failed if there is no identifier of an unoccupied space block;
and the third allocating subunit is used for allocating the space block occupying the failed node to the node as the space block corresponding to the node if the space block occupying the failed node exists.
7. The apparatus of claim 6, wherein the allocation unit comprises:
a writing unit, configured to write information of the node into a space block corresponding to the node; wherein the information of the node comprises an identifier of the node.
8. The apparatus of claim 6, wherein the first allocation subunit comprises:
the first judging subunit is used for judging whether the space block occupied by the node is updated in a preset period or not if the space block occupied by the node exists;
and the fourth sub-unit is used for distributing the space block occupied by the node to the node as the space block corresponding to the node if the space block occupied by the node is not updated in the preset period.
9. The apparatus of claim 8, further comprising:
and the returning unit is used for modifying the identifier of the node and returning the identifier to the reading unit if the space block occupied by the node is updated in the preset period.
10. The apparatus of claim 6, wherein the third subunit comprises:
the second judgment subunit is configured to, if there is a space block occupying the failed node, judge whether the space block occupying the failed node has been updated after waiting for a preset period;
and the fifth allocating subunit is used for allocating the space block which occupies the node with the failure as the identifier of the space block corresponding to the node if the space block which occupies the node with the failure is not updated.
CN201910736626.1A 2019-08-09 2019-08-09 Resource processing method and device Active CN110515911B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910736626.1A CN110515911B (en) 2019-08-09 2019-08-09 Resource processing method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910736626.1A CN110515911B (en) 2019-08-09 2019-08-09 Resource processing method and device

Publications (2)

Publication Number Publication Date
CN110515911A CN110515911A (en) 2019-11-29
CN110515911B true CN110515911B (en) 2022-03-22

Family

ID=68625447

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910736626.1A Active CN110515911B (en) 2019-08-09 2019-08-09 Resource processing method and device

Country Status (1)

Country Link
CN (1) CN110515911B (en)

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104657260A (en) * 2013-11-25 2015-05-27 航天信息股份有限公司 Achievement method for distributed locks controlling distributed inter-node accessed shared resources
CN108874551A (en) * 2018-06-26 2018-11-23 郑州云海信息技术有限公司 A kind of distributed type lock management method and device

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP4917138B2 (en) * 2009-10-07 2012-04-18 インターナショナル・ビジネス・マシーンズ・コーポレーション Object optimum arrangement device, object optimum arrangement method, and object optimum arrangement program

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104657260A (en) * 2013-11-25 2015-05-27 航天信息股份有限公司 Achievement method for distributed locks controlling distributed inter-node accessed shared resources
CN108874551A (en) * 2018-06-26 2018-11-23 郑州云海信息技术有限公司 A kind of distributed type lock management method and device

Also Published As

Publication number Publication date
CN110515911A (en) 2019-11-29

Similar Documents

Publication Publication Date Title
CN107491351B (en) Resource allocation method, device and equipment based on priority
CN109062512B (en) Distributed storage cluster, data read-write method, system and related device
CN108897628B (en) Method and device for realizing distributed lock and electronic equipment
CN109240840B (en) Disaster recovery method and device for cluster system and machine readable medium
CN106802939B (en) Method and system for solving data conflict
CN108572876B (en) Method and device for realizing read-write lock
JPH04308961A (en) Means and apparatus for notifying state of synchronous locking of occupied process
CN108616424B (en) Resource scheduling method, computer equipment and system
JP2007122664A (en) Information processing method and information processor
JP4407956B2 (en) Information processing method and information processing apparatus
US9063929B2 (en) Information processing apparatus, information processing method, computer-readable recording medium having stored therein program
CN112506821B (en) System bus interface request arbitration method and related components
CN111880956A (en) Data synchronization method and device
CN112363828B (en) Memory fragment management method and device, vehicle-mounted system and vehicle
CN110515911B (en) Resource processing method and device
CN110990318B (en) PCIe bus address expansion method, device, equipment and medium
CN117078495A (en) Memory allocation method, device, equipment and storage medium of graphic processor
JP2004178578A (en) Device, method and program of conflict arbitration
CN108073453B (en) Method and device for scheduling CPU (Central processing Unit) resources in distributed cluster
CN113064723B (en) Storage medium, electronic device, bus resource allocation method and device
CN111090520B (en) User allocation method and device for exclusive resources, electronic equipment and storage medium
CN114679465A (en) Resource operation method and device, electronic equipment and storage medium
CN110839068B (en) Service request processing method and device, electronic equipment and readable storage medium
CN114666180A (en) Distribution method and device of simulation ECU (electronic control Unit) nodes, electronic equipment and storage medium
KR20220069113A (en) Data structures, storage means and devices

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant