CN111083228B - Identification number generation method and device and electronic equipment - Google Patents
Identification number generation method and device and electronic equipment Download PDFInfo
- Publication number
- CN111083228B CN111083228B CN201911348920.1A CN201911348920A CN111083228B CN 111083228 B CN111083228 B CN 111083228B CN 201911348920 A CN201911348920 A CN 201911348920A CN 111083228 B CN111083228 B CN 111083228B
- Authority
- CN
- China
- Prior art keywords
- network node
- identification
- node
- bits
- current
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/01—Protocols
- H04L67/10—Protocols in which an application is distributed across nodes in the network
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L43/00—Arrangements for monitoring or testing data switching networks
- H04L43/10—Active monitoring, e.g. heartbeat, ping or trace-route
- H04L43/106—Active monitoring, e.g. heartbeat, ping or trace-route using time related information in packets, e.g. by adding timestamps
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/50—Network services
- H04L67/60—Scheduling or organising the servicing of application requests, e.g. requests for application data transmissions using the analysis and optimisation of the required network resources
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Health & Medical Sciences (AREA)
- Cardiology (AREA)
- General Health & Medical Sciences (AREA)
- Computer And Data Communications (AREA)
Abstract
The application relates to the technical field of computer operating systems, and discloses a method and a device for generating an identification number and electronic equipment, wherein the method for generating the identification number comprises the following steps: when a generation request of an identification number is received, acquiring a current timestamp of the generation request of the identification number; if the current time stamp is in the effective time period of the network node, determining the bit number of the serial number corresponding to the generation request based on the bit number of the node identification of the network node; the number of bits of the node identification of the one network node is determined based on the current running number of the network nodes; determining a sequence number corresponding to the generation request based on the number of bits of the sequence number; an identification number is generated based on the current timestamp, the node identification, and the serial number. In the identification number generation method provided by the application, a single network node can also quickly generate a large number of identification numbers, so that the identification number generation efficiency is improved.
Description
Technical Field
The application relates to the technical field of computer operating systems, in particular to a method and a device for generating an identification number and electronic equipment.
Background
In complex distributed systems, it is often necessary to uniquely identify large amounts of data and messages. Such as in financial, payment, dining, hotel, movie systems for some applications, where data is growing, a unique identification number (Identity document, ID) is required to identify a piece of data or message after the database is sorted, the self-increasing identification number of the database is clearly not satisfactory, and a system capable of generating a globally unique identification number is highly desirable.
In the conventional method for generating the identification number, each network node generates 409.6 ten thousand identification numbers at most in 1 second, and when a large number of identification numbers need to be generated in a single network node in a rapid batch manner, queuing is caused because of the upper limit of the number of generated identification numbers per second, so that the generation efficiency of the identification numbers is low.
Disclosure of Invention
The present application aims to solve at least one of the above technical drawbacks, and particularly proposes the following technical solutions:
in a first aspect, there is provided a method for generating an identification number, including:
for any one of the at least one network node, when a generation request of the identification number is received, acquiring a current timestamp of the generation request of the identification number;
If the current time stamp is in the effective time period of the network node, determining the bit number of the serial number corresponding to the generation request based on the bit number of the node identification of the network node; the number of bits of the node identification of the one network node is determined based on the current running number of the network nodes;
determining a sequence number corresponding to the generation request based on the number of bits of the sequence number;
an identification number is generated based on the current timestamp, the node identification, and the serial number.
In an optional embodiment of the first aspect, when the generation request of the identification number is received, before obtaining the current timestamp of the reception of the generation request of the identification number, the method further comprises:
and sending a registration request to a registration server, and receiving the effective time period and the node identification of the network node returned by the registration server.
In an alternative embodiment of the first aspect, the number of bits of the node identification of the one network node is obtained by rounding up and in the current number of network nodes running.
In an optional embodiment of the first aspect, determining the number of bits of the sequence number corresponding to the generation request based on the number of bits of the node identification of the one network node comprises:
subtracting the number of bits of the node identification of the network node from the second preset number of bits to obtain the number of bits of the serial number corresponding to the generation request.
In an alternative embodiment of the first aspect, generating the identification number based on the current timestamp, the node identification and the sequence number comprises:
and splicing the current timestamp, the node identification and the serial number to generate an identification number.
In a second aspect, there is provided a method for generating an identification number, including:
receiving a registration request of at least one network node to be registered, and determining the running number of the current network node based on the registration request;
determining, for any one of the at least one network node to be registered, a node identification of the one network node based on a current number of network node operations;
transmitting the node identification to the one network node to enable the one network node to generate an identification number;
wherein the identification number is derived based on the current timestamp, node identification and sequence number of the one network node receiving the generation request for the identification number; the number of bits of the sequence number is determined based on the number of bits of the node identification.
In an optional embodiment of the second aspect, the method for generating the identification number further comprises:
if the operation capacity of the registration server is smaller than the current network node operation number, expanding the operation capacity to obtain updated capacity;
if the update capacity is greater than or equal to the running number of the current network nodes, determining an effective time period of one network node based on the generation time of the update capacity aiming at any network node in at least one network node to be registered;
If the running capacity is greater than or equal to the running number of the current network nodes, determining an effective time period of the network node based on the current time stamp;
the validity period is sent to the one network node such that the one network node generates an identification number when the current timestamp is within the validity period.
In an alternative embodiment of the second aspect, the valid period of time includes a valid start time and a valid end time;
determining the effective period of the one network node based on the generation time of the update capacity comprises:
taking the generation time of the update capacity as the effective starting time;
and determining the effective termination time based on the effective start time and the preset effective duration.
In an optional embodiment of the second aspect, the method for generating the identification number further comprises:
receiving a renewing application of at least one network node to be renewed;
if the registration server starts to expand the operation capacity, determining the current network node operation quantity of the registration server when the operation capacity is expanded to obtain the update capacity;
updating the effective termination time of the network node for any one of the at least one network node to be leased, and executing the determination of the node identification of the one network node based on the current running number of the network nodes;
If the registration server does not start to expand the operation capacity, updating the effective termination time of any network node in the at least one network node to be leased.
In a third aspect, there is provided an identification number generating apparatus, including:
a first obtaining module, configured to obtain, for any network node of the at least one network node, a current timestamp of the received generation request of the identification number when the generation request of the identification number is received; the number of bits of the current timestamp is a first preset number of bits;
a first determining module, configured to determine, based on a number of bits of a node identifier of the one network node, a number of bits of a sequence number corresponding to the generation request if the current timestamp is within a valid period of the one network node; the number of bits of the node identification of the one network node is determined based on the current running number of the network nodes;
a second determining module, configured to determine a sequence number corresponding to the generation request based on a number of bits of the sequence number;
and the first generation module is used for generating an identification number based on the current timestamp, the node identification and the serial number.
In an optional embodiment of the fourth aspect, the generating means of the identification number further comprises:
And the sending module is used for sending a registration request to the registration server and receiving the effective time period and the node identification of the network node returned by the registration server.
In an alternative embodiment of the fourth aspect, the number of bits of the node identification of the one network node is obtained by rounding up and in the direction of the current number of network nodes running.
In an optional embodiment of the fourth aspect, the first determining module is specifically configured to, when determining the number of bits of the sequence number corresponding to the generation request based on the number of bits of the node identifier of the one network node:
subtracting the number of bits of the node identification of the network node from the second preset number of bits to obtain the number of bits of the serial number corresponding to the generation request.
In an alternative embodiment of the fourth aspect, the first generating module is specifically configured to, when generating the identification number based on the current timestamp, the node identification and the serial number:
and splicing the current timestamp, the node identification and the serial number to generate an identification number.
In a fourth aspect, there is provided an identification number generating apparatus, including:
a receiving module, configured to receive a registration request of at least one network node to be registered, and determine a current running number of network nodes based on the registration request;
A third determining module, configured to determine, for any network node of at least one network node to be registered, a node identifier of the one network node based on the current running number of network nodes;
a sending module, configured to send the node identifier to the one network node, so that the one network node generates an identifier number;
wherein the identification number is derived based on a current timestamp, a node identification and a sequence number of the one network node receiving a generation request for the identification number; the number of bits of the sequence number is determined based on the number of bits of the node identification.
In an optional embodiment of the fourth aspect, the generating device of the identification number further comprises an updating module, the updating module being configured to:
if the operation capacity of the registration server is smaller than the current network node operation number, expanding the operation capacity to obtain updated capacity;
if the update capacity is greater than or equal to the running number of the current network nodes, determining an effective time period of one network node based on the generation time of the update capacity aiming at any network node in at least one network node to be registered;
if the running capacity is greater than or equal to the running number of the current network nodes, determining an effective time period of the network node based on the current time stamp;
The validity period is sent to the one network node such that the one network node generates an identification number when the current timestamp is within the validity period.
In an alternative embodiment of the fourth aspect, the valid period of time comprises a valid start time and a valid end time;
the update module is specifically configured to, when determining the valid period of the one network node based on the generation time of the update capacity:
taking the generation time of the update capacity as the effective starting time;
and determining the effective termination time based on the effective start time and the preset effective duration.
In an optional embodiment of the fourth aspect, the generating device of the identification number further includes a renewing module configured to:
receiving a renewing application of at least one network node to be renewed;
if the registration server starts to expand the operation capacity, determining the current network node operation quantity of the registration server when the operation capacity is expanded to obtain the update capacity;
updating the effective termination time of the network node for any one of the at least one network node to be leased, and executing the determination of the node identification of the one network node based on the current running number of the network nodes;
if the registration server does not start to expand the operation capacity, updating the effective termination time of any network node in the at least one network node to be leased.
In a fifth aspect, there is provided an electronic device including a memory, a processor, and a computer program stored on the memory and executable on the processor, the processor implementing the method for generating an identification number as shown in any one of the first to third aspects of the present application when the program is executed by the processor.
In a sixth aspect, there is provided a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, implements the method of generating an identification number as shown in any one of the first to third aspects of the present application.
The beneficial effects that this application provided technical scheme brought are: when receiving a generation request of an identification number of an application program, acquiring a current timestamp of the received generation request of the identification number, if the current timestamp is within an effective time period of the network node, determining the number of digits of a serial number according to the number of digits of the node identification sent by a registration server so as to generate the serial number, and generating the identification number according to the current timestamp, the node identification and the serial number, wherein the number of digits of the node identification in the identification number and the number of digits of the serial number are variable, so that a single network node can also quickly generate a large number of identification numbers in batch, and the generation efficiency of the identification number is improved.
Additional aspects and advantages of the application will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of the application.
Drawings
The foregoing and/or additional aspects and advantages of the present application will become apparent and readily appreciated from the following description of the embodiments, taken in conjunction with the accompanying drawings, in which:
fig. 1 is an application environment diagram of a method for generating an identification number according to an embodiment of the present application;
FIG. 2 is a schematic diagram of a system for generating an identification number according to an example of the present application;
fig. 3 is a flow chart of a method for generating an identification number according to an embodiment of the present application;
FIG. 4 is a schematic diagram of a data structure of an identification number according to an embodiment of the present application;
FIG. 5 is a schematic diagram of a data structure of an identification number provided in the examples of the present application;
fig. 6 is a flowchart of a method for generating an identification number according to an embodiment of the present application;
FIG. 7 is a schematic diagram of an effective time determination scheme according to an embodiment of the present application;
FIG. 8 is a schematic diagram of an effective time determination scheme according to an embodiment of the present application;
fig. 9 is a flowchart of a method for generating an identification number according to an embodiment of the present application;
Fig. 10 is a schematic structural diagram of an identification number generating device according to an embodiment of the present application;
fig. 11 is a schematic structural diagram of an identification number generating device according to an embodiment of the present application;
fig. 12 is a schematic structural diagram of an identification number generating device according to an embodiment of the present application;
fig. 13 is a schematic structural diagram of an electronic device for generating an identification number according to an embodiment of the present application.
Detailed Description
Embodiments of the present application are described in detail below, examples of which are illustrated in the accompanying drawings, wherein like or similar reference numerals refer to like or similar elements or elements having like or similar functions throughout. The embodiments described below by referring to the drawings are exemplary only for the purpose of illustrating the present application and are not to be construed as limiting the present application.
As used herein, the singular forms "a", "an", "the" and "the" are intended to include the plural forms as well, unless expressly stated otherwise, as understood by those skilled in the art. It will be further understood that the terms "comprises" and/or "comprising," when used in this specification, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof. It will be understood that when an element is referred to as being "connected" or "coupled" to another element, it can be directly connected or coupled to the other element or intervening elements may also be present. Further, "connected" or "coupled" as used herein may include wirelessly connected or wirelessly coupled. The term "and/or" as used herein includes all or any element and all combination of one or more of the associated listed items.
For the purpose of making the objects, technical solutions and advantages of the present application more apparent, the embodiments of the present application will be described in further detail below with reference to the accompanying drawings.
The method, the device, the electronic equipment and the computer readable storage medium for generating the identification number aim to solve the technical problems in the prior art.
The following describes the technical solutions of the present application and how the technical solutions of the present application solve the above technical problems in detail with specific embodiments. The following embodiments may be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments. Embodiments of the present application will be described below with reference to the accompanying drawings.
The identification number generation method provided by the application can be applied to an application environment shown in fig. 1. Specifically, the identification number generation system 100 may include at least one network node 104 and a registration server 102; the registration server 102 receives a registration request of the network node 104 to be registered, and determines the current network node operation number of the network node 104 based on the registration request; registration server 102 determines a node identification for network node 104 based on the current number of network node runs; the network node 104 receives the node identification; when a generation request of an identification number is received, acquiring a current timestamp of the received generation request; the network node 104 determines the number of bits of the sequence number corresponding to the generation request based on the number of bits of the node identification, and determines the sequence number corresponding to the generation request based on the number of bits of the sequence number; the network node generates an identification number based on the current timestamp, the node identification and the serial number and sends the generated identification number to the application.
In order to further explain the method of generating the identification number in the present application, a system comprising a registration server and a network node will be further described below in connection with examples.
In one example, as shown in fig. 2, the registration service provides services for registration and deregistration of a network node (the work machine shown in the figure), the operation of registration is initiated by the network node master, and the operation of deregistration may be initiated by the network node master or forced by the registration server after expiration. Registration services register and deregister in a protocol that supports RPC and HTTP/HTTPs at the service layer, and the service layer is a cluster that can be laterally extended. The database of the registration service is mainly used for storing registration information and state of network nodes, and supports a mainstream NoSQL database, such as Redis, ETCD, mongoDB, by means of an adapter, or can support a relational database, such as MySQL, and can adopt a NoSQL solution in actual use.
The main task of the network node is to generate an identification number, which is first registered with the system to obtain its own machine identification, validation time and expiration time, i.e. the validity period. After the expiration time, the network node may not generate the identification number, so the network node needs to apply for a renewal to the system before the expiration time. Because the system may expand or contract, the machine identification, validation time, and expiration time obtained during a rental may be different from the registration or previous rental, and the time variation of a particular rental will be described in more detail below. There is no mandatory requirement for the network location of the network node, the use of registration services is recommended in the context of the intranet by the protocol of RPC, and the use of the protocol of HTTP/HTTPs is recommended in the context of the extranet (Internet). The network node can comprise an edge node, and the edge node refers to a network node which has fewer intermediate links from the final equipment access, and has better response capability and connection speed for the final access equipment.
In the embodiment of the present application, a possible implementation manner is provided, as shown in fig. 3, and a method for generating an identification number is provided, which may be applied to a network node shown in fig. 1, and may include the following steps:
step S301, for any network node of the at least one network node, when a generation request of an identification number is received, obtaining a current timestamp of the received generation request of the identification number.
Wherein the network node may be a work machine for generating an identification number, the network node may receive a generation request for an identification number originating from a local and/or application and/or server, and generate a corresponding identification number based on the generation request.
Specifically, a network node may receive multiple generation requests, and each time a generation request is received, a corresponding identification number is generated.
Step S302, if the current time stamp is in the effective time period of the network node, determining the number of bits of the serial number corresponding to the generation request based on the number of bits of the node identification of the network node; the number of bits of the node identification of the one network node is determined based on the current number of network node runs.
Any network node has an effective time period, the effective time period includes an effective start time and an effective end time, when the network node to be registered is registered through the registration server, the network node is a network node for generating an identification number, and when the network node is registered through the registration server, the registration server sends the effective time period and the node identification of the network node to the network node.
If the current time stamp is within the valid time period of the network node, the network node can generate the identification number, and if the current time stamp is not within the valid time period of the network node, the network node can not generate the identification number.
In particular, the node identification may be a number or letter comprising at least one bit, the number of bits of the node identification being determined based on the current number of network node runs.
In a specific implementation process, the current running number of the network nodes refers to that the network nodes are determined based on the number of the network nodes which are already registered and the number of the network nodes which request registration when the network nodes apply for registration.
For example, if 100 network nodes have already been registered and there are 50 new network nodes requesting registration, the number of current network nodes running is 150, and the number of node identities of the 50 network nodes requesting registration is determined according to the number of current network nodes running.
It will be appreciated that the number of node identities of the 50 network nodes requesting registration is not necessarily the same as the number of node identities of the 100 registered network nodes, and that the number of node identities of the 100 registered network nodes is determined based on the current number of network nodes running at the time of registration request for the 100 network nodes.
Step S303, a serial number corresponding to the generation request is determined based on the number of bits of the serial number.
In the implementation process, the network node may randomly generate the corresponding sequence number according to the number of bits of the sequence number, or may obtain the generated sequence number with the number of bits from the registration server or other terminals, where the specific sequence number generation mode is not limited.
Step S304, generating an identification number based on the current timestamp, the node identification and the serial number.
Specifically, the number of bits of the current timestamp may be set, the number of bits of the node identifier is determined based on the number of running nodes of the current network, and the number of bits of the sequence number is determined based on the number of bits of the node identifier, i.e. the number of bits of the node identifier and the number of bits of the sequence number may be both variable.
In the implementation process, the current time stamp, the node identifier and the serial number can be combined, spliced or operated based on a preset rule to obtain an identifier, and the identifier is sent to an application program for sending the generation request.
According to the method for generating the identification numbers, when the generation request of the identification numbers is received, the current time stamp of the generation request of the identification numbers is obtained, if the current time stamp is in the effective time period of the network node, the number of bits of the serial numbers is determined according to the number of bits of the node identifications sent by the registration server, so that the serial numbers are generated, and then the identification numbers are generated according to the current time stamp, the node identifications and the serial numbers, wherein the number of the node identifications and the number of the serial numbers in the identification numbers are variable, so that a single network node can also quickly generate a large number of identification numbers in batch, and the generation efficiency of the identification numbers is improved.
In one possible implementation manner provided in the embodiment of the present application, when the generation request of the identification number of the application is received, before obtaining the current timestamp of the generation request of the identification number, step S301 may further include:
and sending a registration request to a registration server, and receiving the effective time period and the node identification of the network node returned by the registration server.
In the specific implementation process, the network node sends a registration request to a registration server, the registration server determines the number of bits of node identifiers of the network node according to the current operation number of the network node, generates the node identifiers according to the number of bits of the node identifiers, and generates an effective time period according to the time of receiving the registration request.
The registration server takes the time of receiving the registration request as the effective starting time, and adds the effective starting time with a preset time length to obtain the effective ending time.
In the embodiment of the application, a possible implementation manner is provided, and the bit number of the node identification of the network node is obtained by opening the running number of the current network node and rounding up.
Specifically, the number of bits of the network node identifier is related to the number of registered network nodes in the system, that is, the number of registered network nodes running currently, and the calculation formula is as follows:
wherein bits represents the number of bits, num represents the running number of the current network node, and symbolsRepresenting an upward rounding.
In one possible implementation manner provided in the embodiment of the present application, determining, based on the number of bits of the node identifier of the one network node, the number of bits of the sequence number corresponding to the generation request in step S302 may include:
subtracting the number of bits of the node identification of the network node from the second preset number of bits to obtain the number of bits of the serial number corresponding to the generation request.
Specifically, the sum of the number of bits of the node identifier and the number of bits of the serial number may be set to a fixed second preset number of bits, the number of bits of the serial number is determined based on the number of bits of the node identifier, and the number of bits of the node identifier is determined based on the current number of network node operations.
For example, the second preset number of bits may be set to 32, and the number of bits that may be used by the sequence number is:
wherein bits represents the number of bits, num represents the running number of the current network node, and symbolsRepresenting an upward rounding.
In one possible implementation manner provided in the embodiment of the present application, generating the identification number based on the current timestamp, the node identifier and the serial number in step S304 may include:
And splicing the current timestamp, the node identification and the serial number to generate an identification number.
As shown in fig. 4, the data structure of the identification number of the present application includes two parts: the first part is a current timestamp, and the number of bits of the current timestamp is a first preset number of bits; the second part comprises a node identifier and a serial number, wherein the total bit number of the second part is fixed and is a second preset bit number; the respective number of bits of the node identification and sequence number may vary when in the second part.
Taking the example shown in fig. 5, the current time stamp (i.e., in fig. 5) is set to 32 bits, the total number of bits of the node identifier (the work machine identifier in fig. 5) and the serial number is set to 32 bits, the minimum timing unit of the 32-bit time stamp is 1 second, 136 years can be used, and the 32-bit work machine identifier and the serial number mean that the theoretical upper limit of the number of generated identification numbers by the whole system in one timing unit (1 second) is about 43 hundred million.
If the number of bits of the current timestamp is 32, the second preset number of bits is also 32, that is, the total number of bits of the node identifier and the serial number is set to 32 bits, the number of the maximum identifier number generated by each network node in a timing unit can be calculated according to the number of bits of the serial number, and is as follows:
wherein num is id Representing the maximum number of identification numbers generated by each network node in a timing unit.
Finally, the relation between the number of the identification numbers generated by each timing unit of the whole system and the running number of the current network node can be obtained as follows:
wherein num is work Indicating the current number of network nodes running.
This also means when the number of network nodes is num work =2 n When n is more than 0, the number of the identification numbers generated by the system in each timing unit is the largest, and the identification numbers are substituted into the formula (4) to obtain the following formula:
num id =2 32 (5)
and when the number of network nodes is num work =2 n -1 (n > 0), the system generates the least number of identification numbers per timing unit, and the number is obtained by substituting formula (4):
num id =2 32 -2 (32-n) (6)
in the above embodiment, 43 hundred million network nodes are allowed to operate simultaneously, and each network node generates an identification number every second; it also allows one network node to operate alone, but it can generate 43 hundred million identification numbers in one second, i.e. the present application can generate a large number of identification numbers when a small number of network nodes are running or when a large number of network nodes are running.
In addition, the upper limit of the number of identification numbers generated by the system of one timing unit is 2 31 To 2 32 The upper limit of the generation of the identification number per second of the whole system is between 21 hundred million and 43 hundred million, namely the generation speed of the identification number can be effectively improved whether a plurality of network nodes or a single network node operates.
According to the method for generating the identification numbers, when the generation request of the identification numbers is received, the current time stamp of the generation request of the identification numbers is obtained, if the current time stamp is in the effective time period of the network node, the number of bits of the serial numbers is determined according to the number of bits of the node identifications sent by the registration server, so that the serial numbers are generated, and then the identification numbers are generated according to the current time stamp, the node identifications and the serial numbers, wherein the number of the node identifications and the number of the serial numbers in the identification numbers are variable, so that a single network node can also quickly generate a large number of identification numbers in batch, and the generation efficiency of the identification numbers is improved.
Further, if the current timestamp is set to 32 bits, the second preset bit number is 32, 43 hundred million network nodes are allowed to operate simultaneously, and each network node generates an identification number every second; it also allows one network node to operate alone, but it can generate 43 hundred million identification numbers in one second, i.e. the present application can generate a large number of identification numbers when a small number of network nodes are running or when a large number of network nodes are running.
In addition, the upper limit of the number of identification numbers generated by the system of one timing unit is 2 31 To 2 32 The upper limit of the generation of the identification number per second of the whole system is between 21 hundred million and 43 hundred million, namely the generation speed of the identification number can be effectively improved whether a plurality of network nodes or a single network node operates.
In an embodiment of the present application, as shown in fig. 6, a method for generating an identification number is provided, which may be applied to the registration server shown in fig. 1, and may include:
step S601, receiving a registration request of at least one network node to be registered, and determining the current running number of the network nodes based on the registration request.
Specifically, the current running number of network nodes refers to that the network nodes are determined based on the number of network nodes already registered and the number of network nodes requesting registration when the network nodes apply for registration.
Step S602, for any network node of the at least one network node to be registered, determining a node identification of the one network node based on the current running number of network nodes.
Specifically, the running number of the current network node can be divided and rounded up to obtain the node identification of the network node.
For example, if 100 network nodes have registered and there are new 50 network nodes requesting registration, then the current network node running number is 150, then 150 is opened and the number of bits of node identification of these 50 network nodes is obtained by upward evidence.
It will be appreciated that the number of node identities of the 50 network nodes requesting registration is not necessarily the same as the number of node identities of the 100 registered network nodes, and that the number of node identities of the 100 registered network nodes is determined based on the current number of network nodes running at the time of registration request for the 100 network nodes.
Step S603, the node identification is sent to the network node so that the network node generates an identification number;
wherein the identification number is derived based on the current timestamp, node identification and sequence number of the one network node receiving the generation request for the identification number; the number of bits of the sequence number is determined based on the number of bits of the node identification.
Specifically, the current timestamp, the node identifier, and the serial number may be concatenated to generate an identification number.
The specific manner of generating the identification number is described in detail in the method of generating the identification number applied to the network node, and will not be described herein.
In the above embodiment, the registration server receives a registration request of at least one network node to be registered, determines the current operation number of the network nodes based on the registration request, determines, for any one of the at least one network node to be registered, a node identifier of the one network node based on the current operation number of the network node, and sends the node identifier to the one network node, so that the one network node generates the identifier number; the identification number is obtained based on the current timestamp, the node identification and the serial number of the generation request of the identification number received by the network node; the number of bits of the sequence number is determined based on the number of bits of the node identification. The number of the node identification digits and the number of the serial numbers in the identification numbers are variable, so that a single network node can also quickly generate a large number of identification numbers in batches, and the generation efficiency of the identification numbers is improved.
The embodiment of the application provides a possible implementation manner, and the method for generating the identification number further comprises the following steps:
(1) If the operation capacity of the registration server is smaller than the current network node operation number, expanding the operation capacity to obtain updated capacity;
(2) If the update capacity is greater than or equal to the running number of the current network nodes, determining an effective time period of one network node based on the generation time of the update capacity aiming at any network node in at least one network node to be registered;
(3) If the running capacity is greater than or equal to the running number of the current network nodes, determining an effective time period of the network node based on the current time stamp;
(4) The validity period is sent to the one network node such that the one network node generates an identification number when the current timestamp is within the validity period.
Specifically, the running capacity refers to the number of running possible for the network node in the entire system in which the registration server and the network node are set.
In the specific implementation process, the registration server can start to expand and contract the operation capacity of the system; the operating capacity is a dynamic value and the system will dynamically adjust to the number of operating network nodes with a theoretical value between 1 and 43 billion (4294967296). However, this value is doubled each time according to the number of current network nodes, and the following table describes in detail such a procedure:
It is apparent from the above table that the upper limit of the operating capacity for a network node is a power of 2 (2, 4,8, 16, 32, 64, …), i.e. one time expansion, multiplied by 2 on the basis of the current operating capacity.
It should be specifically noted that, in the present application, the operation capacity of the system for the network node may be set in a fixed and non-adjustable form, that is, a certain operation capacity is set fixedly; it may also be provided in an adjustable form, i.e. dynamic expansion or contraction of the operating capacity, in which case a minimum and maximum operating capacity, for example a minimum of 2 and a maximum of 4290772992, may be provided.
The embodiment of the application provides a possible implementation manner, and the effective time period comprises an effective starting time and an effective ending time; the determining the valid period of the one network node based on the generation time of the update capacity of step S602 may include:
(1) Taking the generation time of the update capacity as the effective starting time;
(2) And determining the effective termination time based on the effective start time and the preset effective duration.
In the specific implementation process, the effective starting time is added with the preset effective duration to obtain the effective ending time.
The determination of the effective start time in the case where the system starts up or does not expand upon registration will be described in detail below with reference to the embodiments and drawings.
As shown in fig. 7, when a network node (i.e. a working machine in the figure) sends a registration request to a registration server (i.e. a registration server in the figure), the registration server returns registration information to the network node, wherein the registration information includes an effective time period and a node identifier, and if the registration server does not start capacity expansion, the effective start time (i.e. the effective time shown in the figure) in the effective time period is the time when the registration server receives the registration request; if the registration server starts capacity expansion, the effective starting time in the effective time period is the time after capacity expansion, namely the generation time of the updated capacity.
Specifically, if the current timestamp is within the valid period of the network node, the network node may generate the identification number, and if the current timestamp is not within the valid period of the network node, the network node cannot generate the identification number, and before expiration, the network node needs to apply for a lease to the system. The system may expand or contract, so the node identifier, the valid start time and the valid end time acquired during the time of renewing lease may be different from those of the node at the time of registration or last time of renewing lease.
In one possible implementation manner provided in the embodiments of the present application, the method for generating the identification number may further include:
(1) And receiving a renewing application of at least one network node to be renewed.
Specifically, if the time difference between the current time and the effective termination time of the network node is smaller than a preset threshold, the network node may send a lease renewal application to the registration server to delay the effective termination time.
(2) If the registration server has started to expand the operation capacity, determining the current network node operation number of the registration server when the operation capacity is expanded to obtain the update capacity.
Specifically, the operation capacity expansion started may be that after the registration server detects that the operation capacity is smaller than or equal to the current operation number of the network nodes, the registration server prepares to start to expand the operation capacity, or the registration server is already expanding the operation capacity.
(3) Updating the effective termination time of the network node for any one of the at least one network node to be leased, and performing a determination of the node identity of the one network node based on the current number of network nodes running.
Specifically, after the registration server expands the operation capacity to obtain the update capacity, the node identifier of the network node applying for renewing lease is updated based on the current operation capacity of the network node, so as to update the identifier number of the network node.
(4) If the registration server does not start to expand the operation capacity, updating the effective termination time of any network node in the at least one network node to be leased.
As shown in fig. 8, when the network node (i.e. the working machine shown in the figure) applies for renewing lease to the registration server (i.e. the registration server shown in the figure), if the registration server does not start capacity expansion, renewing lease is performed to the network node, i.e. the effective termination time of the network node is delayed, and information that renewing lease is successful is returned to the network node; if the registration server starts the capacity expansion of the system, the number of bits of the node identification needs to be recalculated for the network node applying for renewing lease, that is, a new generation rule is shown in the figure, and the effective starting time of the network node becomes the time after the capacity expansion, that is, the generation time of the updated capacity.
In the specific implementation process, the registration server detects the number of network nodes in the system, expands or contracts according to the change of the number of the network nodes, does not need user intervention, but can also be forced by a user in a mode of modifying configuration and control commands, and the failure time stamp (namely effective termination time) obtained during registration and continuous lease of the network nodes is unified in the whole system, namely is failed simultaneously; if the system is in a static capacity mode, the dead time (i.e., the active period) can be set to be long, for example, 30 days; if the number of network nodes of the system changes rapidly and frequent capacity expansion and contraction operations are needed, the failure time can be shortened; if the system failure time (namely the effective time period) exceeds 20 minutes and the next failure time exceeds 10 minutes when the capacity expansion and the capacity contraction are prepared, the registration server can send out a failure-advanced message to the network node through two mechanisms of message push and heartbeat, and the failure time is set to be 5 minutes later; if all running network nodes return to receive the message, the failure time is formally reset to 5 minutes later. The failure time will not change as long as there is one network node that is running that is not receiving back.
In the above method for generating an identification number, the registration server receives a registration request of at least one network node to be registered, determines the running number of the current network node based on the registration request, determines, for any one of the at least one network node to be registered, a node identification of the one network node based on the running number of the current network node, and sends the node identification to the one network node so that the one network node generates the identification number; the identification number is obtained based on the current timestamp, the node identification and the serial number of the generation request of the identification number received by the network node; the number of bits of the sequence number is determined based on the number of bits of the node identification. The number of the node identification digits and the number of the serial numbers in the identification numbers are variable, so that a single network node can also quickly generate a large number of identification numbers in batches, and the generation efficiency of the identification numbers is improved.
Further, the registration server can expand the operation capacity based on the current operation number and the operation capacity of the network nodes, and can automatically adapt to the scenario of a large number of network nodes or a large number of identification numbers of a single node, so to speak, the upper limit of the generation speeds of the network nodes and the single network node is not fixed, so that the number of the identification numbers generated by the whole system per second is more, and the theoretical upper limit of the system is more approximate to 43 hundred million per second.
In an embodiment of the present application, a possible implementation manner is provided, as shown in fig. 9, and a method for generating an identification number is provided, which may be applied to the system shown in fig. 1, and may include:
in step S901, the registration server receives a registration request of at least one network node to be registered, and determines the running number of the current network node based on the registration request.
Specifically, the current running number of network nodes refers to that when the network nodes apply for registration, the registration server determines based on the number of network nodes that have already been registered and the number of network nodes that request registration.
Step S902, for any network node in the at least one network node to be registered, the registration server determines a node identification of the network node based on the current running number of network nodes.
Specifically, the running number of the current network node can be divided and rounded up to obtain the node identification of the network node.
For example, if 100 network nodes have registered and there are new 50 network nodes requesting registration, then the current network node running number is 150, then 150 is opened and the number of bits of node identification of these 50 network nodes is obtained by upward evidence.
It will be appreciated that the number of node identities of the 50 network nodes requesting registration is not necessarily the same as the number of node identities of the 100 registered network nodes, and that the number of node identities of the 100 registered network nodes is determined based on the current number of network nodes running at the time of registration request for the 100 network nodes.
Step S903, the network node receives the node identification; when a generation request of an identification number is received, a current timestamp of the receipt of the generation request is acquired.
Wherein the network node may be a work machine for generating an identification number, the network node may receive a generation request for an identification number originating from a local and/or application and/or server, and generate a corresponding identification number based on the generation request.
Specifically, a network node may receive multiple generation requests, and each time a generation request is received, a corresponding identification number is generated.
In step S904, the network node determines the number of bits of the sequence number corresponding to the generation request based on the number of bits of the node identification, and determines the sequence number corresponding to the generation request based on the number of bits of the sequence number.
In the implementation process, the network node may randomly generate the corresponding sequence number according to the number of bits of the sequence number, or may obtain the generated sequence number with the number of bits from the registration server or other terminals, where the specific sequence number generation mode is not limited.
In step S905, the network node generates an identification number based on the current timestamp, the node identification and the serial number.
Specifically, the number of bits of the current timestamp may be set, the number of bits of the node identifier is determined based on the number of running nodes of the current network, and the number of bits of the sequence number is determined based on the number of bits of the node identifier, i.e. the number of bits of the node identifier and the number of bits of the sequence number may be both variable.
In the implementation process, the current time stamp, the node identifier and the serial number can be combined, spliced or operated based on a preset rule to obtain an identifier, and the identifier is sent to an application program for sending the generation request.
In the above method for generating an identification number, the registration server receives a registration request of at least one network node to be registered, determines the running number of the current network node based on the registration request, determines, for any one of the at least one network node to be registered, a node identification of the one network node based on the running number of the current network node, and sends the node identification to the one network node so that the one network node generates the identification number; the identification number is obtained based on the current timestamp, the node identification and the serial number of the generation request of the identification number received by the network node; the number of bits of the sequence number is determined based on the number of bits of the node identification. The number of the node identification digits and the number of the serial numbers in the identification numbers are variable, so that a single network node can also quickly generate a large number of identification numbers in batches, and the generation efficiency of the identification numbers is improved.
In an embodiment of the present application, as shown in fig. 10, a generating device 100 for an identification number is provided, which includes a first obtaining module 1001, a first determining module 1002, a second determining module 1003, and a first generating module 1004, where,
A first obtaining module 1001, configured to obtain, for any network node of at least one network node, when a generation request of an identification number is received, a current timestamp of the generation request of the identification number is received; the number of bits of the current timestamp is a first preset number of bits;
a first determining module 1002, configured to determine, based on the number of bits of the node identifier of the one network node, the number of bits of the sequence number corresponding to the generation request if the current timestamp is within the valid period of the one network node; the number of bits of the node identification of the one network node is determined based on the current running number of the network nodes;
a second determining module 1003, configured to determine a sequence number corresponding to the generation request based on the number of bits of the sequence number;
a first generation module 1004 is configured to generate an identification number based on a current timestamp, a node identification, and a serial number.
In one possible implementation manner provided in the embodiment of the present application, the generating device 100 of the identification number further includes:
and the sending module is used for sending a registration request to the registration server and receiving the effective time period and the node identification of the network node returned by the registration server.
In the embodiment of the application, a possible implementation manner is provided, and the bit number of the node identification of the network node is obtained by opening the running number of the current network node and rounding up.
In this embodiment of the present application, a possible implementation manner is provided, where the first determining module 1002 is specifically configured to, when determining, based on the number of bits of the node identifier of the one network node, the number of bits of the sequence number corresponding to the generation request:
subtracting the number of bits of the node identification of the network node from the second preset number of bits to obtain the number of bits of the serial number corresponding to the generation request.
In this embodiment, a possible implementation manner is provided, where the first generating module 1004 is specifically configured to, when generating the identification number based on the current timestamp, the node identifier, and the serial number:
and splicing the current timestamp, the node identification and the serial number to generate an identification number.
According to the identification number generating device, when the generation request of the identification number of the application program is received, the current timestamp of the generation request of the identification number is obtained, if the current timestamp is in the effective time period of the network node, the number of bits of the serial number is determined according to the number of bits of the node identification sent by the registration server, so that the serial number is generated, and then the identification number is generated according to the current timestamp, the node identification and the serial number, wherein the number of bits of the node identification in the identification number and the number of bits of the serial number are variable, so that a single network node can also quickly generate a large number of identification numbers in batch, and the generation efficiency of the identification number is improved.
Further, if the current timestamp is set to 32 bits, the second preset bit number is 32, 43 hundred million network nodes are allowed to operate simultaneously, and each network node generates an identification number every second; it also allows one network node to operate alone, but it can generate 43 hundred million identification numbers in one second, i.e. the present application can generate a large number of identification numbers when a small number of network nodes are running or when a large number of network nodes are running.
In addition, the upper limit of the number of identification numbers generated by the system of one timing unit is 2 31 To 2 32 The upper limit of the generation of the identification number per second of the whole system is between 21 hundred million and 43 hundred million, namely the generation speed of the identification number can be effectively improved whether a plurality of network nodes or a single network node operates.
In the embodiment of the present application, as shown in fig. 11, a possible implementation manner is provided, and an identifier generating device 110 is provided and applied to a registration server, where the generating device includes a receiving module 1101, a third determining module 1102, and a sending module 1103, where:
a receiving module 1101, configured to receive a registration request of at least one network node to be registered, and determine a current running number of network nodes based on the registration request;
a third determining module 1102, configured to determine, for any network node of the at least one network node to be registered, a node identifier of the one network node based on the current running number of network nodes;
A sending module 1103, configured to send the node identifier to the one network node, so that the one network node generates an identifier number;
wherein the identification number is derived based on the current timestamp, node identification and sequence number of the one network node receiving the generation request for the identification number; the number of bits of the sequence number is determined based on the number of bits of the node identification.
In one possible implementation manner provided in the embodiment of the present application, the generating device 110 of the identification number further includes an updating module, where the updating module is configured to:
if the operation capacity of the registration server is smaller than the current network node operation number, expanding the operation capacity to obtain updated capacity;
if the update capacity is greater than or equal to the running number of the current network nodes, determining an effective time period of one network node based on the generation time of the update capacity aiming at any network node in at least one network node to be registered;
if the running capacity is greater than or equal to the running number of the current network nodes, determining an effective time period of the network node based on the current time stamp;
the validity period is sent to the one network node such that the one network node generates an identification number when the current timestamp is within the validity period.
The embodiment of the application provides a possible implementation manner, and the effective time period comprises an effective starting time and an effective ending time;
the update module is specifically configured to, when determining the valid period of the one network node based on the generation time of the update capacity:
taking the generation time of the update capacity as the effective starting time;
and determining the effective termination time based on the effective start time and the preset effective duration.
In one possible implementation manner provided in the embodiment of the present application, the generating device 110 of the identification number further includes a rental module, configured to:
receiving a renewing application of at least one network node to be renewed;
if the registration server starts to expand the operation capacity, determining the current network node operation quantity of the registration server when the operation capacity is expanded to obtain the update capacity;
updating the effective termination time of the network node for any one of the at least one network node to be leased, and executing the determination of the node identification of the one network node based on the current running number of the network nodes;
if the registration server does not start to expand the operation capacity, updating the effective termination time of any network node in the at least one network node to be leased.
The above-mentioned generating device of the identification number, the registration server receives the registration request of at least one network node to be registered, determines the running number of the current network node based on the registration request, determines the node identification of the one network node based on the running number of the current network node for any network node in the at least one network node to be registered, and sends the node identification to the one network node so as to enable the one network node to generate the identification number; the identification number is obtained based on the current timestamp, the node identification and the serial number of the generation request of the identification number received by the network node; the number of bits of the sequence number is determined based on the number of bits of the node identification. The number of the node identification digits and the number of the serial numbers in the identification numbers are variable, so that a single network node can also quickly generate a large number of identification numbers in batches, and the generation efficiency of the identification numbers is improved.
Further, the registration server can expand the operation capacity based on the current operation number and the operation capacity of the network nodes, and can automatically adapt to the scenario of a large number of network nodes or a large number of identification numbers of a single node, so to speak, the upper limit of the generation speeds of the network nodes and the single network node is not fixed, so that the number of the identification numbers generated by the whole system per second is more, and the theoretical upper limit of the system is more approximate to 43 hundred million per second.
In the embodiment of the present application, as shown in fig. 12, a possible implementation manner is provided, and an identifier generating device 120 is provided, which is applied to a system including a registration server and a network node, and includes a fourth determining module 1201, a fifth determining module 1202, a second obtaining module 1203, a sixth determining module 1204, and a second generating module 1205, where:
a fourth determining module 1201, configured to receive, by the registration server, a registration request of at least one network node to be registered, and determine, based on the registration request, a current running number of network nodes;
a fifth determining module 1202, configured to determine, by the registration server, for any one of the at least one network node to be registered, a node identifier of the network node based on the current running number of network nodes;
a second obtaining module 1203, configured to receive, through a network node, a node identifier; when a generation request of an identification number of an application program is received, acquiring a current timestamp of the received generation request;
a sixth determining module 1204, configured to determine, by the network node, a number of bits of the sequence number corresponding to the generation request based on the number of bits of the node identifier, and determine, based on the number of bits of the sequence number, the sequence number corresponding to the generation request;
A second generating module 1205 is configured to generate, by the network node, an identification number based on the current timestamp, the node identification, and the serial number, and send the generated identification number to the application.
The above-mentioned generating device of the identification number, the registration server receives the registration request of at least one network node to be registered, determines the running number of the current network node based on the registration request, determines the node identification of the one network node based on the running number of the current network node for any network node in the at least one network node to be registered, and sends the node identification to the one network node so as to enable the one network node to generate the identification number; the identification number is obtained based on the current timestamp, the node identification and the serial number of the generation request of the identification number received by the network node; the number of bits of the sequence number is determined based on the number of bits of the node identification. The number of the node identification digits and the number of the serial numbers in the identification numbers are variable, so that a single network node can also quickly generate a large number of identification numbers in batches, and the generation efficiency of the identification numbers is improved.
The generation device of the identification number of the picture in the embodiment of the present disclosure may perform a method for generating the identification number of the picture provided by the embodiment of the present disclosure, and its implementation principle is similar, and actions performed by each module in the generation device of the identification number of the picture in each embodiment of the present disclosure correspond to steps in the generation method of the identification number of the picture in each embodiment of the present disclosure, and detailed functional descriptions of each module in the generation device of the identification number of the picture may be specifically referred to descriptions in the generation method of the identification number of the corresponding picture shown in the foregoing, which are not repeated herein.
Based on the same principles as the methods shown in the embodiments of the present disclosure, there is also provided in the embodiments of the present disclosure an electronic device that may include, but is not limited to: a processor and a memory; a memory for storing computer operating instructions; and the processor is used for executing the method for generating the identification number shown in the embodiment by calling the computer operation instruction. Compared with the prior art, in the identification number generation method, a single network node can also quickly generate a large number of identification numbers in batches, so that the identification number generation efficiency is improved.
In an alternative embodiment, there is provided an electronic device, as shown in fig. 13, the electronic device 4000 shown in fig. 13 includes: a processor 4001 and a memory 4003. Wherein the processor 4001 is coupled to the memory 4003, such as via a bus 4002. Optionally, the electronic device 4000 may also include a transceiver 4004. It should be noted that, in practical applications, the transceiver 4004 is not limited to one, and the structure of the electronic device 4000 is not limited to the embodiment of the present application.
The processor 4001 may be a CPU (Central Processing Unit ), general purpose processor, DSP (Digital Signal Processor, data signal processor), ASIC (Application Specific Integrated Circuit ), FPGA (Field Programmable Gate Array, field programmable gate array) or other programmable logic device, transistor logic device, hardware components, or any combination thereof. Which may implement or perform the various exemplary logic blocks, modules, and circuits described in connection with this disclosure. The processor 4001 may also be a combination that implements computing functionality, e.g., comprising one or more microprocessor combinations, a combination of a DSP and a microprocessor, etc.
The memory 4003 is used for storing application program codes for executing the present application, and execution is controlled by the processor 4001. The processor 4001 is configured to execute application program codes stored in the memory 4003 to realize what is shown in the foregoing method embodiment.
Among them, electronic devices include, but are not limited to: mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and the like, and stationary terminals such as digital TVs, desktop computers, and the like. The electronic device shown in fig. 13 is merely an example and should not impose any limitations on the functionality and scope of use of embodiments of the present disclosure.
The present application provides a computer readable storage medium having a computer program stored thereon, which when run on a computer, causes the computer to perform the corresponding method embodiments described above. Compared with the prior art, the method for generating the identification numbers can generate a large number of identification numbers in batches by a single network node, so that the generation efficiency of the identification numbers is improved.
It should be understood that, although the steps in the flowcharts of the figures are shown in order as indicated by the arrows, these steps are not necessarily performed in order as indicated by the arrows. The steps are not strictly limited in order and may be performed in other orders, unless explicitly stated herein. Moreover, at least some of the steps in the flowcharts of the figures may include a plurality of sub-steps or stages that are not necessarily performed at the same time, but may be performed at different times, the order of their execution not necessarily being sequential, but may be performed in turn or alternately with other steps or at least a portion of the other steps or stages.
It should be noted that the computer readable medium described in the present disclosure may be a computer readable signal medium or a computer readable storage medium, or any combination of the two. The computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples of the computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this disclosure, a computer-readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present disclosure, however, the computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, with the computer-readable program code embodied therein. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, fiber optic cables, RF (radio frequency), and the like, or any suitable combination of the foregoing.
The computer readable medium may be contained in the electronic device; or may exist alone without being incorporated into the electronic device.
The computer-readable medium carries one or more programs which, when executed by the electronic device, cause the electronic device to perform the methods shown in the above-described embodiments.
Computer program code for carrying out operations of the present disclosure may be written in one or more programming languages, including an object oriented programming language such as Java, smalltalk, C ++ and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computer (for example, through the Internet using an Internet service provider).
The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules described in the embodiments of the present disclosure may be implemented in software or hardware. The name of the module is not limited to the module itself in some cases, and for example, the first acquisition module may also be described as "a module for acquiring a current timestamp".
The foregoing description is only of the preferred embodiments of the present disclosure and description of the principles of the technology being employed. It will be appreciated by persons skilled in the art that the scope of the disclosure referred to in this disclosure is not limited to the specific combinations of features described above, but also covers other embodiments which may be formed by any combination of features described above or equivalents thereof without departing from the spirit of the disclosure. Such as those described above, are mutually substituted with the technical features having similar functions disclosed in the present disclosure (but not limited thereto).
Claims (12)
1. A method of generating an identification number, comprising:
for any one of the at least one network node, when a generation request of the identification number is received, acquiring a current timestamp of the generation request of the identification number; the number of bits of the current timestamp is a first preset number of bits;
if the current timestamp is in the valid time period of the network node, determining the number of bits of the serial number corresponding to the generation request based on the number of bits of the node identification of the network node, including: subtracting the bit number of the node identifier from the fixed second preset bit number to obtain the bit number of the serial number corresponding to the generation request; the number of bits of the node identification of the one network node is determined based on the current running number of the network nodes;
Determining a sequence number corresponding to the generation request based on the number of bits of the sequence number;
an identification number is generated based on the current timestamp, the node identification, and the serial number.
2. The method for generating an identification number according to claim 1, wherein before acquiring the current timestamp of the received request for generating an identification number when the request for generating an identification number is received, further comprising:
and sending a registration request to a registration server, and receiving the effective time period and the node identification of the network node returned by the registration server.
3. The method according to claim 2, wherein the number of bits of the node identification of the one network node is obtained by dividing the number of operations of the current network node and rounding up.
4. The method of generating an identification number according to claim 1, wherein the generating an identification number based on the current timestamp, the node identification, and the serial number comprises:
and splicing the current timestamp, the node identification and the serial number to generate the identification number.
5. A method of generating an identification number, comprising:
receiving a registration request of at least one network node to be registered, and determining the running number and the effective time period of the current network node based on the registration request;
Determining, for any one of at least one network node to be registered, a node identification of the one network node based on the current number of network nodes running;
transmitting the node identification and the valid period to the one network node to enable the one network node to generate an identification number;
the method comprises the steps that when a current timestamp of a generation request of which the identification number is the identification number received by one network node is in the effective time period, the identification number is obtained based on the current timestamp, a node identification and a serial number; the number of bits of the serial number is obtained by subtracting the number of bits of the node identification from a fixed second preset number of bits; the number of bits of the current timestamp is a first preset number of bits.
6. The method of generating an identification number according to claim 5, further comprising:
if the operation capacity of the registration server is smaller than the current network node operation quantity, expanding the operation capacity to obtain updated capacity;
if the update capacity is greater than or equal to the running number of the current network nodes, determining an effective time period of one network node based on the generation time of the update capacity aiming at any network node in at least one network node to be registered;
If the running capacity is greater than or equal to the running number of the current network nodes, determining an effective time period of the network node based on the current time stamp;
and transmitting the valid time period to the one network node so that the one network node generates the identification number when the current time stamp is within the valid time period.
7. The method of generating an identification number according to claim 6, wherein the valid period of time includes a valid start time and a valid end time;
the determining the effective time period of the one network node based on the generation time of the update capacity includes:
taking the generation time of the update capacity as the effective starting time;
and determining the effective termination time based on the effective start time and a preset effective duration.
8. The method of generating an identification number of claim 7, further comprising:
receiving a renewing application of at least one network node to be renewed;
if the registration server starts to expand the operation capacity, determining the current network node operation number of the registration server when the operation capacity is expanded to obtain the update capacity;
Updating the effective termination time of the network node for any network node in at least one network node to be leased, and executing the node identification of the network node determined based on the current network node running number;
if the registration server does not start to expand the operation capacity, updating the effective termination time of any network node in at least one network node to be leased.
9. An identification number generation device, comprising:
a first obtaining module, configured to obtain, for any network node of the at least one network node, a current timestamp of the received generation request of the identification number when the generation request of the identification number is received; the number of bits of the current timestamp is a first preset number of bits;
a first determining module, configured to determine, based on a number of bits of a node identifier of the one network node, a number of bits of a sequence number corresponding to the generation request if the current timestamp is within a valid period of the one network node, where the first determining module includes: subtracting the bit number of the node identifier from the fixed second preset bit number to obtain the bit number of the serial number corresponding to the generation request; the number of bits of the node identification of the one network node is determined based on the current running number of the network nodes;
A second determining module, configured to determine a sequence number corresponding to the generation request based on a number of bits of the sequence number;
and the first generation module is used for generating an identification number based on the current timestamp, the node identification and the serial number.
10. An identification number generation device, comprising:
the receiving module is used for receiving a registration request of at least one network node to be registered, and determining the running number and the effective time period of the current network node based on the registration request;
a third determining module, configured to determine, for any network node of at least one network node to be registered, a node identifier of the one network node based on the current running number of network nodes;
a sending module, configured to send the node identifier and the valid period to the one network node, so that the one network node generates an identifier number;
the method comprises the steps that when a current timestamp of a generation request of which the identification number is the identification number received by one network node is in the effective time period, the identification number is obtained based on the current timestamp, a node identification and a serial number; the number of bits of the serial number is obtained by subtracting the number of bits of the node identification from a fixed second preset number of bits; the number of bits of the current timestamp is a first preset number of bits.
11. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the processor implements the method of generating an identification number according to any one of claims 1-8 when executing the program.
12. A computer-readable storage medium, characterized in that the computer-readable storage medium has stored thereon a computer program which, when executed by a processor, implements the method of generating an identification number according to any of claims 1-8.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201911348920.1A CN111083228B (en) | 2019-12-24 | 2019-12-24 | Identification number generation method and device and electronic equipment |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201911348920.1A CN111083228B (en) | 2019-12-24 | 2019-12-24 | Identification number generation method and device and electronic equipment |
Publications (2)
Publication Number | Publication Date |
---|---|
CN111083228A CN111083228A (en) | 2020-04-28 |
CN111083228B true CN111083228B (en) | 2023-06-30 |
Family
ID=70317270
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201911348920.1A Active CN111083228B (en) | 2019-12-24 | 2019-12-24 | Identification number generation method and device and electronic equipment |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN111083228B (en) |
Families Citing this family (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113822015A (en) * | 2020-06-16 | 2021-12-21 | 北京沃东天骏信息技术有限公司 | Serial number generation method and device, electronic equipment and computer readable medium |
CN111949666B (en) * | 2020-08-31 | 2023-12-05 | 深圳赛安特技术服务有限公司 | Identification generation method and device, electronic equipment and storage medium |
CN112202938A (en) * | 2020-10-12 | 2021-01-08 | 广州品唯软件有限公司 | ID generation method, device and system |
CN112559558B (en) * | 2020-12-07 | 2024-04-09 | 北京理房通支付科技有限公司 | Method and device for generating serial numbers, computing equipment and storage medium |
CN113708983B (en) * | 2021-11-01 | 2022-02-11 | 湖南新云网科技有限公司 | Distributed node ID generation method, device, equipment and storage medium |
CN114282968A (en) * | 2021-12-22 | 2022-04-05 | 中国农业银行股份有限公司 | Serial number acquisition method, device, server and storage medium |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
KR100746471B1 (en) * | 2006-10-26 | 2007-08-06 | 주식회사 케이티 | Sensor node id assignment method and method for hierarchical configuration of wireless sensor networks using it |
US7853703B1 (en) * | 2005-03-24 | 2010-12-14 | Google, Inc. | Methods and apparatuses for identification of device presence |
CN107229555A (en) * | 2017-05-04 | 2017-10-03 | 北京小度信息科技有限公司 | Mark generating method and device |
CN109240848A (en) * | 2018-07-27 | 2019-01-18 | 阿里巴巴集团控股有限公司 | A kind of data object tag generation method and device |
CN110554732A (en) * | 2019-08-22 | 2019-12-10 | 北京奇艺世纪科技有限公司 | identification number generation method and device, electronic equipment and storage medium |
Family Cites Families (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US7844244B2 (en) * | 2007-02-23 | 2010-11-30 | Cellco Partnership | Methods, apparatuses, and computer program products for providing dynamic assignment of slot cycle index for network nodes |
US9596237B2 (en) * | 2010-12-14 | 2017-03-14 | Salt Technology, Inc. | System and method for initiating transactions on a mobile device |
CN109740120A (en) * | 2018-12-14 | 2019-05-10 | 深圳壹账通智能科技有限公司 | The generation method of unique identification, device, computer equipment under distributed environment |
CN110096528A (en) * | 2019-04-12 | 2019-08-06 | 中国银行股份有限公司 | The method, apparatus and system of formation sequence in a kind of distributed system |
CN110543518B (en) * | 2019-08-27 | 2022-10-25 | 北京奇艺世纪科技有限公司 | Distributed ID generation method, device, equipment and storage medium |
-
2019
- 2019-12-24 CN CN201911348920.1A patent/CN111083228B/en active Active
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US7853703B1 (en) * | 2005-03-24 | 2010-12-14 | Google, Inc. | Methods and apparatuses for identification of device presence |
KR100746471B1 (en) * | 2006-10-26 | 2007-08-06 | 주식회사 케이티 | Sensor node id assignment method and method for hierarchical configuration of wireless sensor networks using it |
CN107229555A (en) * | 2017-05-04 | 2017-10-03 | 北京小度信息科技有限公司 | Mark generating method and device |
CN109240848A (en) * | 2018-07-27 | 2019-01-18 | 阿里巴巴集团控股有限公司 | A kind of data object tag generation method and device |
CN110554732A (en) * | 2019-08-22 | 2019-12-10 | 北京奇艺世纪科技有限公司 | identification number generation method and device, electronic equipment and storage medium |
Also Published As
Publication number | Publication date |
---|---|
CN111083228A (en) | 2020-04-28 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN111083228B (en) | Identification number generation method and device and electronic equipment | |
US20200328984A1 (en) | Method and apparatus for allocating resource | |
CN110311983B (en) | Service request processing method, device and system, electronic equipment and storage medium | |
CN108347445B (en) | Method and device for realizing remote calling | |
CN110391938B (en) | Method and apparatus for deploying services | |
CN110909521A (en) | Synchronous processing method and device for online document information and electronic equipment | |
CN111158637A (en) | Block chain-based random number generation method, equipment and storage medium | |
CN111581239A (en) | Cache refreshing method and electronic equipment | |
CN111338834B (en) | Data storage method and device | |
CN111431818B (en) | Cross-domain request flow distribution method and device, storage medium and computer equipment | |
CN110764930B (en) | Request or response processing method and device based on message mode | |
CN111161072A (en) | Block chain-based random number generation method, equipment and storage medium | |
CN109471713B (en) | Method and device for inquiring information | |
CN110858201A (en) | Data processing method and system, processor and storage medium | |
US20230006925A1 (en) | Systems for Session-Based Routing | |
CN116108042A (en) | Data processing method, device, electronic equipment, storage medium and program product | |
CN113783740B (en) | Network optimization method, device, equipment and medium | |
CN114095907B (en) | Bluetooth connection control method, device and equipment | |
CN113824675B (en) | Method and device for managing login state | |
CN110661857B (en) | Data synchronization method and device | |
CN115269645A (en) | Information query method and device, electronic equipment and computer readable medium | |
CN113760929A (en) | Data synchronization method and device, electronic equipment and computer readable medium | |
CN107332679B (en) | Centerless information synchronization method and device | |
CN112163176A (en) | Data storage method and device, electronic equipment and computer readable medium | |
CN113761548B (en) | Data transmission method and device for Shuffle process |
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: 40022534 Country of ref document: HK |
|
GR01 | Patent grant | ||
GR01 | Patent grant |