CN117632965A - Identification generation method, device, computer equipment and storage medium - Google Patents

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

Info

Publication number
CN117632965A
CN117632965A CN202311635049.XA CN202311635049A CN117632965A CN 117632965 A CN117632965 A CN 117632965A CN 202311635049 A CN202311635049 A CN 202311635049A CN 117632965 A CN117632965 A CN 117632965A
Authority
CN
China
Prior art keywords
container
identification
identifier
hash table
target
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
CN202311635049.XA
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.)
Industrial and Commercial Bank of China Ltd ICBC
Original Assignee
Industrial and Commercial Bank of China Ltd ICBC
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 Industrial and Commercial Bank of China Ltd ICBC filed Critical Industrial and Commercial Bank of China Ltd ICBC
Priority to CN202311635049.XA priority Critical patent/CN117632965A/en
Publication of CN117632965A publication Critical patent/CN117632965A/en
Pending legal-status Critical Current

Links

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application relates to a method, a device, a computer device and a storage medium for generating an identification. The method comprises the following steps: under the condition that a target container process is started, obtaining a container identifier of a target container; obtaining a hash table, storing a container identifier into the hash table, and obtaining an address identifier of the container identifier in the hash table as a work identifier of a target container; constructing a snowflake algorithm according to the working identification; and obtaining the unique identification of the target container according to a snowflake algorithm. By adopting the method, the working identification of the target container can be quickly and efficiently determined in the containerized deployment service, so that the global unique ID of the target container is generated by utilizing the snowflake algorithm constructed by the working identification, and the generation efficiency of the containerized deployment distributed ID is improved.

Description

Identification generation method, device, computer equipment and storage medium
Technical Field
The present application relates to the field of computer technology, and in particular, to a method, an apparatus, a computer device, a storage medium, and a computer program product for generating an identifier.
Background
In the present business system based on computer technology, for resolution and management, an ID with uniqueness corresponding to each business is generated just like an identity card of people.
The current main stream generation method of global ID aiming at the distributed database comprises UUID/GUID: it is a character string of 32 bits, 26 letters and numbers. Most of the program languages and databases of this scheme provide direct support. In this way, the globally unique ID does not require any additional development effort. But this way is the database ID, which is very inefficient to index because its generation of 32-bit strings is random. And this solution cannot operate independently and needs to rely on a database to perform, thus directly leading to the drawbacks of low performance, high latency and excessively long bit descriptions.
Currently, when a containerized service needs to be deployed, generating a globally unique ID for the service is inefficient.
Disclosure of Invention
In view of the foregoing, it is desirable to provide an identification generation method, apparatus, computer device, computer-readable storage medium, and computer program product that can efficiently generate a globally unique ID for a certain containerized service when the service needs to be deployed.
In a first aspect, the present application provides a method for generating a logo. Comprising the following steps:
under the condition that a target container process is started, obtaining a container identifier of a target container;
obtaining a hash table, storing a container identifier into the hash table, and obtaining an address identifier of the container identifier in the hash table as a work identifier of a target container;
constructing a snowflake algorithm according to the working identification;
and obtaining the unique identification of the target container according to a snowflake algorithm.
In one embodiment, storing the container identification in a hash table includes:
calculating a hash value of the container identifier by adopting a hash algorithm;
storing the container identification into a hash table according to the hash value; the hash table length is 2 to the power of 10, and the address labels are specified as 0 to 1023.
In one embodiment, storing the container identification in the hash table according to the hash value includes:
processing the hash value by adopting a hash algorithm to obtain an address bit;
determining a target storage position corresponding to the container identifier in the hash table according to the address bit;
the container identification is stored to the target storage location.
In one embodiment, obtaining the address identifier of the container identifier in the hash table as the work identifier of the target container includes:
adding a unique address identifier for each storage position in the hash table;
and obtaining an address identifier corresponding to the target storage position as a working identifier of the target container.
In one embodiment, the method further comprises:
and under the condition that the target container process is destroyed, emptying the container identification stored in the target storage position in the hash table.
In one embodiment, obtaining the unique identifier of the target container according to a snowflake algorithm includes:
acquiring an identification time stamp corresponding to the target container according to the container identification;
acquiring a system time stamp under the running environment of a snowflake algorithm;
generating error reporting information under the condition that the identification time stamp is larger than the system time stamp;
and under the condition that the identification time stamp is not greater than the system time stamp, running a snowflake algorithm to generate a unique identification of the target container.
In a second aspect, the present application further provides an identifier generating device. The device comprises:
the acquisition module is used for acquiring the container identification of the target container under the condition that the target container process is started;
the conversion module is used for acquiring the hash table, storing the container identifier into the hash table, and acquiring the address identifier of the container identifier in the hash table as the working identifier of the target container;
the construction module is used for constructing a snowflake algorithm according to the working identification;
and the generating module is used for obtaining the unique identification of the target container according to the snowflake algorithm.
In a third aspect, the present application also provides a computer device. The computer device comprises a memory storing a computer program and a processor which when executing the computer program performs the steps of:
under the condition that a target container process is started, obtaining a container identifier of a target container;
obtaining a hash table, storing a container identifier into the hash table, and obtaining an address identifier of the container identifier in the hash table as a work identifier of a target container;
constructing a snowflake algorithm according to the working identification;
and obtaining the unique identification of the target container according to a snowflake algorithm.
In a fourth aspect, the present application also provides a computer-readable storage medium. The computer readable storage medium having stored thereon a computer program which when executed by a processor performs the steps of:
under the condition that a target container process is started, obtaining a container identifier of a target container;
obtaining a hash table, storing a container identifier into the hash table, and obtaining an address identifier of the container identifier in the hash table as a work identifier of a target container;
constructing a snowflake algorithm according to the working identification;
and obtaining the unique identification of the target container according to a snowflake algorithm.
In a fifth aspect, the present application also provides a computer program product. The computer program product comprises a computer program which, when executed by a processor, implements the steps of:
under the condition that a target container process is started, obtaining a container identifier of a target container;
obtaining a hash table, storing a container identifier into the hash table, and obtaining an address identifier of the container identifier in the hash table as a work identifier of a target container;
constructing a snowflake algorithm according to the working identification;
and obtaining the unique identification of the target container according to a snowflake algorithm.
The identification generation method, the device, the computer equipment, the storage medium and the computer program product acquire the container identification of the target container under the condition that the target container process is started; obtaining a hash table, storing a container identifier into the hash table, and obtaining an address identifier of the container identifier in the hash table as a work identifier of a target container; constructing a snowflake algorithm according to the working identification; and obtaining the unique identification of the target container according to a snowflake algorithm. The method can rapidly and efficiently determine the work identifier of the target container in the containerized deployment service, so that the global unique ID of the target container is generated by utilizing the snowflake algorithm constructed by the work identifier, and the generation efficiency of the containerized deployment distributed ID is improved.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the related art, the drawings that are required to be used in the embodiments or the related technical descriptions will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and other drawings may be obtained according to the drawings without inventive effort for a person having ordinary skill in the art.
FIG. 1 is an application environment diagram of an identification generation method in one embodiment;
FIG. 2 is a flow diagram of an identification generation method in one embodiment;
FIG. 3 is a block diagram of an embodiment of an identification generation device;
fig. 4 is an internal structural diagram of a computer device in one embodiment.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application will be further described in detail with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the present application.
The identifier generating method provided by the embodiment of the application can be applied to an application environment shown in fig. 1. Wherein the terminal 102 communicates with the server 104 via a network. The data storage system may store data that the server 104 needs to process. The data storage system may be integrated on the server 104 or may be located on a cloud or other network server. The terminal 102 may be, but not limited to, various personal computers, notebook computers, smart phones, tablet computers, internet of things devices, and portable wearable devices, where the internet of things devices may be smart speakers, smart televisions, smart air conditioners, smart vehicle devices, and the like. The portable wearable device may be a smart watch, smart bracelet, headset, or the like. The server 104 may be implemented as a stand-alone server or as a server cluster of multiple servers.
In an exemplary embodiment, as shown in fig. 2, an identifier generating method is provided, which is illustrated by taking an example that the method is applied to the server 104 in fig. 1, and includes the following steps 202 to 208.
Wherein:
step 202, obtaining a container identification of the target container under the condition that the target container process is started.
Wherein the target container refers to Docker, and the container identifier refers to dockerin. DockerID is a globally unique identifier used to push, pull, and manage Docker images. Each Docker user should register a Docker id so that functions such as building, pushing, and retrieving images can be used on Docker Hub. DockerID is a central repository hosted by Docker Hub. The user may access the repository using the dockerind, download the desired Docker image, and instantiate as a container.
Optionally, when the Docker application is started, the management node initializes the container, including assigning a globally unique ID, i.e., docker ID. Under the condition that the target container process is started, the DockerID of the Docker can be directly obtained.
Step 204, a hash table is obtained, the container identification is stored in the hash table, and the address identification of the container identification in the hash table is obtained and used as the work identification of the target container.
The work identifier refers to a work ID, and the work ID is an important parameter in a snowflake algorithm and is used for identifying the current work node or machine. The WorkID typically occupies a portion of the ID generated by the snowflake algorithm and can be adjusted as desired. The work node ID plays a role in distinguishing different nodes or machines in a snowflake algorithm, and can be assigned by user definition, and is generally assigned in a globally unique mode. Depending on the scenario and requirements, IP addresses, machine names, data center D, etc. may be used as the working node ID. The range of working node IDs is 0-1023, up to 1024 different nodes or machines can be supported.
Alternatively, a hash table is obtained, the hash table length being 2 to the power of 10, and the address labels being specified as 0 to 1023. Calculating a hash value of the container identifier by adopting a hash algorithm; processing the hash value by adopting a hash algorithm to obtain an address bit; determining a target storage position corresponding to the container identifier in the hash table according to the address bit; the container identification is stored to the target storage location. Adding a unique address identifier for each storage position in the hash table; and obtaining an address identifier corresponding to the target storage position as a working identifier of the target container.
And 206, constructing a snowflake algorithm according to the work identification.
Wherein, in snowflake algorithm, a 64-bit ID is composed of the following parts:
sign bit (1 bit): always 0, indicating that the ID is positive.
Timestamp (41 bits): the time stamp of the generated ID is recorded to the accuracy of the millisecond level.
WorkID (10 bits): for identifying the working node or machine that generated the ID.
Sequence number (12 bits): and the serial numbers generated in the same millisecond ensure that the ID generated by each node in the same millisecond is not repeated.
The WorkID is a parameter in the snowflake algorithm that is used to identify the working node or machine, which together with the timestamp and serial number forms the generated unique ID.
Alternatively, the snowflake algorithm may be deployed as a separate service, and then a globally unique ID system is required to request the snowflake algorithm service to obtain the ID. For each snowflake algorithm service, a 10-bit machine code is required to be designated, and the machine code is set according to own service. Such as a machine room number + machine number, a machine number + service number, or other 10-bit integer value that is distinguishable.
And step 208, obtaining the unique identification of the target container according to a snowflake algorithm.
The unique identifier refers to a global unique ID, which is also called a distributed unique ID.
Optionally, in the case that no time callback problem occurs, a snowflake algorithm is run. The 41 bits of the current timestamp are acquired and shifted left by 22 bits to acquire the timestamp portion. The machine ID is acquired and shifted left by 12 bits to acquire the machine ID part. When a serial number is generated and a plurality of IDs are generated in the same millisecond, the serial number is incremented. The time stamp, machine ID and serial number are combined to form a 64 bit integer ID. The number of bits occupied by each part of the snowflake algorithm is not fixed. For example, your business may be less than 69 years old, then the number of bits occupied by the timestamp may be reduced, the snowflake algorithm service requires more than 1024 nodes to be deployed, and then the reduced number of bits may be supplemented for machine code.
It is noted that the 41 bits in the snowflake algorithm are not directly used to store the current server millisecond timestamp, but rather require the current server timestamp to be subtracted by some initial timestamp value, typically the service online time can be used as the initial timestamp value. For the machine code, the adjustment can be made according to the self condition, such as the machine room number, the server number, the service number, the machine IP, etc. can be used. And in the deployed different snowflake algorithm services, the finally calculated machine codes can be distinguished.
In one possible implementation, when the time is acquired, a time callback problem may occur, where the time on the server suddenly backs to the previous time, and may be caused by an artificial factor, such as a time in which the system environment is modified, or may be a time error between different machines. The solution to the time callback problem may be, but is not limited to: when the callback time is small, an ID is not generated, circulation is carried out until the time point arrives, and when the callback time exceeds a certain size, errors are directly reported, and service is refused; or the expansion bit is utilized, 1 is added to the expansion bit after callback, so that the ID remains unique, the number of bits can be reserved from the machine ID or the serial number, and the position is +1 when callback is performed.
In the above-mentioned label generating method, under the condition that the goal container process starts, obtain the container label of the goal container; obtaining a hash table, storing a container identifier into the hash table, and obtaining an address identifier of the container identifier in the hash table as a work identifier of a target container; constructing a snowflake algorithm according to the working identification; and obtaining the unique identification of the target container according to a snowflake algorithm. The method can rapidly and efficiently determine the work identifier of the target container in the containerized deployment service, so that the global unique ID of the target container is generated by utilizing the snowflake algorithm constructed by the work identifier, and the generation efficiency of the containerized deployment distributed ID is improved.
In one embodiment, obtaining a hash table, storing a container identifier in the hash table, obtaining an address identifier of the container identifier in the hash table as a work identifier of a target container, including: a hash table is obtained. Calculating a hash value of the container identifier by adopting a hash algorithm; processing the hash value by adopting a hash algorithm to obtain an address bit; determining a target storage position corresponding to the container identifier in the hash table according to the address bit; the container identification is stored to the target storage location. Adding a unique address identifier for each storage position in the hash table; and obtaining an address identifier corresponding to the target storage position as a working identifier of the target container.
The hash algorithm maps binary values of any length to binary values of a shorter fixed length, and the binary values of the fixed length obtained by the operation become hash values. Hash values are a unique and extremely compact representation of a piece of data.
Optionally, the dockerin is fixed according to the bit number of the hash value calculated by the hash function, the hash algorithm can be arbitrarily specified, for example, MD4, MD5, SHA, etc., and the generated hash value is recorded as dockerin hash. A hash table micro service for providing service to outside is constructed by using any programming language. The hash table length may be adjusted according to the number of instances, for example, the hash table length is set to 1024 bits in this example, and the address indices 0 through 1023. For example, a web application is deployed by using SpringBoot, and a hash table storage service is provided for all global Docker instances. The hash table can be directly realized through the hashmap and other types of the java. The DockerHash is calculated to obtain address bits by constructing a hash algorithm, such as: a remainder removing method, a folding method, a square centering method and the like. And simultaneously, confirming the final storage position by an open fixed value method. The dockerind is stored in a hash table. And taking the address subscript of the storage position as the workbench ID of the Docker application snowflake algorithm.
In one possible embodiment, in the event that the target container process is destroyed, the container identification stored in the target storage location is emptied in the hash table. That is, when the Docker instance is destroyed, the hash table micro-service is accessed, and the Docker ID stored in the corresponding WorkID location is emptied.
In this embodiment, a hash table is obtained, a dockerin is stored in the hash table, and an address identifier of the dockerin in the hash table is obtained as a WorkID of the target container. The method and the system can rapidly and efficiently determine the workbench ID of the target container in the containerized deployment service, so that the global unique ID of the target container is generated by utilizing the snowflake algorithm constructed by the workbench ID, and the generation efficiency of the containerized deployment distributed ID is improved.
In one embodiment, obtaining the unique identification of the target container according to a snowflake algorithm includes: acquiring an identification time stamp corresponding to the target container according to the container identification; acquiring a system time stamp under the running environment of a snowflake algorithm; generating error reporting information under the condition that the identification time stamp is larger than the system time stamp; and under the condition that the identification time stamp is not greater than the system time stamp, running a snowflake algorithm to generate a unique identification of the target container.
Wherein, the identification timestamp refers to an ID timestamp of the WorkID.
Optionally, a waiting method is adopted to solve the problem of callback of the timestamp, the current ID timestamp is compared with the current system timestamp, when callback does not occur in the current system time, the current ID timestamp is not larger than the current system timestamp, a snowflake algorithm is operated, and a global unique ID of the target container is generated; when the current system time is callback, the current ID time stamp is larger than the current system time stamp to directly report errors until the clock is traced back to the current time stamp.
In this embodiment, according to the container identifier, an identifier timestamp corresponding to the target container is obtained; acquiring a system time stamp under the running environment of a snowflake algorithm; generating error reporting information under the condition that the identification time stamp is larger than the system time stamp; and under the condition that the identification time stamp is not greater than the system time stamp, running a snowflake algorithm to generate a unique identification of the target container. The generation of duplicate IDs can be avoided, and the generation of global unique IDs is ensured.
In one embodiment, a method for generating an identifier includes:
and under the condition that the target container process is started, acquiring the container identification of the target container.
A hash table is obtained, the hash table length is to the power of 2, and the address labels are designated 0 to 1023.
Calculating a hash value of the container identifier by adopting a hash algorithm; processing the hash value by adopting a hash algorithm to obtain an address bit; determining a target storage position corresponding to the container identifier in the hash table according to the address bit; the container identification is stored to the target storage location.
Adding a unique address identifier for each storage position in the hash table; and obtaining an address identifier corresponding to the target storage position as a working identifier of the target container.
And constructing a snowflake algorithm according to the work identification.
Acquiring an identification time stamp corresponding to the target container according to the container identification; acquiring a system time stamp under the running environment of a snowflake algorithm; generating error reporting information under the condition that the identification time stamp is larger than the system time stamp; and under the condition that the identification time stamp is not greater than the system time stamp, running a snowflake algorithm to generate a unique identification of the target container.
And under the condition that the target container process is destroyed, emptying the container identification stored in the target storage position in the hash table.
In one embodiment, taking a dock management platform K8S as an example, a method for generating a tag includes:
when the Docker application is started, the management Node downloads the mirror image to the Node for starting through the mirror image warehouse, the Docker starting number of the appointed application is set in the management platform in advance, and the Docker starting number can be any natural number between 2 and 1024.
When the K8S starts the Docker container process, the container is initialized, including assigning a globally unique ID, referred to herein as dockerID. The allocation method is not specifically described and may be, but is not limited to, uuID allocation.
The DockerID calculates a hash value according to a specified hash function to carry out bit immobilization, a hash algorithm can be arbitrarily specified, such as MD4, MD5, SHA and the like, and the generated hash value is recorded as DockerHash.
A hash table micro service for providing service to outside is constructed by using any programming language. The hash table length may be adjusted according to the number of instances, for example, the hash table length is set to 1024 bits in this example, and the address indices 0 through 1023. For example, a web application is deployed by using SpringBoot, and a hash table storage service is provided for all global Docker instances. The hash table can be directly realized through the hashmap and other types of the java.
The DockerHash is calculated to obtain address bits by constructing a hash algorithm, such as: a remainder removing method, a folding method, a square centering method and the like. And simultaneously, confirming the final storage position by an open fixed value method.
The dockerind is stored in a hash table. And constructing snowflake ID generating service by taking the address index of the storage position as the workbench ID of the Docker applied snowflake algorithm.
Comparing the current ID time stamp with the current system time stamp, when the current system time is callback, the current ID time stamp is larger than the current system time stamp, and the snowflake algorithm is not operated to directly report errors until the clock is traced back to the current time stamp. And running a snowflake algorithm to obtain a snowflake ID, namely a global unique ID, when the current ID time stamp is not greater than the current system time stamp.
When the Docker instance is destroyed, accessing the hash table micro-service, and clearing the Docker ID stored in the corresponding workID position.
It should be understood that, although the steps in the flowcharts related to the embodiments described above are sequentially shown as indicated by arrows, these steps are not necessarily sequentially performed in the order indicated by the arrows. The steps are not strictly limited to the order of execution unless explicitly recited herein, and the steps may be executed in other orders. Moreover, at least some of the steps in the flowcharts described in the above embodiments may include a plurality of steps or a plurality of stages, which are not necessarily performed at the same time, but may be performed at different times, and the order of the steps or stages is not necessarily performed sequentially, but may be performed alternately or alternately with at least some of the other steps or stages.
Based on the same inventive concept, the embodiment of the application also provides an identifier generating device for implementing the identifier generating method. The implementation of the solution provided by the device is similar to the implementation described in the above method, so the specific limitation in the embodiment of one or more identifier generating devices provided below may refer to the limitation of the identifier generating method hereinabove, and will not be repeated herein.
In an exemplary embodiment, as shown in fig. 3, there is provided an identification generating apparatus 300, including: an acquisition module 301, a conversion module 302, a construction module 303 and a generation module 304, wherein:
the obtaining module 301 is configured to obtain a container identifier of the target container when the target container process is started.
The conversion module 302 is configured to obtain a hash table, store the container identifier in the hash table, and obtain an address identifier of the container identifier in the hash table as a work identifier of the target container.
And the construction module 303 is used for constructing a snowflake algorithm according to the work identification.
And the generating module 304 is configured to obtain the unique identifier of the target container according to a snowflake algorithm.
In one embodiment, the conversion module 302 is further configured to calculate a hash value of the container identifier using a hash algorithm; storing the container identification into a hash table according to the hash value; the hash table length is 2 to the power of 10, and the address labels are specified as 0 to 1023.
In one embodiment, the conversion module 302 is further configured to process the hash value with a hash algorithm to obtain an address bit; determining a target storage position corresponding to the container identifier in the hash table according to the address bit; the container identification is stored to the target storage location.
In one embodiment, the conversion module 302 is further configured to add a unique address identifier for each storage location in the hash table; and obtaining an address identifier corresponding to the target storage position as a working identifier of the target container.
In one embodiment, the generating module 304 is further configured to empty the container identifier stored in the target storage location in the hash table in the case where the target container process is destroyed.
In one embodiment, the generating module 304 is further configured to obtain an identifier timestamp corresponding to the target container according to the container identifier; acquiring a system time stamp under the running environment of a snowflake algorithm; generating error reporting information under the condition that the identification time stamp is larger than the system time stamp; and under the condition that the identification time stamp is not greater than the system time stamp, running a snowflake algorithm to generate a unique identification of the target container.
The respective modules in the above-described identification generating means may be implemented in whole or in part by software, hardware, and combinations thereof. The above modules may be embedded in hardware or may be independent of a processor in the computer device, or may be stored in software in a memory in the computer device, so that the processor may call and execute operations corresponding to the above modules.
In one exemplary embodiment, a computer device is provided, which may be a server, the internal structure of which may be as shown in fig. 4. The computer device includes a processor, a memory, an Input/Output interface (I/O) and a communication interface. The processor, the memory and the input/output interface are connected through a system bus, and the communication interface is connected to the system bus through the input/output interface. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The database of the computer device is for storing hash table data. The input/output interface of the computer device is used to exchange information between the processor and the external device. The communication interface of the computer device is used for communicating with an external terminal through a network connection. The computer program is executed by a processor to implement a method of generating an identification.
Those skilled in the art will appreciate that the structures shown in FIG. 4 are block diagrams only and do not constitute a limitation of the computer device on which the present aspects apply, and that a particular computer device may include more or less components than those shown, or may combine some of the components, or have a different arrangement of components.
In one exemplary embodiment, a computer device is provided comprising a memory and a processor, the memory having stored therein a computer program, the processor when executing the computer program performing the steps of: under the condition that a target container process is started, obtaining a container identifier of a target container; obtaining a hash table, storing a container identifier into the hash table, and obtaining an address identifier of the container identifier in the hash table as a work identifier of a target container; constructing a snowflake algorithm according to the working identification; and obtaining the unique identification of the target container according to a snowflake algorithm.
In one embodiment, the processor when executing the computer program further performs the steps of: calculating a hash value of the container identifier by adopting a hash algorithm; storing the container identification into a hash table according to the hash value; the hash table length is 2 to the power of 10, and the address labels are specified as 0 to 1023.
In one embodiment, the processor when executing the computer program further performs the steps of: processing the hash value by adopting a hash algorithm to obtain an address bit; determining a target storage position corresponding to the container identifier in the hash table according to the address bit; the container identification is stored to the target storage location.
In one embodiment, the processor when executing the computer program further performs the steps of: adding a unique address identifier for each storage position in the hash table; and obtaining an address identifier corresponding to the target storage position as a working identifier of the target container.
In one embodiment, the processor when executing the computer program further performs the steps of: and under the condition that the target container process is destroyed, emptying the container identification stored in the target storage position in the hash table.
In one embodiment, the processor when executing the computer program further performs the steps of: acquiring an identification time stamp corresponding to the target container according to the container identification; acquiring a system time stamp under the running environment of a snowflake algorithm; generating error reporting information under the condition that the identification time stamp is larger than the system time stamp; and under the condition that the identification time stamp is not greater than the system time stamp, running a snowflake algorithm to generate a unique identification of the target container.
In one embodiment, a computer readable storage medium is provided having a computer program stored thereon, which when executed by a processor, performs the steps of: under the condition that a target container process is started, obtaining a container identifier of a target container; obtaining a hash table, storing a container identifier into the hash table, and obtaining an address identifier of the container identifier in the hash table as a work identifier of a target container; constructing a snowflake algorithm according to the working identification; and obtaining the unique identification of the target container according to a snowflake algorithm.
In one embodiment, the computer program when executed by the processor further performs the steps of: calculating a hash value of the container identifier by adopting a hash algorithm; storing the container identification into a hash table according to the hash value; the hash table length is 2 to the power of 10, and the address labels are specified as 0 to 1023.
In one embodiment, the computer program when executed by the processor further performs the steps of: processing the hash value by adopting a hash algorithm to obtain an address bit; determining a target storage position corresponding to the container identifier in the hash table according to the address bit; the container identification is stored to the target storage location.
In one embodiment, the computer program when executed by the processor further performs the steps of: adding a unique address identifier for each storage position in the hash table; and obtaining an address identifier corresponding to the target storage position as a working identifier of the target container.
In one embodiment, the computer program when executed by the processor further performs the steps of: and under the condition that the target container process is destroyed, emptying the container identification stored in the target storage position in the hash table.
In one embodiment, the computer program when executed by the processor further performs the steps of: acquiring an identification time stamp corresponding to the target container according to the container identification; acquiring a system time stamp under the running environment of a snowflake algorithm; generating error reporting information under the condition that the identification time stamp is larger than the system time stamp; and under the condition that the identification time stamp is not greater than the system time stamp, running a snowflake algorithm to generate a unique identification of the target container.
In one embodiment, a computer program product is provided comprising a computer program which, when executed by a processor, performs the steps of: under the condition that a target container process is started, obtaining a container identifier of a target container; obtaining a hash table, storing a container identifier into the hash table, and obtaining an address identifier of the container identifier in the hash table as a work identifier of a target container; constructing a snowflake algorithm according to the working identification; and obtaining the unique identification of the target container according to a snowflake algorithm.
In one embodiment, the computer program when executed by the processor further performs the steps of: calculating a hash value of the container identifier by adopting a hash algorithm; storing the container identification into a hash table according to the hash value; the hash table length is 2 to the power of 10, and the address labels are specified as 0 to 1023.
In one embodiment, the computer program when executed by the processor further performs the steps of: processing the hash value by adopting a hash algorithm to obtain an address bit; determining a target storage position corresponding to the container identifier in the hash table according to the address bit; the container identification is stored to the target storage location.
In one embodiment, the computer program when executed by the processor further performs the steps of: adding a unique address identifier for each storage position in the hash table; and obtaining an address identifier corresponding to the target storage position as a working identifier of the target container.
In one embodiment, the computer program when executed by the processor further performs the steps of: and under the condition that the target container process is destroyed, emptying the container identification stored in the target storage position in the hash table.
In one embodiment, the computer program when executed by the processor further performs the steps of: acquiring an identification time stamp corresponding to the target container according to the container identification; acquiring a system time stamp under the running environment of a snowflake algorithm; generating error reporting information under the condition that the identification time stamp is larger than the system time stamp; and under the condition that the identification time stamp is not greater than the system time stamp, running a snowflake algorithm to generate a unique identification of the target container.
It should be noted that, the user information (including, but not limited to, user equipment information, user personal information, etc.) and the data (including, but not limited to, data for analysis, stored data, presented data, etc.) referred to in the present application are information and data authorized by the user or sufficiently authorized by each party, and the collection, use, and processing of the related data are required to meet the related regulations.
Those skilled in the art will appreciate that implementing all or part of the above described methods may be accomplished by way of a computer program stored on a non-transitory computer readable storage medium, which when executed, may comprise the steps of the embodiments of the methods described above. Any reference to memory, database, or other medium used in the various embodiments provided herein may include at least one of non-volatile and volatile memory. The nonvolatile Memory may include Read-Only Memory (ROM), magnetic tape, floppy disk, flash Memory, optical Memory, high density embedded nonvolatile Memory, resistive random access Memory (ReRAM), magnetic random access Memory (Magnetoresistive Random Access Memory, MRAM), ferroelectric Memory (Ferroelectric Random Access Memory, FRAM), phase change Memory (Phase Change Memory, PCM), graphene Memory, and the like. Volatile memory can include random access memory (Random Access Memory, RAM) or external cache memory, and the like. By way of illustration, and not limitation, RAM can be in the form of a variety of forms, such as static random access memory (Static Random Access Memory, SRAM) or dynamic random access memory (Dynamic Random Access Memory, DRAM), and the like. The databases referred to in the various embodiments provided herein may include at least one of relational databases and non-relational databases. The non-relational database may include, but is not limited to, a blockchain-based distributed database, and the like. The processors referred to in the embodiments provided herein may be general purpose processors, central processing units, graphics processors, digital signal processors, programmable logic units, quantum computing-based data processing logic units, etc., without being limited thereto.
The technical features of the above embodiments may be arbitrarily combined, and all possible combinations of the technical features in the above embodiments are not described for brevity of description, however, as long as there is no contradiction between the combinations of the technical features, they should be considered as the scope of the description.
The above examples only represent a few embodiments of the present application, which are described in more detail and are not to be construed as limiting the scope of the present application. It should be noted that it would be apparent to those skilled in the art that various modifications and improvements could be made without departing from the spirit of the present application, which would be within the scope of the present application. Accordingly, the scope of protection of the present application shall be subject to the appended claims.

Claims (10)

1. A method of generating a logo, the method comprising:
under the condition that a target container process is started, obtaining a container identifier of the target container;
acquiring a hash table, storing the container identifier into the hash table, and acquiring an address identifier of the container identifier in the hash table as a work identifier of the target container;
constructing a snowflake algorithm according to the work mark;
and obtaining the unique identification of the target container according to the snowflake algorithm.
2. The method of claim 1, wherein the storing the container identification into the hash table comprises:
calculating a hash value of the container identifier by adopting a hash algorithm;
storing the container identification into the hash table according to the hash value; the hash table length is to the power of 2, and the address labels are designated 0 to 1023.
3. The method of claim 2, wherein the storing the container identification in the hash table according to the hash value comprises:
processing the hash value by adopting a hash algorithm to obtain an address bit;
determining a target storage position corresponding to the container identifier in the hash table according to the address bit;
storing the container identification to the target storage location.
4. A method according to claim 3, wherein said obtaining the address identification of the container identification in the hash table as the job identification of the target container comprises:
adding a unique address identifier for each storage position in the hash table;
and obtaining an address identifier corresponding to the target storage position as a working identifier of the target container.
5. A method according to claim 3, characterized in that the method further comprises:
and under the condition that the target container process is destroyed, emptying the container identification stored in the target storage position in the hash table.
6. The method of claim 1, wherein the obtaining the unique identification of the target container according to the snowflake algorithm comprises:
acquiring an identification time stamp corresponding to the target container according to the container identification;
acquiring a system time stamp of the snowflake algorithm in the running environment;
generating error reporting information under the condition that the identification time stamp is larger than the system time stamp;
and under the condition that the identification time stamp is not greater than the system time stamp, running the snowflake algorithm to generate the unique identification of the target container.
7. An identification generating device, characterized in that the device comprises:
the acquisition module is used for acquiring the container identification of the target container under the condition that the target container process is started;
the conversion module is used for acquiring a hash table, storing the container identification into the hash table, and acquiring an address identification of the container identification in the hash table as a working identification of the target container;
the construction module is used for constructing a snowflake algorithm according to the work identifier;
and the generating module is used for obtaining the unique identification of the target container according to the snowflake algorithm.
8. A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that the processor implements the steps of the method of any of claims 1 to 6 when the computer program is executed.
9. A computer readable storage medium, on which a computer program is stored, characterized in that the computer program, when being executed by a processor, implements the steps of the method of any of claims 1 to 6.
10. A computer program product comprising a computer program, characterized in that the computer program, when being executed by a processor, implements the steps of the method of any of claims 1 to 6.
CN202311635049.XA 2023-11-30 2023-11-30 Identification generation method, device, computer equipment and storage medium Pending CN117632965A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311635049.XA CN117632965A (en) 2023-11-30 2023-11-30 Identification generation method, device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311635049.XA CN117632965A (en) 2023-11-30 2023-11-30 Identification generation method, device, computer equipment and storage medium

Publications (1)

Publication Number Publication Date
CN117632965A true CN117632965A (en) 2024-03-01

Family

ID=90031771

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311635049.XA Pending CN117632965A (en) 2023-11-30 2023-11-30 Identification generation method, device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN117632965A (en)

Similar Documents

Publication Publication Date Title
CN106339254B (en) Method and device for quickly starting virtual machine and management node
US20070050399A1 (en) Storage and retrieval of richly typed hierarchical network models
CN112765182A (en) Data synchronization method and device among cloud server clusters
CN111143446A (en) Data structure conversion processing method and device of data object and electronic equipment
CN112328631A (en) Production fault analysis method and device, electronic equipment and storage medium
CN115543198A (en) Method and device for lake entering of unstructured data, electronic equipment and storage medium
CN113590144B (en) Dependency processing method and device
CN112860412B (en) Service data processing method and device, electronic equipment and storage medium
CN114997111B (en) Service processing method, device, computer equipment and storage medium
CN116204540A (en) Operation log recording method, device, equipment and storage medium
CN117632965A (en) Identification generation method, device, computer equipment and storage medium
CN116304079A (en) Timing-based profile data management method, apparatus, and readable storage medium
CN115687560A (en) Mass keyword searching method based on finite automaton
CN108268545B (en) Method and device for establishing hierarchical user label library
CN116185374A (en) Method, device, electronic equipment and storage medium for acquiring code base dependency relationship
CN111400243B (en) Development management system based on pipeline service and file storage method and device
CN114168581A (en) Data cleaning method and device, computer equipment and storage medium
CN110598072B (en) Feature data aggregation method and device
CN111881220B (en) Data operation method and device under list storage, electronic equipment and storage medium
CN115328892B (en) Business form data structure processing method, system, electronic device and medium
CN113806372B (en) New data information construction method, device, computer equipment and storage medium
CN115250231B (en) Application configuration method and device
CN111414162B (en) Data processing method, device and equipment thereof
CN113050977B (en) Data processing method and system
CN113553329A (en) Data integration system and method

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