CN113672621A - Method, device and equipment for generating time sequence main key - Google Patents

Method, device and equipment for generating time sequence main key Download PDF

Info

Publication number
CN113672621A
CN113672621A CN202110958809.5A CN202110958809A CN113672621A CN 113672621 A CN113672621 A CN 113672621A CN 202110958809 A CN202110958809 A CN 202110958809A CN 113672621 A CN113672621 A CN 113672621A
Authority
CN
China
Prior art keywords
registration
application instance
time
application
primary key
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
CN202110958809.5A
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.)
CCB Finetech Co Ltd
Original Assignee
CCB Finetech Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by CCB Finetech Co Ltd filed Critical CCB Finetech Co Ltd
Priority to CN202110958809.5A priority Critical patent/CN113672621A/en
Publication of CN113672621A publication Critical patent/CN113672621A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures
    • G06F16/2228Indexing structures
    • G06F16/2255Hash tables
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23Updating
    • G06F16/2365Ensuring data consistency and integrity
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2455Query execution
    • G06F16/24552Database cache management
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • Computational Linguistics (AREA)
  • Computing Systems (AREA)
  • Computer Security & Cryptography (AREA)
  • Stored Programmes (AREA)

Abstract

The embodiment of the specification provides a method, a device and equipment for generating a time sequence main key, wherein the method comprises the following steps: when the target application is started, sending a registration request to a time sequence registration device; wherein, the registration request comprises registration metadata; the time sequence registration device is used for generating an application instance registration number corresponding to the target application according to the registration metadata; receiving an application instance registration number sent by a time sequence registration device; acquiring the numerical value of the global counter as a main key counting value; acquiring corresponding time when a target application is started as a primary key time identifier; and generating a time sequence main key for the target application according to the main key time identification, the main key counting value and the application instance registration number. By utilizing the embodiment of the specification, the problem of generation of the time sequence main key in an ultrahigh concurrency scene can be effectively solved.

Description

Method, device and equipment for generating time sequence main key
Technical Field
The present application relates to the field of distributed application technologies, and in particular, to a method, an apparatus, and a device for generating a timing key.
Background
With the arrival of the world of everything interconnection, the number of access terminals of the internet of things is exponentially increased, in order to perform state judgment quickly, grasp trends and perform analysis and decision quickly, each terminal continuously transmits data to a background, so that a QPS (Query Per Second, Query rate Per Second) at a certain moment is developed from hundreds to thousands or even tens of millions of QPS, and high concurrency application scene characteristics, such as high concurrency, high resource dependence, high time sensitivity, and the like, occur, and thus the generation requirement of a timing sequence primary key under a high concurrency environment cannot be met.
In the prior art, for such high-concurrency application scenario characteristics, a timing sequence main key is generated mainly by the following method: (1) the method can automatically accumulate upwards to obtain an automatic growth main key after calling once, has simple implementation mode but poor performance, and cannot meet the requirement of generating the time sequence main key in an ultrahigh concurrent environment. (2) The UUID is used for generating the time sequence main key, the UUID is randomly generated based on the current time, a counter, a hardware identification place and other information, the time sequence main key generated in the mode is irregular and does not contain time sequence characteristics, the global increasing trend of the time sequence main key cannot be reflected, and therefore the requirement for generating the time sequence main key under the ultrahigh concurrent environment cannot be met. (3) The time sequence main key is generated by using a middleware, wherein the middleware mainly comprises a cache middleware such as redis, ehcache, memcache and the like, the time of the mode is mainly consumed on network requests, distributed locks and request return, the cache middleware uses a host memory to cache data, the performance depends on the writing and transaction of the middleware, and the performance bottleneck problem exists. Therefore, the problem of time sequence main key generation in an ultrahigh concurrency scene cannot be effectively solved in the prior art.
Therefore, there is a need for a solution to the above technical problems.
Disclosure of Invention
The embodiment of the specification provides a method, a device and equipment for generating a time sequence main key, and the problem of generation of the time sequence main key in an ultrahigh concurrency scene can be effectively solved.
The method, the device and the equipment for generating the time sequence main key are realized in the following modes.
A method of generating a timing primary key, comprising: applied to a temporal primary key generator, the method comprising: when the target application is started, sending a registration request to a time sequence registration device; wherein, the registration request comprises registration metadata; the time sequence registration device is used for generating an application instance registration number corresponding to the target application according to the registration metadata; receiving an application instance registration number sent by the time sequence registration device; acquiring the numerical value of the global counter as a main key counting value; acquiring corresponding time when the target application is started as a primary key time identifier; and generating a time sequence main key for the target application according to the main key time identification, the main key counting value and the application instance registration number.
An apparatus for generating a timing primary key, comprising: the sending module is used for sending a registration request to the time sequence registration device when the target application is started; wherein, the registration request comprises registration metadata; the time sequence registration device is used for generating an application instance registration number corresponding to the target application according to the registration metadata; the receiving module is used for receiving the application instance registration number sent by the time sequence registration device; the first acquisition module is used for acquiring the numerical value of the global counter as a main key count value; the second acquisition module is used for acquiring the corresponding time when the target application is started as a primary key time identifier; and the generation module is used for generating a time sequence main key for the target application according to the main key time identifier, the main key counting value and the application instance registration number.
An apparatus for generating a timing primary key, comprising at least one processor and a memory storing computer-executable instructions, which when executed by the processor, implement the steps of any one of the method embodiments of the present specification.
A computer readable storage medium having stored thereon computer instructions which, when executed, implement the steps of any one of the method embodiments in the present specification.
The specification provides a method, a device and equipment for generating a time sequence main key. Some embodiments may send a registration request including the registration metadata to the time-series registration apparatus when the target application starts, so that the time-series registration apparatus generates an application instance registration number corresponding to the target application according to the registration metadata and returns the application instance registration number to the time-series primary key generator. And the value of the global counter can be acquired as a main key counting value, the corresponding time when the target application is started is acquired as a main key time identifier, and a time sequence main key is generated for the target application according to the main key time identifier, the main key counting value and the application instance registration number. The time sequence main key is generated by application registration and single point, so that deployment can be realized in multiple regions, multiple centers and multiple clusters, and the requirement of generating the time sequence main key under ultrahigh concurrency is met.
Drawings
The accompanying drawings, which are included to provide a further understanding of the specification, are incorporated in and constitute a part of this specification, and are not intended to limit the specification. In the drawings:
FIG. 1 is a schematic flow chart diagram illustrating one embodiment of a method for generating a timing primary key provided herein;
FIG. 2 is a block diagram of an embodiment of an apparatus for generating a timing primary key provided in the present specification;
fig. 3 is a block diagram of a hardware configuration of an embodiment of a server for generating a timing primary key provided in the present specification.
Detailed Description
In order to make those skilled in the art better understand the technical solutions in the present specification, the technical solutions in the embodiments of the present specification will be clearly and completely described below with reference to the drawings in the embodiments of the present specification, and it is obvious that the described embodiments are only a part of the embodiments in the present specification, and not all of the embodiments. All other embodiments that can be obtained by a person skilled in the art based on one or more embodiments of the present disclosure without making any creative effort shall fall within the protection scope of the embodiments of the present disclosure.
The following describes an embodiment of the present disclosure with a specific application scenario as an example. Specifically, fig. 1 is a schematic flowchart of an embodiment of a method for generating a timing primary key provided in this specification. Although the present specification provides the method steps or apparatus structures as shown in the following examples or figures, more or less steps or modules may be included in the method or apparatus structures based on conventional or non-inventive efforts.
One embodiment provided by the present specification can be applied to a timing primary key generator. Wherein the timing primary key generator may be deployed in a target application. The target application may run in a client or server or the like. The client may include a terminal device, such as a smart phone, a tablet computer, and the like. The server may include a single computer device, or may include a server cluster formed by a plurality of servers, or a server structure of a distributed system, and the like.
It should be noted that the following description of the embodiments does not limit the technical solutions in other extensible application scenarios based on the present specification. In an embodiment of a method for generating a timing primary key, as shown in fig. 1, the method may include the following steps.
S0: when the target application is started, sending a registration request to a time sequence registration device; wherein, the registration request comprises registration metadata; and the time sequence registration device is used for generating an application instance registration number corresponding to the target application according to the registration metadata.
The target application may be a distributed application, or may be another application. The time sequence registration device can be used for receiving the registration metadata of the target application and generating an application instance registration number corresponding to the target application by using the registration metadata for registration. The application instance registration number corresponds to the application instance registration identification one by one. The application instance registration identifier is globally unique in the time sequence registration device and can be used for identifying each application instance running on the distributed host. Wherein each time an application is opened, it is understood to be an application instance.
In some implementations, the temporal primary key generator can collect distributed host and application information as registration metadata. In some implementation scenarios, the registration metadata may include a name of a distributed host deployed by the target application, a name of the target application, a physical address of a network card corresponding to an outbound call of the target application, an ip (internet protocol) address, an external service port number of the target application, and the like.
In some implementation scenarios, after receiving the registration request, the time sequence registration apparatus may perform hash processing on the registration metadata to obtain a first application instance registration identifier; and acquiring an application instance registration number corresponding to the target application according to the first application instance registration identifier.
For example, in some implementation scenarios, the time sequence primary key generator may send a registration request including registration metadata to the time sequence registration apparatus, and after the time sequence registration apparatus receives the post-registration request, the time sequence registration apparatus may perform hash value calculation on the registration metadata according to a preset hash function, and then use the calculation result as the first application instance registration identifier.
In some implementation scenarios, after obtaining the application instance registration identifier, the time-series registration apparatus may obtain an application instance registration number corresponding to the target application according to the application instance registration identifier.
In some implementation scenarios, the obtaining an application instance registration number corresponding to a target application according to the first application instance registration identifier may include: comparing the first application instance registration identification with application instance registration identifications stored in a database; and under the condition that the first application instance registration identification does not exist in the stored application instance registration identifications, generating a corresponding application instance registration number for the target application according to the first application instance registration identification.
In some implementation scenarios, after comparing the first application instance registration identifier with the application instance registration identifiers stored in the database, the method may further include: under the condition that the first application instance registration identification exists in the stored application instance registration identifications, acquiring a second application instance registration identification which is the same as the first application instance registration identification; and taking the application instance registration number corresponding to the second application instance registration identifier as the application instance registration number corresponding to the target application.
For example, in some implementations, after obtaining the first application instance registration identifier, the time-series registration apparatus may compare the first application instance registration identifier with an application instance registration identifier stored in a database corresponding to the time-series registration apparatus. If the database does not exist, an application instance registration number can be generated according to the registration of the first application instance registration identifier; if the application instance registration number exists in the database, the original generated application instance registration number can be directly returned.
It should be noted that "first" and "second" are only used to distinguish the application instance registration identifier, and have no special meaning.
In some implementation scenarios, after the application instance registration number corresponding to the second application instance registration identifier is used as the application instance registration number corresponding to the target application, the registration time of the application instance registration number corresponding to the second application instance registration identifier may also be updated.
In some implementation scenarios, after the application instance registration number corresponding to the second application instance registration identifier is used as the application instance registration number corresponding to the target application, the application instance registration number may be returned to the timing primary key generator.
S2: and receiving the application instance registration number sent by the time sequence registration device.
In some implementation scenarios, after the time-series registration apparatus generates the application instance registration number corresponding to the target application according to the registration metadata, the application instance registration number may be returned to the time-series primary key generator.
In some implementations, the timing primary key generator, upon receiving the application instance registration number, may store it as a global static variable within the scope of the application instance, for global use by the application instance, and valid within the scope of the application instance.
In some implementations, the application instance registration number may be a decimal value of a first predetermined number of digits. Wherein the first predetermined number of bits is at most 6.
For example, in some implementations, the minimum value of the application instance registration number may be 0, and the maximum value may be the third power of 62, i.e., 238328, with a maximum length of 6 digits resulting in a decimal value. Thus, the global may accommodate 238329 application runtime instances to register. It is to be understood that the foregoing is only exemplary, and the application example registration number is not limited to the foregoing examples, and other modifications are possible by those skilled in the art in light of the technical spirit of the present application, and all such modifications are intended to be included within the scope of the present application as long as they achieve the same or similar functions and effects as the present application.
S4: the value of the global counter is obtained as the primary key count value.
In some implementations, the timing primary key generator may obtain the value of the global counter as the primary key count value after receiving the application instance registration number sent by the timing registration apparatus.
In some implementation scenarios, before obtaining the value of the global counter as the primary key count value, the obtaining may include: a global counter is established within the scope of the target application instance. The global counter may be configured to accumulate the generated number of the timing primary keys of the preset time granularity within the range of the target application instance. The preset time granularity may be set according to an actual scenario, and may be, for example, milliseconds, seconds, and the like, which is not limited in this specification.
In some implementations, the primary key count value may be a decimal value of a second predetermined number of digits. Wherein the second predetermined number of bits may be 10 at maximum.
For example, in some implementations, the temporal primary key generator may establish a global counter within the scope of the running application instance for generating a running total of the number of temporal primary keys at a time granularity within the scope of the application instance, the counter starting from 0 and incrementing by 1 for each temporal primary key generated, the maximum value of the running total being 2311, 2147483647, the counter may be reset to 0 after reaching the accumulation maximum and then accumulated again starting from 0 at the next time granularity. Wherein, each accumulation can return a primary key count value of a certain time granularity within the range of an application instance. The global counter is valid within the application runtime instance.
In some implementation scenarios, the global counter may support multi-threaded concurrency through a lockstep mechanism. Thus, each request initiated by the terminal to an application instance generates a response thread. Before accumulation, a thread may acquire a lock for an object, and after accumulation, the lock may be released. In addition, in order to improve the response efficiency, the response threads of other terminals can adopt an unfair locking mechanism, so that the accumulated value returned by a certain time granularity within the range of the application instance can be ensured to be unique by waiting for the accumulation of a locked object counter to be completed before competition.
S6: and acquiring the corresponding time when the target application is started as a primary key time identifier.
In some implementation scenarios, after obtaining the value of the global counter as the primary key count value, the time corresponding to the start of the target application may be obtained as the primary key time identifier. Of course, the time corresponding to the start of the target application may be obtained when the target application is started, or may be obtained when the value of the global counter is obtained, or may be obtained at other times.
In some implementation scenarios, the obtaining, as the primary key time identifier, the time corresponding to the start of the target application may include: converting the acquired time into a decimal value of a third preset digit; and taking the decimal value of the third preset digit as a primary key time identifier. Wherein the third predetermined number of bits may be 13.
For example, in some implementation scenarios, the time sequence primary key generator may collect host time corresponding to the start of the distributed application at a time granularity of microseconds, convert the host time into a decimal value of 13 bits, and use the obtained 13-bit value as the primary key time identifier.
S8: and generating a time sequence main key for the target application according to the main key time identification, the main key counting value and the application instance registration number.
In some implementation scenarios, after obtaining the primary key time identifier, the primary key count value, and the application instance registration number, a timing primary key may be generated for the target application according to the primary key time identifier, the primary key count value, and the application instance registration number.
In some implementation scenarios, the generating a timing primary key for the target application according to the primary key time identifier, the primary key count value, and the application instance registration number may include: and splicing the main key time identification, the main key counting value and the application instance registration number to obtain a time sequence main key corresponding to the target application.
For example, in some implementations, three sets of decimal values may be obtained through the above steps: (1) application instance registration number, maximum 6 decimal values; (2) primary key count value, max 10 decimal values; (3) primary key time identification, 13 decimal values. Further, the three sets of decimal values may be spliced according to the sequence of the primary key time identifier, the primary key count value, and the application instance registration number, so as to generate a time sequence primary key corresponding to the target application. In this way, the generated timing primary key can be globally unique in the distributed database.
Because the lengths of the time sequence main keys obtained by the method cannot be guaranteed to be consistent, in some implementation scenes, the three groups of decimal values obtained are further processed, so that the finally obtained time sequence main keys can meet the main key requirements of the distributed database. Wherein, the distributed database primary key requirement can include: (1) the main key is a text; (2) the main keys are consistent in length; (3) the main key indexing efficiency is high, and the storage space is small.
In some implementation scenarios, before splicing the primary key time identifier, the primary key count value, and the application instance registration number, the method may further include: connecting numbers, capital letters and small letters according to a preset sequence to obtain a first character string; respectively converting the primary key time identification, the primary key count value and the application instance registration number based on the first character string to obtain a target primary key time identification, a target primary key count value and a target application instance registration number; and splicing the target main key time identifier, the target main key counting value and the target application instance registration number to obtain a time sequence main key corresponding to the target application.
In some implementation scenarios, the preset sequence may be a sequence in an ASCII code table, such as the ordering rule of numbers, capital letters, and small letters in the ASCII code table shown in table 1:
TABLE 1
0 1 2 3 4 5 6 7 8 9
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
a b c d e f g h i j k l m n o p q r s t u v w x y z
In some implementations, 62 characters of the number, capital letter and small letter can be connected in sequence in the ASCII code table to form a character string (i.e., the first character string) including 62 characters. Further, instead of representing decimal numbers, a character string including 62 characters may be used to obtain a sixty binary system.
In some implementations, integer division may be applied to convert the decimal values obtained for the primary key time identifier, the primary key count value, and the application instance registration number into sixty-binary text.
In some implementations, the target primary key time stamp may be 7 in length; the target primary key count value may be 6 in length; the target application instance registration number may be 3 in length.
For example, in some implementation scenarios, the decimal value of the application instance registration number may be converted into a sixty binary system with a length of 3 bits, less than 3 bits, and the left may be complemented with 0; converting the decimal value of the main key counting value into a sexagesimal system with the length of 6 bits, wherein less than 6 bits are obtained, and the left side is complemented by 0; and converting the decimal number marked by the time of the main key into a sexagesimal system with the length of 7 bits. Furthermore, the obtained 7-bit, 6-bit and 3-bit sexagesimal fixed-length texts can be connected in sequence to obtain a 16-bit text as a target time sequence main key.
Of course, the above description is only exemplary, the preset sequence is not limited to the above examples, and other modifications are possible for those skilled in the art in light of the technical spirit of the present application, and all that can be achieved is intended to be covered by the scope of the present application as long as the achieved functions and effects are the same as or similar to the present application.
In some implementation scenarios, after the timing primary key generator generates the timing primary key for the target application, heartbeat information may be sent to the timing registration apparatus at a fixed time, so that the timing registration apparatus refreshes the update time of the application running instance identifier according to the heartbeat information. And the application running instance identification corresponds to the application instance registration number.
For example, in some implementations, the timing primary key generator may initiate a heartbeat request to the timing registration device every 10 minutes. Wherein, the heartbeat request can explain the working state of the time sequence main key generator to the time sequence registration device.
In some implementation scenarios, the time-series registration apparatus may include a heartbeat information processing unit and a storage unit. The heartbeat information processing unit can be used for processing heartbeat information sent by the time sequence main key generator, and the updating time of the application running instance identifier in the storage unit can be refreshed once every time the heartbeat information is received. And the storage unit can be used for storing metadata registration data, application running instance identification, application instance registration numbers, heartbeat records and the like.
In some implementation scenarios, a filtering interceptor may be further deployed in the distributed host to intercept the front-end request and ensure normal operation of the service. For example, in some implementation scenarios, after the distributed application is started, the timing sequence primary key generator may apply for registration to the timing sequence registration apparatus, after the registration is successful, the application instance registration number may be obtained, the timing sequence primary key generator operates normally, the filtering interceptor is released, and the distributed application provides services to the outside normally. If the registration is unsuccessful, the registration number of the application instance is not obtained, the time sequence main key generator cannot work normally, at the moment, the filtering interceptor intervenes, 500 exceptions representing errors in the server are returned for being identified by equipment such as a load balancer, the load balancer can take the application off line, and the application cannot provide services to the outside.
In some implementation scenarios, an application launch interceptor may be employed. Specifically, in the application starting process, the time sequence main key generator can apply for registration to the time sequence registration device, and after the registration is successful, an application instance registration number can be obtained, and the application is normally started; and when the registration is unsuccessful and the registration number of the application instance is not obtained, the interceptor intervenes to throw out the abnormal starting, and at the moment, the application cannot be started normally.
In the embodiment of the present specification, the time sequence main key generator is adopted to apply for registration to the time sequence registration apparatus, and each time sequence main key generator can be implemented without repetition. The time sequence registration device can run on a certain host and can be deployed in a distributed mode, so that cross-region and cross-center registration can be realized, and a cache middleware is not needed for carrying out large-scale data synchronization.
In the embodiment of the present specification, since the global counter operates in a single application instance range, it can be ensured that the count values are not repeated in a certain time granularity range. Because the global counter is based on the maximum computing capacity of the application server, the maximum count value cannot be calculated within the unit time granularity range, the counter cannot be reset to 0, a new iteration is generated, and thus, the main key repetition cannot be caused due to the time callback caused by the time synchronization of the host computer, and the maximum fault tolerance can be realized.
In the embodiment of the description, because the timing primary key is generated based on a single application instance, a single operation instance can generate a plurality of primary keys (such as 1000 ten thousand) per second, so that by applying distributed deployment, lateral expansion can be realized, and the maximum online number can reach hundreds of millions (such as 23832 billions) of primary keys, thereby meeting the generation requirement of the timing primary key under the extremely high concurrency condition and making the timing primary key globally unique.
In the embodiment of the specification, deployment can be realized in multiple regions, multiple centers and multiple clusters by applying registration and single-point generation, and the requirement of generating a time sequence main key under ultrahigh concurrency is met.
In the embodiment of the specification, the time identification of the main key, the count value of the main key and the registration number of the application instance are sequentially compressed through the sexagesimal binary conversion and then connected into the time sequence main key with the fixed length of 16 bits, and the time sequence main key is integrally ordered and globally unique, so that the problems of low efficiency of the traditional method and high cost of the existing mainstream scheme are solved, and the throughput capacity of the distributed cluster is improved.
The embodiments of the present description can solve the problems of data synchronization between hosts in distributed caches, and the like, and can solve the problems of cross-region delay, high bandwidth cost, time callback, and the like as QPS increases.
It is to be understood that the foregoing is only exemplary, and the embodiments of the present disclosure are not limited to the above examples, and other modifications may be made by those skilled in the art within the spirit of the present disclosure, and the scope of the present disclosure is intended to be covered by the claims as long as the functions and effects achieved by the embodiments are the same as or similar to the present disclosure.
From the above description, it can be seen that in the embodiment of the present application, when the target application is started, a registration request including the registration metadata may be sent to the time-series registration apparatus, so that the time-series registration apparatus generates an application instance registration number corresponding to the target application according to the registration metadata and returns the application instance registration number to the time-series primary key generator. And the value of the global counter can be acquired as a main key counting value, the corresponding time when the target application is started is acquired as a main key time identifier, and a time sequence main key is generated for the target application according to the main key time identifier, the main key counting value and the application instance registration number. The time sequence main key is generated by application registration and single point, so that deployment can be realized in multiple regions, multiple centers and multiple clusters, and the requirement of generating the time sequence main key under ultrahigh concurrency is met.
In the present specification, each embodiment of the method is described in a progressive manner, and the same and similar parts among the embodiments are referred to each other, and each embodiment focuses on the differences from other embodiments. Reference is made to the description of the method embodiments.
Based on the method for generating the time sequence main key, one or more embodiments of the present specification further provide an apparatus for generating the time sequence main key. The apparatus may include systems (including distributed systems), software (applications), modules, components, servers, clients, etc. that use the methods described in the embodiments of the present specification in conjunction with any necessary apparatus to implement the hardware. Based on the same innovative conception, embodiments of the present specification provide an apparatus as described in the following embodiments. Since the implementation scheme of the apparatus for solving the problem is similar to that of the method, the specific implementation of the apparatus in the embodiment of the present specification may refer to the implementation of the foregoing method, and repeated details are not repeated. As used hereinafter, the term "unit" or "module" may be a combination of software and/or hardware that implements a predetermined function. Although the means described in the embodiments below are preferably implemented in software, an implementation in hardware, or a combination of software and hardware is also possible and contemplated.
Specifically, fig. 2 is a schematic block diagram of an embodiment of an apparatus for generating a timing primary key provided in this specification, and as shown in fig. 2, the apparatus for generating a timing primary key provided in this specification may include: the system comprises a sending module 120, a receiving module 122, a first obtaining module 124, a second obtaining module 126 and a generating module 128.
A sending module 120, configured to send a registration request to the time sequence registration apparatus when the target application is started; wherein, the registration request comprises registration metadata; the time sequence registration device is used for generating an application instance registration number corresponding to the target application according to the registration metadata;
a receiving module 122, configured to receive an application instance registration number sent by the time sequence registration apparatus;
a first obtaining module 124, configured to obtain a value of the global counter as a primary key count value;
a second obtaining module 126, configured to obtain a time corresponding to the start of the target application as a primary key time identifier;
the generating module 128 may be configured to generate a timing primary key for the target application according to the primary key time identifier, the primary key count value, and the application instance registration number.
The registration metadata may include a name of a distributed host deployed by the target application, a name of the target application, a physical address of a network card corresponding to an outbound of the target application, an IP address, and an outbound service port number of the target application.
In some implementation scenarios, the receiving, by the time-series registration apparatus, a registration request may include:
the processing unit may be configured to perform hash processing on the registration metadata to obtain a first application instance registration identifier;
and the obtaining unit may be configured to obtain an application instance registration number corresponding to the target application according to the first application instance registration identifier.
In some implementation scenarios, the obtaining unit may include:
the comparison unit can be used for comparing the first application instance registration identifier with the application instance registration identifiers stored in the database;
the first generating unit may be configured to generate a corresponding application instance registration number for the target application according to the first application instance registration identifier when the first application instance registration identifier does not exist in the stored application instance registration identifiers.
In some implementation scenarios, the obtaining unit may further include:
the first obtaining unit may be configured to obtain a second application instance registration identifier that is the same as the first application instance registration identifier, when the first application instance registration identifier exists in the stored application instance registration identifiers;
the second generating unit may be configured to use an application instance registration number corresponding to the second application instance registration identifier as an application instance registration number corresponding to the target application.
In some implementation scenarios, after taking the application instance registration number corresponding to the second application instance registration identifier as the application instance registration number corresponding to the target application, the method may further include:
and the updating unit may be configured to update the registration time of the application instance registration number corresponding to the second application instance registration identifier.
In some implementation scenarios, before obtaining the value of the global counter as the primary key count value, the obtaining may include:
the establishing unit can be used for establishing a global counter in the range of the target application instance; and the global counter is used for accumulating the generation quantity of the time sequence main keys of the preset time granularity in the range of the target application instance.
In some implementation scenarios, the application instance registration number may be a decimal value of a first predetermined number of digits; the primary key count value may be a decimal value of a second preset digit; the maximum first preset digit number may be 6, and the maximum second preset digit number may be 10.
In some implementation scenarios, the second obtaining module 126 may include:
the conversion unit can be used for converting the acquired time into a decimal numerical value of a third preset digit;
and the second obtaining unit can be used for taking the decimal value of the third preset digit as the primary key time identifier.
In some implementation scenarios, the generating module 128 may include:
the first splicing unit may be configured to splice the primary key time identifier, the primary key count value, and the application instance registration number to obtain a timing primary key corresponding to the target application.
In some implementation scenarios, before splicing the primary key time identifier, the primary key count value, and the application instance registration number, the method may further include:
the connecting unit can be used for connecting numbers, capital letters and small letters according to a preset sequence to obtain a first character string;
a conversion unit, configured to convert the primary key time identifier, the primary key count value, and the application instance registration number based on the first character string, respectively, to obtain a target primary key time identifier, a target primary key count value, and a target application instance registration number;
the second splicing unit may be configured to splice the target primary key time identifier, the target primary key count value, and the target application instance registration number to obtain a timing primary key corresponding to the target application.
In some implementations, the target primary key time stamp may be 7 in length; the target primary key count value may be 6 in length; the target application instance registration number may be 3 in length.
In some implementation scenarios, the method may further include:
the sending unit may be configured to send heartbeat information to the time sequence registration apparatus at regular time, so that the time sequence registration apparatus refreshes the update time of the application running instance identifier according to the heartbeat information; and the application running instance identification corresponds to the application instance registration number.
It should be noted that the above-mentioned description of the apparatus according to the method embodiment may also include other embodiments, and specific implementation manners may refer to the description of the related method embodiment, which is not described herein again.
This specification also provides an embodiment of an apparatus for generating a timing primary key, comprising a processor and a memory for storing processor-executable instructions, which when executed by the processor, implement steps comprising: when the target application is started, sending a registration request to a time sequence registration device; wherein, the registration request comprises registration metadata; the time sequence registration device is used for generating an application instance registration number corresponding to the target application according to the registration metadata; receiving an application instance registration number sent by the time sequence registration device; acquiring the numerical value of the global counter as a main key counting value; acquiring corresponding time when the target application is started as a primary key time identifier; and generating a time sequence main key for the target application according to the main key time identification, the main key counting value and the application instance registration number.
It should be noted that the above-mentioned apparatuses may also include other embodiments according to the description of the method or apparatus embodiments. The specific implementation manner may refer to the description of the related method embodiment, and is not described in detail herein.
The method embodiments provided in the present specification may be executed in a mobile terminal, a computer terminal, a server or a similar computing device. Taking an example of the server running on a server, fig. 3 is a hardware configuration block diagram of an embodiment of a server for generating a timing main key provided in this specification, where the server may be an apparatus for generating a timing main key or a device for generating a timing main key in the above embodiments. As shown in fig. 3, the server 10 may include one or more (only one shown) processors 100 (the processors 100 may include, but are not limited to, a processing device such as a microprocessor MCU or a programmable logic device FPGA), a memory 200 for storing data, and a transmission module 300 for communication functions. It will be understood by those skilled in the art that the structure shown in fig. 3 is only an illustration and is not intended to limit the structure of the electronic device. For example, the server 10 may also include more or fewer components than shown in FIG. 3, and may also include other processing hardware, such as a database or multi-level cache, a GPU, or have a different configuration than shown in FIG. 3, for example.
The memory 200 may be used to store software programs and modules of application software, such as program instructions/modules corresponding to the method for generating a timing main key in the embodiment of the present specification, and the processor 100 executes various functional applications and data processing by executing the software programs and modules stored in the memory 200. Memory 200 may include high speed random access memory and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, memory 200 may further include memory located remotely from processor 100, which may be connected to a computer terminal through a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The transmission module 300 is used for receiving or transmitting data via a network. Specific examples of the network described above may include a wireless network provided by a communication provider of the computer terminal. In one example, the transmission module 300 includes a Network adapter (NIC) that can be connected to other Network devices through a base station so as to communicate with the internet. In one example, the transmission module 300 may be a Radio Frequency (RF) module, which is used for communicating with the internet in a wireless manner.
The foregoing description has been directed to specific embodiments of this disclosure. Other embodiments are within the scope of the following claims. In some cases, the actions or steps recited in the claims may be performed in a different order than in the embodiments and still achieve desirable results. In addition, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing may also be possible or may be advantageous.
The method or apparatus provided by the present specification and described in the foregoing embodiments may implement service logic through a computer program and record the service logic on a storage medium, where the storage medium may be read and executed by a computer, so as to implement the effect of the solution described in the embodiments of the present specification. The storage medium may include a physical device for storing information, and typically, the information is digitized and then stored using an electrical, magnetic, or optical media. The storage medium may include: devices that store information using electrical energy, such as various types of memory, e.g., RAM, ROM, etc.; devices that store information using magnetic energy, such as hard disks, floppy disks, tapes, core memories, bubble memories, and usb disks; devices that store information optically, such as CDs or DVDs. Of course, there are other ways of storing media that can be read, such as quantum memory, graphene memory, and so forth.
The method or apparatus embodiment for generating a time sequence main key provided in this specification may be implemented in a computer by a processor executing corresponding program instructions, for example, implemented in a PC end using a c + + language of a windows operating system, implemented in a linux system, or implemented in an intelligent terminal using, for example, android and iOS system programming languages, implemented in processing logic based on a quantum computer, and the like.
It should be noted that descriptions of the apparatus, the device, and the system described above according to the related method embodiments may also include other embodiments, and specific implementations may refer to descriptions of corresponding method embodiments, which are not described in detail herein.
The embodiments in the present application are described in a progressive manner, and the same and similar parts among the embodiments are referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the hardware + program class embodiment, since it is substantially similar to the method embodiment, the description is simple, and the relevant points can be referred to the partial description of the method embodiment.
For convenience of description, the above devices are described as being divided into various modules by functions, and are described separately. Of course, when implementing one or more of the present description, the functions of some modules may be implemented in one or more software and/or hardware, or the modules implementing the same functions may be implemented by a plurality of sub-modules or sub-units, etc.
The present invention has been described with reference to flowchart illustrations and/or block diagrams of methods, apparatus, devices, systems according to embodiments of the invention. It will be understood that the implementation can be by computer program instructions which can be provided to a processor of a general purpose computer, special purpose computer, embedded processor or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified. These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
As will be appreciated by one skilled in the art, one or more embodiments of the present description may be provided as a method, system, or computer program product. Accordingly, one or more embodiments of the present description may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects.
The above description is merely exemplary of one or more embodiments of the present disclosure and is not intended to limit the scope of one or more embodiments of the present disclosure. Various modifications and alterations to one or more embodiments described herein will be apparent to those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims.

Claims (16)

1. A method of generating a time sequential primary key, for use in a time sequential primary key generator, the method comprising:
when the target application is started, sending a registration request to a time sequence registration device; wherein, the registration request comprises registration metadata; the time sequence registration device is used for generating an application instance registration number corresponding to the target application according to the registration metadata;
receiving an application instance registration number sent by the time sequence registration device;
acquiring the numerical value of the global counter as a main key counting value;
acquiring corresponding time when the target application is started as a primary key time identifier;
and generating a time sequence main key for the target application according to the main key time identification, the main key counting value and the application instance registration number.
2. The method of claim 1, wherein the registration metadata comprises a name of a distributed host deployed by the target application, a name of the target application, a physical address of a network card corresponding to an outbound call of the target application, an IP address, and a port number of the target application to an outbound service.
3. The method of claim 1, wherein the sequential registration apparatus, after receiving the registration request, comprises:
performing hash processing on the registration metadata to obtain a first application instance registration identifier;
and acquiring an application instance registration number corresponding to the target application according to the first application instance registration identifier.
4. The method according to claim 3, wherein obtaining an application instance registration number corresponding to a target application according to the first application instance registration identifier comprises:
comparing the first application instance registration identification with application instance registration identifications stored in a database;
and under the condition that the first application instance registration identification does not exist in the stored application instance registration identifications, generating a corresponding application instance registration number for the target application according to the first application instance registration identification.
5. The method of claim 4, further comprising:
under the condition that the first application instance registration identification exists in the stored application instance registration identifications, acquiring a second application instance registration identification which is the same as the first application instance registration identification;
and taking the application instance registration number corresponding to the second application instance registration identifier as the application instance registration number corresponding to the target application.
6. The method according to claim 5, wherein after the application instance registration number corresponding to the second application instance registration identifier is used as the application instance registration number corresponding to the target application, the method further comprises:
and updating the registration time of the application instance registration number corresponding to the second application instance registration identification.
7. The method of claim 1, wherein obtaining the value of the global counter as the primary key count value comprises:
establishing a global counter within the scope of the target application instance; and the global counter is used for accumulating the generation quantity of the time sequence main keys of the preset time granularity in the range of the target application instance.
8. The method of claim 1, wherein the application instance registration number is a decimal value of a first preset number of digits; the primary key counting value is a decimal value of a second preset digit; wherein the maximum number of the first preset digits is 6, and the maximum number of the second preset digits is 10.
9. The method according to claim 1, wherein the obtaining the time corresponding to the target application when starting as the primary key time identifier comprises:
converting the acquired time into a decimal value of a third preset digit;
and taking the decimal value of the third preset digit as a primary key time identifier.
10. The method of claim 1, wherein generating a timing primary key for the target application according to the primary key time identifier, the primary key count value, and the application instance registration number comprises:
and splicing the main key time identification, the main key counting value and the application instance registration number to obtain a time sequence main key corresponding to the target application.
11. The method of claim 10, wherein before concatenating the primary key time identifier, the primary key count value, and the application instance registration number, further comprising:
connecting numbers, capital letters and small letters according to a preset sequence to obtain a first character string;
respectively converting the primary key time identification, the primary key count value and the application instance registration number based on the first character string to obtain a target primary key time identification, a target primary key count value and a target application instance registration number;
and splicing the target main key time identifier, the target main key counting value and the target application instance registration number to obtain a time sequence main key corresponding to the target application.
12. The method of claim 11, wherein the target primary key time stamp is 7 in length; the length of the target primary key count value is 6; the length of the target application instance registration number is 3.
13. The method of claim 1, further comprising:
sending heartbeat information to the time sequence registration device at regular time so that the time sequence registration device refreshes the updating time of the application running instance identifier according to the heartbeat information; and the application running instance identification corresponds to the application instance registration number.
14. An apparatus for generating a timing primary key, comprising:
the sending module is used for sending a registration request to the time sequence registration device when the target application is started; wherein, the registration request comprises registration metadata; the time sequence registration device is used for generating an application instance registration number corresponding to the target application according to the registration metadata;
the receiving module is used for receiving the application instance registration number sent by the time sequence registration device;
the first acquisition module is used for acquiring the numerical value of the global counter as a main key count value;
the second acquisition module is used for acquiring the corresponding time when the target application is started as a primary key time identifier;
and the generation module is used for generating a time sequence main key for the target application according to the main key time identifier, the main key counting value and the application instance registration number.
15. A device for generating a time-sequential primary key, comprising at least one processor and a memory storing computer-executable instructions, the processor implementing the steps of the method of any one of claims 1 to 13 when executing the instructions.
16. A computer-readable storage medium having stored thereon computer instructions which, when executed, implement the steps of the method of any one of claims 1-13.
CN202110958809.5A 2021-08-20 2021-08-20 Method, device and equipment for generating time sequence main key Pending CN113672621A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110958809.5A CN113672621A (en) 2021-08-20 2021-08-20 Method, device and equipment for generating time sequence main key

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110958809.5A CN113672621A (en) 2021-08-20 2021-08-20 Method, device and equipment for generating time sequence main key

Publications (1)

Publication Number Publication Date
CN113672621A true CN113672621A (en) 2021-11-19

Family

ID=78544199

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110958809.5A Pending CN113672621A (en) 2021-08-20 2021-08-20 Method, device and equipment for generating time sequence main key

Country Status (1)

Country Link
CN (1) CN113672621A (en)

Similar Documents

Publication Publication Date Title
CN110619114B (en) Serial number generation method and system
CN106657216B (en) Serial number generation method and device
US9699028B2 (en) Method and device for updating client
CN111447102B (en) SDN network device access method and device, computer device and storage medium
CN105072160A (en) Serial number generating method and device, and a server
CN110851748A (en) Short link generation method, server, storage medium and computer equipment
CN111083228B (en) Identification number generation method and device and electronic equipment
CN115470008B (en) Metadata access method and device and storage medium
CN113900810A (en) Distributed graph processing method, system and storage medium
CN105491078A (en) Data processing method and device in SOA system, and SOA system
CN107257371B (en) Analytic method and Handle system based on Handle system
CN106156258B (en) Method, device and system for counting data in distributed storage system
CN109862097A (en) ID generation method and device
CN113612864A (en) Method, system, equipment and medium for generating IPv6 address
CN113672621A (en) Method, device and equipment for generating time sequence main key
CN112052144A (en) Information management method, information management device, electronic equipment and storage medium
JP6233846B2 (en) Variable-length nonce generation
CN110935168B (en) Distributed ID generation method, device and equipment for global uniform architecture
CN111988781A (en) Verification method and system for safe access of Internet of things equipment
CN116366609B (en) Global unique identification generation method, system, computer and readable storage medium
CN110708208B (en) Monitoring data acquisition method and device, storage medium and terminal
CN114020970A (en) Query method, query device, storage medium and electronic equipment
EP4170974A1 (en) Slice service processing method and apparatus, network device, and readable storage medium
CN116170437A (en) Link tracking method and system
CN112905126A (en) Method and device for generating storage data identifier

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