CN112905126A - Method and device for generating storage data identifier - Google Patents

Method and device for generating storage data identifier Download PDF

Info

Publication number
CN112905126A
CN112905126A CN202110274913.2A CN202110274913A CN112905126A CN 112905126 A CN112905126 A CN 112905126A CN 202110274913 A CN202110274913 A CN 202110274913A CN 112905126 A CN112905126 A CN 112905126A
Authority
CN
China
Prior art keywords
data
stored
serial number
identification
identifier
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
CN202110274913.2A
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.)
China Electronic System Technology Co ltd
Original Assignee
China Electronic System Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by China Electronic System Technology Co ltd filed Critical China Electronic System Technology Co ltd
Priority to CN202110274913.2A priority Critical patent/CN112905126A/en
Publication of CN112905126A publication Critical patent/CN112905126A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0602Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
    • G06F3/0604Improving or facilitating administration, e.g. storage management
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0629Configuration or reconfiguration of storage systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0668Interfaces specially adapted for storage systems adopting a particular infrastructure
    • G06F3/067Distributed or networked storage systems, e.g. storage area networks [SAN], network attached storage [NAS]

Abstract

The application discloses a method for generating a storage data identifier, which comprises the following steps: responding to a storage instruction of the data to be stored, and acquiring configuration information corresponding to the data to be stored; determining a machine identifier, an area identifier and a project identifier corresponding to the data to be stored according to the configuration information; determining a serial number corresponding to data to be stored according to the serial number corresponding to the historical storage data; determining a time stamp identifier corresponding to the data to be stored according to the determination time of the serial number corresponding to the data to be stored; and if the serial number and the timestamp identification corresponding to the data to be stored do not meet the first preset condition, generating a stored data identification corresponding to the data to be stored according to the machine identification, the area identification, the project identification, the timestamp identification and the serial number corresponding to the data to be stored. Therefore, the method and the device can achieve the technical effects of high readability of the stored data identification service, rapid positioning service, convenience in unified deployment and management, decentralization, global uniqueness of the stored data identification and high concurrency support.

Description

Method and device for generating storage data identifier
Technical Field
The present application relates to the field of data processing, and in particular, to a method and an apparatus for generating a storage data identifier.
Background
For distributed application, a database needs to be subjected to database partitioning and table partitioning, after data fragmentation, a unique ID is used for identifying a piece of data, and the globally unique ID is called a distributed ID. In order to solve the problems of uniform deployment and uniform management of the distributed ID, the distributed ID should meet the requirements of high availability, low delay and increasing trend as much as possible under the conditions of ensuring global uniqueness and high readability.
The existing mainstream distributed ID generation algorithm mainly comprises a UUID-based algorithm, a database-based self-increment ID algorithm, a snowfly algorithm and the like, but the algorithms still have some defects:
1. the UUID is a string of unordered characters consisting of 36 characters, has no business significance, is not easy to store, and has low query efficiency when the data volume is large.
2. The mode based on the database self-increment ID strongly depends on the database, the database ID generation performance is limited and meaningless, and a single-point database is high in pressure and cannot support a high-concurrency scene. The distributed ID generation algorithm based on number segment and database cluster mode is the optimization of database self-increment ID, can reduce the database pressure, but the algorithm service restart based on number segment may lose a segment of ID, resulting in ID hole. The algorithm based on the database cluster also has the problems of difficult capacity expansion and incapability of supporting high concurrency. Furthermore, the IDs generated by these two optimization methods are still not of business significance.
3. The snowfall algorithm supports a high-concurrency scene, is high in performance and low in delay, is increased progressively according to time, but the readability of the original algorithm service is not strong, and secondary development is needed to adapt to services of different companies.
Therefore, a new scheme for generating data ID is needed.
Disclosure of Invention
The application provides a method for generating a stored data identifier, which can realize the technical effects of high readability of a stored data identifier service, rapid service positioning, convenient unified deployment and management, center removal, global uniqueness of the stored data identifier and high support of concurrency, thereby improving the efficiency of generation and management of the stored data identifier and further improving the user experience.
In a first aspect, the present application provides a method for generating a storage data identifier, where the method includes:
responding to a storage instruction of data to be stored, and acquiring configuration information corresponding to the data to be stored;
determining a machine identifier, an area identifier and a project identifier corresponding to the data to be stored according to the configuration information;
determining a serial number corresponding to the data to be stored according to a serial number corresponding to historical storage data;
determining a time stamp identifier corresponding to the data to be stored according to the determination time of the serial number corresponding to the data to be stored;
and if the serial number and the timestamp identification corresponding to the data to be stored do not meet a first preset condition, generating a stored data identification corresponding to the data to be stored according to the machine identification, the area identification, the project identification, the timestamp identification and the serial number corresponding to the data to be stored.
In a second aspect, the present application provides an apparatus for generating an identifier of stored data, the apparatus comprising:
the device comprises an acquisition unit, a storage unit and a processing unit, wherein the acquisition unit is used for responding to a storage instruction of data to be stored and acquiring configuration information corresponding to the data to be stored;
the first determining unit is used for determining a machine identifier, an area identifier and a project identifier corresponding to the data to be stored according to the configuration information;
the second determining unit is used for determining a serial number corresponding to the data to be stored according to a serial number corresponding to historical storage data;
a third determining unit, configured to determine, according to a determination time of a serial number corresponding to the data to be stored, a timestamp identifier corresponding to the data to be stored;
and the generating unit is used for generating a storage data identifier corresponding to the data to be stored according to the machine identifier, the area identifier, the project identifier, the timestamp identifier and the serial number corresponding to the data to be stored if the serial number and the timestamp identifier corresponding to the data to be stored do not meet a first preset condition.
In a third aspect, the present application provides a readable medium comprising executable instructions, which when executed by a processor of an electronic device, perform the method according to any of the first aspect.
In a fourth aspect, the present application provides an electronic device comprising a processor and a memory storing execution instructions, wherein when the processor executes the execution instructions stored in the memory, the processor performs the method according to any one of the first aspect.
According to the technical scheme, the application provides a method for generating the storage data identifier, and the method comprises the following steps: responding to a storage instruction of data to be stored, and acquiring configuration information corresponding to the data to be stored; determining a machine identifier, an area identifier and a project identifier corresponding to the data to be stored according to the configuration information; determining a serial number corresponding to the data to be stored according to a serial number corresponding to historical storage data; determining a time stamp identifier corresponding to the data to be stored according to the determination time of the serial number corresponding to the data to be stored; and if the serial number and the timestamp identification corresponding to the data to be stored do not meet a first preset condition, generating a stored data identification corresponding to the data to be stored according to the machine identification, the area identification, the project identification, the timestamp identification and the serial number corresponding to the data to be stored. It can be seen that, in the present application, the storage data identifier corresponding to the data to be stored is generated by the machine identifier, the area identifier, the project identifier, the timestamp identifier and the serial number, it can be understood that the storage data identifier corresponding to the data to be stored can reflect the machine identifier, the area identifier, the project identifier, the timestamp identifier and the serial number, so that the related products corresponding to the data to be stored can be quickly located according to the storage data identifier corresponding to the data to be stored, for example, when it is detected that there is a problem in the data to be stored, the problem that occurs on which machine of which project when, where and where the storage data identifier corresponding to the data to be stored can be quickly determined according to the storage data identifier corresponding to the data to be stored, so that the storage data identifier corresponding to the data to be stored generated by the present application can make the business readability high, The service can be quickly positioned, and unified deployment and management are facilitated, namely, the stored data identifier corresponding to the data to be stored, which is generated by the application, greatly improves the readability of the service, and is convenient for unified deployment and management; moreover, the storage data identifier corresponding to the data to be stored generated by the application realizes decentralization, that is, any service refers to the tool class generated by the storage data identifier, the service can be regarded as a service for generating the storage data identifier, each service can independently generate the storage data identifier, and the storage data identifier is globally unique; in addition, the method for generating the stored data identifier supports high concurrency, namely, one machine can generate a plurality of stored data identifiers every second, and the service requirements of most distributed applications can be met. Therefore, the method for generating the storage data identification can achieve the technical effects of high readability of the storage data identification service, rapid service positioning, convenient unified deployment and management, center removal, global uniqueness of the storage data identification and high support of concurrence, thereby improving the generation and management efficiency of the storage data identification and further improving the user experience.
Further effects of the above-mentioned unconventional preferred modes will be described below in conjunction with specific embodiments.
Drawings
In order to more clearly illustrate the embodiments or prior art solutions of the present application, the drawings needed for describing the embodiments or prior art will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments described in the present application, and that other drawings can be obtained by those skilled in the art without inventive exercise.
Fig. 1 is a schematic flowchart of a method for generating a storage data identifier according to an embodiment of the present application;
FIG. 2 is a schematic diagram of a storage data identifier according to an embodiment of the present application;
fig. 3 is a schematic structural diagram of a device for generating a storage data identifier according to an embodiment of the present application;
fig. 4 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the technical solutions of the present application will be described in detail and completely with reference to the following embodiments and accompanying drawings. It should be apparent that the described embodiments are only some of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
Various non-limiting embodiments of the present application are described in detail below with reference to the accompanying drawings.
Referring to fig. 1, a method for generating a storage data identifier in this embodiment is shown, and this application may be applied to a device that needs to generate a storage data representation, such as a client, a terminal device, or a server. In this embodiment, the method may include, for example, the steps of:
s101: and responding to a storage instruction of the data to be stored, and acquiring configuration information corresponding to the data to be stored.
In this embodiment, when a user needs to store data to be stored, the user may input a storage instruction for the data to be stored through a client, and at this time, configuration information corresponding to the data to be stored may be acquired in response to the storage instruction for the data to be stored; for example, in a scenario where a database needs to be partitioned and tabulated for distributed applications, after data to be stored is partitioned, a data storage identifier needs to be allocated to the data to be stored, at this time, a user may input a storage instruction for the data to be stored through a client, and then, in response to the storage instruction for the data to be stored, configuration information corresponding to the data to be stored may be acquired.
It should be noted that the configuration information corresponding to the data to be stored may be understood as information capable of reflecting the source of the data to be stored, for example, from which machine of which item the data to be stored is obtained.
In one implementation, the configuration information corresponding to the data to be stored may include: and the item information, the equipment information and/or the position information corresponding to the data to be stored. The device information may be understood as a source device that acquires data to be stored, and may include, for example, a name or a machine number of the source device that acquires the data to be stored; the item information may be understood as an item to which a source device that acquires the data to be stored belongs, and may include, for example, an item name or an item number of an item to which a source device that acquires the data to be stored belongs; the location information may be understood as a geographic location where the source device acquiring the data to be stored is located, and may include, for example, an administrative district corresponding to the geographic location where the source device acquiring the data to be stored is located, for example, a hai lake district in beijing.
S102: and determining a machine identifier, an area identifier and a project identifier corresponding to the data to be stored according to the configuration information.
After the configuration information corresponding to the data to be stored is acquired, the machine identifier, the area identifier, and the project identifier corresponding to the data to be stored may be determined according to the configuration information.
It should be noted that, in this embodiment, a corresponding relationship between the preset location information and the area identifier (for example, the location a corresponds to the area identifier a, it should be noted that the area identifier may be an administrative division code, for example, 100000 of the administrative division code of beijing), a corresponding relationship between the preset item information and the item identifier (for example, the item a corresponds to the item identifier a), and a corresponding relationship between the preset device information and the machine identifier (for example, the device a corresponds to the machine identifier a) may be preset.
Specifically, in this embodiment, the area identifier corresponding to the position information of the data to be stored may be determined according to a preset correspondence between the position information and the area identifier; determining a project identifier corresponding to the project information of the data to be stored according to a preset corresponding relationship between the project information and the project identifier; and determining the machine identifier corresponding to the equipment information of the data to be stored according to the corresponding relation between the preset equipment information and the machine identifier. Namely, the area identifier, the project identifier and the machine identifier can be assigned according to the actual application.
It should be noted that, in an implementation manner, the preset correspondence between the location information and the area identifier may include a correspondence that the location information is blank and the area identifier corresponding to the location information is 000001; the preset corresponding relationship between the item information and the item identifier may include a corresponding relationship in which the item information is blank and the corresponding item identifier is 01; the preset correspondence between the device information and the machine identifier may include a correspondence in which the device information is blank and the corresponding machine identifier is 001. That is, it is determined whether the device information is null, and if the device information is null, an initial value of "001" is assigned to the machine identifier corresponding to the device information; judging whether the position information is null, if so, giving an initial value of '000001' to the area identifier corresponding to the position information; and judging whether the item information is empty, and if so, giving an initial value of '01' to the item identifier corresponding to the item information.
S103: and determining a serial number corresponding to the data to be stored according to the serial number corresponding to the historical storage data.
In this embodiment, if there is no serial number corresponding to the history storage data, a preset starting serial number is used as the serial number corresponding to the data to be stored. Specifically, in an implementation manner of this embodiment, if the generation operation of the serial number corresponding to the data to be stored this time is the first generation operation in the instantiation this time, that is, there is no history stored data, a preset starting serial number (for example, 100) may be used as the serial number corresponding to the data to be stored.
In this embodiment, if there are several serial numbers corresponding to the history storage data, the serial number corresponding to the data to be stored is determined according to the serial number corresponding to the latest generated history storage data. Specifically, in an implementation manner of this embodiment, if the generation operation of the serial number corresponding to the data to be stored this time is not the first generation operation in the instantiation of this time, there is history storage data; a target serial number may be generated according to a serial number corresponding to the latest generated (i.e., the latest time of generation) history storage data, for example, if the serial number corresponding to the history storage data includes a serial number 100 corresponding to the history storage data generated for the first time and a serial number 101 corresponding to the history storage data generated for the second time, 1 may be added to the serial number corresponding to the latest generated history storage data (i.e., the serial number 101 corresponding to the history storage data generated for the second time), and a target serial number 102 may be generated; then, if the target serial number meets a second preset condition, the target serial number may be used as the serial number corresponding to the data to be stored, it should be noted that the second preset condition may be that the target serial number is less than or equal to the maximum value corresponding to the number of bits of the serial number, so that cyclic utilization of the serial number may be ensured, for example, if the number of bits of the serial number is 3 bits, the second preset condition may be that the target serial number is less than or equal to the maximum value corresponding to the number of bits of the serial number, that is, 999, if the target serial number is 102, since 102 is less than 999, that is, the target serial number meets the second preset condition, the target serial number 102 may be used as the serial number corresponding to the data to be stored; if the target serial number does not satisfy the second preset condition, the preset starting serial number is used as the serial number corresponding to the data to be stored, for example, if the number of bits of the serial number is 3, the second preset condition may be that the target serial number is less than or equal to the maximum value corresponding to the number of bits of the serial number, that is, 999, and if the target serial number is greater than 999, the serial number is reset to 100 (that is, the preset starting serial number is 100).
S104: and determining the time stamp identification corresponding to the data to be stored according to the determination time of the serial number corresponding to the data to be stored.
In this embodiment, when determining the serial number corresponding to the data to be stored, the determination time of the serial number corresponding to the data to be stored may be obtained, and then, the timestamp identifier corresponding to the determination time may be determined according to a preset timestamp identifier format.
For example, assuming that the preset timestamp identification format is "yyymmddhhmmsss", that is, "year, month, day, hour, minute, second, millisecond", and the time for determining the sequence number corresponding to the data to be stored is 2021 year, 3 month, 11 day, 13 hour, 00 minute, 00 second, 00 millisecond, that is, the determination time for determining the sequence number corresponding to the data to be stored is 2021 year, 03 month, 11 day, 13 hour, 00 minute, 00 second, 00 millisecond, the timestamp identification corresponding to the determination time may be determined to be "2021031113000000" according to the preset timestamp identification format.
It should be noted that, in an implementation manner of this embodiment, in order to ensure that a storage data identifier generates an error due to time confusion, in this implementation manner, a timestamp identifier corresponding to the to-be-stored data is determined at the determination time according to a sequence number corresponding to the to-be-stored data, and then the method further includes the following steps:
first, it may be determined whether the timestamp identifier corresponding to the to-be-stored data is smaller than the timestamp identifier corresponding to the latest historical storage data.
If the timestamp identifier corresponding to the to-be-stored data is smaller than the timestamp identifier corresponding to the latest historical storage data, it indicates that the determination time of the serial number of the to-be-stored data is earlier than the determination time of the serial number corresponding to the historical storage data, and at this time, it can be determined that time is disordered, which causes an error in generating the timestamp identifier corresponding to the to-be-stored data, so that the step of S105 'generating the stored data identifier corresponding to the to-be-stored data according to the machine identifier, the area identifier, the project identifier, the timestamp identifier and the serial number corresponding to the to-be-stored data if the serial number and the timestamp identifier corresponding to the to-be-stored data do not satisfy a first preset condition', that is, terminating the process; it is emphasized that in one implementation, an exception alert message may also be entered to alert for an exception.
If the timestamp identifier corresponding to the to-be-stored data is not less than the timestamp identifier corresponding to the latest historical storage data, it indicates that the determination time of the serial number of the to-be-stored data is not earlier than the determination time of the serial number corresponding to the historical storage data, and no error occurs in the generation of the timestamp identifier corresponding to the to-be-stored data, and S105 "if the serial number corresponding to the to-be-stored data and the timestamp identifier do not satisfy the first preset condition, the step of generating the stored data identifier corresponding to the to-be-stored data" according to the machine identifier, the area identifier, the project identifier, the timestamp identifier and the serial number corresponding to the to-be-stored data "may be continuously performed.
S105: and if the serial number and the timestamp identification corresponding to the data to be stored do not meet a first preset condition, generating a stored data identification corresponding to the data to be stored according to the machine identification, the area identification, the project identification, the timestamp identification and the serial number corresponding to the data to be stored.
In this embodiment, the first preset condition may be: the timestamp identification corresponding to the data to be stored is the same as the timestamp identification corresponding to the latest historical storage data, and the serial number corresponding to the data to be stored is a preset initial serial number. It should be emphasized that, in an implementation manner, if the generation operation of the sequence number corresponding to the data to be stored this time is the first generation operation in the instantiation this time, that is, there is no history stored data, at this time, the timestamp identifier corresponding to the data to be stored may be compared with a preset timestamp identifier (for example, -1L), and it is determined whether the timestamp identifier and the preset timestamp identifier are the same.
If the serial number and the timestamp identification corresponding to the data to be stored do not meet a first preset condition, for example, the timestamp identification corresponding to the data to be stored is different from the timestamp identification (or the preset timestamp identification) corresponding to the latest historical storage data, and/or the serial number corresponding to the data to be stored is not a preset initial serial number, which indicates that the generated serial number does not fully occupy the digit of the serial number in the current millisecond-level timestamp; the machine identifier, the area identifier, the project identifier, the timestamp identifier and the serial number corresponding to the data to be stored can be spliced according to a preset stored data identifier format to obtain a stored data identifier corresponding to the data to be stored.
It should be noted that, in one implementation, the preset storage data identification format may be as shown in fig. 2, and the preset storage data identification format may be composed of 32-bit characters: 0 (1 st bit is a placeholder and is fixed to '0'), 17-bit time stamp (namely 2 nd bit to 18 th bit are time stamp identifications), 6-bit area ID (namely 19 th bit to 24 th bit are area identifications), 2-bit item ID (namely 25 th bit to 26 th bit are item identifications), 3-bit machine ID (namely 27 th bit to 29 th bit are machine identifications), 3-bit sequence number (namely 30 th bit to 32 th bit are sequence numbers, namely, the count in milliseconds, each time one sequence number is generated, the self-increment sequence number of 1 and 3 bits supports each node to generate 900 sequence numbers every millisecond (same machine and same time intercept), and the ID requirement of most services can be completely met. It can be understood that, because the machine identifier, the area identifier, the project identifier, the timestamp identifier and the serial number are introduced into the storage data identifier corresponding to the data to be stored, the storage data identifier corresponding to the data to be stored can reflect the machine identifier, the area identifier, the project identifier, the timestamp identifier and the serial number, so that the related products corresponding to the data to be stored can be quickly located according to the storage data identifier corresponding to the data to be stored, for example, when a problem of the data to be stored is detected, the problem of which item appears on which machine when, where and where the stored data identifier corresponding to the data to be stored is quickly determined according to the stored data identifier corresponding to the data to be stored, so that the stored data identifier corresponding to the data to be stored generated by the application can enable the readability to be high, The method and the system can quickly position the service and are convenient for unified deployment and management, namely, the stored data identifier corresponding to the data to be stored generated by the method and the system greatly improve the readability of the service and are convenient for unified deployment and management.
It should be noted that, in an implementation manner, the method further includes:
if the serial number and the timestamp identification corresponding to the data to be stored meet a first preset condition, that is, the timestamp identification corresponding to the data to be stored is the same as the timestamp identification (or the preset timestamp identification) corresponding to the latest historical storage data, and the serial number corresponding to the data to be stored is a preset initial serial number, which indicates that the generated serial number occupies the bits of the serial number in the current millisecond-level timestamp, and if the storage data identification corresponding to the data to be stored is continuously generated, repeated storage data identification may occur; in order to ensure that the generated storage data identifier corresponding to the data to be stored is globally unique, at this time, a blocking state is entered (i.e., the generation of the storage data identifier corresponding to the data to be stored is stopped) first until the current time is different from the determination time of the serial number corresponding to the data to be stored (e.g., until the current timestamp is changed to the next millisecond), and then, according to the current time, a timestamp identifier corresponding to the current time is determined, and the timestamp identifier corresponding to the current time is used as the timestamp identifier corresponding to the data to be stored (i.e., the timestamp identifier corresponding to the data to be stored is determined again); then, a storage data identifier corresponding to the data to be stored may be generated according to the machine identifier, the area identifier, the item identifier, the timestamp identifier, and the sequence number corresponding to the data to be stored.
According to the technical scheme, the application provides a method for generating the storage data identifier, and the method comprises the following steps: responding to a storage instruction of data to be stored, and acquiring configuration information corresponding to the data to be stored; determining a machine identifier, an area identifier and a project identifier corresponding to the data to be stored according to the configuration information; determining a serial number corresponding to the data to be stored according to a serial number corresponding to historical storage data; determining a time stamp identifier corresponding to the data to be stored according to the determination time of the serial number corresponding to the data to be stored; and if the serial number and the timestamp identification corresponding to the data to be stored do not meet a first preset condition, generating a stored data identification corresponding to the data to be stored according to the machine identification, the area identification, the project identification, the timestamp identification and the serial number corresponding to the data to be stored. It can be seen that, in the present application, the storage data identifier corresponding to the data to be stored is generated by the machine identifier, the area identifier, the project identifier, the timestamp identifier and the serial number, it can be understood that the storage data identifier corresponding to the data to be stored can reflect the machine identifier, the area identifier, the project identifier, the timestamp identifier and the serial number, so that the related products corresponding to the data to be stored can be quickly located according to the storage data identifier corresponding to the data to be stored, for example, when it is detected that there is a problem in the data to be stored, the problem that occurs on which machine of which project when, where and where the storage data identifier corresponding to the data to be stored can be quickly determined according to the storage data identifier corresponding to the data to be stored, so that the storage data identifier corresponding to the data to be stored generated by the present application can make the business readability high, The service can be quickly positioned, and unified deployment and management are facilitated, namely, the stored data identifier corresponding to the data to be stored, which is generated by the application, greatly improves the readability of the service, and is convenient for unified deployment and management; moreover, the storage data identifier corresponding to the data to be stored generated by the application realizes decentralization, that is, any service refers to the tool class generated by the storage data identifier, the service can be regarded as a service for generating the storage data identifier, each service can independently generate the storage data identifier, and the storage data identifier is globally unique; in addition, the method for generating the stored data identifier supports high concurrency, namely, one machine can generate a plurality of stored data identifiers every second, and the service requirements of most distributed applications can be met. Therefore, the method for generating the storage data identification can achieve the technical effects of high readability of the storage data identification service, rapid service positioning, convenient unified deployment and management, center removal, global uniqueness of the storage data identification and high support of concurrence, thereby improving the generation and management efficiency of the storage data identification and further improving the user experience.
It should be further noted that the generated stored data identifier is decentralized, that is, any service referencing the tool class generated by the stored data identifier may be considered as a generation service itself, each service may independently generate the stored data identifier, and the stored data identifier is globally unique. Because the high order of the stored data identification is the time stamp identification field and the sequence number is the low order, the generated stored data identification is gradually increased along with the increase of time, so that the situation that when an InNODB table element is inserted, a value is suddenly inserted into the middle, and the leaf nodes of a B + tree are split and automatically balanced can be avoided. And based on the snowfall algorithm idea, the generation of the stored data identification can support high concurrency, 90 thousands of IDs can be generated by one machine per second theoretically, and the service requirements of most distributed applications can be met.
Fig. 3 shows a specific embodiment of a generating apparatus for storing data identifiers according to the present application. The apparatus of this embodiment is a physical apparatus for executing the method of the above embodiment. The technical solution is essentially the same as that in the above embodiment, and the corresponding description in the above embodiment is also applicable to this embodiment. The device in this embodiment includes:
an obtaining unit 301, configured to, in response to a storage instruction of data to be stored, obtain configuration information corresponding to the data to be stored;
a first determining unit 302, configured to determine, according to the configuration information, a machine identifier, an area identifier, and an item identifier corresponding to the data to be stored;
a second determining unit 303, configured to determine, according to a serial number corresponding to historical storage data, a serial number corresponding to the data to be stored;
a third determining unit 304, configured to determine, according to a determination time of a serial number corresponding to the data to be stored, a timestamp identifier corresponding to the data to be stored;
a generating unit 305, configured to generate a storage data identifier corresponding to the to-be-stored data according to the machine identifier, the area identifier, the item identifier, the timestamp identifier, and the serial number corresponding to the to-be-stored data if the serial number and the timestamp identifier corresponding to the to-be-stored data do not satisfy a first preset condition.
Optionally, the configuration information corresponding to the data to be stored includes: and the item information, the equipment information and/or the position information corresponding to the data to be stored.
Optionally, the first determining unit 302 is configured to:
determining an area identifier corresponding to the position information of the data to be stored according to a corresponding relation between preset position information and the area identifier;
determining a project identifier corresponding to the project information of the data to be stored according to a corresponding relation between preset project information and the project identifier;
and determining the machine identifier corresponding to the equipment information of the data to be stored according to the corresponding relation between the preset equipment information and the machine identifier.
Optionally, the second determining unit 303 is configured to:
if no serial number corresponding to the historical storage data exists, taking a preset starting serial number as a serial number corresponding to the data to be stored;
and if the serial numbers corresponding to the historical storage data exist, determining the serial number corresponding to the data to be stored according to the serial number corresponding to the newly generated historical storage data.
Optionally, the second determining unit 303 is specifically configured to:
generating a target serial number according to the serial number corresponding to the latest generated historical storage data;
if the target serial number meets a second preset condition, taking the target serial number as a serial number corresponding to the data to be stored;
and if the target serial number does not meet a second preset condition, taking the preset starting serial number as a serial number corresponding to the data to be stored.
Optionally, the third determining unit 304 is configured to:
acquiring the determination time of the serial number corresponding to the data to be stored;
and determining the timestamp identification corresponding to the determined time according to a preset timestamp identification format.
Optionally, the first preset condition is: the timestamp identification corresponding to the data to be stored is the same as the timestamp identification corresponding to the latest historical storage data, and the serial number corresponding to the data to be stored is a preset initial serial number;
the generating unit 305 is configured to:
and if the serial number and the timestamp identification corresponding to the data to be stored do not meet a first preset condition, splicing the machine identification, the area identification, the project identification, the timestamp identification and the serial number corresponding to the data to be stored according to a preset storage data identification format to obtain a storage data identification corresponding to the data to be stored.
Optionally, the generating unit 305 is further configured to:
if the serial number and the timestamp identification corresponding to the data to be stored meet a first preset condition, determining the timestamp identification corresponding to the current time according to the current time until the determination time of the current time is different from the determination time of the serial number corresponding to the data to be stored, and taking the timestamp identification corresponding to the current time as the timestamp identification corresponding to the data to be stored;
and generating a storage data identifier corresponding to the data to be stored according to the machine identifier, the area identifier, the project identifier, the timestamp identifier and the serial number corresponding to the data to be stored.
Optionally, the generating unit 305 is further configured to:
judging whether the timestamp identification corresponding to the data to be stored is smaller than the timestamp identification corresponding to the latest historical storage data;
if the timestamp identification corresponding to the data to be stored is smaller than the timestamp identification corresponding to the latest historical storage data, the step of generating the storage data identification corresponding to the data to be stored according to the machine identification, the area identification, the project identification, the timestamp identification and the serial number corresponding to the data to be stored is not executed if the serial number corresponding to the data to be stored and the timestamp identification do not meet a first preset condition;
and if the timestamp identification corresponding to the data to be stored is not less than the timestamp identification corresponding to the latest historical storage data, continuing to execute the step of generating the storage data identification corresponding to the data to be stored according to the machine identification, the area identification, the project identification, the timestamp identification and the serial number corresponding to the data to be stored if the serial number corresponding to the data to be stored and the timestamp identification do not meet a first preset condition.
Fig. 4 is a schematic structural diagram of an electronic device according to an embodiment of the present application. On the hardware level, the electronic device comprises a processor and optionally an internal bus, a network interface and a memory. The Memory may include a Memory, such as a Random-Access Memory (RAM), and may further include a non-volatile Memory, such as at least 1 disk Memory. Of course, the electronic device may also include hardware required for other services.
The processor, the network interface, and the memory may be connected to each other via an internal bus, which may be an ISA (Industry standard architecture) bus, a PCI (Peripheral Component Interconnect) bus, an EISA (Extended Industry standard architecture) bus, or the like. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one double-headed arrow is shown in FIG. 4, but that does not indicate only one bus or one type of bus.
And the memory is used for storing the execution instruction. In particular, a computer program that can be executed by executing instructions. The memory may include both memory and non-volatile storage and provides execution instructions and data to the processor.
In a possible implementation manner, the processor reads the corresponding execution instruction from the nonvolatile memory into the memory and then runs the corresponding execution instruction, and may also obtain the corresponding execution instruction from other devices, so as to form the generation apparatus for storing the data identifier on a logic level. The processor executes the execution instructions stored in the memory, so that the method for generating the storage data identifier provided in any embodiment of the application is realized through the executed execution instructions.
The method executed by the generating device for storing the data identifier provided by the embodiment shown in fig. 1 of the present application may be applied to a processor, or implemented by the processor. The processor may be an integrated circuit chip having signal processing capabilities. In implementation, the steps of the above method may be performed by integrated logic circuits of hardware in a processor or instructions in the form of software. The Processor may be a general-purpose Processor, including a Central Processing Unit (CPU), a Network Processor (NP), and the like; but also Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), Field Programmable Gate Arrays (FPGAs) or other Programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. The various methods, steps, and logic blocks disclosed in the embodiments of the present application may be implemented or performed. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The steps of the method disclosed in connection with the embodiments of the present application may be directly implemented by a hardware decoding processor, or implemented by a combination of hardware and software modules in the decoding processor. The software module may be located in ram, flash memory, rom, prom, or eprom, registers, etc. storage media as is well known in the art. The storage medium is located in a memory, and a processor reads information in the memory and completes the steps of the method in combination with hardware of the processor.
The embodiment of the present application further provides a readable storage medium, where the readable storage medium stores an execution instruction, and when the stored execution instruction is executed by a processor of an electronic device, the electronic device can be caused to execute the method for generating a stored data identifier provided in any embodiment of the present application, and is specifically configured to execute the method for generating the stored data identifier.
The electronic device described in the foregoing embodiments may be a computer.
It will be apparent to those skilled in the art that embodiments of the present application may be provided as a method or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects.
The embodiments in the present application are described in a progressive manner, and the same and similar parts among the embodiments can be referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, as for the apparatus embodiment, since it is substantially similar to the method embodiment, the description is relatively simple, and for the relevant points, reference may be made to the partial description of the method embodiment.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
The above description is only an example of the present application and is not intended to limit the present application. Various modifications and changes may occur 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 of the present application.

Claims (10)

1. A method for generating an identifier of stored data, the method comprising:
responding to a storage instruction of data to be stored, and acquiring configuration information corresponding to the data to be stored;
determining a machine identifier, an area identifier and a project identifier corresponding to the data to be stored according to the configuration information;
determining a serial number corresponding to the data to be stored according to a serial number corresponding to historical storage data;
determining a time stamp identifier corresponding to the data to be stored according to the determination time of the serial number corresponding to the data to be stored;
and if the serial number and the timestamp identification corresponding to the data to be stored do not meet a first preset condition, generating a stored data identification corresponding to the data to be stored according to the machine identification, the area identification, the project identification, the timestamp identification and the serial number corresponding to the data to be stored.
2. The method according to claim 1, wherein the configuration information corresponding to the data to be stored comprises: and the item information, the equipment information and/or the position information corresponding to the data to be stored.
3. The method according to claim 2, wherein the determining, according to the configuration information, a machine identifier, an area identifier, and an item identifier corresponding to the data to be stored includes:
determining an area identifier corresponding to the position information of the data to be stored according to a corresponding relation between preset position information and the area identifier;
determining a project identifier corresponding to the project information of the data to be stored according to a corresponding relation between preset project information and the project identifier;
and determining the machine identifier corresponding to the equipment information of the data to be stored according to the corresponding relation between the preset equipment information and the machine identifier.
4. The method according to any one of claims 1 to 3, wherein determining the serial number corresponding to the data to be stored according to the serial number corresponding to the historical storage data comprises:
if no serial number corresponding to the historical storage data exists, taking a preset starting serial number as a serial number corresponding to the data to be stored;
and if the serial numbers corresponding to the historical storage data exist, determining the serial number corresponding to the data to be stored according to the serial number corresponding to the newly generated historical storage data.
5. The method according to claim 4, wherein the determining the serial number corresponding to the data to be stored according to the serial number corresponding to the latest generated historical storage data comprises:
generating a target serial number according to the serial number corresponding to the latest generated historical storage data;
if the target serial number meets a second preset condition, taking the target serial number as a serial number corresponding to the data to be stored;
and if the target serial number does not meet a second preset condition, taking the preset starting serial number as a serial number corresponding to the data to be stored.
6. The method according to any one of claims 1 to 3, wherein the determining, according to the determination time of the sequence number corresponding to the data to be stored, the timestamp identifier corresponding to the data to be stored includes:
acquiring the determination time of the serial number corresponding to the data to be stored;
and determining the timestamp identification corresponding to the determined time according to a preset timestamp identification format.
7. A method according to any one of claims 1-3, characterized in that the first preset condition is: the timestamp identification corresponding to the data to be stored is the same as the timestamp identification corresponding to the latest historical storage data, and the serial number corresponding to the data to be stored is a preset initial serial number;
if the serial number and the timestamp identification corresponding to the data to be stored do not meet a first preset condition, generating a stored data identification corresponding to the data to be stored according to the machine identification, the area identification, the project identification, the timestamp identification and the serial number corresponding to the data to be stored, including:
and if the serial number and the timestamp identification corresponding to the data to be stored do not meet a first preset condition, splicing the machine identification, the area identification, the project identification, the timestamp identification and the serial number corresponding to the data to be stored according to a preset storage data identification format to obtain a storage data identification corresponding to the data to be stored.
8. The method of claim 7, further comprising:
if the serial number and the timestamp identification corresponding to the data to be stored meet a first preset condition, determining the timestamp identification corresponding to the current time according to the current time until the determination time of the current time is different from the determination time of the serial number corresponding to the data to be stored, and taking the timestamp identification corresponding to the current time as the timestamp identification corresponding to the data to be stored;
and generating a storage data identifier corresponding to the data to be stored according to the machine identifier, the area identifier, the project identifier, the timestamp identifier and the serial number corresponding to the data to be stored.
9. The method according to any one of claims 1 to 3, wherein after determining the timestamp identifier corresponding to the data to be stored at the determination time according to the sequence number corresponding to the data to be stored, the method further comprises:
judging whether the timestamp identification corresponding to the data to be stored is smaller than the timestamp identification corresponding to the latest historical storage data;
if the timestamp identification corresponding to the data to be stored is smaller than the timestamp identification corresponding to the latest historical storage data, the step of generating the storage data identification corresponding to the data to be stored according to the machine identification, the area identification, the project identification, the timestamp identification and the serial number corresponding to the data to be stored is not executed if the serial number corresponding to the data to be stored and the timestamp identification do not meet a first preset condition;
and if the timestamp identification corresponding to the data to be stored is not less than the timestamp identification corresponding to the latest historical storage data, continuing to execute the step of generating the storage data identification corresponding to the data to be stored according to the machine identification, the area identification, the project identification, the timestamp identification and the serial number corresponding to the data to be stored if the serial number corresponding to the data to be stored and the timestamp identification do not meet a first preset condition.
10. A generating device for storing data identification, the device comprising:
the device comprises an acquisition unit, a storage unit and a processing unit, wherein the acquisition unit is used for responding to a storage instruction of data to be stored and acquiring configuration information corresponding to the data to be stored;
the first determining unit is used for determining a machine identifier, an area identifier and a project identifier corresponding to the data to be stored according to the configuration information;
the second determining unit is used for determining a serial number corresponding to the data to be stored according to a serial number corresponding to historical storage data;
a third determining unit, configured to determine, according to a determination time of a serial number corresponding to the data to be stored, a timestamp identifier corresponding to the data to be stored;
and the generating unit is used for generating a storage data identifier corresponding to the data to be stored according to the machine identifier, the area identifier, the project identifier, the timestamp identifier and the serial number corresponding to the data to be stored if the serial number and the timestamp identifier corresponding to the data to be stored do not meet a first preset condition.
CN202110274913.2A 2021-03-15 2021-03-15 Method and device for generating storage data identifier Pending CN112905126A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110274913.2A CN112905126A (en) 2021-03-15 2021-03-15 Method and device for generating storage data identifier

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110274913.2A CN112905126A (en) 2021-03-15 2021-03-15 Method and device for generating storage data identifier

Publications (1)

Publication Number Publication Date
CN112905126A true CN112905126A (en) 2021-06-04

Family

ID=76105131

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110274913.2A Pending CN112905126A (en) 2021-03-15 2021-03-15 Method and device for generating storage data identifier

Country Status (1)

Country Link
CN (1) CN112905126A (en)

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20040122931A1 (en) * 2002-12-19 2004-06-24 Microsoft Corporation Generating globally unique device identification
CN110750506A (en) * 2019-09-17 2020-02-04 苏宁云计算有限公司 Data object identification generation method and device, computer equipment and storage medium
CN111917897A (en) * 2020-07-15 2020-11-10 深圳市腾讯网域计算机网络有限公司 Identification generation method, device, equipment and storage medium

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20040122931A1 (en) * 2002-12-19 2004-06-24 Microsoft Corporation Generating globally unique device identification
CN110750506A (en) * 2019-09-17 2020-02-04 苏宁云计算有限公司 Data object identification generation method and device, computer equipment and storage medium
CN111917897A (en) * 2020-07-15 2020-11-10 深圳市腾讯网域计算机网络有限公司 Identification generation method, device, equipment and storage medium

Similar Documents

Publication Publication Date Title
JP6716727B2 (en) Streaming data distributed processing method and apparatus
CN113766035A (en) Method and device for service acceptance and consensus
CN111767143A (en) Transaction data processing method, device, equipment and system
CN109032803B (en) Data processing method and device and client
CN111294390B (en) Block data rapid synchronization method, device, equipment and storage medium
CN110543448A (en) data synchronization method, device, equipment and computer readable storage medium
CN111580884A (en) Configuration updating method and device, server and electronic equipment
CN108241715A (en) A kind of distributed data base major key generation method and device
CN111355816A (en) Server selection method, device, equipment and distributed service system
CN111767144A (en) Transaction routing determination method, device, equipment and system for transaction data
CN113704790A (en) Abnormal log information summarizing method and computer equipment
CN108399175B (en) Data storage and query method and device
CN112988458B (en) Data backup method and device, electronic equipment and storage medium
CN110471780B (en) Distributed event processing apparatus, terminal, and computer storage medium
CN112052144B (en) Information management method, device, electronic equipment and storage medium
CN113468143A (en) Data migration method, system, computing device and storage medium
CN110209347B (en) Traceable data storage method
CN110955460B (en) Service process starting method and device, electronic equipment and storage medium
CN110647463B (en) Method and device for restoring test breakpoint and electronic equipment
CN112463808A (en) Data processing method and device of target cluster and server
CN111708763A (en) Data migration method and device of fragment cluster and fragment cluster system
CN112905126A (en) Method and device for generating storage data identifier
CN113254163B (en) Processing method and device of block chain data
CN115134373A (en) Data synchronization method and device, storage medium and electronic equipment
CN111464312B (en) Method and device for processing account addresses in blockchain and electronic equipment

Legal Events

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