CN110830608A - Global unique identifier generation method, device, equipment and storage medium - Google Patents

Global unique identifier generation method, device, equipment and storage medium Download PDF

Info

Publication number
CN110830608A
CN110830608A CN201911114276.1A CN201911114276A CN110830608A CN 110830608 A CN110830608 A CN 110830608A CN 201911114276 A CN201911114276 A CN 201911114276A CN 110830608 A CN110830608 A CN 110830608A
Authority
CN
China
Prior art keywords
time
timeline
clock
target
rollback
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201911114276.1A
Other languages
Chinese (zh)
Other versions
CN110830608B (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.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen 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 Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN201911114276.1A priority Critical patent/CN110830608B/en
Publication of CN110830608A publication Critical patent/CN110830608A/en
Application granted granted Critical
Publication of CN110830608B publication Critical patent/CN110830608B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L61/00Network arrangements, protocols or services for addressing or naming
    • H04L61/30Managing network names, e.g. use of aliases or nicknames
    • H04L61/3015Name registration, generation or assignment
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04JMULTIPLEX COMMUNICATION
    • H04J3/00Time-division multiplex systems
    • H04J3/02Details
    • H04J3/06Synchronising arrangements
    • H04J3/0635Clock or time synchronisation in a network
    • H04J3/0638Clock or time synchronisation among nodes; Internode synchronisation
    • H04J3/0658Clock or time synchronisation among packet nodes
    • H04J3/0661Clock or time synchronisation among packet nodes using timestamps

Abstract

The application discloses a method, a device, equipment and a storage medium for generating a global unique identifier, wherein the method comprises the following steps: presetting a plurality of timelines comprising a current timeline and at least one rollback timeline, wherein the time schedule of the current timeline advances along with the time of a local clock, and the time schedule of the rollback timeline is later than that of the current timeline; when a global unique identifier generation request of a target node is received, determining the clock state of a local clock, and when the clock state is clock backspace, determining the clock backspace time; when the clock back-off time is greater than or equal to a preset threshold value, determining a target back-off time line; determining the timestamp of the target node according to the time point after the clock retreats; determining identification information of a target rollback timeline, node identification and a sequence number of a target node; a globally unique identifier is generated based on a node identification of the target node, the sequence number, the timestamp, and identification information of the target fallback timeline.

Description

Global unique identifier generation method, device, equipment and storage medium
Technical Field
The present application relates to the field of internet communication technologies, and in particular, to a method, an apparatus, a device, and a storage medium for generating a globally unique identifier.
Background
A globally unique identifier is a relatively unique code in a certain system. Global consistency of the distributed database, serializability of parallel operations, global recoverability of the system, etc., all without a globally unique identifier.
In the prior art, a snowflake (snowflake) algorithm is often used for generating a globally unique identifier, the snowflake algorithm uses a 64-bit integer to represent a globally unique identifier, and the globally unique identifier is divided into a sign bit, a timestamp, a node identifier and a sequence number, specifically, as shown in fig. 1, the first bit: 1bit, sign bit, fixed to zero (zero-padding is fixed because some languages, or some databases have no unsigned number, in order to generate a globally unique identifier that can be processed across platforms). Time stamping: and 41bit, and taking a local clock. And (3) node identification: and the 10bit is used for isolating the global unique identifier space generated by different nodes in the distributed cluster and ensuring that the global unique identifiers generated by different nodes are not the same. Sequence number: 12 bits to distinguish globally unique identifiers generated at the same time. However, in the existing linkage shadow, when the server time rolls back (usually due to clock synchronization), a global unique identifier is generated repeatedly in a way of generating the global unique identifier by using a snowflake algorithm, and the unique requirement cannot be met. Therefore, there is a need to provide a more reliable or efficient solution to the problem of generating duplicate globally unique identifiers in the event of clock back-off.
Disclosure of Invention
The application provides a global unique identifier generation method, a global unique identifier generation device, global unique identifier generation equipment and a storage medium, which can effectively solve the problem of global unique identifier repetition caused by clock backspace and meet the unique requirement of a global unique identifier.
In one aspect, the present application provides a method for generating a globally unique identifier, where the method includes:
presetting a plurality of timelines, wherein the plurality of timelines comprise a current timeline and at least one rollback timeline, the time progress of the current timeline advances along with the time of a local clock, and the time progress of the at least one rollback timeline is later than the time progress of the current timeline;
upon receiving a globally unique identifier generation request of a target node, the method comprises:
determining the clock state of a local clock, and determining the clock back-off time when the clock state is clock back-off;
when the clock back-off time is greater than or equal to a preset threshold value, determining a target back-off timeline based on the at least one back-off timeline;
determining the timestamp of the target node according to the time point after the clock retreats;
determining identification information of the target rollback timeline, node identification of the target node and a sequence number of the target node;
generating a globally unique identifier for the target node based on the node identification of the target node, a sequence number, a timestamp, and identification information of the target fallback timeline.
Another aspect provides a globally unique identifier generating apparatus, the apparatus comprising:
the time line setting module is used for presetting a plurality of time lines, wherein the plurality of time lines comprise a current time line and at least one backspacing time line, the time progress of the current time line advances along with the time of a local clock, and the time progress of the at least one backspacing time line is later than the time progress of the current time line;
the clock state determining module is used for determining the clock state of the local clock when receiving a global unique identifier generation request of a target node;
a clock back-off time determining module, configured to determine a clock back-off time when the clock state is a clock back-off;
a target rollback timeline determining module, configured to determine a target rollback timeline based on the at least one rollback timeline when the clock rollback time is greater than or equal to a preset threshold;
the first timestamp determining module is used for determining a timestamp of the target node according to the time point after the clock retreats;
a first information determining module, configured to determine identification information of the target rollback timeline, a node identification of the target node, and a sequence number of the target node;
a first globally unique identifier generating module, configured to generate a globally unique identifier of the target node based on the node identification of the target node, a sequence number, a timestamp, and identification information of the target fallback timeline.
Another aspect provides a globally unique identifier generating device comprising a processor and a memory, the memory having stored therein at least one instruction, at least one program, set of codes, or set of instructions, which is loaded and executed by the processor to implement the globally unique identifier generating method as described above.
Another aspect provides a computer readable storage medium having stored therein at least one instruction, at least one program, set of codes, or set of instructions, which is loaded and executed by a processor to implement the globally unique identifier generating method as described above.
The global unique identifier generation method, the device, the equipment and the storage medium have the following technical effects:
the method comprises the steps that a plurality of time lines are preset, when a global unique identifier generation request of a target node is received, the state of a local clock is determined by the lines, and when the clock state is clock backspace and the clock backspace time is longer, the timestamp of the target node is directly determined by the time point after the clock backspace; when the global unique identifier of the target node is generated, the problem of global unique identifier repetition caused by clock backspacing can be effectively solved by combining the identification information of the target backspacing time line in the backspacing time lines, and the uniqueness requirement of the global unique identifier is met.
Drawings
In order to more clearly illustrate the technical solutions and advantages of the embodiments of the present application or 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 some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative efforts.
FIG. 1 is a schematic diagram illustrating a prior art globally unique identifier according to an embodiment of the present disclosure;
FIG. 2 is a schematic diagram of an application environment provided by an embodiment of the present application;
fig. 3 is a schematic structural diagram of a distributed cluster provided in an embodiment of the present application;
fig. 4 is a flowchart illustrating a method for generating a globally unique identifier according to an embodiment of the present application;
fig. 5 is a schematic flowchart of determining a target fallback timeline based on the at least one fallback timeline according to an embodiment of the present application;
fig. 6 is a schematic flowchart of another process for determining a target rollback timeline based on the at least one rollback timeline provided in the embodiment of the present application;
FIG. 7 is a schematic diagram of a time schedule of multiple timelines provided by embodiments of the present application;
FIG. 8 is a schematic diagram of a current time schedule after a timeline switch provided by an embodiment of the present application;
FIG. 9 is a schematic diagram illustrating a globally unique identifier according to an embodiment of the present disclosure;
FIG. 10 is a flowchart illustrating another globally unique identifier generation method according to an embodiment of the present application;
fig. 11 is a schematic structural diagram of a globally unique identifier generating apparatus according to an embodiment of the present application;
fig. 12 is a block diagram of a hardware structure of a server in a globally unique identifier generation method according to an embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, 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 application.
It should be noted that the terms "first," "second," and the like in the description and claims of this application and in the drawings described above are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the application described herein are capable of operation in sequences other than those illustrated or described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or server that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
Referring to fig. 2, fig. 2 is a schematic diagram of an application environment according to an embodiment of the present application, and as shown in fig. 2, the application environment at least includes a server 100 and a distributed cluster 200.
In this embodiment, the server 100 may include a server operating independently, or a distributed server, or a server cluster composed of a plurality of servers. The server 100 may include a network communication unit, a processor, a memory, and the like. In particular, the server 100 may be configured to generate a globally unique identifier.
In this embodiment, the distributed cluster 200 may include a plurality of network nodes, where the network nodes may include terminal entity devices such as a smart phone, a desktop computer, a tablet computer, a notebook computer, a digital assistant, an Augmented Reality (AR)/Virtual Reality (VR) device, and a smart wearable device, may also include software running in the terminal entity devices, and may also include an independently running server, or a distributed server, or a server cluster composed of a plurality of servers.
In practical applications, the server 100 and the distributed cluster 200 may form a distributed system.
In addition, it should be noted that the distributed cluster 200 in this embodiment may be applied to a blockchain network. As shown in fig. 3 in particular, the network nodes in the distributed cluster 200 may each be considered as distributed nodes 201, 202, 203, 204, 205, and 206 in the distributed system. The distributed nodes may be connected by communication links, such as wired communication links or wireless communication links.
The blockchain is a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, a consensus mechanism and an encryption algorithm. A block chain (Blockchain), which is essentially a decentralized database, is a series of data blocks associated by using a cryptographic method, and each data block contains information of a batch of network transactions, so as to verify the validity (anti-counterfeiting) of the information and generate a next block. The blockchain may include a blockchain underlying platform, a platform product services layer, and an application services layer.
The block chain underlying platform can comprise processing modules such as user management, basic service, intelligent contract and operation monitoring. The user management module is responsible for identity information management of all blockchain participants, and comprises public and private key generation maintenance (account management), key management, user real identity and blockchain address corresponding relation maintenance (authority management) and the like, and under the authorization condition, the user management module supervises and audits the transaction condition of certain real identities and provides rule configuration (wind control audit) of risk control; the basic service module is deployed on all block chain node equipment and used for verifying the validity of the service request, recording the service request to storage after consensus on the valid request is completed, for a new service request, the basic service firstly performs interface adaptation analysis and authentication processing (interface adaptation), then encrypts service information (consensus management) through a consensus algorithm, transmits the service information to a shared account (network communication) completely and consistently after encryption, and performs recording and storage; the intelligent contract module is responsible for registering and issuing contracts, triggering the contracts and executing the contracts, developers can define contract logics through a certain programming language, issue the contract logics to a block chain (contract registration), call keys or other event triggering and executing according to the logics of contract clauses, complete the contract logics and simultaneously provide the function of upgrading and canceling the contracts; the operation monitoring module is mainly responsible for deployment, configuration modification, contract setting, cloud adaptation in the product release process and visual output of real-time states in product operation, such as: alarm, monitoring network conditions, monitoring node equipment health status, and the like.
The platform product service layer provides basic capability and an implementation framework of typical application, and developers can complete block chain implementation of business logic based on the basic capability and the characteristics of the superposed business. The application service layer provides the application service based on the block chain scheme for the business participants to use.
The following describes a method for generating a globally unique identifier, and fig. 4 is a flowchart of a method for generating a globally unique identifier provided in an embodiment of the present application, where the method operation steps described in the embodiment or the flowchart are provided in this specification, but more or less operation steps may be included based on conventional or non-inventive labor. The order of steps recited in the embodiments is merely one manner of performing the steps in a multitude of orders and does not represent the only order of execution. In practice, the system or server product may be implemented in a sequential or parallel manner (e.g., parallel processor or multi-threaded environment) according to the embodiments or methods shown in the figures. Specifically, as shown in fig. 4, the method may include:
s401: a plurality of timelines are set in advance.
In this specification embodiment, the plurality of timelines may include a current timeline whose timeline progresses with the time of the local clock, and at least one fallback timeline whose timeline progresses later than the current timeline.
Specifically, assuming that there are 4 timelines, different time lines are provided with different identification information, and time points (reference time points) at the start of the 4 timelines are consistent, any one timeline is selected as the current timeline, and when a certain timeline is the current timeline, the current timeline can be controlled to advance time progress along with the time of the local clock; correspondingly, the other 3 timelines are rollback timelines, and when one timeline is the rollback timeline, the rollback timeline does not advance with the time of the local clock. When the backspacing happens, the current time line can be switched to the backspacing time line, correspondingly, a certain backspacing time line can be switched to the current time line, and correspondingly, a plurality of time lines present the trend of alternately advancing, so that the time progress is consistent and the forward advancing is realized for any time line, and the problem of clock backspacing does not exist.
S403: upon receiving a globally unique identifier generation request for a target node, a clock state of a local clock is determined.
In this embodiment of the present specification, the target node may be any network node, and specifically, the clock state of the local clock may include clock back-off and clock normal advance. Specifically, when the clock state is clock back, it can be determined that the clock back occurs; when the clock state is that the clock is normally advancing, the time of the clock is in the normal advancing.
In the embodiment of the description, when a global unique identifier generation request of a target node is received, the clock state of a local clock is determined, a clock back-off phenomenon can be timely discovered, and the fact that the global unique identifier is directly generated during clock back-off is avoided.
S405: and when the clock state is clock back, determining the clock back-off time.
In this specification, the clock back-off time may include a time difference between a time point when the clock backs off and a time point after the clock backs off.
S407: when the clock back-off time is larger than or equal to a preset threshold value, determining a target back-off timeline based on the at least one back-off timeline.
In this embodiment of the present specification, the preset threshold may be set in combination with an actual application system, and generally, the higher the system's tolerance to clock backoff is, the larger the preset threshold may be, and the lower the system's tolerance to clock backoff is, the smaller the preset threshold may be. In a specific embodiment, the preset threshold may be set to 1 ms.
In this embodiment, when one of the at least one fallback timeline is a fallback timeline, as shown in fig. 5, the determining a target fallback timeline based on the at least one fallback timeline may include:
s4071: determining a time point corresponding to the current time progress of the rollback timeline;
s4073: and when the time point corresponding to the current time progress is not later than the time point when the clock backs, taking the rollback timeline as a target rollback timeline.
In other embodiments, when the at least one rollback timeline comprises one rollback timeline, and when a time point corresponding to the current time progress of the rollback timeline is later than a time point of the clock rollback time, the clock abnormality warning information is sent out.
In the embodiment of the present specification, the time schedules of the timelines are advanced all the time, and in order to ensure that the time schedule of the target rollback timeline matches the time of the local clock, when only one rollback timeline exists, when the time point corresponding to the current time schedule of the rollback timeline is not later than the time point of the clock rollback, the rollback timeline may be used as the target rollback timeline; on the contrary, if the time point corresponding to the current time progress of the rollback timeline is later than the time point of the clock rollback time, that is, when the proper rollback timeline cannot be found, an error can be reported so as to check whether the clock or the clock synchronization service has a problem in time.
In still other embodiments, as shown in fig. 6, when the at least one fallback timeline includes a plurality of fallback timelines, the determining a target fallback timeline based on the at least one fallback timeline may include:
s4075: determining time points corresponding to the current time schedules of the plurality of rollback timelines;
s4077: taking a backspacing time line of which the time point corresponding to the current time progress is not later than the time point when the clock backs as an initial selection time line;
s4079: and calculating the time difference between the current time progress of the initially selected time line and the current time progress of the current time line.
S40711: and taking the initially selected time line with the minimum time difference as a target rollback time line.
In practical applications, when the at least one rollback timeline includes multiple rollback timelines, the same time point may be rolled back for multiple times, but if the clock is rolled back too frequently, for example, if the number of times of returning the clock to a certain time point (the upper limit number of times of rolling back the clock to a certain time point is the number of the rollback timelines) reaches the upper limit, a clock anomaly warning message may be sent out, so as to check whether the clock or the clock synchronization service has a problem in time. Correspondingly, the method may further include:
and when the time points corresponding to the current time schedules of the plurality of rollback timelines are all later than the time point of the clock rollback time, sending out clock abnormity early warning information.
In the embodiment of the present specification, when there are multiple backoff timelines, a backoff timeline in which a time point corresponding to a current time schedule is not later than a time point when a clock backs may be selected as an initial selection timeline; then, the initially selected timeline with the smallest time difference with the current time schedule of the current timeline can be preferably selected as the target rollback timeline, namely, the timeline with the earliest time schedule in the initially selected timelines is taken as the target rollback timeline, so that the matching degree of the time schedule of the selected target rollback timeline and the time of the local clock can be improved, and the availability of the subsequent rollback timelines can be greatly improved. Accordingly, when a suitable fallback timeline cannot be found based on the above conditions, an error may be reported in order to check whether there is a problem with the clock or the clock synchronization service in time.
In some embodiments, after determining a target fallback timeline based on the at least one fallback timeline, the method may further comprise:
1) pausing the advancing of the time progress of the current time line, and switching the current time line into a backspacing time line;
2) switching the target rollback timeline into a current timeline;
3) adjusting the time progress of the switched current time line to a time point when a clock backs;
4) and controlling the current time line after switching to advance the time progress along with the time of the local clock.
In a specific embodiment, it is assumed that there are 4 timelines, as shown in fig. 7, the identification information of the timelines is 0, 1, 2, and 3, respectively, where the timeline with the identification information of 0 is the current timeline, and the timelines of the 4 timelines is as shown in fig. 7, and it is assumed that when a clock backoff occurs at a certain time, the target timeline is determined to be the backoff timeline with the identification information of 2 in fig. 7. Accordingly, as shown in fig. 8, the advancing of the time progress of the current timeline of which identification information is 0 may be suspended, the current timeline of which identification information is 0 may be switched to the fallback timeline 0, the target fallback timeline of which identification information is 2 may be switched to the current timeline 2, and the time progress of the switched current timeline 2 may be adjusted to the timepoint after the clock is backed off, and then, the time progress of the current timeline 2 may be advanced based on the time of the local clock.
S409: and determining the timestamp of the target node according to the time point after the clock retreats.
In practical applications, the globally unique identifier includes a timestamp, and accordingly, the timestamp of the target node may be determined according to the time point after the clock is backed off. Specifically, the reference time point may be subtracted from the time point after the clock is backed off to obtain the timestamp of the target node. As shown in fig. 8, assuming that the time point after the clock back corresponds to 16:25:29 at 11/8/2019, the reference time point corresponds to 16:20:29 at 11/8/2019, and the timestamp of the target node may be 5 minutes (300 seconds).
S411: and determining the identification information of the target rollback timeline, the node identification of the target node and the sequence number of the target node.
In the embodiment of the present specification, because different timelines are all provided with identification information for distinguishing from other timelines, correspondingly, identification information of a set target rollback timeline may be acquired. The target node is also provided with a node identifier for distinguishing from other nodes, and accordingly, the node identifier of the set target node can be acquired.
In this embodiment of the present specification, the sequence number of the target node may be set in combination with the number of globally unique identifier generation requests received at the current time, so as to distinguish different globally unique identifier generation requests at the current time. Specifically, the number may be incremented from zero, incremented after each globally unique identifier is generated, and the sequence number is cleared when the time stamp is incremented or the timeline is switched.
S413: generating a globally unique identifier for the target node based on the node identification of the target node, a sequence number, a timestamp, and identification information of the target fallback timeline.
In this embodiment of the present specification, bits of identification information of a node identifier, a sequence number, a timestamp, and a target backoff timeline may be set, and an order of the identification information of the node identifier, the sequence number, the timestamp, and the target backoff timeline may be arranged randomly, generally, a sign bit may also be set at a first bit, and in a specific embodiment, a schematic diagram of a configuration of a globally unique identifier including the sign bit, the node identifier, the sequence number, the timestamp, and the identification information of the target backoff timeline may be as shown in fig. 9, specifically, where it is assumed that the timelines are 4 in total, and correspondingly, a bit temporarily used by the identification information of the timeline may be 2.
In practical application, the bits temporarily used by the identification information of the timeline may be set in combination with the number of timelines, and the number of timelines may be determined according to the deployment environment of the service. Generally, clock backspacing caused by clock synchronization is usually only sporadic and mostly small-distance backspacing, and in this case, the temporary bit setting of the identification information of the timeline can be 1bit, i.e. the problem can be solved well by using a double timeline. If the environment is relatively poor, namely the situation of clock back-off is more, the bits temporarily used by the identification information of the time line can be properly increased.
As can be seen from the technical solutions provided by the embodiments of the present specification, in the embodiments of the present specification, by presetting a plurality of time lines, when a global unique identifier generation request of a target node is received, the line determines a state of a local clock, and when the clock state is a clock backoff and the clock backoff time is large, a timestamp of the target node is directly determined by a time point after the clock backoff; when the global unique identifier of the target node is generated, the problem of global unique identifier repetition caused by clock backspacing can be effectively solved by combining the identification information of the target backspacing time lines in the backspacing time lines, and the uniqueness requirement of the global unique identifier is met.
In other embodiments, as shown in fig. 10, the method further comprises:
s415: when the clock back-off time is smaller than a preset threshold value, waiting for the time of the local clock to advance to the time of clock back-off;
s417: when the time advances to the time of clock backspacing, determining the timestamp of the target node according to the time point of the clock backspacing;
s419: and determining the identification information of the current time line, the node identification of the target node and the sequence number of the target node.
S421: generating a globally unique identifier for the target node based on the node identification of the target node, the sequence number, the timestamp, and the identification information of the current timeline.
In this embodiment of the present specification, when the clock status is clock back, the method may further include:
pausing advancement of a timeline of the current timeline;
accordingly, when the time advances to the time when the clock rolls back, the method may further include:
controlling the current timeline to advance in time with time of the local clock.
In the embodiment of the description, when the clock back-off time is short, the globally unique identifier can be generated after the time of the local clock is advanced to the time of the clock back-off, and because the clock back-off time is short, even if the waiting time is generated, the timeliness for generating the globally unique identifier is not greatly influenced, meanwhile, the problem of the duplication of the globally unique identifier caused by the clock back-off can be effectively solved, and the uniqueness requirement of the globally unique identifier is met.
In other embodiments, when the clock state is a normal advance state, the method further comprises:
1) determining a timestamp of the target node according to the current time point of the local clock;
2) determining the identification information of the current time line, the node identification of the target node and the serial number of the target node;
3) generating a globally unique identifier for the target node based on the node identification of the target node, the sequence number, the timestamp, and the identification information of the current timeline.
In this embodiment of the present specification, when the clock state is the normal propulsion state, the timestamp of the target node may be directly determined at the current time point of the local clock (the generation manner of the timestamp may refer to the description of the generation manner of the timestamp, which is not described herein again), and when the globally unique identifier of the target node is generated, the unique requirement of the globally unique identifier may be met by combining the identification information of the current timeline.
An embodiment of the present application further provides a global unique identifier generating apparatus, as shown in fig. 11, the apparatus includes:
a timeline setting module 1110, which may be configured to preset a plurality of timelines, where the plurality of timelines include a current timeline and at least one fallback timeline, a timeline of which a time progress advances with a time of a local clock, and a time progress of the at least one fallback timeline is later than a time progress of the current timeline;
a clock state determination module 1120, which may be configured to determine a clock state of a local clock upon receiving a globally unique identifier generation request of a target node;
a clock back-off time determining module 1130, configured to determine a clock back-off time when the clock state is clock back-off;
a target backoff timeline determining module 1140, which may be configured to determine a target backoff timeline based on the at least one backoff timeline when the clock backoff time is greater than or equal to a preset threshold;
a first timestamp determining module 1150, configured to determine a timestamp of the target node according to a time point after clock rollback;
a first information determining module 1160, which may be configured to determine identification information of the target backoff timeline, a node identification of the target node, and a sequence number of the target node;
a first globally unique identifier generation module 1170 may be configured to generate a globally unique identifier for the target node based on the node identification of the target node, the sequence number, the timestamp, and the identification information of the target fallback timeline.
In some embodiments, the apparatus further comprises:
a first pause advancing module for pausing the advancement of the temporal progress of the current timeline after determining a target backoff timeline based on the at least one backoff timeline;
a first timeline switching module, configured to switch the current timeline into a fallback timeline;
a second timeline switching module, configured to switch the target rollback timeline to a current timeline;
and the first time progress advancing module is used for controlling the time progress of the switched current timeline along with the time of the local clock.
In some embodiments, the apparatus further comprises:
the pushing waiting module is used for waiting for the time of the local clock to be pushed to the time of clock backspacing when the clock backspacing time is smaller than a preset threshold value;
the second timestamp determining module is used for determining the timestamp of the target node according to the time point of clock backspace when the time is advanced to the time of clock backspace;
a second information determining module, configured to determine identification information of the current timeline, a node identification of the target node, and a sequence number of the target node;
a second globally unique identifier generating module, configured to generate a globally unique identifier of the target node based on the node identification of the target node, the sequence number, the timestamp, and the identification information of the current timeline.
In some embodiments, the apparatus further comprises:
a second pause advancing module, configured to pause the advancing of the time progress of the current timeline when the clock status is clock back;
correspondingly, the device further comprises:
a second time progress advancing module for controlling the current timeline to advance time progress with time of the local clock when time advances to a time when clock back-off.
In some embodiments, when the at least one fallback timeline comprises one fallback timeline, the target fallback timeline determination module comprises:
a first time point determining unit, configured to determine a time point corresponding to a current time progress of the fallback timeline;
a first target rollback timeline determining unit, configured to, when a time point corresponding to the current time schedule is not later than a time point when a clock backs, use the rollback timeline as a target rollback timeline;
when the at least one fallback timeline comprises a plurality of fallback timelines, the target fallback timeline determination module comprises:
a second time point determining unit, configured to determine time points corresponding to current time schedules of the multiple fallback timelines;
a primary selection timeline selecting unit, configured to use a rollback timeline, in which a time point corresponding to the current time schedule is not later than a time point when a clock backs, as a primary selection timeline;
the time difference calculating unit is used for calculating the time difference between the current time progress of the primary selection timeline and the current time progress of the current timeline;
and the second target rollback timeline determining unit is used for taking the initially selected timeline with the minimum time difference as the target rollback timeline.
In some embodiments, the apparatus further comprises:
the first early warning unit is used for sending out clock abnormity early warning information when the at least one rollback timeline comprises one rollback timeline and a time point corresponding to the current time progress of the rollback timeline is later than a time point of clock rollback;
and the second early warning unit is used for sending out clock abnormity early warning information when the at least one rollback timeline comprises a plurality of rollback timelines and the time points corresponding to the current time schedules of the rollback timelines are all later than the time points of the clock rollback.
In some embodiments, the apparatus further comprises:
a third timestamp determining module, configured to determine, when the clock state is a normal propulsion state, a timestamp of the target node according to a current time point of the local clock;
a third information determining module, configured to determine identification information of the current timeline, a node identification of the target node, and a sequence number of the target node;
a third globally unique identifier generating module, configured to generate a globally unique identifier of the target node based on the node identification of the target node, the sequence number, the timestamp, and the identification information of the current timeline.
The device and method embodiments in the device embodiment are based on the same application concept.
The embodiment of the present application provides a globally unique identifier generating device, which includes a processor and a memory, where the memory stores at least one instruction, at least one program, a code set, or a set of instructions, and the at least one instruction, the at least one program, the code set, or the set of instructions is loaded and executed by the processor to implement the globally unique identifier generating method provided by the above method embodiment.
The memory may be used to store software programs and modules, and the processor may execute various functional applications and data processing by operating the software programs and modules stored in the memory. The memory can mainly comprise a program storage area and a data storage area, wherein the program storage area can store an operating system, application programs needed by functions and the like; the storage data area may store data created according to use of the apparatus, and the like. Further, the memory may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid state storage device. Accordingly, the memory may also include a memory controller to provide the processor access to the memory.
The method provided by the embodiment of the application can be executed in a mobile terminal, a computer terminal, a server or a similar operation device. Taking the example of running on a server, fig. 12 is a block diagram of a hardware structure of the server of the global unique identifier generation method provided in the embodiment of the present application. As shown in fig. 12, the server 1200 may have a relatively large difference due to different configurations or performances, and may include one or more Central Processing Units (CPUs) 1210 (the processor 1210 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA), a memory 1230 for storing data, and one or more storage media 1220 (e.g., one or more mass storage devices) for storing applications 1223 or data 1222. Memory 1230 and storage media 1220, among other things, may be transient storage or persistent storage. The program stored in the storage medium 1220 may include one or more modules, and each module may include a pairA series of instructions in the server operate. Further, the central processor 1210 may be configured to communicate with the storage medium 1220, and execute a series of instruction operations in the storage medium 1220 on the server 1200. The server 1200 may also include one or more power supplies 1260, one or more wired or wireless network interfaces 1250, one or more input-output interfaces 1240, and/or one or more operating systems 1221, such as a Windows ServerTM,Mac OS XTM,UnixTM,LinuxTM,FreeBSDTMAnd so on.
The input/output interface 1240 may be used to receive or transmit data via a network. The specific example of the network described above may include a wireless network provided by a communication provider of the server 1200. In one example, the input/output Interface 1240 includes a Network Interface Controller (NIC) that may be coupled to other Network devices via a base station to communicate with the internet. In one example, the input/output interface 1240 may be a Radio Frequency (RF) module, which is used to communicate with the internet in a wireless manner.
It will be understood by those skilled in the art that the structure shown in fig. 12 is only an illustration and is not intended to limit the structure of the electronic device. For example, server 1200 may also include more or fewer components than shown in FIG. 12, or have a different configuration than shown in FIG. 12.
Embodiments of the present application further provide a storage medium that can be disposed in a device to store at least one instruction, at least one program, a code set, or a set of instructions related to implementing a globally unique identifier generating method in the method embodiments, where the at least one instruction, the at least one program, the code set, or the set of instructions are loaded and executed by the processor to implement the globally unique identifier generating method provided in the method embodiments.
Alternatively, in this embodiment, the storage medium may be located in at least one network server of a plurality of network servers of a computer network. Optionally, in this embodiment, the storage medium may include, but is not limited to: a U-disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a removable hard disk, a magnetic or optical disk, and other various media capable of storing program codes.
As can be seen from the embodiments of the global unique identifier generation method, apparatus, server, or storage medium provided in the present application, by presetting a plurality of timelines, when a global unique identifier generation request of a target node is received, a line determines a state of a local clock, and when the clock state is clock back and the clock back time is large, a timestamp of the target node is determined directly at a time point after the clock back; when the global unique identifier of the target node is generated, the problem of global unique identifier repetition caused by clock backspacing can be effectively solved by combining the identification information of the target backspacing time line in the backspacing time lines, and the uniqueness requirement of the global unique identifier is met.
It should be noted that: the sequence of the embodiments of the present application is only for description, and does not represent the advantages and disadvantages of the embodiments. And specific embodiments thereof have been described above. Other embodiments are within the scope of the following claims. In some cases, the actions or steps recited in the claims may be performed in a different order than in the embodiments and still achieve desirable results. In addition, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing may also be possible or may be advantageous.
The embodiments in the present specification are described in a progressive manner, and the same and similar parts among the embodiments are referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, as for the device and server embodiments, since they are substantially similar to the method embodiments, the description is simple, and the relevant points can be referred to the partial description of the method embodiments.
It will be understood by those skilled in the art that all or part of the steps for implementing the above embodiments may be implemented by hardware, or may be implemented by a program instructing relevant hardware to implement the above embodiments, where the program may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a magnetic disk, an optical disk, or the like.
The above description is only exemplary of the present application and should not be taken as limiting the present application, as any modification, equivalent replacement, or improvement made within the spirit and principle of the present application should be included in the protection scope of the present application.

Claims (10)

1. A globally unique identifier generation method is characterized in that a plurality of timelines are preset, wherein the timelines of the plurality of timelines comprise a current timeline and at least one rollback timeline, the timelines of the current timeline advances along with the time of a local clock, and the timelines of the at least one rollback timeline is later than that of the current timeline; upon receiving a globally unique identifier generation request of a target node, the method comprises:
determining the clock state of a local clock, and determining the clock back-off time when the clock state is clock back-off;
when the clock back-off time is greater than or equal to a preset threshold value, determining a target back-off timeline based on the at least one back-off timeline;
determining the timestamp of the target node according to the time point after the clock retreats;
determining identification information of the target rollback timeline, node identification of the target node and a sequence number of the target node;
generating a globally unique identifier for the target node based on the node identification of the target node, a sequence number, a timestamp, and identification information of the target fallback timeline.
2. The method of claim 1, wherein after determining a target fallback timeline based on the at least one fallback timeline, the method further comprises:
pausing the advancing of the time progress of the current time line, and switching the current time line into a backspacing time line;
switching the target rollback timeline into a current timeline;
adjusting the time progress of the switched current time line to a time point when a clock backs;
and controlling the current time line after switching to advance the time progress along with the time of the local clock.
3. The method of claim 1, further comprising:
when the clock back-off time is smaller than a preset threshold value, waiting for the time of the local clock to advance to the time of clock back-off;
when the time advances to the time of clock backspacing, determining the timestamp of the target node according to the time point of the clock backspacing;
determining the identification information of the current time line, the node identification of the target node and the serial number of the target node;
generating a globally unique identifier for the target node based on the node identification of the target node, the sequence number, the timestamp, and the identification information of the current timeline.
4. The method of claim 3, wherein when the clock state is clock back, the method further comprises:
pausing advancement of a timeline of the current timeline;
accordingly, when the time advances to the time when the clock rolls back, the method further comprises:
controlling the current timeline to advance in time with time of the local clock.
5. The method of claim 1, wherein when the at least one fallback timeline comprises one fallback timeline, the determining a target fallback timeline based on the at least one fallback timeline comprises:
determining a time point corresponding to the current time progress of the rollback timeline;
when the time point corresponding to the current time progress is not later than the time point when the clock backs, taking the backspacing time line as a target backspacing time line;
when the at least one fallback timeline comprises a plurality of fallback timelines, the determining a target fallback timeline based on the at least one fallback timeline comprises:
determining time points corresponding to the current time schedules of the plurality of rollback timelines;
taking a backspacing time line of which the time point corresponding to the current time progress is not later than the time point when the clock backs as an initial selection time line;
calculating the time difference between the current time progress of the primary selection timeline and the current time progress of the current timeline;
and taking the initially selected time line with the minimum time difference as a target rollback time line.
6. The method of claim 5, further comprising:
when the at least one rollback timeline comprises one rollback timeline, and when a time point corresponding to the current time progress of the rollback timeline is later than a time point of clock rollback, clock abnormity early warning information is sent out;
correspondingly, when the at least one rollback timeline comprises a plurality of rollback timelines, and the time points corresponding to the current time schedules of the rollback timelines are all later than the time points of the clock rollback, clock abnormity early warning information is sent out.
7. The method of claim 1, wherein when the clock state is a normal advance state, the method further comprises:
determining a timestamp of the target node according to the current time point of the local clock;
determining the identification information of the current time line, the node identification of the target node and the serial number of the target node;
generating a globally unique identifier for the target node based on the node identification of the target node, the sequence number, the timestamp, and the identification information of the current timeline.
8. An apparatus for generating a globally unique identifier, the apparatus comprising:
the time line setting module is used for presetting a plurality of time lines, wherein the plurality of time lines comprise a current time line and at least one backspacing time line, the time progress of the current time line advances along with the time of a local clock, and the time progress of the at least one backspacing time line is later than the time progress of the current time line;
the clock state determining module is used for determining the clock state of the local clock when receiving a global unique identifier generation request of a target node;
a clock back-off time determining module, configured to determine a clock back-off time when the clock state is a clock back-off;
a target rollback timeline determining module, configured to determine a target rollback timeline based on the at least one rollback timeline when the clock rollback time is greater than or equal to a preset threshold;
the first timestamp determining module is used for determining a timestamp of the target node according to the time point after the clock retreats;
a first information determining module, configured to determine identification information of the target rollback timeline, a node identification of the target node, and a sequence number of the target node;
a first globally unique identifier generating module, configured to generate a globally unique identifier of the target node based on the node identification of the target node, a sequence number, a timestamp, and identification information of the target fallback timeline.
9. A globally unique identifier generating device, characterized in that said device comprises a processor and a memory, said memory having stored therein at least one instruction, at least one program, set of codes or set of instructions, which is loaded and executed by said processor to implement the globally unique identifier generating method according to any one of claims 1 to 7.
10. A computer readable storage medium having stored therein at least one instruction, at least one program, a set of codes, or a set of instructions, which is loaded and executed by a processor to implement the globally unique identifier generating method according to any one of claims 1 to 7.
CN201911114276.1A 2019-11-14 2019-11-14 Global unique identifier generation method, device, equipment and storage medium Active CN110830608B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911114276.1A CN110830608B (en) 2019-11-14 2019-11-14 Global unique identifier generation method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911114276.1A CN110830608B (en) 2019-11-14 2019-11-14 Global unique identifier generation method, device, equipment and storage medium

Publications (2)

Publication Number Publication Date
CN110830608A true CN110830608A (en) 2020-02-21
CN110830608B CN110830608B (en) 2021-06-15

Family

ID=69555649

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911114276.1A Active CN110830608B (en) 2019-11-14 2019-11-14 Global unique identifier generation method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN110830608B (en)

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111694792A (en) * 2020-05-29 2020-09-22 中国建设银行股份有限公司 Identification generation method and device based on snowfly
CN111708997A (en) * 2020-06-19 2020-09-25 浙江大华技术股份有限公司 Method and device for determining target object identity identifier and storage medium
CN112182005A (en) * 2020-10-10 2021-01-05 中国银联股份有限公司 Serial number generation method and device
CN113420029A (en) * 2021-06-25 2021-09-21 陕西浪潮英信科技有限公司 Global ID generation method, device, equipment and medium for distributed system
CN113589881A (en) * 2021-08-02 2021-11-02 北京汇钧科技有限公司 Method and device for solving clock callback problem
CN117742447A (en) * 2024-02-21 2024-03-22 南京云程半导体有限公司 Clock self-adaptive adjustment method and controller
CN117742447B (en) * 2024-02-21 2024-05-10 南京云程半导体有限公司 Clock self-adaptive adjustment method and controller

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20160328437A1 (en) * 2015-05-04 2016-11-10 International Business Machines Corporation Maintaining consistency between a transactional database system and a non-transactional content repository for document objects
CN106572165A (en) * 2016-10-26 2017-04-19 宜人恒业科技发展(北京)有限公司 Distributed global unique ID application method
CN108804545A (en) * 2018-05-18 2018-11-13 深圳市彬讯科技有限公司 Distributed globally unique ID generation methods and equipment
CN108959386A (en) * 2018-05-31 2018-12-07 深圳壹账通智能科技有限公司 Distributed globally unique ID generation method, device, equipment and storage medium
CN109740120A (en) * 2018-12-14 2019-05-10 深圳壹账通智能科技有限公司 The generation method of unique identification, device, computer equipment under distributed environment
CN110147281A (en) * 2019-05-15 2019-08-20 上海淇毓信息科技有限公司 Optimize method, apparatus, the electronic equipment that snowflake algorithm is applied in financial business

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20160328437A1 (en) * 2015-05-04 2016-11-10 International Business Machines Corporation Maintaining consistency between a transactional database system and a non-transactional content repository for document objects
CN106572165A (en) * 2016-10-26 2017-04-19 宜人恒业科技发展(北京)有限公司 Distributed global unique ID application method
CN108804545A (en) * 2018-05-18 2018-11-13 深圳市彬讯科技有限公司 Distributed globally unique ID generation methods and equipment
CN108959386A (en) * 2018-05-31 2018-12-07 深圳壹账通智能科技有限公司 Distributed globally unique ID generation method, device, equipment and storage medium
CN109740120A (en) * 2018-12-14 2019-05-10 深圳壹账通智能科技有限公司 The generation method of unique identification, device, computer equipment under distributed environment
CN110147281A (en) * 2019-05-15 2019-08-20 上海淇毓信息科技有限公司 Optimize method, apparatus, the electronic equipment that snowflake algorithm is applied in financial business

Cited By (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111694792A (en) * 2020-05-29 2020-09-22 中国建设银行股份有限公司 Identification generation method and device based on snowfly
CN111708997A (en) * 2020-06-19 2020-09-25 浙江大华技术股份有限公司 Method and device for determining target object identity identifier and storage medium
CN111708997B (en) * 2020-06-19 2023-06-13 浙江大华技术股份有限公司 Method, device and storage medium for determining target object identity identifier
CN112182005A (en) * 2020-10-10 2021-01-05 中国银联股份有限公司 Serial number generation method and device
CN113420029A (en) * 2021-06-25 2021-09-21 陕西浪潮英信科技有限公司 Global ID generation method, device, equipment and medium for distributed system
CN113420029B (en) * 2021-06-25 2024-04-12 陕西浪潮英信科技有限公司 Global ID generation method, device, equipment and medium for distributed system
CN113589881A (en) * 2021-08-02 2021-11-02 北京汇钧科技有限公司 Method and device for solving clock callback problem
CN117742447A (en) * 2024-02-21 2024-03-22 南京云程半导体有限公司 Clock self-adaptive adjustment method and controller
CN117742447B (en) * 2024-02-21 2024-05-10 南京云程半导体有限公司 Clock self-adaptive adjustment method and controller

Also Published As

Publication number Publication date
CN110830608B (en) 2021-06-15

Similar Documents

Publication Publication Date Title
CN110830608B (en) Global unique identifier generation method, device, equipment and storage medium
CN111831485B (en) Data recovery method, device, electronic equipment and medium
CN110784495B (en) Block chain-based discovery and configuration information management method for big data cluster system
CN111917897B (en) Identification generation method, device, equipment and storage medium
RU2749339C1 (en) Equipment control method, cluster system, electronic device and readable data media
CN110839071B (en) Information storage method, device and storage medium based on block chain
CN112506702B (en) Disaster recovery method, device, equipment and storage medium for data center
CN107832169B (en) Memory data migration method and device, terminal equipment and storage medium
CN113064744A (en) Task processing method and device, computer readable medium and electronic equipment
CN110704185B (en) Cluster system fragmentation timing task scheduling method and cluster system
CN109614403A (en) The data consistency verification method and device of cluster service node
CN110968644A (en) Data processing method and equipment
CN111698315A (en) Data processing method and device for block and computer equipment
CN111641678A (en) Task scheduling method and device, electronic equipment and medium
CN107656796B (en) Virtual machine cold migration method, system and equipment
CN112231755A (en) Data authorization method, device and system based on block chain
CN113138882A (en) MySQL cluster-based automatic deployment method and device and related equipment
CN114554593A (en) Data processing method and device
CN111953809B (en) Method, device, equipment and system for managing resource address
CN111078463A (en) Data backup method, device and system
CN114566269B (en) Medical resource request method, device, electronic equipment and storage medium
CN113746676B (en) Network card management method, device, equipment, medium and product based on container cluster
CN105429795A (en) Alarm monitoring system and method
CN107710165B (en) Method and device for storage node synchronization service request
CN112685136A (en) Intelligent contract operation method, device, equipment and storage medium

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
REG Reference to a national code

Ref country code: HK

Ref legal event code: DE

Ref document number: 40022955

Country of ref document: HK

GR01 Patent grant
GR01 Patent grant