CN114356925A - Identification generation method and device, electronic equipment and storage medium - Google Patents

Identification generation method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN114356925A
CN114356925A CN202111659877.8A CN202111659877A CN114356925A CN 114356925 A CN114356925 A CN 114356925A CN 202111659877 A CN202111659877 A CN 202111659877A CN 114356925 A CN114356925 A CN 114356925A
Authority
CN
China
Prior art keywords
target
service request
code
determining
timestamp information
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.)
Pending
Application number
CN202111659877.8A
Other languages
Chinese (zh)
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.)
Guahao Net Hangzhou Technology Co Ltd
Original Assignee
Guahao Net Hangzhou Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Guahao Net Hangzhou Technology Co Ltd filed Critical Guahao Net Hangzhou Technology Co Ltd
Priority to CN202111659877.8A priority Critical patent/CN114356925A/en
Publication of CN114356925A publication Critical patent/CN114356925A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Information Transfer Between Computers (AREA)

Abstract

The embodiment of the invention discloses an identification generation method, an identification generation device, electronic equipment and a storage medium, wherein the method comprises the following steps: determining a target reserved code corresponding to the service request when the service request is received; acquiring a target server address corresponding to the service request, and determining a target machine code corresponding to the service request based on the target server address; determining a target time code corresponding to the service request according to the to-be-processed timestamp information carried by the service request and the preset timestamp information; and determining a target sequence code corresponding to the service request according to the to-be-processed timestamp information, and constructing a target identifier corresponding to the service request according to the target reserved code, the target machine code, the target time code and the target sequence code. The technical scheme of the embodiment of the invention reduces the number of the generated IDs per second, avoids the waste of a large number of IDs, gets rid of the dependence of the traditional primary key generation mode on the data center IDs and the data node IDs and enhances the flexibility of the algorithm.

Description

Identification generation method and device, electronic equipment and storage medium
Technical Field
The embodiment of the invention relates to the technical field of data processing, in particular to an identification generation method and device, electronic equipment and a storage medium.
Background
Currently, in a database software system, a unique string of numbers or characters needs to be generated in a database scope for different objects, and the unique string of numbers or characters is used as an Identification (ID) of one record in the database, namely a main key in database terminology.
In the prior art, a Snowflake algorithm (i.e., snowfall algorithm) may be used to generate corresponding IDs for each object, and the algorithm is an open-source distributed algorithm and has the capability of generating globally unique IDs with increasing trend in a distributed system. However, in the process of actually applying the snowflake algorithm, the number of IDs generated in the system per second is too large, and an enterprise cannot effectively utilize all IDs, so that a large amount of IDs are wasted; meanwhile, in the process of generating the ID, the snowflake algorithm can construct a main key for response only by depending on the ID of the data center and the ID of each data node, so that the snowflake algorithm has certain limitation.
Disclosure of Invention
The invention provides an identification generation method, an identification generation device, electronic equipment and a storage medium, which reduce the number of generated IDs per second, avoid the waste of a large number of IDs, get rid of the dependence of a traditional main key generation mode on data center IDs and data node IDs and enhance the flexibility of an algorithm.
In a first aspect, an embodiment of the present invention provides an identifier generating method, where the method includes:
upon receiving a service request, determining a target reservation code corresponding to the service request;
acquiring a target server address corresponding to the service request, and determining a target machine code corresponding to the service request based on the target server address;
determining a target time code corresponding to the service request according to the to-be-processed timestamp information carried by the service request and preset timestamp information;
and determining a target sequence code corresponding to the service request according to the to-be-processed timestamp information, and constructing a target identifier corresponding to the service request according to the target reserved code, the target machine code, the target time code and the target sequence code.
In a second aspect, an embodiment of the present invention further provides an identifier generating apparatus, where the apparatus includes:
the target reservation code determining module is used for determining a target reservation code corresponding to the service request when the service request is received;
the target machine code determining module is used for acquiring a target server address corresponding to the service request and determining a target machine code corresponding to the service request based on the target server address;
the target time code determining module is used for determining a target time code corresponding to the service request according to the to-be-processed time stamp information carried by the service request and preset time stamp information;
and the target identification determining module is used for determining a target sequence code corresponding to the service request according to the to-be-processed timestamp information and constructing a target identification corresponding to the service request according to the target reserved code, the target machine code, the target time code and the target sequence code.
In a third aspect, an embodiment of the present invention further provides an electronic device, where the electronic device includes:
one or more processors;
a storage device for storing one or more programs,
when the one or more programs are executed by the one or more processors, the one or more processors implement the identifier generation method according to any one of the embodiments of the present invention.
In a fourth aspect, embodiments of the present invention further provide a storage medium containing computer-executable instructions, which when executed by a computer processor, are configured to perform the identity generation method according to any one of the embodiments of the present invention.
The technical scheme of the embodiment of the invention determines a target reserved code corresponding to a service request when the service request is received, acquires a target server address corresponding to the service request, determines a target machine code corresponding to the service request based on the target server address, determines a target time code corresponding to the service request according to-be-processed time stamp information and preset time stamp information carried by the service request, determines a target sequence code corresponding to the service request according to-be-processed time stamp information, and finally fuses the various information, namely, a target identifier corresponding to the service request is constructed according to the target reserved code, the target machine code, the target time code and the target sequence code, and the number of generated IDs per second is reduced by realizing the variation of a snowflake algorithm, changing the composition of each part of a generated main key, the waste of a large amount of IDs is avoided, the target machine code is generated by utilizing the server address, the dependence of a traditional primary key generation mode on the data center IDs and the data node IDs is eliminated, and the flexibility of the algorithm is enhanced.
Drawings
In order to more clearly illustrate the technical solutions of the exemplary embodiments of the present invention, a brief description is given below of the drawings used in describing the embodiments. It should be clear that the described figures are only views of some of the embodiments of the invention to be described, not all, and that for a person skilled in the art, other figures can be derived from these figures without inventive effort.
Fig. 1 is a schematic flowchart of a method for generating an identifier according to an embodiment of the present invention;
fig. 2 is a schematic flowchart of an identifier generation method according to a second embodiment of the present invention;
fig. 3 is a block diagram of a structure of an identifier generating apparatus according to a third embodiment of the present invention;
fig. 4 is a schematic structural diagram of an electronic device according to a fourth embodiment of the present invention.
Detailed Description
The present invention will be described in further detail with reference to the accompanying drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the invention and are not limiting of the invention. It should be further noted that, for the convenience of description, only some of the structures related to the present invention are shown in the drawings, not all of the structures.
Example one
Fig. 1 is a flowchart of an identifier generating method according to an embodiment of the present invention, where the embodiment is applicable to a situation where a snowflake algorithm is subjected to variant optimization and a corresponding primary key is constructed by using a server address, and the method may be executed by an identifier generating apparatus, and the apparatus may be implemented in the form of software and/or hardware, and the hardware may be an electronic device, such as a mobile terminal, a PC terminal, or a server.
As shown in fig. 1, the method specifically includes the following steps:
s110, when the service request is received, the target reserved code corresponding to the service request is determined.
The service request may be multiple types of requests associated with each service, for example, the service request may be a request received in a service development and test stage, or a request received when a service formally operates online, and it may be understood that the service request is multiple types of requests that require a globally unique ID to be constructed and stored in a specific database.
In this embodiment, the distributed system may execute the pre-written object program code upon receiving the service request. The object program code refers to an algorithm for generating corresponding primary keys for various objects, and in the actual application process, the object program code may be optimized for a variant of the snowflake algorithm. The conventional snowflake algorithm is explained below.
For the snowflake algorithm, after the corresponding program code is executed, the constructed ID is usually 64 bits, and in a specific primary key structure, the identification bit occupies 1 bit, which can be understood as a sign bit, a positive number is 0, and a negative number is 1, so the ID is usually a positive number and takes 0; the time stamp is 41 bits (millisecond), meanwhile, the time stamp of 41 bits is not the stored time stamp of the current time, but is the difference value with the preset stored time stamp, and the preset time stamp can be generally set as the time for the primary key generator to start using; the data machine bit occupies 10 bits and can be deployed in 1024 nodes, wherein the first 5 bits represent data center IDs, and the last 5 bits represent data node IDs; the last sequence bits are 12 bits, and since the snowflake algorithm is a millisecond count, each node can generate 4096 ID sequence numbers based on the 12-bit count sequence number within 1 millisecond. After the above bits are integrated, more than four million IDs can be generated per second based on a snowflake algorithm.
In this embodiment, on the basis of the existing snowflake algorithm, it may be subjected to variant optimization to obtain the target program code, and correspondingly, during the process of executing the target program code, a corresponding target reserved code also needs to be generated for the received service request. The target reserved code corresponds to an identification bit in a traditional ID structure, and it should be noted that after the snowflake algorithm is modified, the generated target reserved code may be two bits in the ID construction process.
S120, obtaining the address of the target server corresponding to the service request, and determining the target machine code corresponding to the service request based on the address of the target server.
In this embodiment, in the process of constructing the ID based on the object program code, the object machine code corresponding to the data machine bit in the conventional ID structure needs to be generated. The target machine code is still used for characterizing a machine associated with the service request, but is different from a data machine bit constructed by the existing snowflake algorithm in that the target machine code in the embodiment is free from dependence on a data center ID and a data node ID in a generation process, that is, the target machine code is not generated based on the two IDs, but is generated according to an address of a target server, and therefore, in order to determine the target machine code corresponding to the service request, the address of the target server corresponding to the service request also needs to be acquired.
Specifically, the target server address may be an Internet Protocol (IP) address corresponding to the target server, and the IP address is a uniform address format provided by the IP Protocol, and a logical address is allocated to each host of each network on the Internet, so as to mask a difference in physical addresses of the servers. In this embodiment, after the IP address of the server associated with the service request is obtained, the corresponding target machine code may be generated based on the IP address. It should be noted that, after the snowflake algorithm is modified, the generated target machine code is still 10 bits in the process of constructing the ID.
S130, determining a target time code corresponding to the service request according to the to-be-processed time stamp information and the preset time stamp information carried by the service request.
In this embodiment, in the process of constructing the ID based on the target program code, it is also necessary to generate a target time code corresponding to a time stamp in the conventional ID structure. The target time code is still used for representing the difference between the time stamp associated with the service request and the preset time stamp. It can be understood that, when a service request is received, to-be-processed timestamp information carried by the request is determined first, that is, a time when the distributed system receives the service request is determined, and meanwhile, preset timestamp information in the distributed system needs to be determined, where the timestamp information may be time information corresponding to the start identifier generator or time information previously edited by a worker according to actual needs, and the embodiment of the present disclosure is not specifically limited herein. Furthermore, the time information of the service request can be obtained by subtracting the two pieces of time stamp information, and finally, the target time code in the ID can be generated after the time information is processed based on the target program code.
Since there are no more than four million IDs required per second for some enterprises, the target timecode generated based on the target program code is 32 bits in order to reduce the number of IDs generated per second by the algorithm and avoid the waste of a large number of IDs.
S140, determining a target sequence code corresponding to the service request according to the to-be-processed timestamp information, and constructing a target identifier corresponding to the service request according to the target reserved code, the target machine code, the target time code and the target sequence code.
In this embodiment, when the to-be-processed timestamp information carried by the service request is determined, a target sequence code corresponding to the service request may also be determined. The target sequence code is still used to characterize the counting sequence number of the service request at the current time. It can be understood that, when a service request is received, the number of IDs that have been generated for other service requests at the current time (within one second) is determined, and then the determined number is added by one to determine a counting sequence number corresponding to the service request received this time, and further, the counting sequence number is processed based on the target program code, that is, the target sequence code corresponding to the service request is obtained.
In this embodiment, after the target reserved code, the target machine code, the target time code, and the target sequence code are determined, the four codes are further spliced and integrated, and a target identifier corresponding to the service request is constructed. It can be understood that the finally constructed target identifier is 64-bit long type binary digits, and meanwhile, after the corresponding target identifier is constructed for the service request, the target identifier and the request can be associated and stored in a corresponding database for subsequent calling.
According to the technical scheme of the embodiment, when a service request is received, a target reserved code corresponding to the service request is determined, a target server address corresponding to the service request is obtained, a target machine code corresponding to the service request is determined based on the target server address, a target time code corresponding to the service request is determined according to-be-processed time stamp information and preset time stamp information carried by the service request, a target sequence code corresponding to the service request is determined according to-be-processed time stamp information, and finally, the various information are fused, namely, a target identifier corresponding to the service request is constructed according to the target reserved code, the target machine code, the target time code and the target sequence code, through the variant implementation of a snowflake algorithm, the composition of each part of a generated main key is changed, the number of generated IDs per second is reduced, and the waste of a large number of IDs is avoided, and the target machine code is generated by utilizing the server address, so that the dependence of a traditional primary key generation mode on the data center ID and the data node ID is eliminated, and the flexibility of the algorithm is enhanced.
Example two
Fig. 2 is a schematic flow chart of an identifier generation method according to a second embodiment of the present invention, and based on the foregoing embodiment, a 64-bit ID constructed by an existing snowflake algorithm is subdivided, and forms of a 2-bit target reserved bit, a 10-bit target machine code, a 32-bit target time code, and a 20-bit target sequence code are adopted, and a unit of second is used, so that not only can an application service corresponding to a service request be reflected, but also business requirements of an enterprise are met, and an algorithm after variant optimization supports a longer age while original self-increment and high-efficiency characteristics of the snowflake algorithm are retained. The specific implementation manner can be referred to the technical scheme of the embodiment. The technical terms that are the same as or corresponding to the above embodiments are not repeated herein.
As shown in fig. 2, the method specifically includes the following steps:
s210, when the service request is received, determining a target process corresponding to the service request in the distributed system, and determining a target reserved code according to the last two digits of the number of the target process.
In this embodiment, by modifying the existing snowflake algorithm, when a service request is received and a corresponding target reserved code is generated for the service request based on the target program code, a sign bit that does not have any meaning in the conventional identifier can be changed to a target reserved bit that characterizes a specific application service.
Specifically, when a service request is received, a target process associated with the service request may be determined in the distributed system, and further, the last two digits of the target process number may be selected as a target reserved code in the system, for example, the target reserved code may be 00, 11, 01, or 10. Since the target processes have different numbers and the application services associated with the service requests are different, it can be understood that the target reservation codes may also reflect the specific application services.
It should be noted that, in the actual application process, when the application service is started, the process number of the application service may be taken from the distributed system, and a remainder is made for 4 based on the process number, and further, the obtained value is used as a value of the target reserved bit corresponding to the service request.
S220, acquiring the target server address corresponding to the service request, and determining the target machine code corresponding to the service request based on the target server address.
In this embodiment, since the target machine code is generated based on the IP address of the target server without being dependent on the data center ID and the data node ID, there are at least two ways to generate the corresponding target machine code based on the IP address, which will be described below.
The first way is to obtain the address of the target server and determine the target machine code based on the service components deployed in advance.
The pre-deployed service component can be a Zookeeper, the component serves as an open-source project and provides distributed configuration service, synchronization service and naming registration for large-scale distributed computing, and the framework of the component achieves high availability through redundant services. Specifically, in this embodiment, after the IP address of the target server associated with the service request is obtained based on the cloud native environment, the ID of the machine may be generated by using the Zookeeper deployed in advance, which is not described herein again in this embodiment of the disclosure.
The second way is to obtain the address of the target server and convert the address of the target server into a corresponding binary address field; and combining the specified field edited in advance and the last eight bits of the binary address field to obtain the target machine code.
For example, after the IP address "192.168.1.123" of the target server is obtained, 8 bits (i.e. 123) after the IP address is selected to be converted into the corresponding binary address field "01111011", and meanwhile, since the target machine code constructed in the present embodiment is 10 bits, after the binary address field is obtained, two bits (usually default to 0) specified by the user need to be combined with the field to obtain the ten-bit target machine code "0001111011".
It should be noted that, since the present embodiment only depends on the machine IP address to generate the corresponding target machine code, the number of associated machines does not exceed 1024 machines for a single application service.
S230, calculating a difference value between the timestamp information to be processed and the preset timestamp information to obtain target timestamp information, converting the target timestamp information into a corresponding binary system time field, and determining the binary system time field as a target time code.
In this embodiment, after receiving the service request and determining the to-be-processed timestamp information carried by the request and the preset timestamp information of the distributed system, calculation may be performed based on the two pieces of information, and an obtained difference value is used as the target timestamp information, and further, the target timestamp information may be converted by using a method similar to that for obtaining the target machine code by conversion, so as to obtain a 32-bit binary time field, which is used as the target time code.
It should be noted that, in this embodiment, for each service request, the unit of each corresponding timestamp information is second, and the timestamp unit in the existing snowflake algorithm generation identifier is modified from millisecond to second, so that the algorithm after the variation optimization has an effective period of 136 years, which is longer than the effective period of 69 years of the native algorithm, that is, the modified algorithm can support a longer age while reducing the number of IDs generated per second.
S240, determining a target time according to the to-be-processed timestamp information, and determining a to-be-processed sequence code corresponding to a service request before the service request in a service request list associated with the target time; and accumulating the sequence codes to be processed to obtain the target sequence code.
In this embodiment, when the to-be-processed timestamp information corresponding to the service request is determined, not only the target time code but also a target sequence code corresponding to the service request may be determined.
Specifically, a target time corresponding to the timestamp information is determined, for example, a time at which the distributed system receives the service request is determined, then all the service requests received at the time are determined in a service request list of the system, further, a sequence code corresponding to a request before the current service request is used as a sequence code to be processed, and the sequence code is added by one to obtain a target sequence code corresponding to the current service request. In the actual application process, the target sequence code may be regarded as a self-increment code, that is, when the number of service requests received in one second does not reach 1048576, the target sequence code corresponding to each service request may be sequentially incremented according to the sequence received by the system.
And S250, sequentially splicing the target reserved code, the target machine code, the target time code and the target sequence code from left to right, and determining the obtained splicing result as the target identifier.
In this embodiment, after the target reserved code, the target machine code, the target time code, and the target sequence code are determined, the four pieces of information are sequentially spliced from left to right to obtain the target identifier corresponding to the service request, where in the target identifier, the target reserved code occupies 2 bits, the target machine code occupies 10 bits, the target time code occupies 32 bits, and the target sequence code occupies 20 bits. Illustratively, after determining that the target reserved code is 00, the target machine code is 0001110101, the target time code is 00011101101111101110110101110010, and the target sequence code is 00011101010100111100, the above information is spliced, and the obtained 0000011101010001110110111110111011010111001000011101010100111100 is the target identifier corresponding to the service request.
And S260, when a new service request carrying timestamp information to be processed is received, detecting the target sequence code, and when the numerical value corresponding to the target sequence code is smaller than a preset threshold value, accumulating the target sequence code to obtain the target sequence code corresponding to the new service request.
It should be noted that after determining the to-be-processed timestamp information corresponding to the new service request, if it is determined that the number of IDs generated at this time is smaller than the preset threshold 1048576, the target sequence codes may be accumulated on the basis of the last generated ID, so as to obtain the target sequence code corresponding to the new service request, and when the number of IDs has reached 1048576, the target sequence code corresponding to the new service request needs to be generated based on the target program code being blocked to the next second.
According to the technical scheme of the embodiment, the 64-bit ID constructed by the existing snowflake algorithm is divided again, the 2-bit target reserved bit, the 10-bit target machine code, the 32-bit target time code and the 20-bit target sequence code are adopted, and the form is in units of seconds, so that the application service corresponding to the service request can be reflected, the business requirements of enterprises are further met, and the algorithm after variant optimization supports longer years while the original self-increment and high-efficiency characteristics of the snowflake algorithm are reserved.
EXAMPLE III
Fig. 3 is a block diagram of a structure of an identifier generating apparatus according to a third embodiment of the present invention, which is capable of executing an identifier generating method according to any embodiment of the present invention, and has functional modules and beneficial effects corresponding to the executing method. As shown in fig. 3, the apparatus specifically includes: target reserved code determination module 310, target machine code determination module 320, target timecode determination module 330, and target identification determination module 340.
A targeted reservation code determination module 310, configured to determine, upon receiving a service request, a targeted reservation code corresponding to the service request.
And a target machine code determining module 320, configured to obtain a target server address corresponding to the service request, and determine a target machine code corresponding to the service request based on the target server address.
And a target time code determining module 330, configured to determine a target time code corresponding to the service request according to the to-be-processed timestamp information and the preset timestamp information carried in the service request.
And a target identifier determining module 340, configured to determine a target sequence code corresponding to the service request according to the to-be-processed timestamp information, and construct a target identifier corresponding to the service request according to the target reserved code, the target machine code, the target time code, and the target sequence code.
Optionally, the target reserved code determining module 310 is further configured to determine, when the service request is received, a target process corresponding to the service request in the distributed system, and determine the target reserved code according to the last two digits of the number of the target process.
Optionally, the target machine code determining module 320 is further configured to obtain the address of the target server, and determine the target machine code based on a service component deployed in advance; or, obtaining the address of the target server and converting the address of the target server into a corresponding binary address field; and combining the specified field edited in advance and the last eight bits of the binary address field to obtain the target machine code.
On the basis of the above technical solutions, the target time code determining module 330 includes a target timestamp information determining unit and a target time code determining unit.
And the target timestamp information determining unit is used for calculating the difference value between the to-be-processed timestamp information and the preset timestamp information to obtain target timestamp information, wherein the unit of each piece of timestamp information is second.
And the target time code determining unit is used for converting the target timestamp information into a corresponding binary time field and determining the binary time field as the target time code.
On the basis of the above technical solutions, the target identifier determining module 340 includes a target sequence code determining unit and a target identifier determining unit.
A target sequence code determining unit, configured to determine a target time according to the to-be-processed timestamp information, and determine, in a service request list associated with the target time, a to-be-processed sequence code corresponding to a service request that is previous to the service request; and accumulating the sequence codes to be processed to obtain the target sequence code.
A target identifier determining unit, configured to sequentially splice the target reserved code, the target machine code, the target time code, and the target sequence code from left to right, and determine an obtained splicing result as the target identifier; in the target identifier, the target reserved code occupies 2 bits, the target machine code occupies 10 bits, the target time code occupies 32 bits, and the target sequence code occupies 20 bits.
On the basis of the above technical solutions, the identifier generating apparatus further includes a detection module.
And the detection module is used for detecting the target sequence code when a new service request carrying the to-be-processed timestamp information is received, and accumulating the target sequence code when the value corresponding to the target sequence code is smaller than a preset threshold value so as to obtain the target sequence code corresponding to the new service request.
The technical solution provided by this embodiment, when receiving a service request, determines a target reserved code corresponding to the service request, acquires a target server address corresponding to the service request, determines a target machine code corresponding to the service request based on the target server address, determines a target time code corresponding to the service request according to-be-processed timestamp information and preset timestamp information carried in the service request, determines a target sequence code corresponding to the service request according to-be-processed timestamp information, and finally fuses the above various information, that is, a target identifier corresponding to the service request is constructed according to the target reserved code, the target machine code, the target time code, and the target sequence code, and by implementing a variant of a snowflake algorithm, the composition of each part of a generated main key is changed, not only the number of generated IDs per second is reduced, the waste of a large amount of IDs is avoided, the target machine code is generated by utilizing the server address, the dependence of a traditional primary key generation mode on the data center IDs and the data node IDs is eliminated, and the flexibility of the algorithm is enhanced.
The identifier generation device provided by the embodiment of the invention can execute the identifier generation method provided by any embodiment of the invention, and has corresponding functional modules and beneficial effects of the execution method.
It should be noted that, the units and modules included in the apparatus are merely divided according to functional logic, but are not limited to the above division as long as the corresponding functions can be implemented; in addition, specific names of the functional units are only for convenience of distinguishing from each other, and are not used for limiting the protection scope of the embodiment of the invention.
Example four
Fig. 4 is a schematic structural diagram of an electronic device according to a fourth embodiment of the present invention. FIG. 4 illustrates a block diagram of an exemplary electronic device 40 suitable for use in implementing embodiments of the present invention. The electronic device 40 shown in fig. 4 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiment of the present invention.
As shown in fig. 4, electronic device 40 is embodied in the form of a general purpose computing device. The components of electronic device 40 may include, but are not limited to: one or more processors or processing units 401, a system memory 402, and a bus 403 that couples the various system components (including the system memory 402 and the processing unit 401).
Bus 403 represents one or more of any of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, and a processor or local bus using any of a variety of bus architectures. By way of example, such architectures include, but are not limited to, Industry Standard Architecture (ISA) bus, micro-channel architecture (MAC) bus, enhanced ISA bus, Video Electronics Standards Association (VESA) local bus, and Peripheral Component Interconnect (PCI) bus.
Electronic device 40 typically includes a variety of computer system readable media. Such media may be any available media that is accessible by electronic device 40 and includes both volatile and nonvolatile media, removable and non-removable media.
The system memory 402 may include computer system readable media in the form of volatile memory, such as Random Access Memory (RAM)404 and/or cache memory 405. The electronic device 40 may further include other removable/non-removable, volatile/nonvolatile computer system storage media. By way of example only, storage system 406 may be used to read from and write to non-removable, nonvolatile magnetic media (not shown in FIG. 4, and commonly referred to as a "hard drive"). Although not shown in FIG. 4, a magnetic disk drive for reading from and writing to a removable, nonvolatile magnetic disk (e.g., a "floppy disk") and an optical disk drive for reading from or writing to a removable, nonvolatile optical disk (e.g., a CD-ROM, DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to the bus 403 by one or more data media interfaces. Memory 402 may include at least one program product having a set (e.g., at least one) of program modules that are configured to carry out the functions of embodiments of the invention.
A program/utility 408 having a set (at least one) of program modules 407 may be stored, for example, in memory 402, such program modules 407 including, but not limited to, an operating system, one or more application programs, other program modules, and program data, each of which examples or some combination thereof may comprise an implementation of a network environment. Program modules 407 generally perform the functions and/or methods of the described embodiments of the invention.
The electronic device 40 may also communicate with one or more external devices 409 (e.g., keyboard, pointing device, display 410, etc.), with one or more devices that enable a user to interact with the electronic device 40, and/or with any devices (e.g., network card, modem, etc.) that enable the electronic device 40 to communicate with one or more other computing devices. Such communication may be through input/output (I/O) interface 411. Also, the electronic device 40 may communicate with one or more networks (e.g., a Local Area Network (LAN), a Wide Area Network (WAN), and/or a public network, such as the internet) via the network adapter 412. As shown, the network adapter 412 communicates with the other modules of the electronic device 40 over the bus 403. It should be appreciated that although not shown in FIG. 4, other hardware and/or software modules may be used in conjunction with electronic device 40, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems, among others.
The processing unit 401 executes various functional applications and data processing, for example, implementing the identifier generation method provided by the embodiment of the present invention, by executing the program stored in the system memory 402.
EXAMPLE five
Fifth, an embodiment of the present invention further provides a storage medium containing computer-executable instructions, which when executed by a computer processor, perform an identifier generation method.
The method comprises the following steps:
upon receiving a service request, determining a target reservation code corresponding to the service request;
acquiring a target server address corresponding to the service request, and determining a target machine code corresponding to the service request based on the target server address;
determining a target time code corresponding to the service request according to the to-be-processed timestamp information carried by the service request and preset timestamp information;
and determining a target sequence code corresponding to the service request according to the to-be-processed timestamp information, and constructing a target identifier corresponding to the service request according to the target reserved code, the target machine code, the target time code and the target sequence code.
Computer storage media for embodiments of the invention may employ any combination of one or more computer-readable media. The computer readable medium may be a computer readable signal medium or a computer readable storage medium. 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 (a non-exhaustive list) of the computer readable storage medium would include the following: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this document, 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.
A computer readable signal medium may include a propagated data signal with computer readable item code embodied therein, for example, 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.
The item code embodied on the computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
Computer project code for carrying out operations for embodiments of the present invention may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C + + or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The project 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).
It is to be noted that the foregoing is only illustrative of the preferred embodiments of the present invention and the technical principles employed. It will be understood by those skilled in the art that the present invention is not limited to the particular embodiments described herein, but is capable of various obvious changes, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the invention. Therefore, although the present invention has been described in greater detail by the above embodiments, the present invention is not limited to the above embodiments, and may include other equivalent embodiments without departing from the spirit of the present invention, and the scope of the present invention is determined by the scope of the appended claims.

Claims (10)

1. An identifier generation method, comprising:
upon receiving a service request, determining a target reservation code corresponding to the service request;
acquiring a target server address corresponding to the service request, and determining a target machine code corresponding to the service request based on the target server address;
determining a target time code corresponding to the service request according to the to-be-processed timestamp information carried by the service request and preset timestamp information;
and determining a target sequence code corresponding to the service request according to the to-be-processed timestamp information, and constructing a target identifier corresponding to the service request according to the target reserved code, the target machine code, the target time code and the target sequence code.
2. The method of claim 1, wherein determining the target reservation code corresponding to the service request upon receiving the service request comprises:
and when the service request is received, determining a target process corresponding to the service request in a distributed system, and determining the target reserved code according to the last two digits of the number of the target process.
3. The method of claim 1, wherein obtaining a target server address corresponding to the service request and determining a target machine code corresponding to the service request based on the target server address comprises:
acquiring the address of the target server, and determining the target machine code based on a service component deployed in advance; alternatively, the first and second electrodes may be,
acquiring the address of the target server, and converting the address of the target server into a corresponding binary address field;
and combining the specified field edited in advance and the last eight bits of the binary address field to obtain the target machine code.
4. The method according to claim 1, wherein the determining a target time code corresponding to the service request according to the to-be-processed timestamp information and the preset timestamp information carried in the service request comprises:
calculating a difference value between the timestamp information to be processed and the preset timestamp information to obtain target timestamp information, wherein the unit of each timestamp information is second;
and converting the target timestamp information into a corresponding binary time field, and determining the binary time field as the target time code.
5. The method of claim 1, wherein determining the target sequence code corresponding to the service request according to the pending timestamp information comprises:
determining a target time according to the to-be-processed timestamp information, and determining a to-be-processed sequence code corresponding to a service request before the service request in a service request list associated with the target time;
and accumulating the sequence codes to be processed to obtain the target sequence code.
6. The method of claim 1, wherein constructing the target identity corresponding to the service request according to the target reservation code, the target machine code, the target time code, and the target sequence code comprises:
sequentially splicing the target reserved code, the target machine code, the target time code and the target sequence code from left to right, and determining an obtained splicing result as the target identifier;
in the target identifier, the target reserved code occupies 2 bits, the target machine code occupies 10 bits, the target time code occupies 32 bits, and the target sequence code occupies 20 bits.
7. The method of claim 1, further comprising:
and when a new service request carrying the to-be-processed timestamp information is received, detecting the target sequence code, and when the value corresponding to the target sequence code is smaller than a preset threshold value, accumulating the target sequence code to obtain the target sequence code corresponding to the new service request.
8. An identifier generation apparatus, comprising:
the target reservation code determining module is used for determining a target reservation code corresponding to the service request when the service request is received;
the target machine code determining module is used for acquiring a target server address corresponding to the service request and determining a target machine code corresponding to the service request based on the target server address;
the target time code determining module is used for determining a target time code corresponding to the service request according to the to-be-processed time stamp information carried by the service request and preset time stamp information;
and the target identification determining module is used for determining a target sequence code corresponding to the service request according to the to-be-processed timestamp information and constructing a target identification corresponding to the service request according to the target reserved code, the target machine code, the target time code and the target sequence code.
9. An electronic device, characterized in that the electronic device comprises:
one or more processors;
a storage device for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement the identity generation method of any of claims 1-7.
10. A storage medium containing computer-executable instructions for performing the identity generation method of any one of claims 1-7 when executed by a computer processor.
CN202111659877.8A 2021-12-30 2021-12-30 Identification generation method and device, electronic equipment and storage medium Pending CN114356925A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111659877.8A CN114356925A (en) 2021-12-30 2021-12-30 Identification generation method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111659877.8A CN114356925A (en) 2021-12-30 2021-12-30 Identification generation method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN114356925A true CN114356925A (en) 2022-04-15

Family

ID=81105177

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111659877.8A Pending CN114356925A (en) 2021-12-30 2021-12-30 Identification generation method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN114356925A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116010413A (en) * 2022-12-27 2023-04-25 箭牌家居集团股份有限公司 Identification generation method, server and storage medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116010413A (en) * 2022-12-27 2023-04-25 箭牌家居集团股份有限公司 Identification generation method, server and storage medium
CN116010413B (en) * 2022-12-27 2024-02-06 箭牌家居集团股份有限公司 Identification generation method, server and storage medium

Similar Documents

Publication Publication Date Title
CN108681565B (en) Block chain data parallel processing method, device, equipment and storage medium
CN111090628B (en) Data processing method and device, storage medium and electronic equipment
CN111737022B (en) Micro-service-based interface calling method, system, equipment and medium
CN112738791A (en) User information correlation backfill method, device, equipment and medium based on 5G core network
CN114528044B (en) Interface calling method, device, equipment and medium
CN111324441A (en) Operating environment switching method and device, computer equipment and storage medium
CN113204345A (en) Page generation method and device, electronic equipment and storage medium
CN114356925A (en) Identification generation method and device, electronic equipment and storage medium
CN113656193A (en) Application communication method, system, electronic equipment and storage medium
CN110737678B (en) Data searching method, device, equipment and storage medium
CN112069158A (en) Data restoration method, device, equipment and storage medium
CN111510499A (en) Communication method, device, equipment and storage medium
CN113986995A (en) Request distribution method and device, storage medium and electronic equipment
CN113919310A (en) Short message content determination method and device, electronic equipment and storage medium
CN114282968A (en) Serial number acquisition method, device, server and storage medium
CN112866979B (en) User information association method, device, equipment and medium based on 5G service interface
CN111489212B (en) Order billing method, device, equipment and medium based on big data
CN113760920A (en) Data synchronization method and device, electronic equipment and storage medium
CN111061744B (en) Graph data updating method and device, computer equipment and storage medium
CN111628996A (en) Electronic data communication method and system based on Internet of things
CN112312148B (en) Business function starting method and device, electronic equipment and storage medium
CN112445790B (en) Report data storage method, device, equipment and medium
CN110046192B (en) System and method for generating serial number of request information
CN113806416B (en) Method and device for realizing real-time data service and electronic equipment
CN115484149B (en) Network switching method, network switching device, electronic equipment and storage medium

Legal Events

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