CN111538594A - Order ID generation method, device, equipment and medium based on distributed system - Google Patents
Order ID generation method, device, equipment and medium based on distributed system Download PDFInfo
- Publication number
- CN111538594A CN111538594A CN202010319510.0A CN202010319510A CN111538594A CN 111538594 A CN111538594 A CN 111538594A CN 202010319510 A CN202010319510 A CN 202010319510A CN 111538594 A CN111538594 A CN 111538594A
- Authority
- CN
- China
- Prior art keywords
- order
- generated
- node server
- primary key
- distributed system
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
- 238000000034 method Methods 0.000 title claims abstract description 36
- 238000004590 computer program Methods 0.000 claims description 5
- 230000002567 autonomic effect Effects 0.000 claims 1
- 241000533950 Leucojum Species 0.000 description 6
- 230000006870 function Effects 0.000 description 6
- 238000010586 diagram Methods 0.000 description 4
- 238000012545 processing Methods 0.000 description 4
- 230000008676 import Effects 0.000 description 3
- 230000003993 interaction Effects 0.000 description 3
- 238000004891 communication Methods 0.000 description 2
- 239000004973 liquid crystal related substance Substances 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 230000003287 optical effect Effects 0.000 description 2
- 230000008569 process Effects 0.000 description 2
- 238000001514 detection method Methods 0.000 description 1
- 230000002093 peripheral effect Effects 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
- 238000012546 transfer Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements 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/46—Multiprogramming arrangements
- G06F9/50—Allocation of resources, e.g. of the central processing unit [CPU]
- G06F9/5005—Allocation of resources, e.g. of the central processing unit [CPU] to service a request
- G06F9/5027—Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements 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/46—Multiprogramming arrangements
- G06F9/50—Allocation of resources, e.g. of the central processing unit [CPU]
- G06F9/5083—Techniques for rebalancing the load in a distributed system
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/01—Protocols
- H04L67/10—Protocols in which an application is distributed across nodes in the network
- H04L67/1001—Protocols in which an application is distributed across nodes in the network for accessing one among a plurality of replicated servers
- H04L67/1004—Server selection for load balancing
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02P—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN THE PRODUCTION OR PROCESSING OF GOODS
- Y02P90/00—Enabling technologies with a potential contribution to greenhouse gas [GHG] emissions mitigation
- Y02P90/30—Computing systems specially adapted for manufacturing
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The invention relates to the technical field of cloud service, and discloses an order ID generation method based on a distributed system, which comprises the following steps: acquiring all node servers in a distributed system; distributing the ID primary key of the node server by using a preset self-increment sequence algorithm; recording ID generation time stamps of all orders to be generated in the node server, and determining ID serial numbers of all orders to be generated in the node server; and generating a timestamp and the ID serial number of the order to be generated according to the ID main key of the node server, the ID of the order to be generated, and compiling and generating the ID of the order to be generated by using a preset ID generator. The invention also provides an order ID generating device based on the distributed system, electronic equipment and a computer readable storage medium. The invention can solve the problem of ID collision when the order ID is generated based on a distributed system.
Description
Technical Field
The invention relates to the technical field of cloud services, in particular to a method and a device for generating an order ID based on a distributed system, electronic equipment and a computer-readable storage medium.
Background
A distributed system refers to a system in which a plurality of nodes are connected together through a network and coordinated through the transfer of messages. The nodes include database nodes, network nodes, and processor nodes, among others. Generally, a node refers to a software/hardware deployed in a server, that is, a corresponding software/hardware node, for example, each computer connected to a network server is a network node.
Currently, order ID generation for multiple nodes in a distributed system is usually based on an squence algorithm, but when the order ID of the multiple nodes in the distributed system is generated through the squence algorithm, a phenomenon of order ID duplication usually occurs, so that order ID collision occurs.
Disclosure of Invention
The invention provides a method and a device for generating an order ID based on a distributed system, electronic equipment and a computer readable storage medium, and mainly aims to solve the problem of ID collision during order ID generation based on the distributed system and improve the performance of the distributed system.
In order to achieve the above object, the method for generating an order ID based on a distributed system according to the present invention includes:
acquiring all node servers in a distributed system;
distributing the ID primary key of the node server by using a preset self-increment sequence algorithm;
recording ID generation time stamps of all orders to be generated in the node server, and determining ID serial numbers of all orders to be generated in the node server;
and generating a timestamp and the ID serial number of the order to be generated according to the ID main key of the node server, the ID of the order to be generated, and compiling and generating the ID of the order to be generated by using a preset ID generator.
Optionally, the allocating the ID primary key of the node server by using a preset self-increment sequence algorithm includes:
configuring an ID primary key compiling environment of the node server;
importing a jar package generated by a preset ID primary key into the ID primary key compiling environment;
initializing an ID primary key of the node server;
and adding one to the initialized ID primary key of the node server, and then running the jar packet to generate the ID primary key of the node server.
Optionally, the recording ID generation timestamps of all orders to be generated in the node server, and determining ID sequence numbers of all orders to be generated in the node server includes:
and recording the ID generation time stamp of the node server according to the preset time sequence length, and generating the ID serial number of the node server according to the preset ID sequence length.
Optionally, the generating a timestamp and an ID serial number of the order to be generated according to the ID primary key of the node server, the ID of the order to be generated, and compiling and generating the ID of the order to be generated by using a preset ID generator includes:
acquiring ID identification digits of all orders to be generated in the node server according to the ID main key of the node server, the ID generation timestamp of the orders to be generated and the ID serial number of the orders to be generated;
configuring an order ID of the node server to generate a compiling environment, and importing the ID identification digits into the order ID generating compiling environment;
compiling the ID identification digits by using the preset ID generator to obtain a source program code packet generated by the order ID, operating the source program code packet, and generating the ID of the order to be generated.
Optionally, after generating the ID of the order to be generated, the method further includes:
and storing the ID of the order to be generated into a preset cache, setting the ID valid time of the order to be generated in the preset cache, and deleting the corresponding order ID according to the valid time.
In order to solve the above problem, the present invention further provides an order ID generation apparatus based on a distributed system, including:
the acquisition module is used for acquiring all node servers in the distributed system;
the distribution module is used for distributing the ID primary key of the node server by utilizing a preset self-increment sequence algorithm;
the recording and determining module is used for recording the ID generation time stamps of all orders to be generated in the node server and determining the ID serial numbers of all orders to be generated in the node server;
and the generating module is used for generating a timestamp and an ID serial number of the order to be generated according to the ID main key of the node server and the ID of the order to be generated, and compiling and generating the ID of the order to be generated by using a preset ID generator.
Optionally, the allocation module comprises:
configuring and importing a submodule: the ID primary key compiling environment is used for configuring the node server, and a jar packet generated by a preset ID primary key is led into the ID primary key compiling environment;
initializing and operating the sub-modules: and the key management module is used for initializing the ID primary key of the node server, adding one to the initialized ID primary key of the node server and then running the jar packet to generate the ID primary key of the node server.
Optionally, the generating module includes:
an acquisition and configuration submodule: the order ID generation compiling environment is configured, and the ID identification digits are led into the order ID generation compiling environment;
compiling and running the submodule: and compiling the ID identification digits by using the preset ID generator to obtain a source program code packet generated by the order ID, operating the source program code packet, and generating the ID of the order to be generated.
In order to solve the above problem, the present invention also provides an electronic device, including:
a memory storing at least one instruction; and
and the processor executes the instructions stored in the memory to realize the order ID generation method based on the distributed system.
In order to solve the above problem, the present invention further provides a computer-readable storage medium, which stores at least one instruction, where the at least one instruction is executed by a processor in an electronic device to implement the distributed system-based order ID generation method described above.
The embodiment of the invention acquires all node servers in a distributed system, allocates the ID primary keys of the node servers by using a preset self-increment sequence algorithm, and can determine the global uniqueness of the node servers through the allocated ID primary keys, thereby ensuring the ID uniqueness generated in the node servers and further avoiding the phenomenon of random collision when the order IDs are generated in the subsequent node servers; further, deploying ID generation time stamps of all orders to be generated in the node server, determining ID serial numbers of all orders to be generated in the node server, combining the ID main key, the ID generation time stamps and the ID serial numbers, and compiling and generating the IDs of the orders to be generated by using a preset ID generator. Therefore, the order ID generation method, the order ID generation device, the electronic equipment and the computer readable storage medium based on the distributed system can solve the problem of ID collision during order ID generation based on the distributed system and improve the performance of the distributed system.
Drawings
Fig. 1 is a schematic flowchart of an order ID generation method based on a distributed system according to an embodiment of the present invention;
FIG. 2 is a flowchart illustrating a detailed implementation of step S4 in the text feature semantic extracting method of FIG. 1 according to the present invention;
fig. 3 is a schematic block diagram of an order ID generation apparatus based on a distributed system according to an embodiment of the present invention;
fig. 4 is a schematic internal structural diagram of an electronic device implementing the order ID generation method based on the distributed system according to an embodiment of the present invention;
the implementation, functional features and advantages of the objects of the present invention will be further explained with reference to the accompanying drawings.
Detailed Description
It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
The invention provides an order ID generation method based on a distributed system. Fig. 1 is a schematic flow chart of an order ID generation method based on a distributed system according to an embodiment of the present invention. The method may be performed by an apparatus, which may be implemented by software and/or hardware.
In this embodiment, the method for generating an order ID based on a distributed system includes:
and S1, acquiring all node servers in the distributed system.
In at least one embodiment of the present invention, the distributed system is created based on different user requirements and is composed of hardware devices such as servers (hereinafter referred to as node servers), databases, and routers.
In an alternative embodiment, the distributed system may be a mall order system, which includes an order creation subsystem, an order modification subsystem, an order sending subsystem, an order receiving subsystem, and the like. In the mall order system, each subsystem included in the mall order system may be installed in different node servers, and the intercommunication operation between the subsystems is realized through the network connection between the different node servers.
Further, the distributed system in the embodiment of the present invention may utilize different node servers to process different user requirements, for example, if a user requires to create an order, the embodiment of the present invention allocates the order creation task to one of the node servers, where the node server performs order creation according to the user requirement, where the method includes: and obtaining a jar packet of the order, interacting with a background database to obtain a serial number of the order, and returning the serial number to a front-end page to realize the creation of the order.
Further, the embodiment of the present invention obtains all node servers deployed in the distributed system, and uses the reverse proxy to implement the balanced load of each node server in the distributed system, that is, the task amount that each node server needs to execute is consistent, so as to accelerate the processing of the user request and implement the resource service balance of the distributed system.
And S2, distributing the ID primary key of the node server by using a preset self-increment sequence algorithm.
The ID primary key is also called nodeID, and the uniqueness of the node server in the distributed system can be identified through the ID primary key.
Preferably, the preset self-increment sequence algorithm according to the embodiment of the present invention includes a redis self-increment sequence algorithm.
In detail, the allocating the ID primary key of the node server by using a preset self-increment sequence algorithm includes:
configuring an ID primary key compiling environment of the node server, importing a preset ID primary key generation jar packet into the ID primary key compiling environment, initializing the ID primary key of the node server, performing key value plus one operation on the initialized ID primary key of the node server by utilizing a Redis Incr command, and then running the jar packet to generate the ID primary key of the node server.
Optionally, in the embodiment of the present invention, the ID primary key compiling environment of the node server may be configured by using a Java programming language.
Optionally, the preset ID primary key jar package is generated by java language compilation.
Further, after the ID primary key of the node server is allocated by using a preset auto-increment sequence algorithm, the embodiment of the present invention further includes: the ID primary key is stored in a local cache, and the ID primary key of the local cache is directly inquired, so that excessive interaction times with a background database can be avoided, the performance of a distributed system is improved, and the inquiry time of the ID primary key of a subsequent node server is shortened.
In at least one embodiment of the invention, the ID primary key of the node server is distributed by a preset self-increment sequence algorithm, so that the uniqueness of the node server in a distributed system is realized, and the global uniqueness of the order ID generated in different node servers subsequently can be ensured.
And S3, recording ID generation time stamps of all orders to be generated in the node server, and determining the ID serial numbers of all orders to be generated in the node server.
In at least one embodiment of the present invention, ID generation time stamps of all orders to be generated in the node server may be recorded by using a time sequence length of 41-bit millisecond order in a snowflake algorithm structure, and ID sequence numbers of all orders to be generated in the node server may be determined by using a 12-bit ID sequence length in the snowflake algorithm structure.
The ID generation time stamp refers to a difference between an ID generation end time stamp and an ID generation start time stamp.
The ID serial number refers to an order number of an order to be generated, and the ID number of the generated order of the node server can be determined.
The snowflake algorithm comprises the following steps: 1-bit highest bit identifier, 41-bit millisecond time series length, 5-bit data center identification length, 5-bit server identification length and 12-bit ID series length.
And S4, generating a timestamp and an ID serial number of the order to be generated according to the ID main key of the node server and the ID of the order to be generated, and compiling and generating the ID of the order to be generated by using a preset ID generator.
In detail, referring to fig. 2, the generating an ID according to the ID primary key, the ID generation timestamp, and the ID serial number, and compiling the ID of the node server by using a preset ID generator includes:
s40, acquiring the ID identification digits of all orders to be generated in the node server according to the ID primary key of the node server, the ID generation time stamp of the orders to be generated and the ID serial number of the orders to be generated.
Optionally, the ID identification bits include occupied bits of a data center, occupied bits of a serial number, and occupied bits of a machine. The data center refers to a database interacting with the node servers, and the machine refers to a carrier running a task to be executed by the corresponding node server.
S41, configuring the order ID generation compiling environment of the node server, and importing the ID identification digits into the order ID generation compiling environment.
Preferably, the embodiment of the present invention configures an ID generation compilation environment of the node server through a java programming language, and imports the ID identification bits into the ID generation environment by using a get () method.
And S42, compiling the ID identification digits by using the preset ID generator to obtain a source program code packet generated by the order ID, operating the source program code packet, and generating the ID of the order to be generated.
Optionally, the preset ID generator is obtained by compiling through java programming language.
In another embodiment of the present invention, after generating the ID of the order to be generated, the method further includes: and storing the ID of the order to be generated into a redis cache, setting the ID valid time of the order to be generated in the redis cache, and deleting the corresponding order ID according to the valid time so as to support the high concurrency of a distributed system.
The embodiment of the invention acquires all node servers in a distributed system, allocates the ID primary keys of the node servers by using a preset self-increment sequence algorithm, and can determine the global uniqueness of the node servers through the allocated ID primary keys, thereby ensuring the ID uniqueness generated in the node servers and further avoiding the phenomenon of random collision when the order IDs are generated in the subsequent node servers; further, deploying ID generation time stamps of all orders to be generated in the node server, determining ID serial numbers of all orders to be generated in the node server, combining the ID main key, the ID generation time stamps and the ID serial numbers, and compiling and generating the IDs of the orders to be generated by using a preset ID generator. Therefore, the order ID generation method based on the distributed system can solve the problem of ID collision when the order ID based on the distributed system generates the ID, and improve the performance of the distributed system.
Fig. 3 is a schematic block diagram of an order ID generation apparatus based on a distributed system according to an embodiment of the present invention.
The order ID generation apparatus 100 based on the distributed system according to the present invention may be installed in an electronic device. According to the implemented functions, the order ID generation apparatus based on the distributed system may include an acquisition module 101, an allocation module 102, a recording and determining module 103, and a generation module 104. The module of the present invention, which may also be referred to as a unit, refers to a series of computer program segments that can be executed by a processor of an electronic device and that can perform a fixed function, and that are stored in a memory of the electronic device.
In the present embodiment, the functions regarding the respective modules/units are as follows:
the obtaining module 101 is configured to obtain all node servers in the distributed system.
The ID primary key is also called nodeID, and the uniqueness of the node server in the distributed system can be identified through the ID primary key.
Preferably, the preset self-increment sequence algorithm according to the embodiment of the present invention includes a redis self-increment sequence algorithm.
In detail, the allocating the ID primary key of the node server by using a preset self-increment sequence algorithm includes:
configuring an ID primary key compiling environment of the node server, importing a preset ID primary key generation jar packet into the ID primary key compiling environment, initializing the ID primary key of the node server, performing key value plus one operation on the initialized ID primary key of the node server by utilizing a Redis Incr command, and then running the jar packet to generate the ID primary key of the node server.
Optionally, in the embodiment of the present invention, the ID primary key compiling environment of the node server may be configured by using a Java programming language.
Optionally, the preset ID primary key jar package is generated by java language compilation.
Further, after the ID primary key of the node server is allocated by using a preset auto-increment sequence algorithm, the embodiment of the present invention further includes: the ID primary key is stored in a local cache, and the ID primary key of the local cache is directly inquired, so that excessive interaction times with a background database can be avoided, the performance of a distributed system is improved, and the inquiry time of the ID primary key of a subsequent node server is shortened.
In at least one embodiment of the invention, the ID primary key of the node server is distributed by a preset self-increment sequence algorithm, so that the uniqueness of the node server in a distributed system is realized, and the global uniqueness of the order ID generated in different node servers subsequently can be ensured.
The allocating module 102 is configured to allocate the ID primary key of the node server by using a preset auto-increment sequence algorithm.
The ID primary key is also called nodeID, and the uniqueness of the node server in the distributed system can be identified through the ID primary key.
Preferably, the preset self-increment sequence algorithm according to the embodiment of the present invention includes a redis self-increment sequence algorithm.
In detail, the allocating the ID primary key of the node server by using a preset self-increment sequence algorithm includes:
configuration and import sub-module 1020: and the ID primary key compiling environment is used for configuring the node server, and a jar packet generated by a preset ID primary key is led into the ID primary key compiling environment.
Initialization and run sub-module 1021: and the key value adding unit is used for initializing the ID primary key of the node server, adding one to the initialized ID primary key of the node server, and then running the jar packet to generate the ID primary key of the node server.
Optionally, in the embodiment of the present invention, the ID primary key compiling environment of the node server may be configured by using a Java programming language.
Optionally, the preset ID primary key jar package is generated by java language compilation.
Further, after the ID primary key of the node server is allocated by using a preset auto-increment sequence algorithm, the embodiment of the present invention further includes: the ID primary key is stored in a local cache, and the ID primary key of the local cache is directly inquired, so that excessive interaction times with a background database can be avoided, the performance of a distributed system is improved, and the inquiry time of the ID primary key of a subsequent node server is shortened.
In at least one embodiment of the invention, the ID primary key of the node server is distributed by a preset self-increment sequence algorithm, so that the uniqueness of the node server in a distributed system is realized, and the global uniqueness of the order ID generated in different node servers subsequently can be ensured.
The recording and determining module 103 is configured to record ID generation timestamps of all orders to be generated in the node server, and determine ID serial numbers of all orders to be generated in the node server.
In at least one embodiment of the present invention, ID generation time stamps of all orders to be generated in the node server may be recorded by using a time sequence length of 41-bit millisecond order in a snowflake algorithm structure, and ID sequence numbers of all orders to be generated in the node server may be determined by using a 12-bit ID sequence length in the snowflake algorithm structure.
The ID generation time stamp refers to a difference between an ID generation end time stamp and an ID generation start time stamp.
The ID serial number refers to an order number of an order to be generated, and the ID number of the generated order of the node server can be determined.
The snowflake algorithm comprises the following steps: 1-bit highest bit identifier, 41-bit millisecond time series length, 5-bit data center identification length, 5-bit server identification length and 12-bit ID series length.
The generating module 104 is configured to generate a timestamp and an ID serial number of the order to be generated according to the ID primary key of the node server, the ID of the order to be generated, and generate the ID of the order to be generated by compiling with a preset ID generator.
In detail, the generating an ID according to the ID primary key, the ID generation timestamp, and the ID serial number, and compiling the ID of the node server by using a preset ID generator includes:
the acquisition and configuration submodule 1040: the order ID generation compiling environment is configured, and the ID identification digits are imported into the order ID generation compiling environment.
Optionally, the ID identification bits include occupied bits of a data center, occupied bits of a serial number, and occupied bits of a machine. The data center refers to a database interacting with the node servers, and the machine refers to a carrier running a task to be executed by the corresponding node server.
Preferably, the embodiment of the present invention configures an ID generation compilation environment of the node server through a java programming language, and imports the ID identification bits into the ID generation environment by using a get () method.
Compiling and running submodule 1041: and compiling the ID identification digits by using the preset ID generator to obtain a source program code packet generated by the order ID, operating the source program code packet, and generating the ID of the order to be generated.
Optionally, the preset ID generator is obtained by compiling through java programming language.
In another embodiment of the present invention, after generating the ID of the order to be generated, the method further includes: and storing the ID of the order to be generated into a redis cache, setting the ID valid time of the order to be generated in the redis cache, and deleting the corresponding order ID according to the valid time so as to support the high concurrency of a distributed system.
The embodiment of the invention acquires all node servers in a distributed system, allocates the ID primary keys of the node servers by using a preset self-increment sequence algorithm, and can determine the global uniqueness of the node servers through the allocated ID primary keys, thereby ensuring the ID uniqueness generated in the node servers and further avoiding the phenomenon of random collision when the order IDs are generated in the subsequent node servers; further, deploying ID generation time stamps of all orders to be generated in the node server, determining ID serial numbers of all orders to be generated in the node server, combining the ID main key, the ID generation time stamps and the ID serial numbers, and compiling and generating the IDs of the orders to be generated by using a preset ID generator. Therefore, the order ID generation device based on the distributed system can solve the phenomenon of ID collision when the order ID based on the distributed system generates the ID, and improve the performance of the distributed system.
Fig. 4 is a schematic structural diagram of an electronic device implementing the method for generating an order ID based on a distributed system according to an embodiment of the present invention.
The electronic device 1 may comprise a processor 10, a memory 11 and a bus, and may further comprise a computer program stored in the memory 11 and executable on the processor 10, such as an order ID generation program based on a distributed system.
The memory 11 includes at least one type of readable storage medium, which includes flash memory, removable hard disk, multimedia card, card-type memory (e.g., SD or DX memory, etc.), magnetic memory, magnetic disk, optical disk, etc. The memory 11 may in some embodiments be an internal storage unit of the electronic device 1, such as a removable hard disk of the electronic device 1. The memory 11 may also be an external storage device of the electronic device 1 in other embodiments, such as a plug-in mobile hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like, which are provided on the electronic device 1. Further, the memory 11 may also include both an internal storage unit and an external storage device of the electronic device 1. The memory 11 may be used not only to store application software installed in the electronic device 1 and various types of data, such as codes of an order ID generation program based on a distributed system, but also to temporarily store data that has been output or is to be output.
The processor 10 may be composed of an integrated circuit in some embodiments, for example, a single packaged integrated circuit, or may be composed of a plurality of integrated circuits packaged with the same or different functions, including one or more Central Processing Units (CPUs), microprocessors, digital Processing chips, graphics processors, and combinations of various control chips. The processor 10 is a Control Unit (Control Unit) of the electronic device, connects various components of the electronic device by using various interfaces and lines, and executes various functions and processes data of the electronic device 1 by running or executing programs or modules (for example, an order ID generation program based on a distributed system, etc.) stored in the memory 11 and calling data stored in the memory 11.
The bus may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The bus may be divided into an address bus, a data bus, a control bus, etc. The bus is arranged to enable connection communication between the memory 11 and at least one processor 10 or the like.
Fig. 4 only shows an electronic device with components, and it will be understood by those skilled in the art that the structure shown in fig. 4 does not constitute a limitation of the electronic device 1, and may comprise fewer or more components than those shown, or some components may be combined, or a different arrangement of components.
For example, although not shown, the electronic device 1 may further include a power supply (such as a battery) for supplying power to each component, and preferably, the power supply may be logically connected to the at least one processor 10 through a power management device, so as to implement functions of charge management, discharge management, power consumption management, and the like through the power management device. The power supply may also include any component of one or more dc or ac power sources, recharging devices, power failure detection circuitry, power converters or inverters, power status indicators, and the like. The electronic device 1 may further include various sensors, a bluetooth module, a Wi-Fi module, and the like, which are not described herein again.
Further, the electronic device 1 may further include a network interface, and optionally, the network interface may include a wired interface and/or a wireless interface (such as a WI-FI interface, a bluetooth interface, etc.), which are generally used for establishing a communication connection between the electronic device 1 and other electronic devices.
Optionally, the electronic device 1 may further comprise a user interface, which may be a Display (Display), an input unit (such as a Keyboard), and optionally a standard wired interface, a wireless interface. Alternatively, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, an OLED (Organic Light-Emitting Diode) touch device, or the like. The display, which may also be referred to as a display screen or display unit, is suitable for displaying information processed in the electronic device 1 and for displaying a visualized user interface, among other things.
It is to be understood that the described embodiments are for purposes of illustration only and that the scope of the appended claims is not limited to such structures.
The distributed system based order ID generation program 12 stored in the memory 11 of the electronic device 1 is a combination of a plurality of instructions, and when running in the processor 10, can realize:
acquiring all node servers in a distributed system;
distributing the ID primary key of the node server by using a preset self-increment sequence algorithm;
recording ID generation time stamps of all orders to be generated in the node server, and determining ID serial numbers of all orders to be generated in the node server;
and generating a timestamp and the ID serial number of the order to be generated according to the ID main key of the node server, the ID of the order to be generated, and compiling and generating the ID of the order to be generated by using a preset ID generator.
Specifically, the specific implementation method of the processor 10 for the instruction may refer to the description of the relevant steps in the embodiment corresponding to fig. 1, which is not described herein again.
Further, the integrated modules/units of the electronic device 1, if implemented in the form of software functional units and sold or used as separate products, may be stored in a computer readable storage medium. The computer-readable medium may include: any entity or device capable of carrying said computer program code, recording medium, U-disk, removable hard disk, magnetic disk, optical disk, computer Memory, Read-Only Memory (ROM).
In the embodiments provided in the present invention, it should be understood that the disclosed apparatus, device and method can be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the modules is only one logical functional division, and other divisions may be realized in practice.
The modules described as separate parts may or may not be physically separate, and parts displayed as modules may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment.
In addition, functional modules in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, or in a form of hardware plus a software functional module.
It will be evident to those skilled in the art that the invention is not limited to the details of the foregoing illustrative embodiments, and that the present invention may be embodied in other specific forms without departing from the spirit or essential attributes thereof.
The present embodiments are therefore to be considered in all respects as illustrative and not restrictive, the scope of the invention being indicated by the appended claims rather than by the foregoing description, and all changes which come within the meaning and range of equivalency of the claims are therefore intended to be embraced therein. Any reference signs in the claims shall not be construed as limiting the claim concerned.
Furthermore, it is obvious that the word "comprising" does not exclude other elements or steps, and the singular does not exclude the plural. A plurality of units or means recited in the system claims may also be implemented by one unit or means in software or hardware. The terms second, etc. are used to denote names, but not any particular order.
Finally, it should be noted that the above embodiments are only for illustrating the technical solutions of the present invention and not for limiting, and although the present invention is described in detail with reference to the preferred embodiments, it should be understood by those skilled in the art that modifications or equivalent substitutions may be made on the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention.
Claims (10)
1. An order ID generation method based on a distributed system is characterized by comprising the following steps:
acquiring all node servers in a distributed system;
distributing the ID primary key of the node server by using a preset self-increment sequence algorithm;
recording ID generation time stamps of all orders to be generated in the node server, and determining ID serial numbers of all orders to be generated in the node server;
and generating a timestamp and the ID serial number of the order to be generated according to the ID main key of the node server, the ID of the order to be generated, and compiling and generating the ID of the order to be generated by using a preset ID generator.
2. The distributed system-based order ID generation method according to claim 1, wherein said assigning the ID primary key of the node server by using a preset autonomic sequence algorithm comprises:
configuring an ID primary key compiling environment of the node server;
importing a jar package generated by a preset ID primary key into the ID primary key compiling environment;
initializing an ID primary key of the node server;
and adding one to the initialized ID primary key of the node server, and then running the jar packet to generate the ID primary key of the node server.
3. The order ID generation method based on the distributed system as claimed in claim 1, wherein the recording ID generation time stamps of all orders to be generated in the node server, and determining ID serial numbers of all orders to be generated in the node server includes:
and recording the ID generation time stamp of the node server according to the preset time sequence length, and generating the ID serial number of the node server according to the preset ID sequence length.
4. The order ID generation method based on the distributed system as claimed in claim 1, wherein the generating a timestamp and an ID serial number of the order to be generated according to the ID primary key of the node server, the ID of the order to be generated, and compiling and generating the ID of the order to be generated by using a preset ID generator includes:
acquiring ID identification digits of all orders to be generated in the node server according to the ID main key of the node server, the ID generation timestamp of the orders to be generated and the ID serial number of the orders to be generated;
configuring an order ID of the node server to generate a compiling environment, and importing the ID identification digits into the order ID generating compiling environment;
compiling the ID identification digits by using the preset ID generator to obtain a source program code packet generated by the order ID, operating the source program code packet, and generating the ID of the order to be generated.
5. The distributed system-based order ID generation method according to any one of claims 1 to 4, wherein after generating the ID of the order to be generated, the method further comprises:
and storing the ID of the order to be generated into a preset cache, setting the ID valid time of the order to be generated in the preset cache, and deleting the corresponding order ID according to the valid time.
6. An order ID generation apparatus based on a distributed system, the apparatus comprising:
the acquisition module is used for acquiring all node servers in the distributed system;
the distribution module is used for distributing the ID primary key of the node server by utilizing a preset self-increment sequence algorithm;
the recording and determining module is used for recording the ID generation time stamps of all orders to be generated in the node server and determining the ID serial numbers of all orders to be generated in the node server;
and the generating module is used for generating a timestamp and an ID serial number of the order to be generated according to the ID main key of the node server and the ID of the order to be generated, and compiling and generating the ID of the order to be generated by using a preset ID generator.
7. The distributed system-based order ID generation apparatus of claim 6, wherein the assignment module comprises:
configuring and importing a submodule: the ID primary key compiling environment is used for configuring the node server, and a jar packet generated by a preset ID primary key is led into the ID primary key compiling environment;
initializing and operating the sub-modules: and the key management module is used for initializing the ID primary key of the node server, adding one to the initialized ID primary key of the node server and then running the jar packet to generate the ID primary key of the node server.
8. The distributed system-based order ID generation apparatus of claim 6, wherein the generation module comprises:
an acquisition and configuration submodule: the order ID generation compiling environment is configured, and the ID identification digits are led into the order ID generation compiling environment;
compiling and running the submodule: and compiling the ID identification digits by using the preset ID generator to obtain a source program code packet generated by the order ID, operating the source program code packet, and generating the ID of the order to be generated.
9. An electronic device, characterized in that the electronic device comprises:
at least one processor; and the number of the first and second groups,
a memory communicatively coupled to the at least one processor; wherein,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the distributed system based order ID generation method of any of claims 1 to 5.
10. A computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor, implements the distributed system-based order ID generation method according to any one of claims 1 to 5.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010319510.0A CN111538594B (en) | 2020-04-21 | 2020-04-21 | Order ID generation method, device, equipment and medium based on distributed system |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010319510.0A CN111538594B (en) | 2020-04-21 | 2020-04-21 | Order ID generation method, device, equipment and medium based on distributed system |
Publications (2)
Publication Number | Publication Date |
---|---|
CN111538594A true CN111538594A (en) | 2020-08-14 |
CN111538594B CN111538594B (en) | 2023-04-18 |
Family
ID=71975150
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202010319510.0A Active CN111538594B (en) | 2020-04-21 | 2020-04-21 | Order ID generation method, device, equipment and medium based on distributed system |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN111538594B (en) |
Cited By (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112073554A (en) * | 2020-09-08 | 2020-12-11 | 腾讯科技(深圳)有限公司 | Global unique identifier generation method, device and computer readable storage medium |
CN112199083A (en) * | 2020-10-16 | 2021-01-08 | 深圳无域科技技术有限公司 | Configurable ID generation system and method based on expression |
CN112202938A (en) * | 2020-10-12 | 2021-01-08 | 广州品唯软件有限公司 | ID generation method, device and system |
CN112667685A (en) * | 2020-12-29 | 2021-04-16 | 北京先进数通信息技术股份公司 | Serial number configuration method, device, equipment and storage medium |
CN114723525A (en) * | 2022-04-08 | 2022-07-08 | 湖南快乐阳光互动娱乐传媒有限公司 | Order ID processing method and device, storage medium and electronic equipment |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN108765087A (en) * | 2018-05-31 | 2018-11-06 | 康键信息技术(深圳)有限公司 | Order asynchronous processing method, server and storage medium |
CN109639775A (en) * | 2018-11-27 | 2019-04-16 | 湖南蚁为软件有限公司 | Global monotonic increase ID generation method, device, system and equipment |
CN109636551A (en) * | 2019-01-31 | 2019-04-16 | 上海易点时空网络有限公司 | Service order generation method and device |
CN110634052A (en) * | 2019-09-20 | 2019-12-31 | 中国银行股份有限公司 | Method and device for generating order number by distributed architecture |
-
2020
- 2020-04-21 CN CN202010319510.0A patent/CN111538594B/en active Active
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN108765087A (en) * | 2018-05-31 | 2018-11-06 | 康键信息技术(深圳)有限公司 | Order asynchronous processing method, server and storage medium |
CN109639775A (en) * | 2018-11-27 | 2019-04-16 | 湖南蚁为软件有限公司 | Global monotonic increase ID generation method, device, system and equipment |
CN109636551A (en) * | 2019-01-31 | 2019-04-16 | 上海易点时空网络有限公司 | Service order generation method and device |
CN110634052A (en) * | 2019-09-20 | 2019-12-31 | 中国银行股份有限公司 | Method and device for generating order number by distributed architecture |
Cited By (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112073554A (en) * | 2020-09-08 | 2020-12-11 | 腾讯科技(深圳)有限公司 | Global unique identifier generation method, device and computer readable storage medium |
CN112073554B (en) * | 2020-09-08 | 2023-04-18 | 腾讯科技(深圳)有限公司 | Global unique identifier generation method, device and computer readable storage medium |
CN112202938A (en) * | 2020-10-12 | 2021-01-08 | 广州品唯软件有限公司 | ID generation method, device and system |
CN112199083A (en) * | 2020-10-16 | 2021-01-08 | 深圳无域科技技术有限公司 | Configurable ID generation system and method based on expression |
CN112667685A (en) * | 2020-12-29 | 2021-04-16 | 北京先进数通信息技术股份公司 | Serial number configuration method, device, equipment and storage medium |
CN112667685B (en) * | 2020-12-29 | 2024-04-16 | 北京先进数通信息技术股份公司 | Method, device, equipment and storage medium for configuring serial numbers |
CN114723525A (en) * | 2022-04-08 | 2022-07-08 | 湖南快乐阳光互动娱乐传媒有限公司 | Order ID processing method and device, storage medium and electronic equipment |
Also Published As
Publication number | Publication date |
---|---|
CN111538594B (en) | 2023-04-18 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN111538594B (en) | Order ID generation method, device, equipment and medium based on distributed system | |
CN112948427A (en) | Data query method, device, equipment and storage medium | |
CN112464619B (en) | Big data processing method, device and equipment and computer readable storage medium | |
CN113239106A (en) | Excel file export method and device, electronic equipment and storage medium | |
CN112685117A (en) | System language internationalization maintenance method, device and computer readable storage medium | |
CN113297180A (en) | Data migration method and device, electronic equipment and storage medium | |
CN114356530A (en) | Task scheduling method and device, electronic equipment and storage medium | |
CN112445623A (en) | Multi-cluster management method and device, electronic equipment and storage medium | |
CN114398194A (en) | Data collection method and device, electronic equipment and readable storage medium | |
CN114844844A (en) | Delay message processing method, device, equipment and storage medium | |
CN114640707A (en) | Message asynchronous processing method and device, electronic equipment and storage medium | |
CN113221154A (en) | Service password obtaining method and device, electronic equipment and storage medium | |
CN113918305B (en) | Node scheduling method, node scheduling device, electronic equipment and readable storage medium | |
CN115687384A (en) | UUID (user identifier) identification generation method, device, equipment and storage medium | |
CN114911479A (en) | Interface generation method, device, equipment and storage medium based on configuration | |
CN115174555A (en) | File transmission method and device, electronic equipment and storage medium | |
CN114448930A (en) | Short address generation method and device, electronic equipment and computer readable storage medium | |
CN115145870A (en) | Method and device for positioning reason of failed task, electronic equipment and storage medium | |
CN114020414A (en) | Symbiotic method and device of Android system and bottom layer Linux, electronic equipment and storage medium | |
CN115002011A (en) | Flow bidirectional test method and device, electronic equipment and storage medium | |
CN112540839A (en) | Information changing method, device, electronic equipment and storage medium | |
CN112631675A (en) | Workflow configuration method, device, equipment and computer readable storage medium | |
CN112527443A (en) | Prompt box display method and device, electronic equipment and computer readable storage medium | |
CN114003661A (en) | Offline data entry method and device, electronic equipment and storage medium | |
CN114201466A (en) | Method, device and equipment for preventing cache breakdown and readable storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |