CN109697133A - ID generation method, apparatus and system - Google Patents

ID generation method, apparatus and system Download PDF

Info

Publication number
CN109697133A
CN109697133A CN201811623080.0A CN201811623080A CN109697133A CN 109697133 A CN109697133 A CN 109697133A CN 201811623080 A CN201811623080 A CN 201811623080A CN 109697133 A CN109697133 A CN 109697133A
Authority
CN
China
Prior art keywords
server
mark
target
bit
target process
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
CN201811623080.0A
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.)
Guangzhou Cubesili Information Technology Co Ltd
Original Assignee
Guangzhou Huaduo Network 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 Guangzhou Huaduo Network Technology Co Ltd filed Critical Guangzhou Huaduo Network Technology Co Ltd
Priority to CN201811623080.0A priority Critical patent/CN109697133A/en
Publication of CN109697133A publication Critical patent/CN109697133A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/547Remote procedure calls [RPC]; Web services
    • AHUMAN NECESSITIES
    • A63SPORTS; GAMES; AMUSEMENTS
    • A63FCARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
    • A63F13/00Video games, i.e. games using an electronically generated display having two or more dimensions
    • A63F13/30Interconnection arrangements between game servers and game devices; Interconnection arrangements between game devices; Interconnection arrangements between game servers
    • A63F13/35Details of game servers

Abstract

The invention discloses a kind of ID generation methods, apparatus and system, belong to technical field of data processing.The described method includes: receiving the ID acquisition instruction that application end is initiated;Target process mark and server-side mark are obtained, target process is identified as the mark that the target process of ID acquisition instruction is executed in server-side;Based on specified time stamp, target process mark, server-side mark and from increasing sequence, generate Target id, specified time stamp is positively correlated with current time stamp, the bit of specified time stamp is higher than the bit of target process mark and the bit of server-side mark, and the bit of target process mark and the bit of server-side mark are lower than from the bit of increasing sequence;Target id is sent to application end.The present invention is based on specified time stamp, target process identifies, server-side identifies and expands the application range of ID while guaranteeing the global uniqueness of Target id from increasing column-generation Target id by server-side.

Description

ID generation method, apparatus and system
Technical field
The present invention relates to technical field of data processing, in particular to a kind of ID generation method, apparatus and system.
Background technique
It needs in many application scenarios using globally unique identification code (Identifier, ID) at present.Globally unique ID refers to All ID in application scenarios are not repeated, i.e. will not conflict between any two ID.
In a distributed system, Universally Unique Identifier (Universally Unique is generallyd use at present Identifier, UUID) it is used as globally unique ID.UUID is usually by current date and time, clock sequence and globally unique Machine serial number (such as address media access control (Media Access Control, MAC) of network interface card) composition, UUID is logical Often stored in the form of character string.
But since UUID is stored in the form of character string, readability is poor, and search efficiency is lower;In addition, UUID It not can guarantee trend to be incremented by, application limitation is higher.
Summary of the invention
The embodiment of the invention provides a kind of ID generation methods, apparatus and system, can solve and provide ID in the related technology The higher problem of application limitation.The technical solution is as follows:
In a first aspect, providing a kind of ID generation method, it to be used for server-side, which comprises
Receive the ID acquisition instruction that application end is initiated;
Target process mark and server-side mark are obtained, the target process, which is identified as in the server-side, executes the ID The mark of the target process of acquisition instruction;
It is identified based on specified time stamp, target process mark, the server-side and from increasing sequence, generates Target id, The specified time stamp is positively correlated with current time stamp, and the bit of the specified time stamp is higher than target process mark The bit of bit and server-side mark, the bit from increasing sequence are lower than the bit of target process mark The bit of position and server-side mark;
The Target id is sent to the application end.
Optionally, the acquisition target process mark, comprising:
The corresponding target process variable of the target process is obtained, process corresponding to different processes becomes in the server-side Amount is different;
Based on process identification (PID) configuration file, the target process mark is obtained, the process identification (PID) configuration file is for depositing The mapping relations of storage process variable and process identification (PID).
Optionally, described to be based on process identification (PID) configuration file, obtain the target process mark, comprising:
It detects and whether is stored with the target process variable and the target process mark in the process identification (PID) configuration file The mapping relations of knowledge;
It is reflected when being stored with the target process variable in the process identification (PID) configuration file with what the target process identified When penetrating relationship, the target process mark is obtained from the process identification (PID) configuration file.
Optionally, the target process variable and institute whether are stored in the detection process identification (PID) configuration file After the mapping relations for stating target process mark, the method also includes:
There are the target process variable and the target process to identify when not stored in the process identification (PID) configuration file When mapping relations, traverse the process identification (PID) configuration file, with obtain numerical value in the process identification (PID) configuration file it is maximum into Journey mark;
1 obtained numerical value is added to be determined as the target process mark the maximum process identification (PID) of the numerical value;
The mapping of the target process variable and target process mark is stored in the process identification (PID) configuration file Relationship obtains updated process identification (PID) configuration file.
Optionally, the acquisition server-side mark, comprising:
It detects in the system configuration file of the server-side and is identified with the presence or absence of the server-side, the server-side mark Value range is 0 to N-1, and N is the maximum quantity for the server-side that system where the server-side is supported, N is positive integer;
When identifying in the system configuration file of the server-side there are the server-side, the server-side mark is obtained.
Optionally, it is identified with the presence or absence of the server-side in the system configuration file of the detection server-side Afterwards, the method also includes:
When server-side mark is not present in the system configuration file of the server-side, from the O&M of the server-side Server-side ID is obtained in configuration file;
By the server-side ID to N modulus, the server-side mark is obtained.
Optionally, the Target id by a high position to low level successively include marker bit, the specified time stamp, the target into Journey identifies, the server-side identifies and described from increasing sequence;
Alternatively, the Target id successively includes marker bit, specified time stamp, the server-side mark by a high position to low level Know, the target process identifies and described from increasing sequence.
Optionally, the bit wide of the Target id is 64;
The bit wide of the marker bit is 1, and the bit wide range of the specified time stamp is 35-45, the target process The bit wide range of mark is 1-10, and the bit wide range of the server-side mark is 5-10, the bit wide model from increasing sequence Enclose is 6-20.
Second aspect provides a kind of ID generating means, is used for server-side, and described device includes:
Receiving module, for receiving the ID acquisition instruction of application end initiation;
Module is obtained, for obtaining target process mark and server-side mark, the target process is identified as the service The mark of the target process of the ID acquisition instruction is executed in end;
Generation module, for based on specified time stamp, target process mark, server-side mark and from increasing Column generate Target id, and the specified time stamp is positively correlated with current time stamp, and the bit of the specified time stamp is higher than described The bit of target process mark and the bit of server-side mark, the bit from increasing sequence are lower than the target The bit of the bit of process identification (PID) and server-side mark;
Sending module, for sending the Target id to the application end.
Optionally, the acquisition module, is used for:
The corresponding target process variable of the target process is obtained, process corresponding to different processes becomes in the server-side Amount is different;
Based on process identification (PID) configuration file, the target process mark is obtained, the process identification (PID) configuration file is for depositing The mapping relations of storage process variable and process identification (PID).
Optionally, the acquisition module, is also used to:
It detects and whether is stored with the target process variable and the target process mark in the process identification (PID) configuration file The mapping relations of knowledge;
It is reflected when being stored with the target process variable in the process identification (PID) configuration file with what the target process identified When penetrating relationship, the target process mark is obtained from the process identification (PID) configuration file.
Optionally, the acquisition module, is also used to:
There are the target process variable and the target process to identify when not stored in the process identification (PID) configuration file When mapping relations, traverse the process identification (PID) configuration file, with obtain numerical value in the process identification (PID) configuration file it is maximum into Journey mark;
1 obtained numerical value is added to be determined as the target process mark the maximum process identification (PID) of the numerical value;
The mapping of the target process variable and target process mark is stored in the process identification (PID) configuration file Relationship obtains updated process identification (PID) configuration file.
Optionally, the acquisition module, is used for:
It detects in the system configuration file of the server-side and is identified with the presence or absence of the server-side, the server-side mark Value range is 0 to N-1, and N is the maximum quantity for the server-side that system where the server-side is supported, N is positive integer;
When identifying in the system configuration file of the server-side there are the server-side, the server-side mark is obtained.
Optionally, the acquisition module, is also used to:
When server-side mark is not present in the system configuration file of the server-side, from the O&M of the server-side Server-side ID is obtained in configuration file;
By the server-side ID to N modulus, the server-side mark is obtained.
Optionally, the Target id by a high position to low level successively include marker bit, the specified time stamp, the target into Journey identifies, the server-side identifies and described from increasing sequence;
Alternatively, the Target id successively includes marker bit, specified time stamp, the server-side mark by a high position to low level Know, the target process identifies and described from increasing sequence.
Optionally, the bit wide of the Target id is 64;
The bit wide of the marker bit is 1, and the bit wide range of the specified time stamp is 35-45, the target process The bit wide range of mark is 1-10, and the bit wide range of the server-side mark is 5-10, the bit wide model from increasing sequence Enclose is 6-20.
The third aspect provides a kind of ID generation system, the system comprises: at least one server-side is answered at least one With end, the server-side includes the ID generating means as described in second aspect is any.
Fourth aspect provides a kind of ID generating means, comprising: memory and processor;
The memory, for storing computer program;
The processor is realized for executing the computer program stored on the memory as first aspect is any The ID generation method.
5th aspect, provides a kind of computer readable storage medium, the computer-readable recording medium storage has generation Code instruction, the code command are executed by processor, realize the ID generation method as described in first aspect is any.
Technical solution bring beneficial effect provided in an embodiment of the present invention includes:
Specified time stamp, target process mark, server-side mark and from increasing column-generation Target id are based on by server-side. Due to the server-side of different server-sides identify it is different, and in same server-side different processes process identification (PID) it is different, therefore can be with The Target id for guaranteeing that the target process in server-side at a time generates is globally unique.On the one hand, Target id can be adopted Form storage decimally, readable high, the search efficiency based on the Target id is high;On the other hand, due to specified time Stamp is positively correlated with current time stamp, and the bit of specified time stamp is higher than the bit and server-side mark of target process mark Bit, from the bit of increasing sequence lower than the bit of target process mark and the bit of server-side mark, Ke Yibao The ID trend that card generates is incremented by.Therefore compared with the relevant technologies, the application limitation of Target id is reduced, Target id is expanded Application range.
Detailed description of the invention
Fig. 1 is the structural schematic diagram that a kind of ID provided in an embodiment of the present invention generates system;
Fig. 2 is a kind of flow chart of ID generation method provided in an embodiment of the present invention;
Fig. 3 is the flow chart of another kind ID generation method provided in an embodiment of the present invention;
Fig. 4 is a kind of method flow diagram for obtaining target process mark provided in an embodiment of the present invention;
Fig. 5 is a kind of structural schematic diagram of ID generating means provided in an embodiment of the present invention;
Fig. 6 is a kind of structural schematic diagram of server-side provided in an embodiment of the present invention.
Specific embodiment
To make the object, technical solutions and advantages of the present invention clearer, below in conjunction with attached drawing to embodiment party of the present invention Formula is described in further detail.
Fig. 1 is the structural schematic diagram that a kind of ID provided in an embodiment of the present invention generates system, as shown in Figure 1, the ID is generated System 10 includes at least one server-side 101 and at least one application end 102.It is exemplary, it generates system 10 referring to Fig. 1, ID and wraps Include two server-sides 101 and three application ends 102.Each server-side 101 can pass through wired network at least one application end 102 Network or wireless network establish communication connection.
Optionally, server-side 101 is alternatively referred to as machine node.Server-side 101 can be server, such as server-side can be with It is the background server of some gaming platform;Or server-side 101 can be a cloud computing service center.Application end 102 can To be the terminals such as smart phone, tablet computer and wearable device.It is not limited in the embodiment of the present invention.Server-side 101 is used In providing globally unique ID to the application end 102 of connection.
In embodiments of the present invention, by being packaged to snowflake (snowflake) algorithm, server-side 101 is made to be based on envelope Snowflake algorithm after dress generates globally unique ID, the ID include marker bit, specified time stamp, process identification (PID), server-side identify and From increasing sequence, specified time stamp is positively correlated with current time stamp.Wherein, the bit of marker bit is the highest order in ID, is specified The bit of timestamp is higher than the bit of target process mark and the bit of server-side mark, low from the bit of increasing sequence In the bit of target process mark and the bit of server-side mark, that is to say, the ID that server-side generates is by a high position to low level It successively include marker bit, specified time stamp, target process mark, server-side mark and from increasing sequence;Alternatively, what server-side generated ID successively includes marker bit, specified time stamp, server-side mark, target process mark and from increasing sequence by a high position to low level.
Optionally, marker bit is alternatively referred to as sign bit, and when marker bit is 1, expression ID is positive number;When marker bit be 0, indicate ID is negative.
It should be noted that the server-side of different server-sides identifies difference in ID generation system, that is to say for entire For ID generation system, server-side mark is globally unique;In each server-side, the process identification (PID) of different processes is different, It that is to say for single server-side, process identification (PID) is globally unique.Wherein, target process mark and server-side mark are equal For number.In addition, being number due to specified time stamp and from increasing sequence, ID provided in an embodiment of the present invention generates system The ID of generation can be stored using metric form.
Optionally, ID provided in an embodiment of the present invention, which generates system, can be integrated system, be also possible to distributed system System, does not limit this.
Fig. 2 is a kind of flow chart of ID generation method provided in an embodiment of the present invention, generates system for ID as shown in Figure 1 Any server-side 101 in system 10, as shown in Fig. 2, this method comprises:
Step 201 receives the ID acquisition instruction that application end is initiated.
Step 202 obtains target process mark and server-side mark.
Wherein, target process is identified as the mark that the target process of ID acquisition instruction is executed in server-side.
Step 203 is identified based on specified time stamp, target process mark, server-side and from increasing sequence, generates Target id.
Wherein, specified time stamp is positively correlated with current time stamp.The bit of specified time stamp is identified higher than target process Bit and server-side mark bit, bit and server-side from the bit of increasing sequence lower than target process mark The bit of mark.
Optionally, Target id is generated by target process.
Step 204 sends Target id to application end.
In conclusion ID generation method provided in an embodiment of the present invention, server-side is based on specified time stamp, target process mark Know, server-side mark and from increasing column-generation Target id.Since the server-side of different server-sides identifies difference, and same server-side The process identification (PID) of middle difference process is different, therefore can guarantee the Target id that the target process in server-side at a time generates It is globally unique.On the one hand, Target id can be stored using metric form, readable high, based on the Target id Search efficiency is high;On the other hand, it is positively correlated due to specified time stamp with current time stamp, and the bit of specified time stamp is higher than The bit of target process mark and the bit of server-side mark, the ratio of target process mark is lower than from the bit of increasing sequence The bit of special position and server-side mark, it is ensured that the ID trend of generation is incremented by.Therefore compared with the relevant technologies, mesh is reduced The application limitation for marking ID, expands the application range of Target id.
Fig. 3 is the flow chart of another kind ID generation method provided in an embodiment of the present invention, is generated for ID as shown in Figure 1 In system 10, as shown in figure 3, this method comprises:
Step 301, application end send ID acquisition instruction to server-side.
Optionally, the ID acquisition instruction that application end is sent is used to indicate server-side and generates corresponding ID.
Exemplary, application end is to be equipped with the terminal of game client, and server-side is after the corresponding game of game client Platform server.For example, ID acquisition instruction can be generated in game client when user creates virtual room on game client And the ID acquisition instruction is sent to game background server, which is used to indicate game background server and generates the void The quasi- corresponding ID in room (i.e. room number);In another example when user applies for login account on game client, game client ID acquisition instruction can be generated and send the ID acquisition instruction to game background server, which is used to indicate game Background server generates the corresponding ID of the login account.
Optionally, ID acquisition instruction may be used to indicate that server-side generate serial number, the serial number for server-side to Corresponding application end granting reward (such as ideal money, integral, cash and Fu Ka) etc., the embodiment of the present invention is to ID generation method Application scenarios without limitation.
Step 302, server-side obtain target process mark.
Wherein, target process is identified as the mark that the target process of ID acquisition instruction is executed in server-side.
Optionally, step 302 the realization process includes:
S21, the corresponding target process variable of target process is obtained, process variable corresponding to different processes is not in server-side Together.
It should be noted that the process variable of each process is that process is privately owned, therefore different processes are corresponding in server-side Process variable is different, which can unique identification process.
S22, it is based on process identification (PID) configuration file, obtains target process mark, the process identification (PID) configuration file is for storing The mapping relations of process variable and process identification (PID).
Optionally, as shown in figure 4, it is above-mentioned S22's the realization process includes:
Target process variable and target process mark whether are stored in step 221, detection procedure mark configuration file Mapping relations;When being stored with the mapping relations of target process variable and target process mark in process identification (PID) configuration file, hold Row step 222;There are target process variable and the mapping of target process mark to close when not stored in process identification (PID) configuration file When being, step 223 is executed.
Optionally, the corresponding process variable of all processes in server-side has been can store in process identification (PID) configuration file.
Step 222 obtains target process mark from process identification (PID) configuration file.
Step 223, traversal process identification (PID) configuration file, to obtain the maximum process mark of numerical value in process identification (PID) configuration file Know.
Step 224 adds the maximum process identification (PID) of numerical value 1 obtained numerical value to be determined as target process mark.
Exemplary, when the bit wide of process identification (PID) is 3bit, the value range of the process identification (PID) is 0 to 7, if process identification (PID) The maximum process identification (PID) of numerical value is 4 in configuration file, it is determined that target process is identified as 5.
Optionally, with reference to step 223 and step 224, server-side increasing can store respectively in process identification (PID) configuration file The corresponding process identification (PID) of a process;Alternatively, server-side can also store each process pair by descending in process identification (PID) configuration file The process identification (PID) answered, then step 223 and step 224 could alternatively be: traversal process identification (PID) configuration file, to obtain process identification (PID) The smallest process identification (PID) of numerical value in configuration file;The numerical value for subtracting 1 for the maximum process identification (PID) of numerical value and obtaining is determined as target process Mark.Server-side can also store the corresponding process identification (PID) of each process using other modes in process identification (PID) configuration file, It only needs to guarantee that the corresponding process identification (PID) of each process is unique and interior in value range, the embodiment of the present invention does not limit this It is fixed.
Step 225, the mapping relations that target process variable and target process mark are stored in process identification (PID) configuration file, Obtain updated process identification (PID) configuration file.
It optionally, can be based on updated process identification (PID) configuration text when server-side receives ID acquisition instruction again Part obtains the corresponding process identification (PID) of process for executing the ID acquisition instruction, which can refer to above-mentioned steps 221 to step 225, The embodiment of the present invention is to this will not be repeated here.
In embodiments of the present invention, server-side combines the application system of itself, and realization without immersion obtains process identification (PID), It can be applied to a variety of distributed systems, versatility is high.
Step 303, server-side obtain server-side mark.
Optionally, step 303 the realization process includes:
S31, detection service end system configuration file in the presence or absence of server-side identify, server-side mark value range It is 0 to N-1, N is the maximum quantity for the server-side that system where server-side is supported, N is positive integer.
It should be noted that the server-side in system configuration file is identified as number.When the bit wide of server-side mark is p When bit, the maximum quantity N for the server-side that system where the server-side is supported is 2pWhen, then the clothes that are stored in system configuration file The value range for end mark of being engaged in is 0 to 2p-1。
S32, when in the system configuration file of server-side presence service end identify when, obtain server-side mark.
S33, when in the system configuration file of server-side be not present server-side mark when, from the O&M configuration file of server-side Middle acquisition server-side ID.
Wherein, server-side ID is alternatively referred to as machine ID.The server-side ID of different server-sides is different, i.e., server-side ID can be unique Identify server-side.
S34, by server-side ID to N modulus, obtain server-side mark.
Since the numerical value of server-side ID is likely larger than or is equal to N, the value by server-side ID to N modulus, after making modulus In value range in server-side mark.
In embodiments of the present invention, server-side combines the application system of itself, and realization without immersion obtains server-side mark Know, can be applied to a variety of distributed systems, versatility is high.
Step 304, server-side are based on specified time stamp, target process mark, server-side and identify and from increasing sequence, generate mesh Mark ID.
Wherein, specified time stamp is positively correlated with current time stamp.Specified time stamp can be equal to current time stamp and history The difference of timestamp.Optionally, historical time stamp can be timestamp when server-side brings into operation, and be also possible to when current Some set time stamp before quarter, it is not limited in the embodiment of the present invention.
It should be noted that the bit of specified time stamp was identified higher than the bit and server-side of target process mark Bit is lower than the bit of target process mark and the bit of server-side mark from the bit of increasing sequence.In addition, target ID further includes marker bit, and marker bit is the highest order in Target id.Optionally, Target id successively includes label by a high position to low level Position, specified time stamp, target process mark, server-side mark and from increasing sequence;Alternatively, Target id is successively wrapped by a high position to low level Include marker bit, specified time stamp, server-side mark, target process mark and from increasing sequence.
Optionally, specified time stamp and from increasing sequence be Millisecond.
Optionally, the bit wide of Target id is 64bit, and the bit wide of marker bit is 1bit, the bit wide of specified time stamp, target into Journey mark bit wide, server-side mark bit wide and from the sum of bit wide of increasing sequence be 63bit.Optionally, specified time stabs Bit wide range be 35-45, target process mark bit wide range be 1-10, server-side identify bit wide range be 5-10 Position is 6-20 from the bit wide range of increasing sequence.The Target id is long type.In practical application scene, specified time stamp Bit wide, the bit wide of target process mark, the bit wide of server-side mark and the bit wide from increasing sequence can be set according to actual needs Fixed and adjustment, it is not limited in the embodiment of the present invention.
In embodiments of the present invention, when specified time stamp is Millisecond, the specified time stamp that bit wide is m bit is available Year T=(1L < < m)/(1000L*60*60*24*365), wherein " < < " indicates to press bitwise shift left;The position of target process mark Width is n bit, then the server-side is supported while running at most 2nA process;The bit wide of server-side mark is p bit, the then service ID where end, which generates system, can at most support 2pA server-side;It is q from the bit wide of increasing sequence when being classified as Millisecond from increasing Bit, then each process supports that every millisecond at most generates 2qA ID.Wherein, m, n, p and q are positive integer.
Optionally, it includes: that store bit wide be q bit from increasing sequence that server-side, which generates the software implementing course of Target id,; The server-side that q storage bit wides are p bit is moved to left to identify;The target process that the position (p+q) storage bit wide is n bit is moved to left to identify, Move to left the specified time stamp that the position (p+q+n) storage bit wide is m bit.Wherein, Target id can be generated by target process.
It should be noted that the bit wide for the Target id that the embodiment of the present invention generates is 64bit, and the bit wide of UUID is 128bit, therefore compared with the UUID that the relevant technologies provide, the occupied memory space of Target id provided in an embodiment of the present invention It is smaller, storage resource can be saved.
Step 305, server-side send Target id to application end.
Optionally, the identification information of the application end is carried in the ID acquisition instruction that application end is sent, server-side is based on should The identification information of application end sends the Target id generated to the application end, for application end use.
It should be noted that the step sequencing of ID generation method provided in an embodiment of the present invention can be adjusted suitably It is whole, such as step 303 can execute before step 302 or step 302 can be performed simultaneously with step 303, step can also According to circumstances accordingly to be increased and decreased, anyone skilled in the art in the technical scope disclosed by the present invention, The method that variation can be readily occurred in, should be covered by the protection scope of the present invention, therefore repeat no more.
In conclusion ID generation method provided in an embodiment of the present invention, server-side is based on specified time stamp, target process mark Know, server-side mark and from increasing column-generation Target id.Since the server-side of different server-sides identifies difference, and same server-side The process identification (PID) of middle difference process is different, therefore can guarantee the Target id that the target process in server-side at a time generates It is globally unique.On the one hand, Target id can be stored using metric form, readable high, based on the Target id Search efficiency is high;On the other hand, it is positively correlated due to specified time stamp with current time stamp, and the bit of specified time stamp is higher than The bit of target process mark and the bit of server-side mark, the ratio of target process mark is lower than from the bit of increasing sequence The bit of special position and server-side mark, it is ensured that the ID trend of generation is incremented by.In addition, ID provided in an embodiment of the present invention is raw At method, different databases can be applied to, therefore compared with the relevant technologies, reduce the application limitation of Target id, expand The big application range of Target id.
Fig. 5 is a kind of structural schematic diagram of ID generating means provided in an embodiment of the present invention, raw for ID as shown in Figure 1 At any server-side 101 in system 10, as shown in figure 5, the device 40 includes:
Receiving module 401, for receiving the ID acquisition instruction of application end initiation.
Module 402 is obtained, for obtaining target process mark and server-side mark, target process is identified as in server-side and holds The mark of the target process of row ID acquisition instruction.
Generation module 403, for being identified based on specified time stamp, target process mark, server-side and from increasing sequence, being generated Target id, specified time stamp are positively correlated with current time stamp, and the bit of specified time stamp is higher than the bit of target process mark The bit of position and server-side mark, bit and server-side mark from the bit of increasing sequence lower than target process mark Bit.
Sending module 404, for sending Target id to application end.
In conclusion ID generating means provided in an embodiment of the present invention, server-side is based on specified time by generation module Stamp, target process mark, server-side mark and from increasing column-generation Target id.Since the server-side of different server-sides identifies not Together, the process identification (PID) of different processes is different and in same server-side, therefore the target process in server-side can be guaranteed a certain The Target id that moment generates is globally unique.On the one hand, Target id can be stored using metric form, readable Height, the search efficiency based on the Target id are high;On the other hand, it is positively correlated due to specified time stamp with current time stamp, and specified The bit of timestamp is higher than the bit of target process mark and the bit of server-side mark, low from the bit of increasing sequence In the bit of target process mark and the bit of server-side mark, it is ensured that the ID trend of generation is incremented by.In addition, this hair The ID generation method that bright embodiment provides, can be applied to different databases, therefore compared with the relevant technologies, reduce target The application limitation of ID expands the application range of Target id.
Optionally, module is obtained, is used for:
The corresponding target process variable of target process is obtained, process variable corresponding to different processes is different in server-side; Based on process identification (PID) configuration file, target process mark is obtained, process identification (PID) configuration file is used for storage process variable and process The mapping relations of mark.
Optionally, module is obtained, is also used to:
Whether the mapping relations of target process variable and target process mark are stored in detection procedure mark configuration file; When being stored with the mapping relations of target process variable and target process mark in process identification (PID) configuration file, match from process identification (PID) It sets and obtains target process mark in file.
Optionally, module is obtained, is also used to:
When the not stored mapping relations for having target process variable and target process mark in process identification (PID) configuration file, time Process identification (PID) configuration file is gone through, to obtain the maximum process identification (PID) of numerical value in process identification (PID) configuration file;By numerical value it is maximum into Journey mark plus 1 obtained numerical value are determined as target process mark;In process identification (PID) configuration file store target process variable with The mapping relations of target process mark, obtain updated process identification (PID) configuration file.
Optionally, module is obtained, is used for:
It is identified in the system configuration file at detection service end with the presence or absence of server-side, the value range of server-side mark is 0 To N-1, N is the maximum quantity for the server-side that system where server-side is supported, N is positive integer;When the system configuration text of server-side When presence service end identifies in part, server-side mark is obtained.
Optionally, module is obtained, is also used to:
When server-side mark is not present in the system configuration file of server-side, obtained from the O&M configuration file of server-side Take server-side ID;By server-side ID to N modulus, server-side mark is obtained.
Optionally, Target id successively includes marker bit, specified time stamp, target process mark, service by a high position to low level End mark and from increasing sequence;Alternatively, Target id by a high position to low level successively include marker bit, specified time stamp, server-side mark, Target process mark and from increasing sequence.
Optionally the bit wide of Target id is 64;The bit wide of marker bit is 1, and the bit wide range of specified time stamp is 35- 45, the bit wide range of target process mark is 1-10, and the bit wide range of server-side mark is 5-10, from the position of increasing sequence Wide scope is 6-20.
In conclusion ID generating means provided in an embodiment of the present invention, server-side is based on specified time by generation module Stamp, target process mark, server-side mark and from increasing column-generation Target id.Since the server-side of different server-sides identifies not Together, the process identification (PID) of different processes is different and in same server-side, therefore the target process in server-side can be guaranteed a certain The Target id that moment generates is globally unique.On the one hand, Target id can be stored using metric form, readable Height, the search efficiency based on the Target id are high;On the other hand, it is positively correlated due to specified time stamp with current time stamp, and specified The bit of timestamp is higher than the bit of target process mark and the bit of server-side mark, low from the bit of increasing sequence In the bit of target process mark and the bit of server-side mark, it is ensured that the ID trend of generation is incremented by.In addition, this hair The ID generation method that bright embodiment provides, can be applied to different databases, therefore compared with the relevant technologies, reduce target The application limitation of ID expands the application range of Target id.
About the device in above-described embodiment, wherein modules execute the concrete mode of operation in related this method Embodiment in be described in detail, no detailed explanation will be given here.
The embodiment of the invention provides a kind of ID to generate system, as shown in Figure 1, the system includes: at least one server-side 101 and at least one application end 102, the server-side includes ID generating means as shown in Figure 5.
The embodiment of the invention provides a kind of ID generating means, comprising: memory and processor;
The memory, for storing computer program;
The processor is realized as shown in Figure 2 or Figure 3 for executing the computer program stored on the memory ID generation method.
Fig. 6 is a kind of structural schematic diagram of server-side provided in an embodiment of the present invention, which can be server.Institute Stating server 500 includes central processing unit (Central Processing Unit, CPU) 501 including random access memory The system of device (random access memory, RAM) 502 and read-only memory (read only memory, ROM) 503 is deposited Reservoir 504, and the system bus 505 of connection system storage 504 and central processing unit 501.The server 500 also wraps The basic input/output (I/O system) 506 for helping that information is transmitted between each device in computer is included, and for depositing Store up the mass-memory unit 507 of operating system 513, application program 514 and other program modules 515.
The basic input/output 506 includes display 508 for showing information and inputs letter for user The input equipment 509 of such as mouse, keyboard etc of breath.Wherein the display 508 and input equipment 509 are all by being connected to The input and output controller 510 of system bus 505 is connected to central processing unit 501.The basic input/output 506 Can also include input and output controller 510 with for receive and handle from keyboard, mouse or electronic touch pen etc. it is multiple its The input of his equipment.Similarly, input and output controller 510 also provides output to display screen, printer or other kinds of defeated Equipment out.
The mass-memory unit 507 is by being connected to the bulk memory controller (not shown) of system bus 505 It is connected to central processing unit 501.The mass-memory unit 507 and its associated computer-readable medium are server 500 provide non-volatile memories.That is, the mass-memory unit 507 may include such as hard disk or CD-ROM The computer-readable medium (not shown) of driver etc.
Without loss of generality, the computer-readable medium may include computer storage media and communication media.Computer Storage medium includes information such as computer readable instructions, data structure, program module or other data for storage The volatile and non-volatile of any method or technique realization, removable and irremovable medium.Computer storage medium includes RAM, ROM, EPROM, EEPROM, flash memory or other solid-state storages its technologies, CD-ROM, DVD or other optical storages, tape Box, tape, disk storage or other magnetic storage devices.Certainly, skilled person will appreciate that the computer storage medium It is not limited to above-mentioned several.Above-mentioned system storage 504 and mass-memory unit 507 may be collectively referred to as memory.
According to various embodiments of the present invention, the server 500 can also be arrived by network connections such as internets Remote computer operation on network.Namely server 500 can be by the network interface that is connected on the system bus 505 Unit 511 is connected to network 512, in other words, Network Interface Unit 511 also can be used be connected to other kinds of network or Remote computer system (not shown).
The memory further includes that one or more than one program, the one or more programs are stored in In memory, central processing unit 501 realizes that Fig. 2 or ID shown in Fig. 3 is raw by executing one or more programs At method.
The embodiment of the invention provides a kind of computer readable storage medium, the computer-readable recording medium storage has Code command, the code command are executed by processor, realize ID generation method as shown in Figure 2 or Figure 3.
Those of ordinary skill in the art will appreciate that realizing that all or part of the steps of above-described embodiment can pass through hardware It completes, relevant hardware can also be instructed to complete by program, the program can store in a kind of computer-readable In storage medium, storage medium mentioned above can be read-only memory, disk or CD etc..
The foregoing is merely alternative embodiments of the invention, are not intended to limit the invention, it is all in spirit of the invention and Within principle, any modification, equivalent replacement, improvement and so on be should all be included in the protection scope of the present invention.

Claims (11)

1. a kind of ID generation method, which is characterized in that be used for server-side, which comprises
Receive the ID acquisition instruction that application end is initiated;
Target process mark and server-side mark are obtained, the target process, which is identified as in the server-side, executes the ID acquisition The mark of the target process of instruction;
It is identified based on specified time stamp, target process mark, the server-side and from increasing sequence, generates Target id, it is described Specified time stamp is positively correlated with current time stamp, and the bit of the specified time stamp is higher than the bit of target process mark Position and the server-side mark bit, the bit from increasing sequence lower than the target process mark bit and The bit of the server-side mark;
The Target id is sent to the application end.
2. the method according to claim 1, wherein the acquisition target process identifies, comprising:
Obtain the corresponding target process variable of the target process, process variable corresponding to different processes is not in the server-side Together;
Based on process identification (PID) configuration file, obtain the target process mark, the process identification (PID) configuration file for store into The mapping relations of Cheng Bianliang and process identification (PID).
3. according to the method described in claim 2, it is characterized in that, it is described be based on process identification (PID) configuration file, obtain the mesh Mark process identification (PID), comprising:
It detects and whether is stored with the target process variable and target process mark in the process identification (PID) configuration file Mapping relations;
When the mapping for being stored with the target process variable and target process mark in the process identification (PID) configuration file is closed When being, the target process mark is obtained from the process identification (PID) configuration file.
4. according to the method described in claim 3, it is characterized in that, in the detection process identification (PID) configuration file whether It is stored with after the mapping relations of the target process variable and target process mark, the method also includes:
When the mapping for having the target process variable and target process mark not stored in the process identification (PID) configuration file When relationship, the process identification (PID) configuration file is traversed, to obtain the maximum process mark of numerical value in the process identification (PID) configuration file Know;
1 obtained numerical value is added to be determined as the target process mark the maximum process identification (PID) of the numerical value;
The mapping relations of the target process variable and target process mark are stored in the process identification (PID) configuration file, Obtain updated process identification (PID) configuration file.
5. the method according to claim 1, wherein the acquisition server-side identifies, comprising:
It detects in the system configuration file of the server-side and is identified with the presence or absence of the server-side, the value of the server-side mark Range is 0 to N-1, and N is the maximum quantity for the server-side that system where the server-side is supported, N is positive integer;
When identifying in the system configuration file of the server-side there are the server-side, the server-side mark is obtained.
6. according to the method described in claim 5, it is characterized in that, in the system configuration file of the detection server-side After server-side mark, the method also includes:
When server-side mark is not present in the system configuration file of the server-side, configured from the O&M of the server-side Server-side ID is obtained in file;
By the server-side ID to N modulus, the server-side mark is obtained.
7. method according to any one of claims 1 to 6, which is characterized in that
The Target id by a high position to low level successively include marker bit, the specified time stamp, the target process mark, it is described Server-side mark and it is described from increasing sequence;
Alternatively, the Target id by a high position to low level successively include marker bit, the specified time stamp, the server-side mark, Target process mark and described from increasing sequence.
8. a kind of ID generating means, which is characterized in that be used for server-side, described device includes:
Receiving module, for receiving the ID acquisition instruction of application end initiation;
Module is obtained, for obtaining target process mark and server-side mark, the target process is identified as in the server-side Execute the mark of the target process of the ID acquisition instruction;
Generation module, it is raw for being identified based on specified time stamp, target process mark, the server-side and from increasing sequence At Target id, the specified time stamp is positively correlated with current time stamp, and the bit of the specified time stamp is higher than the target The bit of the bit of process identification (PID) and server-side mark, the bit from increasing sequence are lower than the target process The bit of the bit of mark and server-side mark;
Sending module, for sending the Target id to the application end.
9. a kind of ID generates system, which is characterized in that the system comprises: at least one server-side and at least one application end, The server-side includes ID generating means as claimed in claim 8.
10. a kind of ID generating means characterized by comprising memory and processor;
The memory, for storing computer program;
The processor is realized for executing the computer program stored on the memory as claim 1 to 7 is any The ID generation method.
11. a kind of computer readable storage medium, which is characterized in that the computer-readable recording medium storage has code to refer to It enables, the code command is executed by processor, realizes the ID generation method as described in claim 1 to 7 is any.
CN201811623080.0A 2018-12-28 2018-12-28 ID generation method, apparatus and system Pending CN109697133A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811623080.0A CN109697133A (en) 2018-12-28 2018-12-28 ID generation method, apparatus and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811623080.0A CN109697133A (en) 2018-12-28 2018-12-28 ID generation method, apparatus and system

Publications (1)

Publication Number Publication Date
CN109697133A true CN109697133A (en) 2019-04-30

Family

ID=66233030

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811623080.0A Pending CN109697133A (en) 2018-12-28 2018-12-28 ID generation method, apparatus and system

Country Status (1)

Country Link
CN (1) CN109697133A (en)

Cited By (19)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110287184A (en) * 2019-05-28 2019-09-27 必成汇(成都)科技有限公司 The method for generating distributed unique ID
CN110505306A (en) * 2019-08-30 2019-11-26 公安部交通管理科学研究所 A kind of data ID generation method may specify digit
CN110602158A (en) * 2019-07-24 2019-12-20 中国联合网络通信集团有限公司 Global unique ID generation system and method, ID generator and storage medium
CN110598068A (en) * 2019-09-19 2019-12-20 京东数字科技控股有限公司 Global identification generation method and device
CN110677511A (en) * 2019-09-29 2020-01-10 北京三快在线科技有限公司 Identification generation method, device, equipment and storage medium in distributed system
CN110798358A (en) * 2019-11-05 2020-02-14 泰康保险集团股份有限公司 Distributed service identification method and device, computer readable medium and electronic equipment
CN110825741A (en) * 2019-10-30 2020-02-21 北京蜜莱坞网络科技有限公司 Quick query method and device for tracking log
CN111046057A (en) * 2019-12-26 2020-04-21 京东数字科技控股有限公司 Data processing method and device for server cluster, computer equipment and medium
CN111190915A (en) * 2020-01-02 2020-05-22 腾讯科技(深圳)有限公司 Method for determining road tool identifier or role identifier, server and storage medium
CN111241508A (en) * 2019-12-31 2020-06-05 航天信息股份有限公司 Method and device for generating picture library authorization code and method and device for using picture library authorization code
CN111708997A (en) * 2020-06-19 2020-09-25 浙江大华技术股份有限公司 Method and device for determining target object identity identifier and storage medium
CN111708775A (en) * 2020-05-21 2020-09-25 四川虹美智能科技有限公司 Self-adding ID generation method, device and system
CN111917897A (en) * 2020-07-15 2020-11-10 深圳市腾讯网域计算机网络有限公司 Identification generation method, device, equipment and storage medium
CN112202938A (en) * 2020-10-12 2021-01-08 广州品唯软件有限公司 ID generation method, device and system
CN112202662A (en) * 2020-09-23 2021-01-08 北京达佳互联信息技术有限公司 Method and device for generating instant messaging identification information
CN112398968A (en) * 2020-11-24 2021-02-23 天津五八到家货运服务有限公司 ID generation system and method, generation terminal, server terminal and storage medium
WO2021052029A1 (en) * 2019-09-17 2021-03-25 苏宁云计算有限公司 Data object identifier generation method and apparatus, computer device, and storage medium
CN111930384B (en) * 2020-07-02 2021-04-06 上海微亿智造科技有限公司 Application method and system based on optimized snowflake algorithm in industrial big data
CN112905585A (en) * 2019-11-19 2021-06-04 北京沃东天骏信息技术有限公司 Number generation method and device

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102769667A (en) * 2012-06-29 2012-11-07 北京奇虎科技有限公司 Method, equipment and system for generating ID
CN107229555A (en) * 2017-05-04 2017-10-03 北京小度信息科技有限公司 Mark generating method and device
CN108959386A (en) * 2018-05-31 2018-12-07 深圳壹账通智能科技有限公司 Distributed globally unique ID generation method, device, equipment and storage medium

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102769667A (en) * 2012-06-29 2012-11-07 北京奇虎科技有限公司 Method, equipment and system for generating ID
CN107229555A (en) * 2017-05-04 2017-10-03 北京小度信息科技有限公司 Mark generating method and device
CN108959386A (en) * 2018-05-31 2018-12-07 深圳壹账通智能科技有限公司 Distributed globally unique ID generation method, device, equipment and storage medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
郭彦峰等: "《包装物流技术》", 30 June 2008 *

Cited By (25)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110287184A (en) * 2019-05-28 2019-09-27 必成汇(成都)科技有限公司 The method for generating distributed unique ID
CN110602158A (en) * 2019-07-24 2019-12-20 中国联合网络通信集团有限公司 Global unique ID generation system and method, ID generator and storage medium
CN110505306A (en) * 2019-08-30 2019-11-26 公安部交通管理科学研究所 A kind of data ID generation method may specify digit
CN110505306B (en) * 2019-08-30 2021-12-21 公安部交通管理科学研究所 Data ID generation method capable of specifying digit
WO2021052029A1 (en) * 2019-09-17 2021-03-25 苏宁云计算有限公司 Data object identifier generation method and apparatus, computer device, and storage medium
CN110598068A (en) * 2019-09-19 2019-12-20 京东数字科技控股有限公司 Global identification generation method and device
CN110677511A (en) * 2019-09-29 2020-01-10 北京三快在线科技有限公司 Identification generation method, device, equipment and storage medium in distributed system
CN110677511B (en) * 2019-09-29 2021-01-01 北京三快在线科技有限公司 Identification generation method, device, equipment and storage medium in distributed system
CN110825741A (en) * 2019-10-30 2020-02-21 北京蜜莱坞网络科技有限公司 Quick query method and device for tracking log
CN110798358A (en) * 2019-11-05 2020-02-14 泰康保险集团股份有限公司 Distributed service identification method and device, computer readable medium and electronic equipment
CN112905585A (en) * 2019-11-19 2021-06-04 北京沃东天骏信息技术有限公司 Number generation method and device
CN111046057A (en) * 2019-12-26 2020-04-21 京东数字科技控股有限公司 Data processing method and device for server cluster, computer equipment and medium
CN111241508A (en) * 2019-12-31 2020-06-05 航天信息股份有限公司 Method and device for generating picture library authorization code and method and device for using picture library authorization code
CN111190915A (en) * 2020-01-02 2020-05-22 腾讯科技(深圳)有限公司 Method for determining road tool identifier or role identifier, server and storage medium
CN111190915B (en) * 2020-01-02 2023-05-16 腾讯科技(深圳)有限公司 Prop identification or role identification determining method, server and storage medium
CN111708775B (en) * 2020-05-21 2023-06-27 四川虹美智能科技有限公司 Self-increment ID generation method, device and system
CN111708775A (en) * 2020-05-21 2020-09-25 四川虹美智能科技有限公司 Self-adding ID generation method, device and system
CN111708997B (en) * 2020-06-19 2023-06-13 浙江大华技术股份有限公司 Method, device and storage medium for determining target object identity identifier
CN111708997A (en) * 2020-06-19 2020-09-25 浙江大华技术股份有限公司 Method and device for determining target object identity identifier and storage medium
CN111930384B (en) * 2020-07-02 2021-04-06 上海微亿智造科技有限公司 Application method and system based on optimized snowflake algorithm in industrial big data
CN111917897A (en) * 2020-07-15 2020-11-10 深圳市腾讯网域计算机网络有限公司 Identification generation method, device, equipment and storage medium
CN111917897B (en) * 2020-07-15 2024-03-05 深圳市腾讯网域计算机网络有限公司 Identification generation method, device, equipment and storage medium
CN112202662A (en) * 2020-09-23 2021-01-08 北京达佳互联信息技术有限公司 Method and device for generating instant messaging identification information
CN112202938A (en) * 2020-10-12 2021-01-08 广州品唯软件有限公司 ID generation method, device and system
CN112398968A (en) * 2020-11-24 2021-02-23 天津五八到家货运服务有限公司 ID generation system and method, generation terminal, server terminal and storage medium

Similar Documents

Publication Publication Date Title
CN109697133A (en) ID generation method, apparatus and system
CN108769111A (en) A kind of server connection method, computer readable storage medium and terminal device
US10754869B2 (en) Managing data format of data received from devices in an internet of things network
CN109408590B (en) Method, device and equipment for expanding distributed database and storage medium
CN108881227B (en) Operation control method and device of remote whiteboard system and remote whiteboard system
CN109829287A (en) Api interface permission access method, equipment, storage medium and device
CN107800733B (en) Method and equipment for generating session identifier in distributed system
CN109582458A (en) Resource information loading method, device, storage medium and processor
CN108243079A (en) A kind of method and apparatus that network access is carried out based on VPC
CN108259533A (en) A kind of data transmission method and device
CN108694218A (en) A kind of method and apparatus data write-in and read
CN104202387A (en) Metadata recovery method and related device
US10296394B2 (en) Consistent hashing
CN109901798A (en) Date storage method and device
CN109145053B (en) Data processing method and device, client and server
CN110046062A (en) Distributed data processing method and system
CN110619022B (en) Node detection method, device, equipment and storage medium based on block chain network
CN109377383A (en) Product data synchronous method, device, computer equipment and storage medium
CN103905201B (en) Interaction method and device for master application and multiple slave applications
CN107451070B (en) Data processing method and server
CN101783742B (en) Discovery method and device of network topology
CN107948242A (en) More service number template message sending methods and system
CN107070719A (en) A kind of device management method and device
CN106888264A (en) A kind of method for interchanging data and device
CN109547259A (en) Application configuration method, apparatus, storage medium and electronic equipment

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
TA01 Transfer of patent application right
TA01 Transfer of patent application right

Effective date of registration: 20210115

Address after: 511442 3108, 79 Wanbo 2nd Road, Nancun Town, Panyu District, Guangzhou City, Guangdong Province

Applicant after: GUANGZHOU CUBESILI INFORMATION TECHNOLOGY Co.,Ltd.

Address before: 511446 28th floor, block B1, Wanda Plaza, Wanbo business district, Nancun Town, Panyu District, Guangzhou City, Guangdong Province

Applicant before: GUANGZHOU HUADUO NETWORK TECHNOLOGY Co.,Ltd.

EE01 Entry into force of recordation of patent licensing contract
EE01 Entry into force of recordation of patent licensing contract

Application publication date: 20190430

Assignee: GUANGZHOU HUADUO NETWORK TECHNOLOGY Co.,Ltd.

Assignor: GUANGZHOU CUBESILI INFORMATION TECHNOLOGY Co.,Ltd.

Contract record no.: X2021440000052

Denomination of invention: ID generation method, device and system

License type: Common License

Record date: 20210222

RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20190430