CN110505306B - Data ID generation method capable of specifying digit - Google Patents

Data ID generation method capable of specifying digit Download PDF

Info

Publication number
CN110505306B
CN110505306B CN201910811184.2A CN201910811184A CN110505306B CN 110505306 B CN110505306 B CN 110505306B CN 201910811184 A CN201910811184 A CN 201910811184A CN 110505306 B CN110505306 B CN 110505306B
Authority
CN
China
Prior art keywords
value
length
mac
temp
data
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201910811184.2A
Other languages
Chinese (zh)
Other versions
CN110505306A (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.)
Traffic Management Research Institute of Ministry of Public Security
Original Assignee
Traffic Management Research Institute of Ministry of Public Security
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 Traffic Management Research Institute of Ministry of Public Security filed Critical Traffic Management Research Institute of Ministry of Public Security
Priority to CN201910811184.2A priority Critical patent/CN110505306B/en
Publication of CN110505306A publication Critical patent/CN110505306A/en
Application granted granted Critical
Publication of CN110505306B publication Critical patent/CN110505306B/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/50Network services
    • H04L67/51Discovery or management thereof, e.g. service location protocol [SLP] or web services
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/06Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols the encryption apparatus using shift registers or memories for block-wise or stream coding, e.g. DES systems or RC4; Hash functions; Pseudorandom sequence generators
    • H04L9/0643Hash functions, e.g. MD5, SHA, HMAC or f9 MAC
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L2101/00Indexing scheme associated with group H04L61/00
    • H04L2101/60Types of network addresses
    • H04L2101/618Details of network addresses
    • H04L2101/622Layer-2 addresses, e.g. medium access control [MAC] addresses

Abstract

The invention provides a data ID generation method capable of assigning digits, which can generate a unique data ID by operating alone without relying on other services and can continuously and efficiently generate the data ID in a distributed environment and a high-concurrency scene. In the technical scheme of the invention, a 10-system initial data ID value is obtained by acquiring the map of the server which provides the data service request and the jvmpid of the application process and performing bit OR operation by using the map, the jvmpid, the timestamp and the self-increment value; and finally, according to the appointed digit, computing the ID value of the initial data through a uuid algorithm to generate the unique ID of the appointed digit.

Description

Data ID generation method capable of specifying digit
Technical Field
The invention relates to the technical field of computer communication, in particular to a data ID generation method capable of specifying digit.
Background
After the public security traffic integrated command platform is popularized nationwide for three times, the national traffic police headquarters and the branch teams complete the installation and deployment of the integrated platform. The total number of the installation points of 31 general teams and 309 branch teams in the whole country is 6.2 hundred million pieces of traffic track information, 272 ten thousand pieces of traffic violation information and 33 ten thousand pieces of other various information, and the data access volume of each part is increased explosively. As shown in fig. 1, a public security traffic integrated command platform 1 has been installed and deployed in each region, a front-end device or a management platform 4 accesses to a data transmission exchange server 2 located in a private traffic network through an integrated platform data access cluster 3, applies for various services to each server such as an image storage server 5 and a database server 6, and sets an enough integrated platform access server 7 in the integrated platform data access cluster 3; the original data ID generation method depends on the self-increment sequence of services such as a database, an image storage service and the like, the ID repetition phenomenon occurs in a lot of cities with large data volume, and the generated junk data seriously influences the normal use of the system; even the phenomena of database downtime and data access service blocking occur when the concurrency is large; moreover, since connection with a database or other server is required to be established every time an ID is acquired, connection time is consumed, performance of access service cannot be improved, and all places can only be relieved by means of stacking servers, which causes unnecessary resource waste.
Disclosure of Invention
In order to solve the problems that in the prior art, data ID generation is limited by other services to generate repeated IDs and the time consumption for acquiring the data IDs is long, the invention provides a data ID generation method capable of assigning digits, which is independent of other services, operates and generates unique data IDs and can continuously and efficiently generate the data IDs in a distributed environment and a high-concurrency scene.
The technical scheme of the invention is as follows: a data ID generation method capable of designating digit, characterized by comprising the steps of:
s1: in the data transmission exchange server, the system acquires the expected bit number ID.Length of the data ID required by each data service according to the requirement of each accessed data service request;
s2: acquiring a server address map of an integrated platform access server which provides the data service request, and obtaining a 5-bit machine address value MAC.ID (media access control) of a 2-system after calculating based on a Hash algorithm;
s3: acquiring jvmpid of the corresponding application process of the data service request in the integrated platform access server, and obtaining a 5-bit 2-system process address value JVCMP.ID after calculation based on a Hash algorithm;
s4: acquiring initial time Time.Standard preset in the data transmission exchange server system;
s5: obtaining the current time of the data transmission switching server system, calculating the difference between the current time and the initial time to obtain a timestamp time;
s6: left-shifting the binary value of the timestamp by 32 bits to obtain a temporary timestamp value;
s7: left-shifting the binary value of the machine address MAC.ID by 27 bits to obtain a temporary machine address value;
s8: left-shifting the binary value of the process address value JVCMP.ID by 22 bits to obtain a temporary process address value;
s9: setting a 22-bit auto-increment value, wherein the initial value of the auto-increment value is 0;
s10: performing bit OR operation on the temporary timestamp value, the temporary machine address value, the temporary process address value and the initial value of the self-increment value to obtain an initial data ID value original.ID;
s11: length, based on UUID algorithm, converting the initial data ID into ID value of assigned digit, namely obtaining final assigned length data ID.
It is further characterized in that:
in step S2, the method for calculating the machine address value mac.id includes the following steps:
s2-1: acquiring the IP address of the integrated platform access server, and quitting the calculation if the acquisition fails;
if the IP address is successfully acquired, acquiring a mac address of the server according to the IP address of the server;
s2-2: length of the server address, mac;
s2-3: converting the macid with the length of mac.length bit into a long type numerical value to obtain Mac _ temp 1;
s2-4: carrying out bit AND calculation on the binary value of the Mac _ temp1 and 0x000000ff to obtain Mac _ temp 2;
s2-5: converting the macid with the length of mac.length-1 bit into a long type numerical value to obtain Mac _ temp 3;
s2-6: the binary value of the Mac _ temp3 is shifted left by 8 bits to obtain Mac _ temp 4;
s2-7: after 0x000000ff is shifted to the left by 8 bits, performing AND operation on the binary value of Mac _ temp4 to obtain Mac _ temp 5;
s2-8: performing bit OR operation on the binary value of the Mac _ temp2 and the binary value of the Mac _ temp5 to obtain Mac _ temp 6;
s2-9: the binary value of the Mac _ temp6 is shifted right by 6 bits to obtain Mac _ temp 7;
s2-10: dividing the decimal value of Mac _ temp7 by 32 and then taking the remainder, wherein the obtained value is the machine address value MAC.ID;
in step S3, the method for calculating the process address value jcmp.id includes the following steps:
s3-1: acquiring the application process information jvmpid;
if the application process information jvmpid is failed to be obtained, assigning the value of the machine address value MAC.ID to the JVM _ temp1, and executing S3-3;
s3-2: splicing the machine address value MAC.ID and the application process information jvmpid to obtain JVM _ temp 1;
s3-3, calculating hashcode of JVM _ temp1 to obtain JVM _ temp 2;
s3-4: carrying out bit AND operation on the 16-system values of JVM _ temp2 and 65535 to obtain JVM _ temp 3;
s3-5: dividing the decimal value JVM _ temp3 by 32 and then taking the remainder, wherein the obtained value is the process address value JVCMP.ID;
in step S5, the method for calculating the timestamp time includes the following steps:
s5-1: comparing the current time with the initial time standard;
s5-2: if time.current = time.standard, it is confirmed whether the counter is full,
if the counter is not full, the counter is incremented by 1, and the step S5-3 is executed;
otherwise, if the counter is full, waiting for the next second, and executing the step S5-3;
if the time is greater than the time standard, initializing a counter, and then executing step S5-3;
if the current is time, the system is abnormal, and the calculation is finished;
s5-3: calculating a difference value between the current time and the initial time to obtain a time difference value, wherein the time difference value is the timestamp time;
in step S11, the method for obtaining the data ID of the specified length by calculation includes the following steps:
s11-1: creating an empty array ID [ ID.Length ], the length of which is the expected digit ID.Length;
s11-2: acquiring a Copy ID _ Copy preset in a system, wherein the Copy ID _ Copy is a character string with a fixed length, and the length of the character string is Max _ RADIX;
s11-2: confirming the relationship between the initial data ID value original.ID and 0:
if original.ID > 0, the intermediate value ID _ Temp is assigned-original.ID;
otherwise, the intermediate value ID _ Temp is assigned as original.ID if the original.ID is less than 0;
s11-3: converting the initial data ID value original. ID to string ID _ Temp2 using a UUID algorithm based on the intermediate value ID _ Temp, the Copy ID _ Copy;
s11-4: comparing the bit number ID _ Temp2_ length of ID _ Temp2 with the expected bit number id.length:
if ID _ Temp2_ length < id.length, 0 is supplemented to the upper bit of ID _ Temp2 until ID _ Temp2_ length = id.length, and then a new value is assigned to ID _ Temp 2;
if the ID _ Temp2_ length > ID.Length, intercepting the low ID.Length bit value of ID _ Temp2, assigning the low ID.Length bit value to ID _ Temp2, and assigning the ID.Length value to ID _ Temp2_ length;
s11-5: when the ID _ Temp2_ length = ID.Length, taking out the value of ID _ Temp2, and assigning the value to the data ID with the specified length, namely obtaining the final data ID with the specified number of bits;
in step S11-3, converting the initial data ID value original. ID to string ID _ Temp2 using UUID algorithm, including the steps of:
s11-3-1: comparing the intermediate value with the maximum number of bits Max _ RADIX of the copy;
if ID _ Temp < -Max _ RADIX, then the following calculation is performed:
a 1: length is obtained after ID _ Temp is divided by the number of digits ID _ copy of the copy, the remainder is assigned to a remainder Temp _ Remain, and the obtained quotient value is assigned to a quotient Temp _ Quot;
a 2: after acquiring the character of the TempV1 th bit in the Copy ID _ Copy, putting the character into the lowest bit in the array ID [ ID.Length ];
a 3: assigning the value of the quotient Temp _ Quot to the intermediate value ID _ Temp;
a 4: the lowest bit of the array ID [ ID.Length ] is moved forward by 1 bit;
a 5: executing the step S11-3-1;
otherwise, if ID _ Temp > -Max _ RADIX, S11-3-2 is performed;
s11-3-2: the characters in the array ID [ ID.Length ] are converted to the value ID _ Temp2 of character type.
The invention provides a data ID generating method capable of assigning digits, which is characterized in that a 10-system initial data ID value is obtained by acquiring a map of a server for providing a data service request and a jvmpid of an application process and performing bit OR operation by using the map, the jvmpid, a timestamp and a self-increment value; finally, according to the appointed digit, computing the ID value of the initial data through a uuid algorithm to generate an unique ID of the appointed digit; data are distinguished through the server address macid and the jvmpid of the application process, and the 5-bit macid and the 5-bit jvmid have 1024 combinations in total, so that the probability of data ID collision in a distributed system is reduced; through time stamp division, the IDs generated in each second are subjected to self-increment sequencing through the time stamps; the self-increment value is 22 bits, namely, 22 power data IDs of 2 can be generated every second, and the ID collision cannot be generated in the whole system; and finally, based on a UUID algorithm, converting the generated data ID into the data ID with the appointed digit, and ensuring that the requirements of different digits can be met. In the technical scheme of the invention, the process of generating the data ID does not depend on an external database, but is independently generated in a public security traffic integrated command platform, so that the method has good compatibility and expandability; and the UUID algorithm, the Hash algorithm and the SnowFlake algorithm can be used in a distributed environment, and the ID can be continuously and efficiently generated in a high-concurrency scene.
Drawings
FIG. 1 is a schematic diagram of a system according to an embodiment of the present invention;
FIG. 2 is a schematic diagram of a process for converting an initial data ID value to a specified length data ID using the UUID algorithm.
Detailed Description
As shown in fig. 1 to 2, a method for generating a data ID with a specifiable number of bits includes the following steps:
s1: in the data transmission exchange server 2, the system acquires the expected length of the data ID required by each data service, i.e. the expected bit number id.length, according to the requirement of each accessed data service request;
s2: acquiring a server address map of an integrated platform access server 7 which provides a data service request, and calculating based on a Hash algorithm to obtain a 5-bit machine address value MAC.ID of 2-system;
s3: acquiring jvmpid of an application process corresponding to the data service request in the integrated platform access server 7, and obtaining a 5-bit 2-system process address value JVCMP.ID after calculating based on a Hash algorithm;
s4: acquiring initial time Time.Standard preset in a data transmission exchange server 2 system;
s5: acquiring the current time of the data transmission switching server 2 system, and calculating the difference between the current time and the initial time to obtain a timestamp time;
s6: left-shifting the binary value of the timestamp by 32 bits to obtain a temporary timestamp value;
s7: the binary value of the machine address MAC.ID is shifted to the left by 27 bits to obtain a temporary machine address value;
s8: the binary value of the process address value JVCMP.ID is shifted to the left by 22 bits to obtain a temporary process address value;
s9: setting a 22-bit auto-increment value, wherein the initial value of the auto-increment value is 0;
s10: carrying out bit OR operation on the temporary timestamp value, the temporary machine address value, the temporary process address value and the initial value of the self-increment to obtain an initial data ID value origin.ID;
s11: length, based on UUID algorithm, converting the initial data ID into ID value of specified bit number, i.e. obtaining final specified length data ID.
The initial data ID structure generated in step S10 is as follows:
1||0 - 0000000000 0000000000 0000000000 0 - 00000 -00000 -0000000000 0000000000 00
this is a 64-bit string ID; in the character string, the first bit is unused and can be reserved as the sign bit of the long character string, and the next 31 bits are second-level time; the next 5 mac address identification bits, 5 jvmpid; the last 22 bits are the counts in the current second, and the sum is just 64 bits to form a Long type character string; the generated long type is finally converted into a 36-system through a UUID algorithm.
The mac address and the jvmpid are used for distinguishing, and the whole system is sorted according to the time increment, so that the ID collision can not be generated in the whole distributed system.
That is, the 64-bit ID includes: (32 (sec) +5 (madid) +5(jvmpid) +22 (repeat accumulate))
Timestamp (31 bits are accounted for): seconds, i.e., 31 times second of 2, can be used for about 69 years;
macid (5 bits are occupied): i.e. 2 to the power of 5 equals 32 machines;
jvmpid (5 bits): i.e. a power of 5 of 2 equals 32 processes;
self-increment (22 bits occupied): the 22 nd power of 2 equals 4,194,304. That is, up to 419 ten thousand ids can be generated per second, if the cpu produces ids faster than 419 ten thousand per second, then the thread needs to wait until the next second and recount is taken from the increment.
In step S2, the method for calculating a machine address value mac.id includes the steps of:
s2-1: acquiring the IP address of the integrated platform access server 7, and quitting the calculation if the acquisition fails;
if the IP address is successfully acquired, acquiring a mac address of the server according to the IP address of the server;
if the mac address acquisition fails, assigning 1 to the macid;
s2-2: length of the server address, mac;
s2-3: converting the macid with the length of mac.length bit into a long type numerical value to obtain Mac _ temp 1;
s2-4: carrying out bit AND calculation on the binary value of the Mac _ temp1 and 0x000000ff to obtain Mac _ temp 2;
s2-5: converting the macid with the length of mac.length-1 bit into a long type numerical value to obtain Mac _ temp 3;
s2-6: the binary value of the Mac _ temp3 is shifted left by 8 bits to obtain Mac _ temp 4;
s2-7: after 0x000000ff is shifted to the left by 8 bits, performing AND operation on the binary value of Mac _ temp4 to obtain Mac _ temp 5;
s2-8: performing bit OR operation on the binary value of the Mac _ temp2 and the binary value of the Mac _ temp5 to obtain Mac _ temp 6;
s2-9: the binary value of the Mac _ temp6 is shifted right by 6 bits to obtain Mac _ temp 7;
s2-10: the decimal value of Mac temp7 is divided by 32 to obtain the remainder, and the obtained value is the machine address value mac.id.
In step S3, the method for calculating a process address value jvcmp.id includes the steps of:
s3-1: acquiring application process information jvmpid;
if the acquisition of the application process information jvmpid fails, assigning the value of the machine address value MAC.ID to JVM _ temp1, and executing S3-3;
s3-2: splicing the machine address value MAC.ID and the application process information jvmpid to obtain JVM _ temp 1;
s3-3, calculating hashcode of JVM _ temp1 to obtain JVM _ temp 2;
s3-4: carrying out bit AND operation on the 16-system values of JVM _ temp2 and 65535 to obtain JVM _ temp 3;
s3-5: dividing the decimal value JVM _ temp3 by 32 and then taking the remainder, wherein the obtained value is the process address value JVCMP.ID;
in step S5, the method for calculating the timestamp time includes the following steps:
s5-1: comparing the current time with the initial time;
s5-2: if time.current = time.standard, it is confirmed whether the counter is full,
if the counter is not full, the counter is incremented by 1, and the step S5-3 is executed;
otherwise, if the counter is full, waiting for the next second, and executing the step S5-3;
if the time is greater than the time standard, initializing a counter, and then executing step S5-3;
if the current is time, the system is abnormal, and the calculation is finished;
s5-3: and calculating the difference between the current time and the initial time to obtain a time difference, wherein the time difference is the timestamp time.
Calculating a process address value JVCMP.ID based on a SnowFlake algorithm, obtaining a timestamp of the current data ID by calculating the current time and the preset initial time in the system, confirming whether the number of the data IDs generated in the current 1 second exceeds 419 supported by the system through a counter, waiting the thread for the next second if the speed of cpu generating the ID is more than 419 ten thousand per second, recounting to obtain a self-increment value, further avoiding the problem of ID collision caused by excessive data requirements, and ensuring that the data IDs in an interactive system cannot generate collision.
In step S11, the method for obtaining the data ID of the specified length by calculation includes the following steps:
s11-1: creating an empty array ID [ ID.Length ], wherein the length of the empty array ID [ ID.Length ] is the expected digit ID.Length;
s11-2: acquiring Copy ID _ Copy preset in a system, wherein the Copy ID _ Copy is a character string with a fixed length, and the length of the character string is Max _ RADIX;
s11-2: confirm the relationship of initial data ID value original.id and 0:
if original.ID > 0, the intermediate value ID _ Temp is assigned-original.ID;
otherwise, the intermediate value ID _ Temp is assigned as original.ID if the original.ID is less than 0;
s11-3: converting the initial data ID value origin to the string ID _ Temp2 using UUID algorithm based on the intermediate value ID _ Temp, Copy ID _ Copy;
using UUID algorithm to convert the initial data ID value original. ID to string ID _ Temp2, comprising the steps of:
s11-3-1: comparing the intermediate value with the maximum bit number Max _ RADIX of the copy;
if ID _ Temp < -Max _ RADIX, then the following calculation is performed:
a 1: length is obtained after ID _ Temp is divided by the number of digits ID _ copy of the copy, the remainder is assigned to a remainder Temp _ Remain, and the obtained quotient value is assigned to a quotient Temp _ Quot;
a 2: after acquiring the character of the TempV1 th bit in the Copy ID _ Copy, putting the character into the lowest bit in the array ID [ ID.Length ];
a 3: assigning the value of the quotient Temp _ Quot to an intermediate value ID _ Temp;
a 4: the lowest bit of the array ID [ id.length ] is shifted forward by 1 bit;
a 5: executing the step S11-3-1;
otherwise, if ID _ Temp > -Max _ RADIX, S11-3-2 is performed;
s11-3-2: converting characters in the array ID [ ID.Length ] into a value ID _ Temp2 of the character type;
s11-4: comparing the bit number ID _ Temp2_ length of ID _ Temp2 with the expected bit number id.length:
if ID _ Temp2_ length < id.length, 0 is supplemented to the upper bit of ID _ Temp2 until ID _ Temp2_ length = id.length, and then a new value is assigned to ID _ Temp 2;
if ID _ Temp2_ length > ID.Length, the low ID.Length bit value of ID _ Temp2 is intercepted and assigned to ID _ Temp2, and ID.Length is assigned to ID _ Temp2_ length;
s11-5: and when the ID _ Temp2_ length = ID.Length, taking out the value of the ID _ Temp2, and assigning the value to the data ID with the specified length, namely obtaining the final data ID with the specified number of bits.
After the system obtains the initial data ID of 64 bits, based on UUID algorithm, the initial data ID is converted into a character string with the length of expected bit number ID.
The data IDs are sorted according to the time increment on the whole, and the ID collision cannot be generated in the whole distributed system; the UUID algorithm, the Hash algorithm and the SnowFlake algorithm used in the calculation scheme of the invention have high calculation efficiency, and tests show that the SnowFlake can generate about 20 ten thousand IDs (according to the CPU calculation performance) per second, thereby completely meeting the requirements of the existing traffic control.

Claims (5)

1. A data ID generation method capable of designating digit, characterized by comprising the steps of:
s1: in the data transmission exchange server, the system acquires the expected bit number ID.Length of the data ID required by each data service according to the requirement of each accessed data service request;
s2: acquiring a server address map of an integrated platform access server which provides the data service request, and obtaining a 5-bit machine address value MAC.ID (media access control) of a 2-system after calculating based on a Hash algorithm;
s3: acquiring jvmpid of the corresponding application process of the data service request in the integrated platform access server, and obtaining a 5-bit 2-system process address value JVCMP.ID after calculation based on a Hash algorithm;
s4: acquiring initial time Time.Standard preset in the data transmission exchange server system;
s5: obtaining the current time of the data transmission switching server system, calculating the difference between the current time and the initial time to obtain a timestamp time;
s6: left-shifting the binary value of the timestamp by 32 bits to obtain a temporary timestamp value;
s7: left-shifting the binary value of the machine address MAC.ID by 27 bits to obtain a temporary machine address value;
s8: left-shifting the binary value of the process address value JVCMP.ID by 22 bits to obtain a temporary process address value;
s9: setting a 22-bit auto-increment value, wherein the initial value of the auto-increment value is 0;
s10: performing bit OR operation on the temporary timestamp value, the temporary machine address value, the temporary process address value and the initial value of the self-increment value to obtain an initial data ID value original.ID;
s11: length, based on UUID algorithm, converting the initial data ID into ID value of assigned digit, namely obtaining final assigned length data ID;
in step S11, the method for obtaining the data ID of the specified length by calculation includes the following steps:
s11-1: creating an empty array ID [ ID.Length ], the length of which is the expected digit ID.Length;
s11-2: acquiring a Copy ID _ Copy preset in a system, wherein the Copy ID _ Copy is a character string with a fixed length, and the length of the character string is Max _ RADIX;
s11-2: confirming the relationship between the initial data ID value original.ID and 0:
if original.ID > 0, the intermediate value ID _ Temp is assigned-original.ID;
otherwise, the intermediate value ID _ Temp is assigned as original.ID if the original.ID is less than 0;
s11-3: converting the initial data ID value original. ID to string ID _ Temp2 using a UUID algorithm based on the intermediate value ID _ Temp, the Copy ID _ Copy;
s11-4: comparing the bit number ID _ Temp2_ length of ID _ Temp2 with the expected bit number id.length:
if ID _ Temp2_ length < id.length, 0 is supplemented to the upper bit of ID _ Temp2 until ID _ Temp2_ length = id.length, and then a new value is assigned to ID _ Temp 2;
if the ID _ Temp2_ length > ID.Length, intercepting the low ID.Length bit value of ID _ Temp2, assigning the low ID.Length bit value to ID _ Temp2, and assigning the ID.Length value to ID _ Temp2_ length;
s11-5: and when the ID _ Temp2_ length = ID.Length, taking out the value of the ID _ Temp2, and assigning the value to the data ID with the specified length, namely obtaining the final data ID with the specified number of bits.
2. The method of claim 1, wherein the data ID is generated by a method comprising the steps of: in step S2, the method for calculating the machine address value mac.id includes the following steps:
s2-1: acquiring the IP address of the integrated platform access server, and quitting the calculation if the acquisition fails;
if the IP address is successfully acquired, acquiring a mac address of the server according to the IP address of the server;
s2-2: length of the server address, mac;
s2-3: converting the macid with the length of mac.length bit into a long type numerical value to obtain Mac _ temp 1;
s2-4: carrying out bit AND calculation on the binary value of the Mac _ temp1 and 0x000000ff to obtain Mac _ temp 2;
s2-5: converting the macid with the length of mac.length-1 bit into a long type numerical value to obtain Mac _ temp 3;
s2-6: the binary value of the Mac _ temp3 is shifted left by 8 bits to obtain Mac _ temp 4;
s2-7: after 0x000000ff is shifted to the left by 8 bits, performing AND operation on the binary value of Mac _ temp4 to obtain Mac _ temp 5;
s2-8: performing bit OR operation on the binary value of the Mac _ temp2 and the binary value of the Mac _ temp5 to obtain Mac _ temp 6;
s2-9: the binary value of the Mac _ temp6 is shifted right by 6 bits to obtain Mac _ temp 7;
s2-10: the decimal value of Mac temp7 is divided by 32 to obtain the remainder, and the obtained value is the machine address value mac.id.
3. The method of claim 1, wherein the data ID is generated by a method comprising the steps of: in step S3, the method for calculating the process address value jcmp.id includes the following steps:
s3-1: acquiring the application process information jvmpid;
if the application process information jvmpid is failed to be obtained, assigning the value of the machine address value MAC.ID to JVM _ temp1, and executing S3-3;
s3-2: splicing the machine address value MAC.ID and the application process information jvmpid to obtain JVM _ temp 1;
s3-3, calculating hashcode of JVM _ temp1 to obtain JVM _ temp 2;
s3-4: carrying out bit AND operation on the 16-system values of JVM _ temp2 and 65535 to obtain JVM _ temp 3;
s3-5: and dividing the decimal value JVM _ temp3 by 32 to obtain the remainder, wherein the obtained value is the process address value JVCMP.ID.
4. The method of claim 1, wherein the data ID is generated by a method comprising the steps of: in step S5, the method for calculating the timestamp time includes the following steps:
s5-1: comparing the current time with the initial time standard;
s5-2: if time.current = time.standard, it is confirmed whether the counter is full,
if the counter is not full, the counter is incremented by 1, and the step S5-3 is executed;
otherwise, if the counter is full, waiting for the next second, and executing the step S5-3;
if the time is greater than the time standard, initializing a counter, and then executing step S5-3;
if the current is time, the system is abnormal, and the calculation is finished;
s5-3: and calculating the difference value between the current time and the initial time to obtain a time difference value, wherein the time difference value is the timestamp time.
5. The method of claim 1, wherein the data ID is generated by a method comprising the steps of: in step S11-3, converting the initial data ID value original. ID to string ID _ Temp2 using UUID algorithm, including the steps of:
s11-3-1: comparing the intermediate value with the maximum number of bits Max _ RADIX of the copy;
if ID _ Temp < -Max _ RADIX, then the following calculation is performed:
a 1: length is obtained after ID _ Temp is divided by the number of digits ID _ copy of the copy, the remainder is assigned to a remainder Temp _ Remain, and the obtained quotient value is assigned to a quotient Temp _ Quot;
a 2: after acquiring the character of the TempV1 th bit in the Copy ID _ Copy, putting the character into the lowest bit in the array ID [ ID.Length ];
a 3: assigning the value of the quotient Temp _ Quot to the intermediate value ID _ Temp;
a 4: the lowest bit of the array ID [ ID.Length ] is moved forward by 1 bit;
a 5: executing the step S11-3-1;
otherwise, if ID _ Temp > -Max _ RADIX, S11-3-2 is performed;
s11-3-2: the characters in the array ID [ ID.Length ] are converted to the value ID _ Temp2 of character type.
CN201910811184.2A 2019-08-30 2019-08-30 Data ID generation method capable of specifying digit Active CN110505306B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910811184.2A CN110505306B (en) 2019-08-30 2019-08-30 Data ID generation method capable of specifying digit

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910811184.2A CN110505306B (en) 2019-08-30 2019-08-30 Data ID generation method capable of specifying digit

Publications (2)

Publication Number Publication Date
CN110505306A CN110505306A (en) 2019-11-26
CN110505306B true CN110505306B (en) 2021-12-21

Family

ID=68590577

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910811184.2A Active CN110505306B (en) 2019-08-30 2019-08-30 Data ID generation method capable of specifying digit

Country Status (1)

Country Link
CN (1) CN110505306B (en)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111638866A (en) * 2020-04-26 2020-09-08 北京中交兴路信息科技有限公司 Random number generation method, device, equipment and storage medium
CN112491996B (en) * 2020-11-18 2022-08-12 深圳前海微众银行股份有限公司 Method and device for generating service request
CN112579566B (en) * 2020-12-14 2023-03-31 浪潮云信息技术股份公司 Distributed ID generation method and device
CN113282662B (en) * 2021-06-03 2023-11-03 广东辰宜信息科技有限公司 Block information processing method, device, equipment and medium
CN115686759B (en) * 2023-01-04 2023-04-07 恒丰银行股份有限公司 Method and system for calculating unique identification code of virtual machine

Citations (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101242407A (en) * 2008-03-07 2008-08-13 公安部交通管理科学研究所 Digital anti-counterfeit method and system for motive car qualification license
CN103580863A (en) * 2012-08-01 2014-02-12 中国移动通信集团公司 Communication safety control method and device, and nodes of Internet of Things
CN105187566A (en) * 2014-05-30 2015-12-23 北大方正集团有限公司 User identification obtaining method and device
CN106572165A (en) * 2016-10-26 2017-04-19 宜人恒业科技发展(北京)有限公司 Distributed global unique ID application method
CN106776932A (en) * 2016-12-01 2017-05-31 湖北荆楚网络科技股份有限公司 A kind of method that unique ID is generated in distributed system
CN107454203A (en) * 2017-07-19 2017-12-08 成都数联铭品科技有限公司 The method for generating unique ID in a distributed system
CN107864233A (en) * 2017-11-08 2018-03-30 千寻位置网络有限公司 Globally unique ID structures and generation method
CN108833117A (en) * 2018-07-25 2018-11-16 海南新软软件有限公司 A kind of storage of private key and read method, device and hardware device
CN108959386A (en) * 2018-05-31 2018-12-07 深圳壹账通智能科技有限公司 Distributed globally unique ID generation method, device, equipment and storage medium
CN109639775A (en) * 2018-11-27 2019-04-16 湖南蚁为软件有限公司 Global monotonic increase ID generation method, device, system and equipment
CN109697133A (en) * 2018-12-28 2019-04-30 广州华多网络科技有限公司 ID generation method, apparatus and system
WO2019079845A1 (en) * 2017-10-27 2019-05-02 The Crown in Right of the State of South Australia Road traffic monitoring and notification system
WO2019143208A1 (en) * 2018-01-19 2019-07-25 삼성전자 주식회사 Apparatus and method for communication in broadcast system

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10142353B2 (en) * 2015-06-05 2018-11-27 Cisco Technology, Inc. System for monitoring and managing datacenters

Patent Citations (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101242407A (en) * 2008-03-07 2008-08-13 公安部交通管理科学研究所 Digital anti-counterfeit method and system for motive car qualification license
CN103580863A (en) * 2012-08-01 2014-02-12 中国移动通信集团公司 Communication safety control method and device, and nodes of Internet of Things
CN105187566A (en) * 2014-05-30 2015-12-23 北大方正集团有限公司 User identification obtaining method and device
CN106572165A (en) * 2016-10-26 2017-04-19 宜人恒业科技发展(北京)有限公司 Distributed global unique ID application method
CN106776932A (en) * 2016-12-01 2017-05-31 湖北荆楚网络科技股份有限公司 A kind of method that unique ID is generated in distributed system
CN107454203A (en) * 2017-07-19 2017-12-08 成都数联铭品科技有限公司 The method for generating unique ID in a distributed system
WO2019079845A1 (en) * 2017-10-27 2019-05-02 The Crown in Right of the State of South Australia Road traffic monitoring and notification system
CN107864233A (en) * 2017-11-08 2018-03-30 千寻位置网络有限公司 Globally unique ID structures and generation method
WO2019143208A1 (en) * 2018-01-19 2019-07-25 삼성전자 주식회사 Apparatus and method for communication in broadcast system
CN108959386A (en) * 2018-05-31 2018-12-07 深圳壹账通智能科技有限公司 Distributed globally unique ID generation method, device, equipment and storage medium
CN108833117A (en) * 2018-07-25 2018-11-16 海南新软软件有限公司 A kind of storage of private key and read method, device and hardware device
CN109639775A (en) * 2018-11-27 2019-04-16 湖南蚁为软件有限公司 Global monotonic increase ID generation method, device, system and equipment
CN109697133A (en) * 2018-12-28 2019-04-30 广州华多网络科技有限公司 ID generation method, apparatus and system

Non-Patent Citations (4)

* Cited by examiner, † Cited by third party
Title
python生成并处理uuid的方法;魔镜之恋;《https://blog.csdn.net/yl416306434/article/details/80569688》;20180604;全文 *
Runtime deduction of case ID for unlabeled business process execution events;Iman M. A. Helal;《IEEE》;20160711;全文 *
UUID介绍与生成方法;MyObject-C;《https://blog.csdn.net/nawenqiang/article/details/82684001》;20180913;全文 *
基于Spring Cloud的新风设备管理系统的设计与实现;许晓虎;《中国优秀硕士学位论文全文数据库信息科技辑》;20190731;全文 *

Also Published As

Publication number Publication date
CN110505306A (en) 2019-11-26

Similar Documents

Publication Publication Date Title
CN110505306B (en) Data ID generation method capable of specifying digit
CN108959386B (en) Distributed global unique ID generation method, device, equipment and storage medium
CN106657216B (en) Serial number generation method and device
CN111538594B (en) Order ID generation method, device, equipment and medium based on distributed system
CN111625252A (en) Cluster upgrading maintenance method and device, electronic equipment and storage medium
CN105162760A (en) Random draw-off method, apparatus and system
CN103064757A (en) Method and system for backing up data
EP4012980A1 (en) Application identification method and apparatus, and storage medium
CN110830608A (en) Global unique identifier generation method, device, equipment and storage medium
CN108733802B (en) Identification code generation and analysis method and device, storage medium and electronic equipment
CN112702228A (en) Service current limiting response method and device, electronic equipment and readable storage medium
CN114389889A (en) File full life cycle management method and device based on block chain technology
CN112685117A (en) System language internationalization maintenance method, device and computer readable storage medium
CN112464619B (en) Big data processing method, device and equipment and computer readable storage medium
CN115576998B (en) Power distribution network data integration method and system based on multi-dimensional information fusion
CN115687384A (en) UUID (user identifier) identification generation method, device, equipment and storage medium
CN111581187A (en) Data management method and device for intelligent park, computer equipment and storage medium
CN114268559B (en) Directional network detection method, device, equipment and medium based on TF-IDF algorithm
CN115470241A (en) Aggregated data updating method and device based on mapping dictionary table
TW202315360A (en) Microservice allocation method, electronic equipment, and storage medium
CN114547011A (en) Data extraction method and device, electronic equipment and storage medium
CN110935168B (en) Distributed ID generation method, device and equipment for global uniform architecture
CN112631675A (en) Workflow configuration method, device, equipment and computer readable storage medium
CN111506654B (en) Data partitioning method for data routing
CN107305610B (en) Access path processing method and device, and automaton identification method, device and system

Legal Events

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