CN111083228A - Identification number generation method and device and electronic equipment - Google Patents

Identification number generation method and device and electronic equipment Download PDF

Info

Publication number
CN111083228A
CN111083228A CN201911348920.1A CN201911348920A CN111083228A CN 111083228 A CN111083228 A CN 111083228A CN 201911348920 A CN201911348920 A CN 201911348920A CN 111083228 A CN111083228 A CN 111083228A
Authority
CN
China
Prior art keywords
network node
identification
node
bits
identification number
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201911348920.1A
Other languages
Chinese (zh)
Other versions
CN111083228B (en
Inventor
何平
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tencent Cloud Computing Beijing Co Ltd
Original Assignee
Tencent Cloud Computing Beijing Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Tencent Cloud Computing Beijing Co Ltd filed Critical Tencent Cloud Computing Beijing Co Ltd
Priority to CN201911348920.1A priority Critical patent/CN111083228B/en
Publication of CN111083228A publication Critical patent/CN111083228A/en
Application granted granted Critical
Publication of CN111083228B publication Critical patent/CN111083228B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L43/00Arrangements for monitoring or testing data switching networks
    • H04L43/10Active monitoring, e.g. heartbeat, ping or trace-route
    • H04L43/106Active monitoring, e.g. heartbeat, ping or trace-route using time related information in packets, e.g. by adding timestamps
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/60Scheduling or organising the servicing of application requests, e.g. requests for application data transmissions using the analysis and optimisation of the required network resources

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 timestamp is within 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 identifier of the network node; the number of bits of the node identifier 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 sequence number. According to the identification number generation method, a single network node can also quickly generate a large number of identification numbers, and the identification number generation efficiency is improved.

Description

Identification number generation method and device and electronic equipment
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, a large amount of data and messages often need to be uniquely identified. For example, in financial, payment, catering, hotel, and movie systems of some application programs, data is increasing, an Identity Document (ID) is required to identify a piece of data or a message after data is sorted and tabulated, and a self-increasing ID of a database obviously cannot meet the requirement, and a system capable of generating a globally unique ID is very necessary.
In a common generation method of identification numbers, 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 batches, queuing is caused by the upper limit of the number of identification numbers generated in each second, so that the generation efficiency of the identification numbers is low.
Disclosure of Invention
The purpose of the present application is to solve at least one of the above technical drawbacks, and to provide the following solutions:
in a first aspect, a method for generating an identification number is provided, including:
for any network node in at least one network node, 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 timestamp is within 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 identifier of the network node; the number of bits of the node identifier 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 sequence number.
In an optional embodiment of the first aspect, when receiving the generation request of the identification number, obtaining a current timestamp of the reception of the generation request of the identification number further includes:
and sending a registration request to the registration server, and receiving the valid time period and the node identification of the network node returned by the registration server.
In an optional embodiment of the first aspect, the number of bits of the node identifier of the one network node is obtained by rounding up the running number of the current network node.
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:
and subtracting the digit of the node identifier of the network node from the second preset digit to obtain the digit of the serial number corresponding to the generation request.
In an optional 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, a method for generating an identification number is provided, 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 a node identifier of any one network node in at least one network node to be registered based on the running number of the current network node;
sending the node identification to the one network node to enable the one network node to generate an identification number;
the identification number is obtained based on the current timestamp, the node identification and the serial number of the request for generating the identification number received by the network node; the number of bits of the serial 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 an identification number further comprises:
if the operation capacity of the registration server is smaller than the operation number of the current network nodes, the operation capacity is enlarged to obtain the updated capacity;
if the update capacity is larger than or equal to the running number of the current network nodes, aiming at any one network node in at least one network node to be registered, determining the effective time period of the network node based on the generation time of the update capacity;
if the operation capacity is larger than or equal to the operation number of the current network nodes, determining the effective time period of the network node based on the current timestamp;
and sending the valid time period to the one network node, so that the one network node generates the identification number when the current timestamp is within the valid time period.
In an alternative embodiment of the second aspect, the validity period comprises a validity start time and a validity end time;
determining a validity period for the one network node based on the generation time of the update capacity, comprising:
taking the generation time of the updated capacity as an effective starting time;
and determining the effective termination time based on the effective starting time and the preset effective duration.
In an optional embodiment of the second aspect, the method for generating an identification number further comprises:
receiving a renewal application of at least one network node to be renewed;
if the register server starts to expand the operation capacity, when the expanded operation capacity obtains the updated capacity, determining the current network node operation number of the register server;
updating the effective termination time of the network node aiming at any network node in at least one network node to be rented continuously, and determining the node identifier of the network node based on the running number of the current network node;
and if the register server does not start to expand the operation capacity, updating the effective termination time of the network node aiming at any network node in at least one network node to be rented continuously.
In a third aspect, an apparatus for generating an identification number is provided, including:
the first acquisition module is used for acquiring a current timestamp of a generation request of a received identification number when the generation request of the identification number is received for any network node in at least one network node; the digit of the current timestamp is a first preset digit;
a first determining module, configured to determine, based on the number of bits of the node identifier of the one network node, the number of bits of the serial number corresponding to the generation request if the current timestamp is within the valid time period of the one network node; the number of bits of the node identifier 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;
a first generation module to generate an identification number based on the current timestamp, the node identification, and the sequence 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 the 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 optional embodiment of the fourth aspect, the number of bits of the node identifier of the one network node is obtained by rounding up the running number of the current network node.
In an optional embodiment of the fourth aspect, 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, the first determining module is specifically configured to:
and subtracting the digit of the node identifier of the network node from the second preset digit to obtain the digit of the serial number corresponding to the generation request.
In an optional embodiment of the fourth aspect, the first generating module, when generating the identification number based on the current timestamp, the node identification, and the sequence number, is specifically configured to:
and splicing the current timestamp, the node identification and the serial number to generate an identification number.
In a fourth aspect, an apparatus for generating an identification number is provided, including:
the system comprises a receiving module, a registering module and a judging module, wherein the receiving module is used for receiving a registering request of at least one network node to be registered and determining the running number of the current network node based on the registering request;
a third determining module, configured to determine, for any network node in at least one network node to be registered, a node identifier of the network node based on the current network node running number;
a sending module, configured to send the node identifier to the one network node, so that the one network node generates an identifier number;
the identification number is obtained based on the current timestamp, the node identification and the serial number of the request for generating the identification number received by the network node; the number of bits of the serial number is determined based on the number of bits of the node identification.
In an optional embodiment of the fourth aspect, the apparatus for generating an identification number further comprises an updating module, and the updating module is configured to:
if the operation capacity of the registration server is smaller than the operation number of the current network nodes, the operation capacity is enlarged to obtain the updated capacity;
if the update capacity is larger than or equal to the running number of the current network nodes, aiming at any one network node in at least one network node to be registered, determining the effective time period of the network node based on the generation time of the update capacity;
if the operation capacity is larger than or equal to the operation number of the current network nodes, determining the effective time period of the network node based on the current timestamp;
and sending the valid time period to the one network node, so that the one network node generates the identification number when the current timestamp is within the valid time period.
In an optional embodiment of the fourth aspect, the validity period comprises a validity start time and a validity end time;
when determining the valid time period of the network node based on the generation time of the update capacity, the update module is specifically configured to:
taking the generation time of the updated capacity as an effective starting time;
and determining the effective termination time based on the effective starting time and the preset effective duration.
In an optional embodiment of the fourth aspect, the generation apparatus of the identification number further comprises a renewal module, configured to:
receiving a renewal application of at least one network node to be renewed;
if the register server starts to expand the operation capacity, when the expanded operation capacity obtains the updated capacity, determining the current network node operation number of the register server;
updating the effective termination time of the network node aiming at any network node in at least one network node to be rented continuously, and determining the node identifier of the network node based on the running number of the current network node;
and if the register server does not start to expand the operation capacity, updating the effective termination time of the network node aiming at any network node in at least one network node to be rented continuously.
In a fifth aspect, an electronic device is provided, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, and when the processor executes the computer program, the processor implements the method for generating an identification number shown in any one of the first to third aspects of the present application.
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 shown in any one of the first to third aspects of the present application.
The beneficial effect that technical scheme that this application provided brought is: when a generation request of an identification number of an application program is received, a current timestamp of the generation request of the received identification number is obtained, if the current timestamp is in an effective time period of the network node, the digit of a serial number is determined according to the digit of a node identification sent by a registration server, so that the serial number is generated, the identification number is generated according to the current timestamp, the node identification and the serial number, and the node identification digit in the identification number and the digit of the serial number are variable, so that a large number of identification numbers can be rapidly generated in batches by a single network node, and the generation efficiency of the identification number is improved.
Additional aspects and advantages of the present 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 present 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 of 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 schematic flowchart of a method for generating an identification number according to an embodiment of the present application;
fig. 4 is a schematic data structure diagram of an identification number provided in an embodiment of the present application;
FIG. 5 is a data structure diagram of an identification number provided by an example of the present application;
fig. 6 is a schematic flowchart of a method for generating an identification number according to an embodiment of the present application;
fig. 7 is a schematic diagram of a scheme for determining an effective time according to an embodiment of the present application;
fig. 8 is a schematic diagram of a scheme for determining an effective time according to an embodiment of the present application;
fig. 9 is a schematic 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 generation apparatus according to an embodiment of the present application;
fig. 11 is a schematic structural diagram of an identification number generation apparatus according to an embodiment of the present application;
fig. 12 is a schematic structural diagram of an identification number generation apparatus 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
Reference will now be made in detail to the embodiments of the present application, examples of which are illustrated in the accompanying drawings, wherein like or similar reference numerals refer to the same or similar elements or elements having the same or similar function throughout. The embodiments described below with reference to the drawings are exemplary only for the purpose of explaining 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 the context clearly indicates otherwise. 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. As used herein, the term "and/or" includes all or any element and all combinations of one or more of the associated listed items.
To make the objects, technical solutions and advantages of the present application more clear, embodiments of the present application will be described in further detail below with reference to the accompanying drawings.
The application provides a method and a device for generating an identification number, an electronic device and a computer-readable storage medium, which aim to solve the above technical problems in the prior art.
The following describes the technical solutions of the present application and how to solve the above technical problems with specific embodiments. The following several specific embodiments may be combined with each other, and details of the same or similar concepts or processes may not be repeated in some embodiments. Embodiments of the present application will be described below with reference to the accompanying drawings.
The method for generating the identification number provided by the application can be applied to the 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 a network node 104 to be registered, and determines the current network node operation number of the network node 104 based on the registration request; the registration server 102 determines a node identifier of the network node 104 based on the current network node operation number; 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 serial number corresponding to the generation request based on the number of bits of the node identifier, and determines the serial number corresponding to the generation request based on the number of bits of the serial number; the network node generates an identification number based on the current timestamp, the node identification and the sequence number, and sends the generated identification number to the application program.
To further illustrate the method of generating an identification number in the present application, a system comprising a registration server and a network node will be further described below with reference to examples.
In one example, as shown in fig. 2, the registration service provides a service for registering and deregistering a network node (a work machine shown in the figure), the operation of registering is initiated by a network node master, and the operation of deregistering can be initiated by the network node actively or forced by a registration server after expiration. The registration service performs registration and deregistration in a protocol that supports RPC and HTTP/HTTPS at the service layer, and the service layer is a cluster that can be expanded horizontally. The database of the registration service is mainly used for storing registration information and states of network nodes, supports mainstream NoSQL databases such as Redis, ETCD, MongoDB and the like in an adapter mode, can also support relational databases such as MySQL, and can also adopt a solution of NoSQL in actual use.
The network node mainly works to generate an identification number, and registers with the system to acquire a machine identification, an effective time and an expiration time of the network node, namely an effective time period. The network node may not generate an identification number after the expiration time, and thus the network node needs to apply for renewal of lease to the system before the expiration time. Because the system may have capacity expansion or capacity reduction, the machine identifier, effective time and expiration time obtained during renewal may be different from those obtained during registration or previous renewal, and the time change of a specific renewal will be described in detail below. The network position of the network node has no mandatory requirement, the environment of the internal network suggests the protocol of RPC to use the registration service, and the environment of the external network (Internet) suggests the protocol of HTTP/HTTPS. The network nodes can comprise edge nodes, and the edge nodes are network nodes with fewer intermediate links from the final equipment access and have better response capability and connection speed to the final access equipment.
A possible implementation manner is provided in the embodiment of the present application, and as shown in fig. 3, a method for generating an identification number is provided, which may be applied to the network node shown in fig. 1, and may include the following steps:
step S301, for any network node in at least one network node, when receiving a generation request of an identification number, obtaining a current timestamp of the generation request of the received identification number.
The network node may be a working machine for generating the identification number, and the network node may receive a generation request of the identification number from a local and/or application program and/or a server, and generate a corresponding identification number based on the generation request.
Specifically, one network node may receive multiple generation requests, and generate a corresponding identification number each time a generation request is received.
Step S302, if the current timestamp 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 identifier of the network node; the number of bits of the node identification of the one network node is determined based on the current network node operation number.
Any network node has an effective time period, the effective time period comprises effective starting time and effective ending time, the network node to be registered becomes the network node for generating the identification number after being registered by the registration server, and the registration server sends the effective time period and the node identification of the network node to the network node when being registered by the registration server.
If the current timestamp is within the valid time period of the network node, the network node may generate the identification number, and if the current timestamp is not within the valid time period of the network node, the network node may not generate the identification number.
Specifically, the node identifier may be a number or letter including at least one bit, and the number of bits of the node identifier is determined based on the current running number of the network node.
In a specific implementation process, the current network node operation number refers to the number of network nodes that have already been registered and the number of network nodes that request registration when the network nodes apply for registration.
For example, 100 network nodes are already registered, and 50 new network nodes request registration, the current network node operation number is 150, and the number of bits of the node identifiers of the 50 network nodes requesting registration is determined according to the current network node operation number.
It is understood that the number of bits of the node identifications of the 50 network nodes requesting registration is not necessarily the same as the number of bits of the node identifications of the 100 registered network nodes, and the number of bits of the node identifications of the 100 registered network nodes is determined based on the current running number of the network nodes of the 100 network nodes at the time of requesting registration.
In step S303, the sequence number corresponding to the generation request is determined based on the number of digits of the sequence number.
In a specific implementation process, the network node may randomly generate a corresponding serial number according to the number of digits of the serial number, or may obtain a generated serial number having the number of digits from a registration server or other terminals, where a generation manner of the specific serial number is not limited herein.
Step S304, an identification number is generated based on the current timestamp, the node identification and the sequence 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 current network node running number, and the number of bits of the serial number is determined based on the number of bits of the node identifier, that is, the number of bits of the node identifier and the number of bits of the serial number may be variable.
In a specific implementation process, the current timestamp, the node identifier, and the serial number may be combined, spliced, or calculated based on a preset rule to obtain an identifier, and the identifier is sent to the application program that sends the generation request.
According to the method for generating the identification number, when the generation request of the identification number 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 digit of the serial number is determined according to the digit of the node identification sent by the registration server, so that the serial number is generated, the identification number is generated according to the current timestamp, the node identification and the serial number, and the node identification digit and the digit of the serial number in the identification number are variable, so that a large number of identification numbers can be rapidly generated in batches by a single network node, and the generation efficiency of the identification number is improved.
In this embodiment, a possible implementation manner is provided, where before obtaining the current timestamp of the request for generating the identification number when the request for generating the identification number of the application program is received in step S301, the method may further include:
and sending a registration request to the registration server, and receiving the valid 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 the registration server, the registration server determines the number of digits of the node identifiers of the network node according to the running number of the current network node, generates the node identifiers according to the digits 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 effective starting time, and adds the effective starting time to a preset time length to obtain the effective termination time.
The embodiment of the application provides a possible implementation manner, and the bit number of the node identifier of one network node is obtained by rounding up the running number of the current network node.
Specifically, the number of bits of the network node identifier is related to the number of network nodes registered in the system, that is, the number of network nodes currently operating, and the calculation formula is as follows:
Figure BDA0002334161470000111
wherein, bits represents the number of bits, num represents the running number of the current network node, and symbol
Figure BDA0002334161470000112
Indicating rounding up.
A possible implementation manner is provided in this embodiment of the present application, the determining, based on the number of bits of the node identifier of the network node, the number of bits of the serial number corresponding to the generation request in step S302 may include:
and subtracting the digit of the node identifier of the network node from the second preset digit to obtain the digit 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 change of the number of bits of the serial number is determined based on the change of the number of bits of the node identifier, and the number of bits of the node identifier is determined based on the current network node operation number.
For example, the second preset number of bits may be set to 32, and then the number of bits that may be used for the sequence number is:
Figure BDA0002334161470000113
wherein, bits represents the number of bits, num represents the running number of the current network node, and symbol
Figure BDA0002334161470000114
Indicating rounding up.
A possible implementation manner is provided in this embodiment of the present application, and the generating an identification number based on the current timestamp, the node identification, and the sequence 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 digit of the current timestamp is a first preset digit; the second part comprises a node identifier and a serial number, wherein the total digit of the second part is fixed and is a second preset digit; the respective numbers of bits of the node identification and the sequence number in the second part may vary.
Taking fig. 5 as an example, the current timestamp (i.e., in fig. 5) is set to 32 bits, the total number of bits of the node identifier (i.e., the work machine identifier in fig. 5) and the serial number is set to 32 bits, the minimum timing unit of the 32-bit timestamp is 1 second, which can be used for about 136 years, and the 32-bit work machine identifier and the serial number mean that the theoretical upper limit of the number of generated identification numbers in one timing unit (1 second) of the whole system is about 43 billion.
If the number of bits of the current timestamp is 32 and the second preset number of bits is 32, that is, the total number of bits of the node identifier and the serial number is set to be 32 bits, then the maximum number of identifier numbers generated by each network node in one timing unit can be calculated according to the number of bits of the serial number as:
Figure BDA0002334161470000121
wherein, numidIndicating the maximum number of identification numbers generated by each network node in a timing unit.
Finally, the relationship between the number of identification numbers generated by each timing unit of the whole system and the running number of the current network nodes is obtained as follows:
Figure BDA0002334161470000122
wherein, numworkRepresenting the number of network nodes currently operating.
This also means that when the number of network nodes is numwork=2nWhen (n)>0) The number of the identification numbers generated by the system in each timing unit is the largest, and the identification numbers are obtained by substituting the formula (4):
numid=232(5)
when the number of network nodes is numwork=2n1 time (n)>0) The number of the identification numbers generated by the system in each timing unit is minimum, and the identification numbers are substituted into the formula (4) to obtain:
numid=232-2(32-n)(6)
in the above embodiment, 43 hundred million network nodes are allowed to operate simultaneously, each network node generating an identification number per second; it also allows a network node to work 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.
Furthermore, the upper limit of the number of identification numbers generated by a system of time units will be 231To 232In between, that is, the upper limit of the identification number generated by the whole system per second floats between 21 hundred million and 43 hundred million, namely, whether a plurality of network nodes or a single network node operates, the generation speed of the identification number can be effectively improved.
According to the method for generating the identification number, when the generation request of the identification number 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 digit of the serial number is determined according to the digit of the node identification sent by the registration server, so that the serial number is generated, the identification number is generated according to the current timestamp, the node identification and the serial number, and the node identification digit and the digit of the serial number in the identification number are variable, so that a large number of identification numbers can be rapidly generated in batches by a single network node, and the generation efficiency of the identification number is improved.
Further, if the current timestamp is set to 32 bits, the second preset number of bits is 32, 43 hundred million network nodes are allowed to operate simultaneously, and each network node generates an identification number per second; it also allows a network node to work 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.
Furthermore, the upper limit of the number of identification numbers generated by a system of time units will be 231To 232In between, that is, the upper limit of the identification number generated by the whole system per second floats between 21 hundred million and 43 hundred million, namely, whether a plurality of network nodes or a single network node operates, the generation speed of the identification number can be effectively improved.
A possible implementation manner is provided in the embodiment of the present application, and 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 running number of the current network node based on the registration request.
Specifically, the current network node operation number refers to the number of network nodes that are registered and the number of network nodes that request registration when the network nodes apply for registration.
Step S602, for any network node in at least one network node to be registered, determining a node identifier of the network node based on the current network node running number.
Specifically, the running number of the current network node may be set in the direction and rounded up to obtain the node identifier of the network node.
For example, 100 network nodes are already registered, 50 new network nodes request registration, if the number of the current network nodes is 150, 150 nodes are opened and upwards forensics is performed to obtain the number of bits of the node identifiers of the 50 network nodes.
It is understood that the number of bits of the node identifications of the 50 network nodes requesting registration is not necessarily the same as the number of bits of the node identifications of the 100 registered network nodes, and the number of bits of the node identifications of the 100 registered network nodes is determined based on the current running number of the network nodes of the 100 network nodes at the time of requesting registration.
Step S603, sending the node identifier to the one network node, so that the one network node generates an identifier number;
the identification number is obtained based on the current timestamp, the node identification and the serial number of the request for generating the identification number received by the network node; the number of bits of the serial number is determined based on the number of bits of the node identification.
Specifically, the current timestamp, the node identifier, and the sequence number may be concatenated to generate an identification number.
The specific way of generating the identification number has been elaborated in the method for generating the identification number applied to the network node, and is not described herein again.
In the above embodiment, 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 identifier of the one network node based on the running number of the current network node, and sends the node identifier to the one network node, so that the one network node generates an identifier number; the identification number is obtained based on the current timestamp, the node identification and the serial number of the request for generating the identification number received by the network node; the number of bits of the serial number is determined based on the number of bits of the node identification. The node identification digit number and the serial number digit number in the identification number are all variable, so that a single network node can also quickly produce a large number of identification numbers in batches, and the generation efficiency of the identification numbers is improved.
The embodiment of the present application provides a possible implementation manner, and the method for generating an identification number further includes:
(1) if the operation capacity of the registration server is smaller than the operation number of the current network nodes, the operation capacity is enlarged to obtain the updated capacity;
(2) if the update capacity is larger than or equal to the running number of the current network nodes, aiming at any one network node in at least one network node to be registered, determining the effective time period of the network node based on the generation time of the update capacity;
(3) if the operation capacity is larger than or equal to the operation number of the current network nodes, determining the effective time period of the network node based on the current timestamp;
(4) and sending the valid time period to the one network node, so that the one network node generates the identification number when the current timestamp is within the valid time period.
Specifically, the operation capacity refers to the number of possible operations 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 reduce the operation capacity of the system; the operating capacity is a dynamic value, and the system will dynamically adjust according to the number of operating network nodes, and the theoretical value is between 1 and 43 hundred million (4294967296 is an accurate value). However, this value is again based on the way that the current network node operation number is doubled each time, and the following table will describe such a process in detail:
Figure BDA0002334161470000151
from the above table it is apparent 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 capacity expansion each time, multiplied by 2 on the basis of the current operating capacity.
It should be particularly noted that, in the present application, the operation capacity of the system for the network node may be set to a fixed and non-adjustable form, that is, a certain operation capacity is set fixedly; it may also be adjustable, i.e. the operating capacity may be dynamically increased or decreased, in which case a minimum and maximum value of the operating capacity may be set, e.g. a minimum value of 2 and a maximum value of 4290772992 for the operating capacity.
The embodiment of the application provides a possible implementation manner, and the effective time period comprises effective starting time and 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 updated capacity as an effective starting time;
(2) and determining the effective termination time based on the effective starting 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 termination time.
The following describes, in detail, a process for determining a valid start time when the system starts expansion or does not expand during registration, with reference to the embodiments and the drawings.
As shown in fig. 7, when a network node (i.e., a working machine in the figure) sends a registration application to a registration server (i.e., a registration server in the figure), the registration server returns registration information to the network node, where the registration information includes an effective time period and a node identifier, and if the registration server does not start capacity expansion, an effective start time in the effective time period (i.e., an effective time shown in the figure) is a time when the registration server receives the registration application; 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, the network node may generate the identification number only if the current timestamp is within the valid time period of the network node, and the network node may not generate the identification number already if the current timestamp is not within the valid time period of the network node. The system may have capacity expansion or capacity reduction, so the node identifier, the valid start time and the valid end time acquired during the lease renewal may be different from those of the node during registration or the last lease renewal.
The embodiment of the present application provides a possible implementation manner, and the method for generating an identification number may further include:
(1) and receiving a renewal 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 the preset threshold, the network node may send a lease renewal application to the registration server to delay the effective termination time.
(2) And if the register server starts to expand the operation capacity, determining the current network node operation number of the register server when the expanded operation capacity obtains the updated capacity.
Specifically, the started expanded operation capacity may be that the registration server is ready to start expanding the operation capacity after detecting that the operation capacity is less than or equal to the current network node operation number, or that the registration server is already expanding the operation capacity.
(3) And updating the effective termination time of the network node aiming at any network node in at least one network node to be leased continuously, and determining the node identification of the network node based on the current network node operation number.
Specifically, after the registration server expands the operating capacity to obtain the updated capacity, the node identifier of the network node that applies for renewal of lease is updated based on the current network node operating capacity, so that the identifier number of the network node is updated.
(4) And if the register server does not start to expand the operation capacity, updating the effective termination time of the network node aiming at any network node in at least one network node to be rented continuously.
As shown in fig. 8, when a network node (i.e., a working machine shown in the figure) applies for renewal of lease to a registration server (i.e., a registration server shown in the figure), if the registration server does not start capacity expansion, the network node is renewed, that is, the effective termination time of the network node is delayed, and information that renewal of lease is successful is returned to the network node; if the registration server starts the capacity expansion of the system, the network node applying for renewal of lease needs to recalculate the bit number of the node identifier, that is, the new generation rule 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 for updating the capacity.
In the specific implementation process, the number of the network nodes in the system is detected by the registration server, capacity expansion or capacity reduction is carried out according to the number change of the network nodes, user intervention is not needed, but the method can also be implemented forcibly by a user in a mode of modifying configuration and control commands, and the failure timestamps (namely, effective termination time) acquired during network node registration and lease renewal are unified in the whole system, namely, the failure is carried out at the same time; if the system is in a static capacity mode, the dead time (i.e., active time period) may 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 capacity reduction operations are required, the failure time can be shortened; if the system failure time (namely the effective time period) exceeds 20 minutes and the time for preparing capacity expansion and capacity reduction exceeds 10 minutes from the next failure time, the registration server can send a message of failure in advance to the network node through two mechanisms of message pushing and heartbeat, and the failure time is set to be 5 minutes later; if all the running network nodes return to receive the message, the expiration time is formally reset to be 5 minutes later. As long as there is one running network node that does not return a receipt, the expiration time does not change.
In the 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 the node identification of the 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 network node so that the 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 request for generating the identification number received by the network node; the number of bits of the serial number is determined based on the number of bits of the node identification. The node identification digit number and the serial number digit number in the identification number are all variable, so that a single network node can also quickly produce a large number of identification numbers in batches, and the generation efficiency of the identification numbers is improved.
Furthermore, the registration server can expand the operation capacity based on the current network node operation number and operation capacity, can automatically adapt to the scenes of a large number of network nodes or a large number of identification numbers of a single node, and can say that no fixed network node and no upper limit of the generation speed of the single network node exist, so that the number of the identification numbers generated by the whole system per second is more, and is closer to the theoretical upper limit of the identification numbers which are about 43 hundred million per second.
A possible implementation manner is provided in the embodiment of the present application, as shown in fig. 9, 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 network node operation number refers to the number of network nodes that the registration server determines based on the number of network nodes that have already registered and the number of network nodes that request registration when the network nodes apply for registration.
Step S902, for any network node in at least one network node to be registered, the registration server determines a node identifier of the network node based on the current network node running number.
Specifically, the running number of the current network node may be set in the direction and rounded up to obtain the node identifier of the network node.
For example, 100 network nodes are already registered, 50 new network nodes request registration, if the number of the current network nodes is 150, 150 nodes are opened and upwards forensics is performed to obtain the number of bits of the node identifiers of the 50 network nodes.
It is understood that the number of bits of the node identifications of the 50 network nodes requesting registration is not necessarily the same as the number of bits of the node identifications of the 100 registered network nodes, and the number of bits of the node identifications of the 100 registered network nodes is determined based on the current running number of the network nodes of the 100 network nodes at the time of requesting registration.
Step S903, the network node receives the node identification; when a generation request of an identification number is received, a current timestamp of the reception of the generation request is acquired.
The network node may be a working machine for generating the identification number, and the network node may receive a generation request of the identification number from a local and/or application program and/or a server, and generate a corresponding identification number based on the generation request.
Specifically, one network node may receive multiple generation requests, and generate a corresponding identification number each time a generation request is received.
In step S904, the network node determines the number of bits of the serial number corresponding to the generation request based on the number of bits of the node identifier, and determines the serial number corresponding to the generation request based on the number of bits of the serial number.
In a specific implementation process, the network node may randomly generate a corresponding serial number according to the number of digits of the serial number, or may obtain a generated serial number having the number of digits from a registration server or other terminals, where a generation manner of the specific serial number is not limited herein.
Step S905, the network node generates an identification number based on the current timestamp, the node identification, and the sequence 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 current network node running number, and the number of bits of the serial number is determined based on the number of bits of the node identifier, that is, the number of bits of the node identifier and the number of bits of the serial number may be variable.
In a specific implementation process, the current timestamp, the node identifier, and the serial number may be combined, spliced, or calculated based on a preset rule to obtain an identifier, and the identifier is sent to the application program that sends the generation request.
In the 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 the node identification of the 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 network node so that the 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 request for generating the identification number received by the network node; the number of bits of the serial number is determined based on the number of bits of the node identification. The node identification digit number and the serial number digit number in the identification number are all variable, so that a single network node can also quickly produce a large number of identification numbers in batches, and the generation efficiency of the identification numbers is improved.
One possible implementation manner is provided in the embodiment of the present application, and as shown in fig. 10, there is provided an identification number generation apparatus 100, which includes a first obtaining module 1001, a first determining module 1002, a second determining module 1003, and a first generating module 1004, wherein,
a first obtaining module 1001, configured to, for any network node in the at least one network node, obtain, when a generation request for an identification number is received, a current timestamp of the generation request for the identification number; the digit of the current timestamp is a first preset digit;
a first determining module 1002, configured to determine, based on the number of bits of the node identifier of the one network node, a number of bits of a serial number corresponding to the generation request if the current timestamp is within the valid time period of the one network node; the number of bits of the node identifier 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 generating module 1004 for generating an identification number based on the current timestamp, the node identification and the sequence number.
In the embodiment of the present application, a possible implementation manner is provided, and the apparatus 100 for generating an identification number further includes:
and the sending module is used for sending the 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.
The embodiment of the application provides a possible implementation manner, and the bit number of the node identifier of one network node is obtained by rounding up the running number of the current network node.
In an embodiment of the present application, a possible implementation manner is provided, and when determining, based on the number of bits of the node identifier of the network node, the number of bits of the serial number corresponding to the generation request, the first determining module 1002 is specifically configured to:
and subtracting the digit of the node identifier of the network node from the second preset digit to obtain the digit of the serial number corresponding to the generation request.
In an embodiment of the present application, a possible implementation manner is provided, and when the first generating module 1004 generates the identification number based on the current timestamp, the node identification, and the sequence number, the first generating module is specifically configured to:
and splicing the current timestamp, the node identification and the serial number to generate an identification number.
The device for generating the identification number obtains the current timestamp of the request for generating the identification number when the request for generating the identification number of the application program is received, if the current timestamp is in the effective time period of the network node, the digit of the serial number is determined according to the digit of the node identification sent by the registration server, so that the serial number is generated, the identification number is generated according to the current timestamp, the node identification and the serial number, and the node identification digit and the digit of the serial number in the identification number are variable, so that a single network node can also rapidly generate a large number of identification numbers in batches, and the generation efficiency of the identification numbers is improved.
Further, if the current timestamp is set to 32 bits, the second preset number of bits is 32, 43 hundred million network nodes are allowed to operate simultaneously, and each network node generates an identification number per second; it also allows a network node to work 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.
Furthermore, the upper limit of the number of identification numbers generated by a system of time units will be 231To 232In between, that is, the upper limit of the identification number generated by the whole system per second floats between 21 hundred million and 43 hundred million, namely, whether a plurality of network nodes or a single network node operates, the generation speed of the identification number can be effectively improved.
A possible implementation manner is provided in the embodiment of the present application, and as shown in fig. 11, a generation apparatus 110 for an identification number is provided, which is applied to a registration server, and 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 running number of a current network node based on the registration request;
a third determining module 1102, configured to determine, for any network node in the at least one network node to be registered, a node identifier of the network node based on the current network node operation number;
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;
the identification number is obtained based on the current timestamp, the node identification and the serial number of the request for generating the identification number received by the network node; the number of bits of the serial number is determined based on the number of bits of the node identification.
In an embodiment of the present application, a possible implementation manner is provided, where the generating device 110 of the identification number further includes an updating module, and the updating module is configured to:
if the operation capacity of the registration server is smaller than the operation number of the current network nodes, the operation capacity is enlarged to obtain the updated capacity;
if the update capacity is larger than or equal to the running number of the current network nodes, aiming at any one network node in at least one network node to be registered, determining the effective time period of the network node based on the generation time of the update capacity;
if the operation capacity is larger than or equal to the operation number of the current network nodes, determining the effective time period of the network node based on the current timestamp;
and sending the valid time period to the one network node, so that the one network node generates the identification number when the current timestamp is within the valid time period.
The embodiment of the application provides a possible implementation manner, and the effective time period comprises effective starting time and effective ending time;
when determining the valid time period of the network node based on the generation time of the update capacity, the update module is specifically configured to:
taking the generation time of the updated capacity as an effective starting time;
and determining the effective termination time based on the effective starting time and the preset effective duration.
In an embodiment of the present application, a possible implementation manner is provided, where the generating device 110 of the identification number further includes a renewal lease module, configured to:
receiving a renewal application of at least one network node to be renewed;
if the register server starts to expand the operation capacity, when the expanded operation capacity obtains the updated capacity, determining the current network node operation number of the register server;
updating the effective termination time of the network node aiming at any network node in at least one network node to be rented continuously, and determining the node identifier of the network node based on the running number of the current network node;
and if the register server does not start to expand the operation capacity, updating the effective termination time of the network node aiming at any network node in at least one network node to be rented continuously.
In the apparatus for generating an identification number, the registration server receives a registration request of at least one network node to be registered, determines a 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 request for generating the identification number received by the network node; the number of bits of the serial number is determined based on the number of bits of the node identification. The node identification digit number and the serial number digit number in the identification number are all variable, so that a single network node can also quickly produce a large number of identification numbers in batches, and the generation efficiency of the identification numbers is improved.
Furthermore, the registration server can expand the operation capacity based on the current network node operation number and operation capacity, can automatically adapt to the scenes of a large number of network nodes or a large number of identification numbers of a single node, and can say that no fixed network node and no upper limit of the generation speed of the single network node exist, so that the number of the identification numbers generated by the whole system per second is more, and is closer to the theoretical upper limit of the identification numbers which are about 43 hundred million per second.
A possible implementation manner is provided in this embodiment of the present application, as shown in fig. 12, a generation apparatus 120 of an identification number is provided, and 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, through a registration server, a registration request of at least one network node to be registered, and determine, based on the registration request, a current network node operation number;
a fifth determining module 1202, configured to determine, by the registration server, a node identifier of the network node based on the current network node running number, for any network node of the at least one network node to be registered;
a second obtaining module 1203, configured to receive the node identifier through the network node; 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 bit number of a serial number corresponding to the generation request based on the bit number of the node identifier, and determine, based on the bit number of the serial number, the serial number corresponding to the generation request;
a second generating module 1205, configured to generate, by the network node, an identification number based on the current timestamp, the node identifier, and the sequence number, and send the generated identification number to the application program.
In the apparatus for generating an identification number, the registration server receives a registration request of at least one network node to be registered, determines a 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 request for generating the identification number received by the network node; the number of bits of the serial number is determined based on the number of bits of the node identification. The node identification digit number and the serial number digit number in the identification number are all variable, so that a single network node can also quickly produce a large number of identification numbers in batches, and the generation efficiency of the identification numbers is improved.
The generation device of the picture identification number according to the embodiment of the present disclosure may execute the generation method of the picture identification number provided by the embodiment of the present disclosure, and the implementation principle is similar, the actions performed by each module in the generation device of the picture identification number according to each embodiment of the present disclosure correspond to the steps in the generation method of the picture identification number according to each embodiment of the present disclosure, and for the detailed function description of each module of the generation device of the picture identification number, reference may be specifically made to the description in the generation method of the corresponding picture identification number shown in the foregoing, and details are not repeated here.
Based on the same principle as the method shown in the embodiments of the present disclosure, embodiments of the present disclosure also provide an electronic device, which 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 generation method of 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 rapidly 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 comprising: a processor 4001 and a memory 4003. Processor 4001 is coupled to memory 4003, such as via bus 4002. Optionally, the electronic device 4000 may further comprise a transceiver 4004. In addition, the transceiver 4004 is not limited to one in practical applications, 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), a general-purpose Processor, a DSP (Digital Signal Processor), an ASIC (Application specific integrated Circuit), an FPGA (Field Programmable Gate Array) or other Programmable logic device, a transistor logic device, a hardware component, or any combination thereof. Which may implement or perform the various illustrative logical blocks, modules, and circuits described in connection with the disclosure. The processor 4001 may also be a combination that performs a computational function, including, for example, a combination of one or more microprocessors, a combination of a DSP and a microprocessor, or the like.
Bus 4002 may include a path that carries information between the aforementioned components. The bus 4002 may be a PCI (Peripheral Component Interconnect) bus, an EISA (extended industry Standard Architecture) bus, or the like. The bus 4002 may be divided into an address bus, a data bus, a control bus, and the like. For ease of illustration, only one thick line is shown in FIG. 7, but this is not intended to represent only one bus or type of bus.
The Memory 4003 may be a ROM (Read Only Memory) or other types of static storage devices that can store static information and instructions, a RAM (Random Access Memory) or other types of dynamic storage devices that can store information and instructions, an EEPROM (Electrically erasable programmable Read Only Memory), a CD-ROM (Compact Read Only Memory) or other optical disk storage, optical disk storage (including Compact disk, laser disk, optical disk, digital versatile disk, blu-ray disk, etc.), a magnetic disk storage medium or other magnetic storage devices, or any other medium that can be used to carry or store desired program code in the form of instructions or data structures and that can be accessed by a computer, but is not limited to.
The memory 4003 is used for storing application codes for executing the scheme of the present application, and the execution is controlled by the processor 4001. Processor 4001 is configured to execute application code stored in memory 4003 to implement what is shown in the foregoing method embodiments.
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 fixed terminals such as digital TVs, desktop computers, and the like. The electronic device shown in fig. 13 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present disclosure.
The present application provides a computer-readable storage medium, on which a computer program is stored, which, when running on a computer, enables the computer to execute the corresponding content in the foregoing method embodiments. Compared with the prior art, the identification number generation method can rapidly generate a large number of identification numbers in batches by a single network node, so that the identification number generation efficiency 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, the steps are not necessarily performed in order as indicated by the arrows. The steps are not performed in the exact order shown and may be performed in other orders unless explicitly stated herein. Moreover, at least a portion of the steps in the flow chart of the figure may include multiple sub-steps or multiple stages, which are not necessarily performed at the same time, but may be performed at different times, which are not necessarily performed in sequence, but may be performed alternately or alternately with other steps or at least a portion of the sub-steps or stages of other steps.
It should be noted that the computer readable medium in the present disclosure can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination 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 present 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 contrast, in the present disclosure, a computer readable signal medium may comprise a propagated data signal with computer readable program code embodied therein, either in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. 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, optical cables, RF (radio frequency), etc., or any suitable combination of the foregoing.
The computer readable medium may be embodied in the electronic device; or may exist separately without being assembled 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 embodiments.
Computer program code for carrying out operations for aspects of the present disclosure may be written in any combination of 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 type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
The flowchart 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 by software or hardware. The name of the module does not in some cases constitute a limitation of the module itself, and for example, the first obtaining module may also be described as a "module for obtaining a current timestamp".
The foregoing description is only exemplary of the preferred embodiments of the disclosure and is illustrative of the principles of the technology employed. It will be appreciated by those skilled in the art that the scope of the disclosure herein is not limited to the particular combination of features described above, but also encompasses other embodiments in which any combination of the features described above or their equivalents does not depart from the spirit of the disclosure. For example, the above features and (but not limited to) the features disclosed in this disclosure having similar functions are replaced with each other to form the technical solution.

Claims (13)

1. A method for generating an identification number, comprising:
for any network node in at least one network node, 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 timestamp is within 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 identifier of the network node; the number of bits of the node identifier 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;
generating an identification number based on the current timestamp, the node identification, and the sequence number.
2. The method according to claim 1, wherein said step of obtaining, when the request for generating the identification number is received, a current timestamp of the request for generating the identification number is received, further comprises the step of:
and sending a registration request to the registration server, and receiving the valid 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 identifier of the one network node is obtained by rounding up the running number of the current network node.
4. The method according to claim 1, wherein said 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:
and subtracting the digit of the node identifier of the network node from the second preset digit to obtain the digit of the serial number corresponding to the generation request.
5. The method of generating an identification number according to claim 1, wherein said generating an 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 the identification number.
6. A method for generating an identification number, comprising:
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 a node identifier of any one of at least one network node to be registered based on the running number of the current network node;
sending the node identification to the one network node to enable the one network node to generate an identification number;
the identification number is obtained based on the current timestamp, the node identification and the serial number of the request for generating the identification number received by the network node; the number of bits of the serial number is determined based on the number of bits of the node identification.
7. The method of generating an identification number according to claim 6, further comprising:
if the operation capacity of the registration server is smaller than the operation number of the current network nodes, the operation capacity is expanded to obtain updated capacity;
if the update capacity is larger than or equal to the running number of the current network nodes, aiming at any one network node in at least one network node to be registered, determining the effective time period of the network node based on the generation time of the update capacity;
if the operation capacity is larger than or equal to the operation number of the current network nodes, determining the effective time period of the network node based on the current timestamp;
and sending the valid time period to the network node, so that the network node generates the identification number when the current timestamp is within the valid time period.
8. The method of generating an identification number according to claim 7, wherein the valid period of time includes a valid start time and a valid end time;
the determining the validity period of the one network node based on the generation time of the update capacity includes:
taking the generation time of the updated capacity as the effective starting time;
and determining the effective termination time based on the effective starting time and a preset effective duration.
9. The method for generating an identification number according to claim 8, further comprising:
receiving a renewal application of at least one network node to be renewed;
if the register server is started to expand the operation capacity, when the operation capacity is expanded to obtain the updated capacity, determining the current network node operation number of the register server;
updating the effective termination time of any network node in at least one network node to be rented continuously, and executing the determination of the node identifier of the network node based on the current network node operation number;
and if the register server does not start to expand the operation capacity, updating the effective termination time of the network node aiming at any network node in at least one network node to be rented continuously.
10. An apparatus for generating an identification number, comprising:
the first acquisition module is used for acquiring a current timestamp of a generation request of a received identification number when the generation request of the identification number is received for any network node in at least one network node; the digit of the current timestamp is a first preset digit;
a first determining module, configured to determine, based on the number of bits of the node identifier of the one network node, the number of bits of the serial number corresponding to the generation request if the current timestamp is within the valid time period of the one network node; the number of bits of the node identifier 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;
a first generation module to generate an identification number based on the current timestamp, the node identification, and the sequence number.
11. An apparatus for generating an identification number, comprising:
the system comprises a receiving module, a registering module and a judging module, wherein the receiving module is used for receiving a registering request of at least one network node to be registered and determining the running number of the current network node based on the registering request;
a third determining module, configured to determine, for any network node in at least one network node to be registered, a node identifier of the network node based on the current network node running number;
a sending module, configured to send the node identifier to the one network node, so that the one network node generates an identifier number;
the identification number is obtained based on the current timestamp, the node identification and the serial number of the request for generating the identification number received by the network node; the number of bits of the serial number is determined based on the number of bits of the node identification.
12. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements the method of generating an identification number according to any one of claims 1 to 9 when executing the program.
13. 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 one of claims 1 to 9.
CN201911348920.1A 2019-12-24 2019-12-24 Identification number generation method and device and electronic equipment Active CN111083228B (en)

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 true CN111083228A (en) 2020-04-28
CN111083228B 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)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111949666A (en) * 2020-08-31 2020-11-17 平安国际智慧城市科技股份有限公司 Identification generation method and device, electronic equipment and storage medium
CN112202938A (en) * 2020-10-12 2021-01-08 广州品唯软件有限公司 ID generation method, device and system
CN112559558A (en) * 2020-12-07 2021-03-26 北京理房通支付科技有限公司 Serial number generation method and device, computing device and storage medium
CN113708983A (en) * 2021-11-01 2021-11-26 湖南新云网科技有限公司 Distributed node ID generation method, device, equipment and storage medium
CN113822015A (en) * 2020-06-16 2021-12-21 北京沃东天骏信息技术有限公司 Serial number generation method and device, electronic equipment and computer readable medium

Citations (10)

* Cited by examiner, † Cited by third party
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
US20080205327A1 (en) * 2007-02-23 2008-08-28 Cellco Partnership Methods, Apparatuses, and Computer Program Products for Providing Dynamic Assignment of Slot Cycle Index for Network Nodes
US7853703B1 (en) * 2005-03-24 2010-12-14 Google, Inc. Methods and apparatuses for identification of device presence
US20120150750A1 (en) * 2010-12-14 2012-06-14 Xtreme Mobility Inc. System and method for initiating transactions on a mobile device
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
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
CN110543518A (en) * 2019-08-27 2019-12-06 北京奇艺世纪科技有限公司 Distributed ID generation method, device, equipment and storage medium
CN110554732A (en) * 2019-08-22 2019-12-10 北京奇艺世纪科技有限公司 identification number generation method and device, electronic equipment and storage medium

Patent Citations (10)

* Cited by examiner, † Cited by third party
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
US20080205327A1 (en) * 2007-02-23 2008-08-28 Cellco Partnership Methods, Apparatuses, and Computer Program Products for Providing Dynamic Assignment of Slot Cycle Index for Network Nodes
US20120150750A1 (en) * 2010-12-14 2012-06-14 Xtreme Mobility Inc. System and method for initiating transactions on a mobile device
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
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
CN110554732A (en) * 2019-08-22 2019-12-10 北京奇艺世纪科技有限公司 identification number generation method and device, electronic equipment and storage medium
CN110543518A (en) * 2019-08-27 2019-12-06 北京奇艺世纪科技有限公司 Distributed ID generation method, device, equipment and storage medium

Cited By (8)

* Cited by examiner, † Cited by third party
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
CN111949666A (en) * 2020-08-31 2020-11-17 平安国际智慧城市科技股份有限公司 Identification generation method and device, electronic equipment and storage 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
CN112559558A (en) * 2020-12-07 2021-03-26 北京理房通支付科技有限公司 Serial number generation method and device, computing device and storage medium
CN112559558B (en) * 2020-12-07 2024-04-09 北京理房通支付科技有限公司 Method and device for generating serial numbers, computing equipment and storage medium
CN113708983A (en) * 2021-11-01 2021-11-26 湖南新云网科技有限公司 Distributed node ID generation method, device, equipment and storage medium
CN113708983B (en) * 2021-11-01 2022-02-11 湖南新云网科技有限公司 Distributed node ID generation method, device, equipment and storage medium

Also Published As

Publication number Publication date
CN111083228B (en) 2023-06-30

Similar Documents

Publication Publication Date Title
CN111083228B (en) Identification number generation method and device and electronic equipment
US11146502B2 (en) Method and apparatus for allocating resource
CN113485980A (en) Data processing method and device, electronic equipment and storage medium
CN109471713B (en) Method and device for inquiring information
CN108011926B (en) Message sending method, message processing method, server and system
CN113824675B (en) Method and device for managing login state
CN114691175A (en) Application updating method, device and system
CN110489231B (en) Transaction information recording method, apparatus and computer readable storage medium
CN114640595A (en) Cascading method, device, electronic equipment and storage medium
CN113760929A (en) Data synchronization method and device, electronic equipment and computer readable medium
WO2015040628A1 (en) System and method for automated authentication
CN113037420A (en) Reading time stamp obtaining method and device, electronic equipment and storage medium
CN112163176A (en) Data storage method and device, electronic equipment and computer readable medium
US20150379548A1 (en) Method and System for Data Processing
CN107332679B (en) Centerless information synchronization method and device
CN110661857A (en) Data synchronization method and device
CN110858201A (en) Data processing method and system, processor and storage medium
CN113612676B (en) Social group message synchronization method, device, equipment and storage medium
US20170134486A1 (en) Method and device for information synchronization
CN113472565B (en) Method, apparatus, device and computer readable medium for expanding server function
CN116009792B (en) Data reading and writing device and method in image processing and electronic equipment
CN113242306B (en) Block chain consensus method and device
CN113761548B (en) Data transmission method and device for Shuffle process
WO2023143061A1 (en) Data access method and data access system thereof
CN112905924A (en) Method, device, equipment and storage medium for concurrent response of thermal Key data

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