Service initialization method, service initialization device and electronic device

By sorting initialization requests in distributed clusters and using optimistic lock election mechanisms, the problem of repeated initialization in distributed cluster environments is solved, and the application startup success rate and resource utilization efficiency are improved.

CN116248499BActive Publication Date: 2025-08-22中国邮政储蓄银行股份有限公司
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211732223.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-12-30
Publication Date
2025-08-22
Estimated Expiration
2042-12-30

AI Technical Summary

Technical Problem

In a distributed cluster environment, repeated initialization problems are prone to occur during the initialization of the existing timing task engine, resulting in the failure of application startup.

Method used

By receiving and sorting the initialization request information, it is determined that the target initialization request information has not been executed, and an optimistic locking election mechanism is adopted to avoid repeated initialization.

Benefits of technology

Reduces the probability of repeated execution of service initialization, improves application startup success rate, and reduces resource consumption and performance bottlenecks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116248499B_ABST
    Figure CN116248499B_ABST
Patent Text Reader

Abstract

The present application provides a service initialization method, service initialization device, and electronic device. The method includes: in response to receiving multiple initialization request messages sent by various services, sorting all initialization request messages in the order of receipt, wherein the initialization request messages are request messages for initializing the services; determining whether a target initialization request message has been executed, wherein the target initialization request message is the initialization request message with the shortest time interval between the target initialization request message and the current moment; and if it is determined that the target initialization request message has not been executed, initializing the service corresponding to the target initialization request message according to the target initialization request message. This reduces the occurrence of repeated service initialization, thereby solving the problem of repeated initialization that is prone to occur in the prior art.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of service initialization, and in particular to a service initialization method, a service initialization device, a computer-readable storage medium, and an electronic device. Background Art

[0002] In a distributed cluster, when the application service starts, the scheduled tasks in the initialization code are persisted to the database. However, most scheduled task engines currently use pessimistic database locking. When an application node is initialized and releases the database lock, another application will acquire the database lock. This can cause the application to time out from connecting to the database and cause the application to fail to start.

[0003] In distributed scenarios, many business scenarios require scheduled triggering. When the application starts, the scheduled period is loaded into memory or a database for subsequent scheduled tasks to trigger. The existing open-source scheduled component, quart, initializes the service by using pessimistic locking to select an application node that loads the scheduled period and initializes the task. After the node is initialized, the lock is released, but another application node acquires the lock and then initializes it. This leads to duplicate initialization. Summary of the Invention

[0004] The main purpose of this application is to provide a service initialization method, a service initialization device, a computer-readable storage medium and an electronic device, so as to at least solve the problem of repeated initialization that is prone to occur in the prior art.

[0005] In order to achieve the above-mentioned purpose, according to one aspect of the present application, a service initialization method is provided, the method comprising: in response to multiple initialization request messages received from various services, sorting all the initialization request messages in the order of receipt time, the initialization request messages being request information for initializing the services; determining whether the target initialization request message has been executed, wherein the target initialization request message is the initialization request message with the shortest time interval between the target initialization request message and the current moment among all the initialization request messages; and in the case that it is determined that the target initialization request message has not been executed, initializing the service corresponding to the target initialization request message according to the target initialization request message.

[0006] Optionally, the method further includes: in a case where it is determined that the target initialization request information has been executed, determining whether the initialization request information with the shortest time interval between the initialization request information other than the target initialization request information and the current moment has been executed; in a case where it is determined that the initialization request information with the shortest time interval between the initialization request information other than the target initialization request information and the current moment has not been executed, initializing the service corresponding to the initialization request information with the shortest time interval between the initialization request information other than the target initialization request information and the current moment.

[0007] Optionally, determining whether the target initialization request information has been executed includes: in a case where the target initialization request information does not exist in an information recording library, determining whether the target initialization request information has been executed, the information recording library being used to store the initialization request information that has been executed; determining whether the initialization request information other than the target initialization request information with the shortest time interval between it and the current moment has been executed includes: in a case where the initialization request information other than the target initialization request information with the shortest time interval between it and the current moment already exists in the information recording library, determining whether the initialization request information other than the target initialization request information with the shortest time interval between it and the current moment has been executed.

[0008] Optionally, the method further includes: determining whether the target initialization request information crashes during execution; if the target initialization request information crashes during execution, determining whether the initialization request information with the shortest time interval between the initialization request information and the current moment other than the target initialization request information has been executed.

[0009] Optionally, after determining whether the target initialization request information crashes during execution, the method further includes: changing the status of the target initialization request information in the task database to completed if the target initialization request information does not crash during execution.

[0010] Optionally, after the status of the target initialization request information in the task database is changed to completed, the method includes: determining whether the execution status of the target initialization request information in the task database has been successfully changed to completed; and determining that the initialization task of the service has been completed if the execution status of the target initialization request information in the task database is successfully changed to completed.

[0011] Optionally, after determining whether the execution status of the target initialization request information in the task database has been successfully changed to completed, the method further includes: when the execution status of the target initialization request information in the task database has not been successfully changed to completed, determining whether the initialization request information with the shortest time interval between the initialization request information other than the target initialization request information and the current moment has been executed.

[0012] According to another aspect of the present application, a service initialization device is provided, which includes a first processing unit, a second processing unit and a third processing unit; the first processing unit is used to respond to multiple initialization request messages sent by each service, and sort all the initialization request messages in the order of receipt time, the initialization request information being request information for initializing the service; the second processing unit is used to determine whether the target initialization request information has been executed, wherein the target initialization request information is the initialization request information with the shortest time interval between the target initialization request information and the current moment among all the initialization request information; the third processing unit is used to initialize the service corresponding to the target initialization request information according to the target initialization request information when it is determined that the target initialization request information has not been executed.

[0013] According to another aspect of the present application, a computer-readable storage medium is provided, wherein the computer-readable storage medium includes a stored program, wherein when the program is executed, the device where the computer-readable storage medium is located is controlled to execute any one of the service initialization methods.

[0014] According to another aspect of the present application, an electronic device is provided, which includes one or more processors, a memory, and one or more programs, wherein the one or more programs are stored in the memory and are configured to be executed by the one or more processors, and the one or more programs include an initialization method for executing any one of the services described.

[0015] By applying the technical solution of the present application, all the initialization request information are sorted in the order of the time they were received to determine whether the target initialization request information has been executed. If it is determined that the target initialization request information has not been executed, the service corresponding to the target initialization request information is initialized according to the target initialization request information, thereby reducing the occurrence of repeated service initialization and solving the problem of repeated initialization that is prone to occur in the prior art. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] The drawings that constitute part of this application are used to provide a further understanding of this application. The illustrative embodiments of this application and their descriptions are used to explain this application and do not constitute an improper limitation on this application. In the drawings:

[0017] Figure 1 A hardware structure block diagram of a mobile terminal for executing a service initialization method provided in an embodiment of the present application is shown;

[0018] Figure 2 A flowchart illustrating a method for initializing a service provided in accordance with an embodiment of the present application is shown;

[0019] Figure 3 A flowchart illustrating another service initialization method provided according to an embodiment of the present application is shown;

[0020] Figure 4 A schematic diagram of a service initialization device provided according to an embodiment of the present application is shown.

[0021] The above drawings include the following reference numerals:

[0022] 102. Processor; 104. Memory; 106. Transmission device; 108. Input / output device. DETAILED DESCRIPTION

[0023] It should be noted that, in the absence of conflict, the embodiments and features of the embodiments in this application can be combined with each other. The present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.

[0024] In order to enable those skilled in the art to better understand the present invention, the following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts should fall within the scope of protection of this application.

[0025] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequential order. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present application described here. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0026] For ease of description, some nouns or terms involved in the embodiments of the present application are explained below:

[0027] Distributed: Divide a problem that requires enormous computing power into many small parts, then distribute these parts to multiple computers for processing, and finally combine these calculation results to get the final result.

[0028] A cluster is a group (or several) of independent computers, connected via a high-speed communications network, forming a larger computer service system. Each cluster node (i.e., each computer in the cluster) is an independent server running its own service. These servers can communicate with each other, collaboratively providing applications, system resources, and data to users, and are managed as a single system. When a user requests a cluster system, the cluster appears to be a single, independent server, but in reality, the user is requesting a group of clustered servers.

[0029] As introduced in the background technology, in a distributed scenario, there will be many business scenarios that require timed triggering. When the application starts, the timing period is loaded into the memory or database for subsequent task timing triggering; the initialization of the existing timing open source component quart service selects an application node that loads the timing period through a pessimistic lock at startup to initialize the task. After the initialization of this node is completed, the lock is released and at the same time, it is acquired by another application node, and then initialized. This will cause repeated initialization problems. In order to solve the repeated initialization problem that is prone to occur in the prior art, the embodiments of the present application provide a service initialization method, a service initialization device, a computer-readable storage medium and an electronic device.

[0030] The technical solutions in the embodiments of the present invention will be described clearly and completely below with reference to the accompanying drawings in the embodiments of the present invention.

[0031] The method embodiments provided in the embodiments of the present application can be executed in a mobile terminal, a computer terminal or a similar computing device. Taking running on a mobile terminal as an example, Figure 1 FIG. 1 is a hardware structure diagram of a mobile terminal according to an embodiment of the present invention, and FIG. Figure 1 As shown, the mobile terminal may include one or more ( Figure 1 Only one is shown) a processor 102 (the processor 102 may include but is not limited to a microprocessor MCU or a programmable logic device FPGA and other processing devices) and a memory 104 for storing data, wherein the mobile terminal may also include a transmission device 106 and an input and output device 108 for communication functions. It will be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the mobile terminal. Figure 1 More or fewer components than shown, or with Figure 1 Different configurations shown.

[0032] The memory 104 can be used to store computer programs, such as software programs and modules of application software, such as the computer program corresponding to the device information display method in the embodiment of the present invention. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, implementing the above-mentioned method. The memory 104 may include a high-speed random access memory and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include a memory remotely located relative to the processor 102, and these remote memories can be connected to the mobile terminal via a network. Examples of the above-mentioned networks include but are not limited to the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof. The transmission device 106 is used to receive or send data via a network. Specific examples of the above-mentioned network may include a wireless network provided by the mobile terminal's communication provider. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, abbreviated as NIC), which can be connected to other network devices via a base station to communicate with the Internet. In one example, the transmission device 106 may be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.

[0033] In this embodiment, a method for initializing a service running on a mobile terminal, a computer terminal, or a similar computing device is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0034] Figure 2 This is a flow chart of a method for initializing a service according to an embodiment of the present application. Figure 2 As shown, the method includes the following steps:

[0035] Step S201, in response to receiving multiple initialization request messages sent by various services, sorting all the initialization request messages in the order of receipt time, wherein the initialization request messages are request messages for initializing the services;

[0036] Step S202: Determine whether the target initialization request information has been executed, wherein the target initialization request information is the initialization request information with the shortest time interval between the target initialization request information and the current moment among all the initialization request information;

[0037] Step S203: When it is determined that the target initialization request information has not been executed, the service corresponding to the target initialization request information is initialized according to the target initialization request information.

[0038] In the above steps, by sorting all the above initialization request information in the order of the time of receipt, it is determined whether the target initialization request information has been executed. When it is determined that the above target initialization request information has not been executed, the above service corresponding to the above target initialization request information is initialized according to the above target initialization request information, thereby reducing the occurrence of repeated execution of service initialization, and thus solving the problem of repeated initialization that is prone to occur in the prior art.

[0039] This avoids the situation where the application startup failure rate increases due to pessimistic lock elections. At the same time, a node is elected to avoid repeated data initialization through status judgment.

[0040] In one embodiment of the present application, the above method also includes: in a case where it is determined that the above target initialization request information has been executed, determining whether the above initialization request information with the shortest time interval between the above initialization request information other than the above target initialization request information and the current moment has been executed; in a case where it is determined that the above initialization request information with the shortest time interval between the above initialization request information other than the above target initialization request information and the current moment has not been executed, initializing the above service corresponding to the above initialization request information with the shortest time interval between the above initialization request information other than the above target initialization request information and the current moment.

[0041] Specifically, when it is determined that the above-mentioned target initialization request information has been executed, it means that the target initialization request information has been executed, and other initialization request information needs to be executed, that is, the above-mentioned initialization request information other than the above-mentioned target initialization request information with the shortest time interval between it and the current moment. For example, the receiving time of the initialization request information A is 12:01:04, the receiving time of the initialization request information B is 12:01:05, and the receiving time of the initialization request information C is 12:01:03. Then the initialization request information B is the target initialization request information, and the initialization request information A is the above-mentioned initialization request information other than the above-mentioned target initialization request information with the shortest time interval between it and the current moment.

[0042] In one embodiment of the present application, determining whether the above-mentioned target initialization request information has been executed includes: in a case where the above-mentioned target initialization request information does not exist in an information recording library, determining whether the above-mentioned target initialization request information has been executed, and the above-mentioned information recording library is used to store the above-mentioned initialization request information that has been executed; determining whether the above-mentioned initialization request information other than the above-mentioned target initialization request information with the shortest time interval between it and the current moment has been executed includes: in a case where the above-mentioned initialization request information other than the above-mentioned target initialization request information with the shortest time interval between it and the current moment already exists in the information recording library, determining whether the above-mentioned initialization request information other than the above-mentioned target initialization request information with the shortest time interval between it and the current moment has been executed.

[0043] Specifically, it is not necessarily that the operation has been executed, so it is necessary to determine whether it has been executed, thereby ensuring that the repeated execution rate is reduced as much as possible.

[0044] In one embodiment of the present application, the above method also includes: determining whether the above target initialization request information crashes during the execution process; in the event that the above target initialization request information crashes during the execution process, determining whether the above initialization request information with the shortest time interval between the above initialization request information and the current moment other than the above target initialization request information has been executed.

[0045] In one embodiment of the present application, after determining whether the above-mentioned target initialization request information crashes during execution, the above-mentioned method further includes: if the above-mentioned target initialization request information does not crash during execution, changing the status of the above-mentioned target initialization request information in the task database to completed.

[0046] Specifically, if the target initialization request information does not crash during execution, the initialization work is determined to have been completed. However, the status of the target initialization request information in the task database needs to be changed to completed before the initialization work is truly completed.

[0047] In one embodiment of the present application, after the status of the above-mentioned target initialization request information in the task database is changed to completed, the above-mentioned method includes: determining whether the execution status of the above-mentioned target initialization request information in the above-mentioned task database has been successfully changed to completed; in the case that the execution status of the above-mentioned target initialization request information in the above-mentioned task database is successfully changed to completed, determining that the initialization task of the above-mentioned service has been completed.

[0048] Specifically, if the execution status is successfully updated, it is determined that the initialization task has been completed.

[0049] In one embodiment of the present application, after determining whether the execution status of the above-mentioned target initialization request information in the above-mentioned task database has been successfully changed to completed, the above-mentioned method also includes: in the case that the execution status of the above-mentioned target initialization request information in the above-mentioned task database has not been successfully changed to completed, determining whether the above-mentioned initialization request information with the shortest time interval between the above-mentioned initialization request information and the current moment other than the above-mentioned target initialization request information has been executed.

[0050] Specifically, during the execution status modification process, the execution status may not be updated successfully due to a programming error. At this time, it is necessary to determine whether other initialization request information can be executed, that is, to determine whether the initialization request information with the shortest time interval between the above-mentioned initialization request information and the current moment other than the above-mentioned target initialization request information has been executed.

[0051] There is an election table that records the server information and initialization status of each scheduled task data in each cluster when it is initialized. When the application starts, there are no records in the table, and all applications started at the same time will insert data into the election table. Node A with a successful insertion represents a successful election. Nodes B...Z with unsuccessful insertions wait for the successfully elected node to initialize data. The successfully elected node A starts to initialize data, inserts the data into the database, and then successfully initializes. The status in the election table is changed to success, and the application starts successfully. If the successfully elected node A fails to initialize data, the status in the election table is changed to failure, and the application starts unsuccessfully. Nodes B...Z that are not successfully elected monitor the initialization status in the election table and periodically poll to detect the health status of the successfully elected node A. If the successfully elected node A is in a healthy state, the remaining nodes B...Z wait for the node to complete initialization before the application starts successfully. If the successfully elected node A is in an unhealthy state, the remaining nodes B...Z take over initialization. Whichever of the remaining nodes B...Z wins will update the server address in the election table to its own node B address, and node B will start initialization. When the status in the election table is updated to success, data initialization is complete, and all applications start successfully.

[0052] Elections are performed using optimistic locking to avoid data inconsistency caused by concurrent initialization and repeated initialization. Initialization progress maintenance is used to achieve the goal of starting nodes in the cluster after data initialization is completed, and the initialization progress can be monitored. Node health status judgment avoids long waits caused by initialization node abnormalities. Optimistic lock elections avoid timeouts and task startup failures caused by pessimistic locks. MD5 codes are used for data consistency verification to avoid repeated data initialization and to allow for the addition, deletion, modification, and query of data.

[0053] Pessimistic locking always assumes the worst case scenario, so each time data is updated, the data will be locked. In this way, if others want to use the data, they will be blocked until the lock is obtained. Therefore, the data will only be used by one thread resource at a time, and other threads will be blocked. After use, the resources will be transferred to other threads. This will increase resource consumption and have low performance. This application uses an optimistic locking method, with conditional judgment when updating data. If a thread is using the data, it will return immediately without blocking and waiting, reducing resource consumption and increasing concurrency performance. The return value is used to determine whether the node should perform subsequent initialization operations.

[0054] Through the above embodiments, data inconsistency caused by concurrent initialization is avoided, and repeated initialization is avoided; the goal of starting nodes in the cluster after data initialization is completed is achieved through initialization progress maintenance, and the initialization progress can be monitored at the same time; the long waiting time caused by initialization node abnormality is avoided by judging the node health status; and the optimistic lock election is used to avoid timeouts and task startup failures caused by pessimistic locks.

[0055] In order to enable those skilled in the art to more clearly understand the technical solution of the present application, the implementation process of the service initialization method of the present application will be described in detail below with reference to specific embodiments.

[0056] This embodiment relates to a specific service initialization method, such as Figure 3 As shown, the following steps are included:

[0057] Step S1: in response to a plurality of initialization request messages received from various services, all the initialization request messages are sorted in the order of receipt, wherein the initialization request messages are request messages for initializing the services;

[0058] Step S2: Determine whether the target initialization request information exists in the information record library, if yes, proceed to step S3, if not, proceed to step S4;

[0059] Step S3: Determine whether the target initialization request information has been executed, wherein the target initialization request information is the initialization request information with the shortest time interval between the initialization request information and the current moment among all the initialization request information; if it is determined that the target initialization request information has been executed, determine whether the initialization request information with the shortest time interval between the initialization request information other than the target initialization request information and the current moment has been executed; if it is determined that the initialization request information with the shortest time interval between the initialization request information other than the target initialization request information and the current moment has not been executed, Initialize the service corresponding to the initialization request information with the shortest time interval between the initialization request information other than the target initialization request information and the current moment, i.e., proceed to step S2 (the difference from step S2 is that the initialization request information with the shortest time interval between the initialization request information other than the target initialization request information and the current moment is judged to determine whether the information exists in the information record library. The same applies to the subsequent step S3, only the judgment object is changed, and no further details are given here); if it is determined that the target initialization request information has not been executed, initialize the service using the target initialization request information, and then proceed to step S4;

[0060] Step S4: Determine whether a system downtime occurs during the execution of the target initialization request information; if a system downtime occurs, proceed to step S2 (the difference from step S2 is that the initialization request information with the shortest time interval between the initialization request information and the current time is determined to determine whether the information exists in the information record library. The same applies to step S3, with only the determination object being changed. This will not be further described here). If a system downtime does not occur, proceed to step S5;

[0061] Step S5: Determine whether the execution status of the above-mentioned target initialization request information in the above-mentioned task database has been successfully changed to completed; if it has been successfully changed, determine that the initialization task of the above-mentioned service has been completed; if it has not been successfully changed, proceed to step S2 (the difference from step S2 is that the above-mentioned initialization request information other than the above-mentioned target initialization request information with the shortest time interval with the current moment is judged, and whether the information exists in the information record library. The same applies to step S3 afterwards, only the judgment object is changed, and it will not be repeated here).

[0062] It should be noted that the steps shown in the flowcharts of the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and that, although a logical order is shown in the flowcharts, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0063] The embodiments of the present application also provide a device for initializing a service. It should be noted that the device for initializing a service in the embodiments of the present application can be used to execute the initialization method for a service provided in the embodiments of the present application. The device is used to implement the above-mentioned embodiments and preferred implementation modes, and those that have been described will not be repeated here. As used below, the term "module" can be a combination of software and / or hardware that implements a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.

[0064] The following introduces the initialization device of the service provided in the embodiment of the present application.

[0065] Figure 4 Schematic diagram of a service initialization device provided according to an embodiment of the present application. Figure 4As shown, the device includes a first processing unit 41, a second processing unit 42 and a third processing unit 43; the first processing unit 41 is used to respond to multiple initialization request messages sent by each service, and sort all the above initialization request messages in the order of receipt time, and the above initialization request information is request information for initializing the above service; the second processing unit 42 is used to determine whether the target initialization request information has been executed, wherein the above target initialization request information is the initialization request information with the shortest time interval between all the above initialization request information and the current moment; the third processing unit 43 is used to initialize the above service corresponding to the above target initialization request information according to the above target initialization request information when it is determined that the above target initialization request information has not been executed.

[0066] In the above-mentioned device, by sorting all the above-mentioned initialization request information in the order of the time of receipt, it is determined whether the target initialization request information has been executed. When it is determined that the above-mentioned target initialization request information has not been executed, the above-mentioned service corresponding to the above-mentioned target initialization request information is initialized according to the above-mentioned target initialization request information, thereby reducing the occurrence of repeated execution of service initialization, and thus solving the problem of repeated initialization that is prone to occur in the prior art.

[0067] In one embodiment of the present application, the device also includes a first determination unit and a fourth processing unit. The first determination unit is used to determine whether the initialization request information other than the target initialization request information and the initialization request information with the shortest time interval between the current moment has been executed when it is determined that the target initialization request information has been executed; the fourth processing unit is used to initialize the service corresponding to the initialization request information other than the target initialization request information and the initialization request information with the shortest time interval between the current moment and the initialization request information when it is determined that the initialization request information other than the target initialization request information and the initialization request information with the shortest time interval between the current moment and the initialization request information has not been executed.

[0068] In one embodiment of the present application, the second processing unit includes a first determination module, which is used to determine whether the above-mentioned target initialization request information has been executed when the above-mentioned target initialization request information does not exist in the information recording library, and the above-mentioned information recording library is used to store the above-mentioned initialization request information that has been executed; the first determination unit includes a second determination module, which is used to determine whether the above-mentioned initialization request information other than the above-mentioned target initialization request information and the above-mentioned initialization request information with the shortest time interval between the above-mentioned initialization request information and the current moment has been executed when the above-mentioned initialization request information other than the above-mentioned target initialization request information and the above-mentioned initialization request information with the shortest time interval between the above-mentioned initialization request information and the current moment already exists in the information recording library.

[0069] In one embodiment of the present application, the device also includes a second determination unit and a third determination unit, the second determination unit is used to determine whether the above-mentioned target initialization request information crashes during the execution process; the third determination unit is used to determine whether the above-mentioned initialization request information other than the above-mentioned target initialization request information has the shortest time interval with the current moment in the above-mentioned initialization request information when the above-mentioned target initialization request information crashes during the execution process.

[0070] In one embodiment of the present application, the device also includes a fifth processing unit, which, after determining whether the above-mentioned target initialization request information crashes during execution, is used to change the status of the above-mentioned target initialization request information in the task database to completed if the above-mentioned target initialization request information does not crash during execution.

[0071] In one embodiment of the present application, the device also includes a fourth determination unit and a fifth determination unit. After the status of the above-mentioned target initialization request information in the task database is changed to completed, the fourth determination unit is used to determine whether the execution status of the above-mentioned target initialization request information in the above-mentioned task database has been successfully changed to completed; the fifth determination unit is used to determine that the initialization task of the above-mentioned service has been completed when the execution status of the above-mentioned target initialization request information in the above-mentioned task database is successfully changed to completed.

[0072] In one embodiment of the present application, the device also includes a sixth determination unit. After determining whether the execution status of the above-mentioned target initialization request information in the above-mentioned task database has been successfully changed to completed, the sixth determination unit is used to determine whether the above-mentioned initialization request information with the shortest time interval between the above-mentioned initialization request information and the current moment has been executed when the execution status of the above-mentioned target initialization request information in the above-mentioned task database has not been successfully changed to completed.

[0073] The service initialization device includes a processor and a memory. The first, second, and third processing units are stored in the memory as program units, and the processor executes the program units stored in the memory to implement the corresponding functions. The modules are all located in the same processor; alternatively, the modules can be located in different processors in any combination.

[0074] The processor includes a kernel, which retrieves the corresponding program unit from the memory. One or more kernels can be set, and the repeated initialization problem that is prone to occur in the prior art can be solved by adjusting the kernel parameters.

[0075] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM, and the memory includes at least one memory chip.

[0076] An embodiment of the present invention provides a computer-readable storage medium, which includes a stored program. When the program is executed, the device where the computer-readable storage medium is located is controlled to execute the initialization method for the service.

[0077] Specifically, the service initialization method includes:

[0078] Step S201, in response to receiving multiple initialization request messages sent by various services, sorting all the initialization request messages in the order of receipt time, wherein the initialization request messages are request messages for initializing the services;

[0079] Step S202: Determine whether the target initialization request information has been executed, wherein the target initialization request information is the initialization request information with the shortest time interval between the target initialization request information and the current moment among all the initialization request information;

[0080] Step S203: When it is determined that the target initialization request information has not been executed, the service corresponding to the target initialization request information is initialized according to the target initialization request information.

[0081] In one embodiment of the present application, the above method also includes: in a case where it is determined that the above target initialization request information has been executed, determining whether the above initialization request information with the shortest time interval between the above initialization request information other than the above target initialization request information and the current moment has been executed; in a case where it is determined that the above initialization request information with the shortest time interval between the above initialization request information other than the above target initialization request information and the current moment has not been executed, initializing the above service corresponding to the above initialization request information with the shortest time interval between the above initialization request information other than the above target initialization request information and the current moment.

[0082] In one embodiment of the present application, determining whether the above-mentioned target initialization request information has been executed includes: in a case where the above-mentioned target initialization request information does not exist in an information recording library, determining whether the above-mentioned target initialization request information has been executed, and the above-mentioned information recording library is used to store the above-mentioned initialization request information that has been executed; determining whether the above-mentioned initialization request information other than the above-mentioned target initialization request information with the shortest time interval between it and the current moment has been executed includes: in a case where the above-mentioned initialization request information other than the above-mentioned target initialization request information with the shortest time interval between it and the current moment already exists in the information recording library, determining whether the above-mentioned initialization request information other than the above-mentioned target initialization request information with the shortest time interval between it and the current moment has been executed.

[0083] In one embodiment of the present application, the above method also includes: determining whether the above target initialization request information crashes during the execution process; in the event that the above target initialization request information crashes during the execution process, determining whether the above initialization request information with the shortest time interval between the above initialization request information and the current moment other than the above target initialization request information has been executed.

[0084] In one embodiment of the present application, after determining whether the above-mentioned target initialization request information crashes during execution, the above-mentioned method further includes: if the above-mentioned target initialization request information does not crash during execution, changing the status of the above-mentioned target initialization request information in the task database to completed.

[0085] In one embodiment of the present application, after the status of the above-mentioned target initialization request information in the task database is changed to completed, the above-mentioned method includes: determining whether the execution status of the above-mentioned target initialization request information in the above-mentioned task database has been successfully changed to completed; in the case that the execution status of the above-mentioned target initialization request information in the above-mentioned task database is successfully changed to completed, determining that the initialization task of the above-mentioned service has been completed.

[0086] In one embodiment of the present application, after determining whether the execution status of the above-mentioned target initialization request information in the above-mentioned task database has been successfully changed to completed, the above-mentioned method also includes: in the case that the execution status of the above-mentioned target initialization request information in the above-mentioned task database has not been successfully changed to completed, determining whether the above-mentioned initialization request information with the shortest time interval between the above-mentioned initialization request information and the current moment other than the above-mentioned target initialization request information has been executed.

[0087] An embodiment of the present invention provides a processor, which is used to run a program, wherein the initialization method of the service is executed when the program is running.

[0088] Specifically, the service initialization method includes:

[0089] Step S201, in response to receiving multiple initialization request messages sent by various services, sorting all the initialization request messages in the order of receipt time, wherein the initialization request messages are request messages for initializing the services;

[0090] Step S202: Determine whether the target initialization request information has been executed, wherein the target initialization request information is the initialization request information with the shortest time interval between the target initialization request information and the current moment among all the initialization request information;

[0091] Step S203: When it is determined that the target initialization request information has not been executed, the service corresponding to the target initialization request information is initialized according to the target initialization request information.

[0092] In one embodiment of the present application, the above method also includes: in a case where it is determined that the above target initialization request information has been executed, determining whether the above initialization request information with the shortest time interval between the above initialization request information other than the above target initialization request information and the current moment has been executed; in a case where it is determined that the above initialization request information with the shortest time interval between the above initialization request information other than the above target initialization request information and the current moment has not been executed, initializing the above service corresponding to the above initialization request information with the shortest time interval between the above initialization request information other than the above target initialization request information and the current moment.

[0093] In one embodiment of the present application, determining whether the above-mentioned target initialization request information has been executed includes: in a case where the above-mentioned target initialization request information does not exist in an information recording library, determining whether the above-mentioned target initialization request information has been executed, and the above-mentioned information recording library is used to store the above-mentioned initialization request information that has been executed; determining whether the above-mentioned initialization request information other than the above-mentioned target initialization request information with the shortest time interval between it and the current moment has been executed includes: in a case where the above-mentioned initialization request information other than the above-mentioned target initialization request information with the shortest time interval between it and the current moment already exists in the information recording library, determining whether the above-mentioned initialization request information other than the above-mentioned target initialization request information with the shortest time interval between it and the current moment has been executed.

[0094] In one embodiment of the present application, the above method also includes: determining whether the above target initialization request information crashes during the execution process; in the event that the above target initialization request information crashes during the execution process, determining whether the above initialization request information with the shortest time interval between the above initialization request information and the current moment other than the above target initialization request information has been executed.

[0095] In one embodiment of the present application, after determining whether the above-mentioned target initialization request information crashes during execution, the above-mentioned method further includes: if the above-mentioned target initialization request information does not crash during execution, changing the status of the above-mentioned target initialization request information in the task database to completed.

[0096] In one embodiment of the present application, after the status of the above-mentioned target initialization request information in the task database is changed to completed, the above-mentioned method includes: determining whether the execution status of the above-mentioned target initialization request information in the above-mentioned task database has been successfully changed to completed; in the case that the execution status of the above-mentioned target initialization request information in the above-mentioned task database is successfully changed to completed, determining that the initialization task of the above-mentioned service has been completed.

[0097] In one embodiment of the present application, after determining whether the execution status of the above-mentioned target initialization request information in the above-mentioned task database has been successfully changed to completed, the above-mentioned method also includes: in the case that the execution status of the above-mentioned target initialization request information in the above-mentioned task database has not been successfully changed to completed, determining whether the above-mentioned initialization request information with the shortest time interval between the above-mentioned initialization request information and the current moment other than the above-mentioned target initialization request information has been executed.

[0098] An embodiment of the present invention provides a device, comprising a processor, a memory, and a program stored in the memory and executable on the processor. When the processor executes the program, the processor implements at least the following steps: in response to multiple initialization request messages received from various services, sorting all of the aforementioned initialization request messages in the order of their receipt, wherein the aforementioned initialization request messages are request messages for initializing the aforementioned services; determining whether the target initialization request message has been executed, wherein the aforementioned target initialization request message is the initialization request message with the shortest time interval between the aforementioned initialization request messages and the current moment; and, if it is determined that the aforementioned target initialization request message has not been executed, initializing the aforementioned service corresponding to the aforementioned target initialization request message according to the aforementioned target initialization request message. The device herein may be a server, a PC, a PAD, a mobile phone, etc.

[0099] In one embodiment of the present application, the above method also includes: in a case where it is determined that the above target initialization request information has been executed, determining whether the above initialization request information with the shortest time interval between the above initialization request information other than the above target initialization request information and the current moment has been executed; in a case where it is determined that the above initialization request information with the shortest time interval between the above initialization request information other than the above target initialization request information and the current moment has not been executed, initializing the above service corresponding to the above initialization request information with the shortest time interval between the above initialization request information other than the above target initialization request information and the current moment.

[0100] In one embodiment of the present application, determining whether the above-mentioned target initialization request information has been executed includes: in a case where the above-mentioned target initialization request information does not exist in an information recording library, determining whether the above-mentioned target initialization request information has been executed, and the above-mentioned information recording library is used to store the above-mentioned initialization request information that has been executed; determining whether the above-mentioned initialization request information other than the above-mentioned target initialization request information with the shortest time interval between it and the current moment has been executed includes: in a case where the above-mentioned initialization request information other than the above-mentioned target initialization request information with the shortest time interval between it and the current moment already exists in the information recording library, determining whether the above-mentioned initialization request information other than the above-mentioned target initialization request information with the shortest time interval between it and the current moment has been executed.

[0101] In one embodiment of the present application, the above method also includes: determining whether the above target initialization request information crashes during the execution process; in the event that the above target initialization request information crashes during the execution process, determining whether the above initialization request information with the shortest time interval between the above initialization request information and the current moment other than the above target initialization request information has been executed.

[0102] In one embodiment of the present application, after determining whether the above-mentioned target initialization request information crashes during execution, the above-mentioned method further includes: if the above-mentioned target initialization request information does not crash during execution, changing the status of the above-mentioned target initialization request information in the task database to completed.

[0103] In one embodiment of the present application, after the status of the above-mentioned target initialization request information in the task database is changed to completed, the above-mentioned method includes: determining whether the execution status of the above-mentioned target initialization request information in the above-mentioned task database has been successfully changed to completed; in the case that the execution status of the above-mentioned target initialization request information in the above-mentioned task database is successfully changed to completed, determining that the initialization task of the above-mentioned service has been completed.

[0104] In one embodiment of the present application, after determining whether the execution status of the above-mentioned target initialization request information in the above-mentioned task database has been successfully changed to completed, the above-mentioned method also includes: in the case that the execution status of the above-mentioned target initialization request information in the above-mentioned task database has not been successfully changed to completed, determining whether the above-mentioned initialization request information with the shortest time interval between the above-mentioned initialization request information and the current moment other than the above-mentioned target initialization request information has been executed.

[0105] The present application also provides a computer program product, which, when executed on a data processing device, is suitable for executing an initialization program having at least the following method steps: in response to multiple initialization request messages received from various services, sorting all the above initialization request messages in the order of receipt time, the above initialization request messages being request information for initializing the above services; determining whether the target initialization request message has been executed, wherein the above target initialization request message is the initialization request message with the shortest time interval between the above target initialization request message and the current moment; and in the case of determining that the above target initialization request message has not been executed, performing initialization processing on the above service corresponding to the above target initialization request message according to the above target initialization request message.

[0106] In one embodiment of the present application, the above method also includes: in a case where it is determined that the above target initialization request information has been executed, determining whether the above initialization request information with the shortest time interval between the above initialization request information other than the above target initialization request information and the current moment has been executed; in a case where it is determined that the above initialization request information with the shortest time interval between the above initialization request information other than the above target initialization request information and the current moment has not been executed, initializing the above service corresponding to the above initialization request information with the shortest time interval between the above initialization request information other than the above target initialization request information and the current moment.

[0107] In one embodiment of the present application, determining whether the above-mentioned target initialization request information has been executed includes: in a case where the above-mentioned target initialization request information does not exist in an information recording library, determining whether the above-mentioned target initialization request information has been executed, and the above-mentioned information recording library is used to store the above-mentioned initialization request information that has been executed; determining whether the above-mentioned initialization request information other than the above-mentioned target initialization request information with the shortest time interval between it and the current moment has been executed includes: in a case where the above-mentioned initialization request information other than the above-mentioned target initialization request information with the shortest time interval between it and the current moment already exists in the information recording library, determining whether the above-mentioned initialization request information other than the above-mentioned target initialization request information with the shortest time interval between it and the current moment has been executed.

[0108] In one embodiment of the present application, the above method also includes: determining whether the above target initialization request information crashes during the execution process; in the event that the above target initialization request information crashes during the execution process, determining whether the above initialization request information with the shortest time interval between the above initialization request information and the current moment other than the above target initialization request information has been executed.

[0109] In one embodiment of the present application, after determining whether the above-mentioned target initialization request information crashes during execution, the above-mentioned method further includes: if the above-mentioned target initialization request information does not crash during execution, changing the status of the above-mentioned target initialization request information in the task database to completed.

[0110] In one embodiment of the present application, after the status of the above-mentioned target initialization request information in the task database is changed to completed, the above-mentioned method includes: determining whether the execution status of the above-mentioned target initialization request information in the above-mentioned task database has been successfully changed to completed; in the case that the execution status of the above-mentioned target initialization request information in the above-mentioned task database is successfully changed to completed, determining that the initialization task of the above-mentioned service has been completed.

[0111] In one embodiment of the present application, after determining whether the execution status of the above-mentioned target initialization request information in the above-mentioned task database has been successfully changed to completed, the above-mentioned method also includes: in the case that the execution status of the above-mentioned target initialization request information in the above-mentioned task database has not been successfully changed to completed, determining whether the above-mentioned initialization request information with the shortest time interval between the above-mentioned initialization request information and the current moment other than the above-mentioned target initialization request information has been executed.

[0112] The present application also provides an electronic device, which includes one or more processors, a memory, and one or more programs, wherein the one or more programs are stored in the memory and are configured to be executed by the one or more processors, and the one or more programs include an initialization method for executing any one of the above services.

[0113] Obviously, those skilled in the art will appreciate that the various modules or steps of the present invention described above can be implemented using a general-purpose computing device, can be centralized on a single computing device, or can be distributed across a network of multiple computing devices. They can be implemented using program code executable by the computing device, and thus, can be stored in a storage device and executed by the computing device. In some cases, the steps shown or described herein can be performed in a different order than that shown, or can be fabricated as separate integrated circuit modules, or multiple modules or steps can be fabricated as a single integrated circuit module. Thus, the present invention is not limited to any particular combination of hardware and software.

[0114] Those skilled in the art will appreciate that the embodiments of the present application can be provided as methods, systems, or computer program products. Therefore, the present application can adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application can adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.

[0115] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the steps in the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0116] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.

[0117] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.

[0118] In a typical configuration, a computing device includes one or more processors (CPUs), input / output interfaces, network interfaces, and memory.

[0119] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.

[0120] Computer-readable media includes permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. The information can be computer-readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include transitory computer-readable media (transitory media), such as modulated data signals and carrier waves.

[0121] It should also be noted that the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, commodity, or apparatus that includes a series of elements includes not only those elements but also other elements not explicitly listed, or includes elements inherent to such process, method, commodity, or apparatus. In the absence of further limitations, an element defined by the phrase "comprises a ..." does not exclude the presence of other identical elements in the process, method, commodity, or apparatus that includes the element.

[0122] From the above description, it can be seen that the above embodiments of the present application achieve the following technical effects:

[0123] 1) The service initialization method of the present application determines whether the target initialization request information has been executed by sorting all the above-mentioned initialization request information in the order of the time of receipt. If it is determined that the above-mentioned target initialization request information has not been executed, the above-mentioned service corresponding to the above-mentioned target initialization request information is initialized according to the above-mentioned target initialization request information, thereby reducing the occurrence of repeated execution of service initialization, and thus solving the problem of repeated initialization that is prone to occur in the prior art.

[0124] 2) The initialization method of the service of this application avoids data inconsistency caused by concurrent initialization and avoids repeated initialization; the goal of starting nodes in the cluster after data initialization is completed is achieved through initialization progress maintenance, and the initialization progress can be monitored at the same time; the judgment of the node health status avoids long waiting times caused by initialization node abnormalities; through optimistic lock election, it avoids timeouts and task startup failures caused by pessimistic locks.

[0125] The above description is merely a preferred embodiment of the present application and is not intended to limit the present application. Various modifications and variations are possible for those skilled in the art. Any modifications, equivalent substitutions, or improvements made within the spirit and principles of the present application shall be included within the scope of protection of the present application.

Claims

1. A service initialization method, characterized in that: include: In response to receiving multiple initialization request messages sent by various services, sorting all the initialization request messages in a time sequence of receipt, wherein the initialization request messages are request messages for initializing the services; Determining whether a target initialization request message has been executed, wherein the target initialization request message is the initialization request message with the shortest time interval between the target initialization request message and the current moment among all the initialization request messages; In a case where it is determined that the target initialization request information has not been executed, initializing the service corresponding to the target initialization request information according to the target initialization request information; The method further includes: determining whether a downtime occurs during the execution of the target initialization request information; if a downtime occurs during the execution of the target initialization request information, determining whether the initialization request information other than the target initialization request information and having the shortest time interval with the current moment has been executed; After determining whether the target initialization request information crashes during execution, the method further includes: if the target initialization request information does not crash during execution, changing the status of the target initialization request information in the task database to completed.

2. The method according to claim 1, characterized in that The method further comprises: If it is determined that the target initialization request information has been executed, determining whether the initialization request information other than the target initialization request information and having the shortest time interval with the current moment has been executed; When it is determined that the initialization request information with the shortest time interval between the initialization request information other than the target initialization request information and the current moment has not been executed, the service corresponding to the initialization request information with the shortest time interval between the initialization request information other than the target initialization request information and the current moment is initialized.

3. The method according to claim 2, characterized in that Determining whether the target initialization request information has been executed includes: if the target initialization request information does not exist in an information recording library, determining whether the target initialization request information has been executed, the information recording library being used to store the initialization request information that has been executed; Determining whether the initialization request information other than the target initialization request information and the initialization request information with the shortest time interval between it and the current moment has been executed, comprising: when the initialization request information other than the target initialization request information and the initialization request information with the shortest time interval between it and the current moment already exists in the information recording library, determining whether the initialization request information other than the target initialization request information and the initialization request information with the shortest time interval between it and the current moment has been executed.

4. The method according to claim 1, wherein After changing the status of the target initialization request information in the task database to completed, the method includes: determining whether the execution status of the target initialization request information in the task database has been successfully changed to completed; In a case where the execution status of the target initialization request information in the task database is successfully changed to completed, it is determined that the initialization task of the service is completed.

5. The method according to claim 4, characterized in that After determining whether the execution status of the target initialization request information in the task database has been successfully changed to completed, the method further includes: When the execution status of the target initialization request information in the task database is changed from unsuccessfully to completed, it is determined whether the initialization request information other than the target initialization request information and the initialization request information with the shortest time interval with the current moment has been executed.

6. A service initialization device, characterized in that: include: a first processing unit, configured to, in response to a plurality of received initialization request messages sent by various services, sort all the initialization request messages in a time sequence of receipt, wherein the initialization request messages are request messages for initializing the services; A second processing unit is configured to determine whether a target initialization request message has been executed, wherein the target initialization request message is the initialization request message having the shortest time interval with the current moment among all the initialization request messages; a third processing unit, configured to, if it is determined that the target initialization request information has not been executed, perform initialization processing on the service corresponding to the target initialization request information according to the target initialization request information; The apparatus further includes a second determining unit and a third determining unit, the second determining unit being configured to determine whether a downtime occurs during the execution of the target initialization request information; and the third determining unit being configured to determine, if a downtime occurs during the execution of the target initialization request information, whether the initialization request information other than the target initialization request information and having the shortest time interval with the current moment has been executed. The device also includes a fifth processing unit, which, after determining whether the target initialization request information crashes during execution, is used to change the status of the target initialization request information in the task database to completed if the target initialization request information does not crash during execution.

7. A computer-readable storage medium, characterized in that The computer-readable storage medium includes a stored program, wherein when the program is executed, the device where the computer-readable storage medium is located is controlled to execute the service initialization method according to any one of claims 1 to 5.

8. An electronic device, characterized in that: include: One or more processors, a memory, and one or more programs, wherein the one or more programs are stored in the memory and are configured to be executed by the one or more processors, and the one or more programs include an initialization method for executing the service described in any one of claims 1 to 5.

Citation Information

Patent Citations

  • Data collaborative initialization method and device, equipment and medium

    CN114327797A

  • On-demand initialization of services in an application server

    US7937491B1