Data identifier generation method and device, readable medium and electronic equipment

By determining the current timestamp in the target service instance and determining the target sequence in multiple preset sequences in high concurrency scenarios, the problem of data identification conflicts is solved and the speed and efficiency of data identification generation are improved.

CN119357249APending Publication Date: 2025-01-24BEIJING YOUZHUJU NETWORK TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310912925.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-07-24
Publication Date
2025-01-24

AI Technical Summary

Technical Problem

In the high concurrency scenario, the data identification generated by the snowflake algorithm in the prior art is prone to conflicting problems, and the use of pessimistic locks limits the concurrency capability, resulting in a degradation of service performance.

Method used

The current timestamp is determined by responding to the data of the data in the target service instance, and the target sequence is determined in the at least two preset sequences according to the current timestamp, and the sequence number of the target sequence is used to generate the data identification.

Benefits of technology

This method reduces the conflict of data identification under the high -concurrency scene, improves the generating speed of the data identification, and reduces the generation of duplicate data identification.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119357249A_ABST
    Figure CN119357249A_ABST
Patent Text Reader

Abstract

The invention relates to a data identification generation method and device, a readable medium and electronic device.The data identification generation method comprises the steps that in response to generation of data in a target service instance, a current timestamp is determined; a target sequence is determined in at least two preset sequences according to the current timestamp, each preset sequence has a sequence number which is initially a preset numerical value, and the sequence number is progressively increased after being used for generating a corresponding data identifier; and generating a data identifier of the data at least according to the serial number of the target sequence. According to the technical scheme, the target sequence can be determined in the at least two preset sequences according to the current timestamp, and the data identifier of the data is generated at least according to the sequence number of the target sequence. On one hand, the data identifier generation speed can be increased, and on the other hand, generation of repeated data identifiers can be reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technology, and in particular, to a data identification generation method, device, readable medium and electronic device. Background Art

[0002] In the field of data processing, in order to distinguish different data, a unique data identifier is generally generated for each data. In related technologies, data identifiers are mostly generated based on the snowflake algorithm. In high-concurrency scenarios, there is a problem of conflict between data identifiers. Summary of the invention

[0003] This summary is provided to introduce concepts in a brief form that will be described in detail in the detailed description below. This summary is not intended to identify key features or essential features of the claimed technical solution, nor is it intended to limit the scope of the claimed technical solution.

[0004] In a first aspect, the present disclosure provides a method for generating a data identifier, the method comprising:

[0005] In response to generation of data in the target service instance, determining a current timestamp;

[0006] Determining a target sequence from at least two preset sequences according to the current timestamp, wherein each of the preset sequences has a sequence number that is initially a preset value, and the sequence number increases after being used to generate a corresponding data identifier;

[0007] A data identifier of the data is generated based at least on the sequence number of the target sequence.

[0008] In a second aspect, the present disclosure provides a data identification generating device, the device comprising:

[0009] A first determination module, configured to determine a current timestamp in response to generation of data in a target service instance;

[0010] A second determination module is used to determine a target sequence from at least two preset sequences according to the current timestamp, wherein each of the preset sequences has a sequence number that is initially a preset value, and the sequence number increases after being used to generate a corresponding data identifier;

[0011] A generating module is used to generate a data identifier of the data at least according to the sequence number of the target sequence.

[0012] In a third aspect, the present disclosure provides a computer-readable medium having a computer program stored thereon, which, when executed by a processing device, implements the steps of the method described in the first aspect.

[0013] In a fourth aspect, the present disclosure provides an electronic device, including:

[0014] a storage device having a computer program stored thereon;

[0015] A processing device is used to execute the computer program in the storage device to implement the steps of the method described in the first aspect.

[0016] Through the above technical solution, the target sequence can be determined in at least two preset sequences according to the current timestamp, and the data identifier of the data can be generated according to at least the sequence number of the target sequence. Compared with the related art, in which the data identifier is generated by the sequence number of a sequence, the present solution sets at least two sequences for generating data identifiers, which can improve the generation speed of data identifiers on the one hand, and reduce the generation of duplicate data identifiers on the other hand.

[0017] Other features and advantages of the present disclosure will be described in detail in the following detailed description. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] The above and other features, advantages and aspects of the embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and the originals and elements are not necessarily drawn to scale. In the drawings:

[0019] Figure 1 is a flow chart of a data identification generation method provided according to an exemplary embodiment of the present disclosure;

[0020] Figure 2 It is a schematic diagram of generating a data identifier in a high-concurrency scenario according to an exemplary embodiment of the present disclosure;

[0021] Figure 3 is another schematic diagram of generating data identifiers in a high-concurrency scenario according to an exemplary embodiment of the present disclosure;

[0022] Figure 4 A block diagram of generating a working node identifier is provided according to an exemplary embodiment of the present disclosure;

[0023] Figure 5 is another working node identification generation block diagram provided according to an exemplary embodiment of the present disclosure;

[0024] Figure 6 is another working node identification generation block diagram provided according to an exemplary embodiment of the present disclosure;

[0025] Figure 7is another working node identification generation block diagram provided according to an exemplary embodiment of the present disclosure;

[0026] Figure 8 is a data identification generation block diagram provided according to an exemplary embodiment of the present disclosure;

[0027] Fig. 9 is a block diagram of a data identification generating device provided according to an exemplary embodiment of the present disclosure;

[0028] Fig.10 It is a structural diagram of an electronic device provided according to an exemplary embodiment of the present disclosure. DETAILED DESCRIPTION

[0029] Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as being limited to the embodiments described herein, which are instead provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are only for exemplary purposes and are not intended to limit the scope of protection of the present disclosure.

[0030] It should be understood that the various steps described in the method embodiments of the present disclosure may be performed in different orders and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this respect.

[0031] The term "including" and its variations used herein are open inclusions, i.e., "including but not limited to". The term "based on" means "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". The relevant definitions of other terms will be given in the following description.

[0032] It should be noted that the concepts such as "first" and "second" mentioned in the present disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.

[0033] It should be noted that the modifications of "one" and "plurality" mentioned in the present disclosure are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, it should be understood as "one or more".

[0034] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only used for illustrative purposes and are not used to limit the scope of these messages or information.

[0035] It is understandable that before using the technical solutions disclosed in the embodiments of the present disclosure, the types, scope of use, usage scenarios, etc. of the personal information involved in the present disclosure should be informed to the user and the user's authorization should be obtained in an appropriate manner in accordance with relevant laws and regulations.

[0036] For example, in response to receiving an active request from a user, a prompt message is sent to the user to clearly prompt the user that the operation requested to be performed will require obtaining and using the user's personal information. Thus, the user can autonomously choose whether to provide personal information to software or hardware such as an electronic device, application, server, or storage medium that performs the operation of the technical solution of the present disclosure according to the prompt message.

[0037] As an optional but non-limiting implementation, in response to receiving an active request from the user, the prompt information may be sent to the user in the form of a pop-up window, in which the prompt information may be presented in text form. In addition, the pop-up window may also carry a selection control for the user to choose "agree" or "disagree" to provide personal information to the electronic device.

[0038] It is understandable that the above notification and the process of obtaining user authorization are merely illustrative and do not constitute a limitation on the implementation of the present disclosure. Other methods that meet the relevant laws and regulations may also be applied to the implementation of the present disclosure.

[0039] At the same time, it is understandable that the data involved in this technical solution (including but not limited to the data itself, the acquisition or use of the data) shall comply with the requirements of relevant laws, regulations and relevant provisions.

[0040] As mentioned in the background technology, in the field of data processing, in order to distinguish different data, a unique data identifier is generally generated for each data. In the related technology, data identifiers are mostly generated based on the snowflake algorithm. Since there is only one sequence in the snowflake algorithm, there is a problem of conflict between data identifiers in high-concurrency scenarios.

[0041] Specifically, Figure 2As shown, thread 0 and thread 1 are at the same timestamp, thread 2 is at the next timestamp, and thread 0 and thread 2 are executed normally, and thread 1 loses the time slice before executing "sequence number + 1". In this case, since the current timestamp of thread 0 is the same as the last timestamp, thread 0 changes the sequence number from 0 to 1 after normal execution, and generates a corresponding data identifier. Since thread 1 loses the time slice before executing "sequence number + 1", thread 1 needs to reacquire the time slice and execute "sequence number + 1" and subsequent steps after thread 2 is executed normally. At the same time, since thread 0, thread 1 and thread 2 share the same sequence, and thread 2 has set the sequence number of the sequence from 1 to 0 during normal execution, when thread 1 regains the time slice and executes "sequence number + 1" and subsequent steps, it will change the sequence number from 0 to 1 and generate a corresponding data identifier, resulting in a conflict between the data identifier generated by thread 1 and the data identifier generated by thread 0.

[0042] In order to overcome the problem of conflicting data identifiers in high-concurrency scenarios, the relevant technology uses pessimistic locks to ensure atomicity. Specifically, when a thread generates a data identifier, it first obtains a pessimistic lock, enters the calculation after successfully obtaining the pessimistic lock, and releases the pessimistic lock after generating the data identifier. In this way, since the thread that cannot obtain the pessimistic lock cannot enter the calculation to generate the data identifier, it can be guaranteed that no matter how many concurrent threads there are, there is only one thread that can calculate and generate the data identifier. However, this method limits the concurrency capability and greatly reduces the service performance.

[0043] In view of this, the embodiments of the present disclosure provide a data identifier generation method, device, readable medium and electronic device to solve the above technical problems.

[0044] The embodiments of the present disclosure are further explained below with reference to the accompanying drawings.

[0045] Figure 1 is a flowchart of a method for generating a data identifier according to an exemplary embodiment of the present disclosure, referring to Figure 1 , the method may include the following steps:

[0046] S101: In response to generation of data in a target service instance, determine a current timestamp.

[0047] A service is a software component or system that provides a specific function or service. It defines a set of interfaces and behaviors to meet user needs. A service is an abstract concept that can be implemented by multiple service instances.

[0048] A service instance is a specific implementation or running entity of a service. It is a specific object or instance created based on a service definition and is used to actually provide functions and services. A service can have multiple service instances, and each service instance can run in different environments to provide service capabilities and resources.

[0049] For example, the image processing service defines a set of image processing functions and interfaces, such as image cropping, resizing, and filter effects. Multiple image processing service instances can be created in different environments, such as running one image processing service instance on server A and another image processing service instance on server B. Each image processing service instance can process images independently and provide users with fast and reliable image processing services.

[0050] Correspondingly, the target service instance is a specific implementation or running entity of the target service, which can be determined according to the actual business scenario, and the embodiments of the present disclosure do not impose any restrictions on this. For example, the target service can be a short video publishing service, a video call service, or an audio processing service, and correspondingly, the target service instance can be a short video publishing service instance, a video call service instance, or an audio processing service instance.

[0051] S102: Determine a target sequence in at least two preset sequences according to the current timestamp, wherein each of the preset sequences has a sequence number that is initially a preset value, and the sequence number increases after being used to generate a corresponding data identifier.

[0052] In a possible implementation manner, determining a target sequence from at least two preset sequences according to the current timestamp may include:

[0053] Determine a numerical value at a preset position in the current timestamp; determine a target sequence in at least two preset sequences according to a first preset rule and the numerical value, wherein the first preset rule is used to characterize the correspondence between all possible values ​​at the preset position in the current timestamp and the preset sequence.

[0054] It should be understood that the preset position can be set according to actual conditions, and the present disclosure does not impose any restrictions on this. For example, the preset position can be the last digit in the current timestamp, the second to last digit in the current timestamp, or the last two digits in the current timestamp.

[0055] In addition, it should be understood that in the first preset rule, the correspondence between all possible values ​​at the preset position and the preset sequence can also be set according to actual conditions, and the embodiments of the present disclosure do not impose any limitation on this.

[0056] In a possible implementation, in the first preset rule, the multiple possible values ​​at the preset position correspond to a preset sequence. The multiple possible values ​​at the preset position correspond to a preset sequence, which may be multiple continuous values ​​corresponding to a preset sequence or multiple discrete values ​​corresponding to a preset sequence, and the embodiment of the present disclosure does not impose any limitation on this.

[0057] For example, the preset position is the last bit in the current timestamp, and the possible values ​​of the last bit are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, and the preset sequence includes a first preset sequence and a second preset sequence. When the first preset rule is used to characterize that multiple continuous values ​​at the preset position correspond to a preset sequence, the corresponding relationship between the possible values ​​of the last bit in the current timestamp and the preset sequence can be: value 0, value 1, value 2, value 3 and value 4 correspond to the first preset sequence, and value 5, value 6, value 7, value 8 and value 9 correspond to the second preset sequence. When the first preset rule is used to characterize that multiple discrete values ​​at the preset position correspond to a preset sequence, the corresponding relationship between the possible values ​​of the last bit in the current timestamp and the preset sequence can be: value 0, value 2, value 4, value 6 and value 8 correspond to the first preset sequence, and value 1, value 3, value 5, value 7 and value 9 correspond to the second preset sequence. It should be understood that this is only an illustrative description and does not constitute a limitation to the solution.

[0058] In a possible implementation manner, in the first preset rule, each possible value at the preset position corresponds to a preset sequence, and the preset sequences corresponding to each possible value are different.

[0059] In this embodiment, by making each possible value at the preset position correspond to a preset sequence, when multiple service instances are controlled concurrently, each service instance only modifies the preset sequence corresponding to the corresponding timestamp, thereby avoiding service instances with different timestamps from modifying the same preset sequence and causing the generation of duplicate data identifiers. On the other hand, since service instances with different timestamps can modify the corresponding preset sequence at the same time, the speed of generating data identifiers can be increased.

[0060] S103: Generate a data identifier of the data at least according to the sequence number of the target sequence.

[0061] For example, Figure 3As shown, thread 0 and thread 1 are at the same timestamp, and the corresponding target sequence is a 0ms sequence. Thread 2 is at the next timestamp, and the corresponding sequence is a 1ms sequence. Thread 0 and thread 2 are executed normally, and thread 1 loses the time slice before executing "target sequence number + 1". In this case, since the current timestamp of thread 0 is the same as the last timestamp, thread 0 changes the sequence number of the 0ms sequence from 0 to 1 after normal execution, and generates a corresponding data identifier. Since thread 1 loses the time slice before executing "target sequence number + 1", thread 1 needs to reacquire the time slice and execute "target sequence number + 1" and subsequent steps after thread 2 is executed normally. At the same time, since thread 1 and thread 2 do not share the same target sequence, thread 2 will not set the sequence number of the 0ms sequence from 1 to 0 when it is executed normally. Therefore, when thread 1 regains the time slice and executes "target sequence number + 1" and subsequent steps, it will change the sequence number of the 0ms sequence from 1 to 2 and generate a corresponding data identifier, thereby avoiding conflicts between the data identifier generated by thread 1 and the data identifier generated by thread 0.

[0062] In summary, through the above technical solution, the target sequence can be determined in at least two preset sequences according to the current timestamp, and the data identifier of the data can be generated at least according to the sequence number of the target sequence. Compared with the related art, all service instances sequentially change the sequence number of the same sequence and generate data identifiers. This solution sets at least two sequences for generating data identifiers, so that at least two service instances with different timestamps can simultaneously change the sequence numbers of different sequences and generate data identifiers. On the one hand, the speed of generating data identifiers can be improved, and on the other hand, the generation of duplicate data identifiers can be reduced.

[0063] In a possible implementation manner, the data identifier generation method may further include:

[0064] Determine a working node identifier of the target service instance, where the working node identifier is generated after the target service instance is started according to a program package embedded in the target service and used to generate a working node identifier;

[0065] The step of generating a data identifier of the data at least according to the sequence number of the target sequence comprises:

[0066] A data identifier of the data is generated based at least on the sequence number of the target sequence and the working node identifier.

[0067] It should be understood that a worker ID refers to an identifier used to uniquely identify a worker in a distributed system, which can be represented by a string, a number, or a universally unique identifier, and the embodiments of the present disclosure do not impose any restrictions on this. A worker node refers to a computing node that performs specific tasks in a distributed system and is responsible for actual computing and processing. In general, a worker node corresponds to a service instance, which is used to complete the functions provided by the service together with the service instance.

[0068] It should also be understood that there are a large number of working nodes in the distributed system. In order to determine which working node the corresponding data comes from based on the data identifier, this embodiment obtains the working node identifier of the target service instance, and generates a data identifier based on at least the working node identifier of the target service instance and the serial number of the target sequence, so that data traceability can be performed based on the data identifier.

[0069] It should also be understood that the work node identification in the related art is generated based on the work node identification generation service. In this way, it is necessary to deploy at least one work node identification generation service in the distributed system, which increases the complexity of the distributed system. In order to overcome this technical problem, this embodiment embeds a program package for generating a work node identification in the service instance, so that when the target service instance is started, the work node identification of the target service instance can be automatically generated according to the embedded program package. On the one hand, the structure of the distributed system is simplified, and on the other hand, since the program package for generating a work node identification is embedded in the service instance, it can be expanded at will.

[0070] In a possible implementation manner, the working node identifier may be generated in the following manner:

[0071] Determine the container group identifier corresponding to the target service instance;

[0072] A hash value of the container group identifier is determined, and the hash value is determined as the working node identifier of the target service instance.

[0073] It should be understood that the container group identifier (PodName) is used to identify the name of the container group (Pod), and the container group identifier is usually represented by a string, for example, a container group identifier can be represented by a string "dp-579db514ad-699bcf4dc9-cspbv". The container group is a minimum scheduling unit of cloud computing, which is used to deploy and run service instances.

[0074] It should also be understood that the hash algorithm maps input data (such as a string) to an output of a fixed size, namely a hash value. However, since there are many possibilities for input data and the output space of the hash algorithm is limited, different input data may produce the same hash value, which may lead to conflicts in the identification of working nodes. In order to avoid conflicts in the identification of working nodes, in a possible implementation method, a suitable hash function can be selected according to the actual situation to increase the distribution of hash values ​​and reduce the probability of conflicts in hash values, or by increasing the size of the hash table to accommodate more hash values ​​and reduce the possibility of conflicts.

[0075] In a possible implementation manner, in order to avoid conflicts in the generated working node identifiers, the working node identifiers may also be generated in the following manner: Figure 4 As shown:

[0076] After the target service instance is started, a candidate working node identifier of the target service instance is randomly generated; an attempt is made to insert the candidate working node identifier into a preset working node table, and the preset working node table is at least used to store working node identifiers of different service instances; if the candidate working node identifier is successfully inserted into the preset working node table, the candidate working node identifier is determined as the working node identifier of the target service instance.

[0077] It should be understood that the working node identifiers of different service instances stored in the preset working node may be working node identifiers of different service instances of the same service, or may be working node identifiers of different service instances of different services, and the embodiments of the present disclosure do not impose any restrictions on this. When the working node identifiers of different service instances stored in the preset working node are working node identifiers of different service instances of the same service, a first correspondence between the service instance and the working node identifier may also be stored in the preset working node. When the working node identifiers of different service instances stored in the preset working node are working node identifiers of different service instances of different services, a correspondence between services, service instances, and working node identifiers may also be stored in the preset working node.

[0078] It should also be understood that the candidate working node identifier is randomly generated, and there is a situation where the candidate working node identifier conflicts with the working node identifier in the preset working node table. Therefore, it is possible to determine whether the candidate working node identifier conflicts with the working node identifier in the preset working node table by trying to insert the candidate working node identifier into the preset working node table. Specifically, if the candidate working node identifier is successfully inserted into the preset working node table, it means that before the candidate working node identifier is inserted into the preset working node table, there is no working node identifier in the preset working node table that conflicts with the candidate working node identifier. In other words, the candidate working node identifier is not occupied by other service instances, so the candidate working node identifier can be used as the working node identifier of the target service instance. If the candidate working node identifier cannot be inserted into the preset working node table, it means that there is already a working node identifier in the preset working node table that conflicts with the candidate working node identifier. In other words, the candidate working node identifier has been occupied by other service instances, and it is necessary to randomly generate the candidate working node identifier of the target service instance again until the candidate working node identifier is successfully inserted into the preset working node table.

[0079] In a possible implementation, Figure 5 As shown, the data identification generation method may also include:

[0080] If the candidate working node identifier is not successfully inserted into the preset working node table, determine whether the initial service instance corresponding to the candidate working node identifier is alive, wherein the initial service instance is a service instance that uses the candidate working node identifier as the working node identifier before the target service instance; when the initial service instance is not alive, determine whether the service instance corresponding to the candidate working node identifier in the preset working node table is the initial service instance, if the service instance corresponding to the candidate working node identifier in the preset working node table is the initial service instance, update the initial service instance to the target service instance.

[0081] It should be understood that due to problems such as service instance crash, network problems or insufficient resources, the service instance may be in a non-survival state, that is, the service instance is unavailable, unable to respond to requests or unable to complete the corresponding task. In this case, since the service instance is no longer able to operate normally, its corresponding working node identifier can be reclaimed and allocated to other service instances.

[0082] It should also be understood that, since the candidate work node identifier is randomly generated, in a concurrent scenario, there may be multiple service instances corresponding to the same candidate work node identifier. In this case, if the candidate work node identifier is already occupied, and the service instance occupying the candidate work node identifier is in a non-living state, there is a situation where the same work node identifier in the preset work node table is updated multiple times by the service instance, which in turn affects the generation of the data identifier.

[0083] For example, both the first service instance and the second service instance randomly generate a candidate working node identifier A, and the candidate working node identifier A is occupied by a non-surviving third service instance. In this case, both the first service instance and the second service instance will update the service instance corresponding to the candidate working node identifier A to themselves in the preset working node table. Therefore, there is a situation where the first service instance has just updated the third service instance corresponding to the candidate working node identifier A to the first service instance, and the second service instance immediately updates the first service instance corresponding to the candidate working node identifier A to the second service instance, thereby causing the first service instance to lack a working node identifier and be unable to generate a data identifier for the data of the first service instance.

[0084] In order to avoid the occurrence of the above situation, the embodiment of the present disclosure determines whether the service instance corresponding to the candidate working node identifier in the preset working node table is the initial service instance when the initial service instance is not alive, and then determines whether the service instance corresponding to the candidate working node identifier has been updated. If not, the initial service instance is updated to the target service instance; if it has been updated, the candidate working node identifier is regenerated.

[0085] In a possible implementation, Figure 6 As shown, the data identification generation method may also include:

[0086] Before determining whether the initial service instance corresponding to the candidate working node identifier is alive, determining an update time of the initial service instance, and determining whether a time interval between the update time and the current time is greater than a preset time interval;

[0087] Accordingly, determining whether the initial service instance corresponding to the candidate working node identifier is alive may include:

[0088] When the time interval between the update time and the current time is greater than the preset time interval, it is determined whether the initial service instance corresponding to the candidate working node identifier is alive.

[0089] It should be understood that the service instance will generally be in a non-survival state after completing the corresponding task, that is, the service instance will be in a non-survival state after surviving for a period of time. Therefore, it can be determined whether to judge whether the initial service instance corresponding to the candidate working node identifier is alive based on the survival time of the service instance. In addition, since the service instance needs to update its corresponding working node identifier to the preset node identifier table when it is started, it is possible to first determine the size of the update time interval and the preset time interval of the initial service instance, and then determine whether it is necessary to judge the survival state of the initial service instance. Specifically, if the update time interval of the initial service instance is greater than the preset time interval, it means that the initial service instance is likely to be in a non-survival state, so it is necessary to further specifically judge whether the initial service instance is really in a non-survival state; if the update time interval is less than or equal to the preset time interval, it means that the initial service instance is likely to be in a survival state. At the same time, in order to reduce the data processing process, the survival state of the initial service instance is no longer judged.

[0090] It should also be understood that the preset time interval can be set according to actual conditions, and the present disclosure does not impose any restrictions on this. For example, the preset time interval can be set to 5 minutes or 10 minutes.

[0091] In a possible implementation, Figure 7 As shown, the determining whether the initial service instance corresponding to the candidate working node identifier is alive may include:

[0092] Determine the communication identification information corresponding to the candidate working node identifier; query the preset working node table according to the communication identification information, and determine whether the initial service instance corresponding to the candidate working node identifier is alive according to the query result.

[0093] It should be understood that the communication identification information refers to the network address of the service instance, which is used to uniquely identify a service instance on the network and can usually be represented by an Internet Protocol address (IP address).

[0094] It should also be understood that in a distributed system or microservice architecture, each service instance usually corresponds to a work node identifier and communication identifier information. In order to quickly find the work node identifier of the service instance according to the communication identifier information of the service instance, this embodiment establishes a one-to-one correspondence between the communication identifier information and the work node identifier, and stores it in a preset work node table, so that it can be determined whether there is a work node identifier in the preset work node table according to the communication identifier information in the preset work node table, and then determine whether the service instance is alive according to the work node identifier. Specifically, if there is no work node identifier in the preset work node table, it means that the service instance corresponding to the work node identifier is in a non-survival state. If there is a work node identifier in the preset work node table, it means that the service instance corresponding to the work node identifier is in a survival state.

[0095] In a possible implementation manner, the data identifier generation method may further include:

[0096] Get historical timestamps;

[0097] Accordingly, generating the data identifier of the data at least according to the sequence number of the target sequence may include:

[0098] When the current timestamp is greater than the historical timestamp, an attempt is made to update the historical timestamp to the current timestamp. If the historical timestamp is successfully updated to the current timestamp, the sequence number of the target sequence is set to the target preset value to obtain the target sequence number, and a data identifier of the data is generated based on at least the current timestamp and the target sequence number.

[0099] It should be understood that in the same service instance, the data that needs to generate data identification is infinite, while the representation of the serial number in the sequence is limited. In order to avoid the situation where the serial number cannot represent the data identification of different data, the embodiment of the present disclosure adds a timestamp on the basis of the serial number. Since each timestamp is different and the data generated in each timestamp is limited, by combining the timestamp and the serial number, data identification can be generated for infinite data.

[0100] Specifically, Figure 8As shown, in response to the generation of data in the target service instance, the current timestamp, the historical timestamp (i.e., the last timestamp) and the target sequence are obtained, and the size of the current timestamp and the historical timestamp is determined; if the current timestamp is equal to the historical timestamp, it means that the timestamp of the data identifier to be generated is the same as the timestamp of the previous data identifier, so the serial number of the target sequence can be changed, for example, a data identifier different from the previous data identifier can be generated by adding 1 to the serial number. If the current timestamp is greater than the historical timestamp, it means that the timestamp of the data identifier to be generated is different from the timestamp of the previous data identifier, so a data identifier different from the previous data identifier can be generated by changing the timestamp. At the same time, in order to determine whether the timestamp is changed later, when the two timestamps before and after change, the historical timestamp can also be updated to the current timestamp. In addition, since there are many data that need to generate data identifiers in the same timestamp, in order to avoid the situation where the serial number of the target sequence cannot represent the data identifiers of different data, when the timestamps before and after change, the serial number of the target sequence can also be reset to the starting value, such as 00000, and different data identifiers can be generated in combination with the current timestamp.

[0101] In addition, it should be understood that within the same timestamp, there are multiple service instances that need to generate data identifiers. If when the timestamp changes, that is, when it just changes from the historical timestamp to the current timestamp, each service instance of the current timestamp updates the historical timestamp to the current timestamp and performs the target sequence number setting operation, a duplicate data identifier will be generated. To solve the above problem, when the service instance executes the step of updating the historical timestamp to the current timestamp, the embodiment of the present disclosure first determines whether the historical timestamp has been changed by other service instances, that is, whether the historical timestamp has been changed to the current timestamp. If the historical timestamp has not been changed by other service instances, it means that the service instance is the first service instance to generate a data identifier within the current timestamp, so the historical timestamp can be updated to the current timestamp, and the target sequence number setting operation can be performed to generate a data identifier. If the historical timestamp has been changed by other service instances, it means that the target sequence number corresponding to the current timestamp has been set to 0, so it is necessary to re-acquire the timestamp and perform the target sequence number + 1 operation to generate a data identifier.

[0102] For example, service instance A and service instance B exist in the current timestamp, and when service instance A executes the step of "updating the last timestamp to the current timestamp", service instance B is already waiting to execute the step of "updating the last timestamp to the current timestamp". In this case, if service instance B does not judge whether the historical timestamp has been changed to the current timestamp when executing the step of "updating the last timestamp to the current timestamp", both service instance A and service instance B will execute the operation of "setting the target sequence number to 0" and the operation of "generating a data identifier of the data based on at least the current timestamp and the target sequence number", thereby making the data identifiers generated by service instance A and service instance B the same. If service instance B first judges whether the historical timestamp has been changed to the current timestamp when executing the operation of "updating the last timestamp to the current timestamp", it will be found that the historical timestamp has been changed, so service instance B will re-acquire the current timestamp. At the same time, since the historical timestamp has been changed to the current timestamp by service instance A, service instance B will perform the "target sequence number + 1" operation and the "generate a data identifier for the data based on at least the current timestamp and the target sequence number" operation after re-obtaining the current timestamp, thereby making the data identifiers generated by service instance A and service instance B different.

[0103] Based on the same concept, the embodiment of the present disclosure also provides a data identification generating device, such as Fig. 9 As shown, the data identification generating device 900 may include:

[0104] A first determination module 901, configured to determine a current timestamp in response to generation of data in a target service instance;

[0105] A second determination module 902 is configured to determine a target sequence from at least two preset sequences according to the current timestamp, wherein each of the preset sequences has a sequence number that is initially a preset value, and the sequence number increases after being used to generate a corresponding data identifier;

[0106] The generating module 903 is used to generate a data identifier of the data at least according to the sequence number of the target sequence.

[0107] In a possible implementation manner, the first determining module 901 may include:

[0108] A first determining unit, configured to determine a value at a preset position in the current timestamp;

[0109] A second determination unit is used to determine a target sequence in at least two preset sequences according to a first preset rule and the numerical value, wherein the first preset rule is used to characterize the correspondence between all possible values ​​located at the preset position in the current timestamp and the preset sequence.

[0110] In a possible implementation manner, in the first preset rule, each possible value at the preset position corresponds to a preset sequence, and the preset sequences corresponding to each possible value are different.

[0111] In a possible implementation manner, the data identifier generating device 900 may further include:

[0112] A third determination module is used to determine the working node identifier of the target service instance, where the working node identifier is generated after the target service instance is started according to an embedded program package for generating the working node identifier;

[0113] Correspondingly, the generating module 903 may also be configured to generate a data identifier of the data at least according to the sequence number of the target sequence and the working node identifier.

[0114] In a possible implementation manner, the working node identifier may be generated in the following manner:

[0115] After the target service instance is started, randomly generating a candidate working node identifier of the target service instance;

[0116] Try to insert the candidate working node identifier into a preset working node table, where the preset working node table is used to store at least working node identifiers of different service instances;

[0117] If the candidate working node identifier is successfully inserted into the preset working node table, the candidate working node identifier is determined as the working node identifier of the target service instance.

[0118] In a possible implementation manner, the working node identifier may also be generated in the following manner:

[0119] If the candidate working node identifier is not successfully inserted into the preset working node table, determining whether the initial service instance corresponding to the candidate working node identifier is alive, wherein the initial service instance is a service instance that uses the candidate working node identifier as a working node identifier before the target service instance;

[0120] When the initial service instance is not alive, determine whether the service instance corresponding to the candidate working node identifier in the preset working node table is the initial service instance; if the service instance corresponding to the candidate working node identifier in the preset working node table is the initial service instance, update the initial service instance to the target service instance.

[0121] In a possible implementation manner, the working node identifier may also be generated in the following manner:

[0122] Before determining whether the initial service instance corresponding to the candidate working node identifier is alive, determining an update time of the initial service instance, and determining whether a time interval between the update time and the current time is greater than a preset time interval;

[0123] Accordingly, determining whether the initial service instance corresponding to the candidate working node identifier is alive may include:

[0124] When the time interval between the update time and the current time is greater than the preset time interval, it is determined whether the initial service instance corresponding to the candidate working node identifier is alive.

[0125] In a possible implementation manner, determining whether the initial service instance corresponding to the candidate working node identifier is alive may include:

[0126] Determine the communication identification information corresponding to the candidate working node identification;

[0127] A query is performed in the preset working node table according to the communication identification information, and based on the query result, it is determined whether the initial service instance corresponding to the candidate working node identifier is alive.

[0128] In a possible implementation manner, the data identifier generating device 900 may further include:

[0129] Acquisition module, used to obtain historical timestamps;

[0130] Correspondingly, the generation module 903 can also be used to attempt to update the historical timestamp to the current timestamp when the current timestamp is greater than the historical timestamp. If the historical timestamp is successfully updated to the current timestamp, the sequence number of the target sequence is set to the target preset value to obtain the target sequence number, and generate a data identifier for the data based on at least the current timestamp and the target sequence number.

[0131] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.

[0132] Based on the same concept, an embodiment of the present disclosure further provides a computer-readable medium on which a computer program is stored, and when the program is executed by a processing device, the steps of the above-mentioned data identifier generation method are implemented.

[0133] Based on the same concept, an embodiment of the present disclosure further provides an electronic device, including:

[0134] a storage device having a computer program stored thereon;

[0135] A processing device is used to execute the computer program in the storage device to implement the steps of the above-mentioned data identification generation method.

[0136] Reference below Fig.10 , which shows a schematic diagram of the structure of an electronic device 1000 suitable for implementing the embodiment of the present disclosure. The terminal device in the embodiment of the present disclosure may include but is not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), vehicle terminals (such as vehicle navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Fig.10 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.

[0137] like Fig.10 As shown, the electronic device 1000 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 1001, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1002 or a program loaded from a storage device 1008 into a random access memory (RAM) 1003. In the RAM 1003, various programs and data required for the operation of the electronic device 1000 are also stored. The processing device 1001, the ROM 1002, and the RAM 1003 are connected to each other via a bus 1004. An input / output (I / O) interface 1005 is also connected to the bus 1004.

[0138] Typically, the following devices may be connected to the I / O interface 1005: an input device 1006 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 1007 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 1008 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 1009. The communication device 1009 may allow the electronic device 1000 to communicate with other devices wirelessly or by wire to exchange data. Although Fig.10 The electronic device 1000 is shown with various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.

[0139] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device 1009, or installed from a storage device 1008, or installed from a ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiment of the present disclosure are executed.

[0140] It should be noted that the computer-readable medium disclosed above may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in combination with an instruction execution system, device or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. The computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.

[0141] In some embodiments, any currently known or future developed network protocol such as HTTP (HyperText Transfer Protocol) can be used for communication, and can be interconnected with any form or medium of digital data communication (e.g., communication network). Examples of communication networks include local area networks ("LAN"), wide area networks ("WAN"), internets (e.g., the Internet), and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any currently known or future developed networks.

[0142] The computer-readable medium may be included in the electronic device, or may exist independently without being installed in the electronic device.

[0143] The above-mentioned computer-readable medium carries one or more programs. When the above-mentioned one or more programs are executed by the electronic device, the electronic device: determines a current timestamp in response to the generation of data in a target service instance; determines a target sequence in at least two preset sequences according to the current timestamp, wherein each of the preset sequences has a sequence number that is initially a preset value, and the sequence number changes incrementally after being used to generate a corresponding data identifier; generates a data identifier for the data at least according to the sequence number of the target sequence.

[0144] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages ​​or a combination thereof, including, but not limited to, object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0145] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0146] The modules involved in the embodiments described in the present disclosure may be implemented by software or hardware, wherein the name of a module does not, in some cases, limit the module itself.

[0147] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.

[0148] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0149] The above description is only a preferred embodiment of the present disclosure and an explanation of the technical principles used. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solutions formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosed concept. For example, the above features are replaced with the technical features with similar functions disclosed in the present disclosure (but not limited to) by each other to form a technical solution.

[0150] In addition, although each operation is described in a specific order, this should not be understood as requiring these operations to be performed in the specific order shown or in a sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although some specific implementation details are included in the above discussion, these should not be interpreted as limiting the scope of the present disclosure. Some features described in the context of a separate embodiment can also be implemented in a single embodiment in combination. On the contrary, the various features described in the context of a single embodiment can also be implemented in multiple embodiments individually or in any suitable sub-combination mode.

[0151] Although the subject matter has been described in language specific to structural features and / or method logic actions, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. On the contrary, the specific features and actions described above are merely example forms of implementing the claims. Regarding the device in the above embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment related to the method, and will not be elaborated here.

Claims

1. A method for generating a data identifier, characterized in that: The method comprises: In response to generation of data in the target service instance, determining a current timestamp; Determining a target sequence from at least two preset sequences according to the current timestamp, wherein each of the preset sequences has a sequence number that is initially a preset value, and the sequence number increases after being used to generate a corresponding data identifier; A data identifier of the data is generated based at least on the sequence number of the target sequence.

2. The method according to claim 1, characterized in that: The determining a target sequence from at least two preset sequences according to the current timestamp includes: Determine a value at a preset position in the current timestamp; According to a first preset rule and the numerical value, a target sequence is determined in at least two preset sequences, wherein the first preset rule is used to characterize the correspondence between all possible values ​​at the preset position in the current timestamp and the preset sequence.

3. The method according to claim 2, characterized in that In the first preset rule, each possible value at the preset position corresponds to a preset sequence, and the preset sequences corresponding to each possible value are different.

4. The method according to any one of claims 1 to 3, characterized in that The method further comprises: Determine a working node identifier of the target service instance, where the working node identifier is generated after the target service instance is started according to an embedded program package for generating a working node identifier; The step of generating a data identifier of the data at least according to the sequence number of the target sequence comprises: A data identifier of the data is generated based at least on the sequence number of the target sequence and the working node identifier.

5. The method according to claim 4, characterized in that The working node identifier is generated in the following way: After the target service instance is started, randomly generating a candidate working node identifier of the target service instance; Try to insert the candidate working node identifier into a preset working node table, where the preset working node table is used to store at least working node identifiers of different service instances; If the candidate working node identifier is successfully inserted into the preset working node table, the candidate working node identifier is determined as the working node identifier of the target service instance.

6. The method according to claim 5, characterized in that The method further comprises: If the candidate working node identifier is not successfully inserted into the preset working node table, determining whether the initial service instance corresponding to the candidate working node identifier is alive, wherein the initial service instance is a service instance that uses the candidate working node identifier as a working node identifier before the target service instance; When the initial service instance is not alive, determine whether the service instance corresponding to the candidate working node identifier in the preset working node table is the initial service instance; if the service instance corresponding to the candidate working node identifier in the preset working node table is the initial service instance, update the initial service instance to the target service instance.

7. The method according to claim 6, characterized in that The method further comprises: Before determining whether the initial service instance corresponding to the candidate working node identifier is alive, determining an update time of the initial service instance, and determining whether a time interval between the update time and the current time is greater than a preset time interval; The determining whether the initial service instance corresponding to the candidate working node identifier is alive includes: When the time interval between the update time and the current time is greater than the preset time interval, it is determined whether the initial service instance corresponding to the candidate working node identifier is alive.

8. The method according to claim 6, characterized in that The determining whether the initial service instance corresponding to the candidate working node identifier is alive includes: Determine the communication identification information corresponding to the candidate working node identification; A query is performed in the preset working node table according to the communication identification information, and based on the query result, it is determined whether the initial service instance corresponding to the candidate working node identifier is alive.

9. The method according to any one of claims 1 to 3, characterized in that: The method further comprises: Get historical timestamps; The step of generating a data identifier of the data at least according to the sequence number of the target sequence comprises: When the current timestamp is greater than the historical timestamp, an attempt is made to update the historical timestamp to the current timestamp. If the historical timestamp is successfully updated to the current timestamp, the sequence number of the target sequence is set to the target preset value to obtain the target sequence number, and a data identifier of the data is generated based on at least the current timestamp and the target sequence number.

10. A data identification generating device, characterized in that: The device comprises: A first determination module, configured to determine a current timestamp in response to generation of data in a target service instance; A second determination module is used to determine a target sequence from at least two preset sequences according to the current timestamp, wherein each of the preset sequences has a sequence number that is initially a preset value, and the sequence number increases after being used to generate a corresponding data identifier; A generating module is used to generate a data identifier of the data at least according to the sequence number of the target sequence.

11. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processing device, the steps of the method described in any one of claims 1 to 9 are implemented.

12. An electronic device, characterized in that: include: a storage device having a computer program stored thereon; A processing device, configured to execute the computer program in the storage device to implement the steps of the method according to any one of claims 1 to 9.