Task scheduling method, device, medium and related equipment under remote multi-active architecture
By detecting and switching the dispatch center and computer room, it ensures that tasks are correctly allocated and executed under the multi-active remote architecture, which solves the task disorder problem caused by xxl-job's inability to support the multi-active remote multi-center mode and improves the efficiency and accuracy of task scheduling. .
Patent Information
- Application Number
- CN202211182005.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-27
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2042-09-27
AI Technical Summary
In the existing technology, xxl-job cannot support the remote multi-active multi-center mode, which leads to the disorder of remote cluster scheduling tasks and reduces the efficiency and accuracy of task scheduling.
By detecting whether the dispatching centers corresponding to computer rooms deployed in different regions meet the task triggering conditions, obtain the current dispatching center and current computer room that successfully trigger the scheduling task, and determine whether there is a registered target executor in the current dispatching center. If it exists, schedule it The task is sent to the target executor, and the task is allowed to be executed when the computer room identification contained in the target executor is the current computer room identification. Otherwise, execution is not allowed. If it does not exist, the dispatch center and computer room are switched.
It effectively avoids excessive access and task failures caused by multiple dispatch centers querying the database at the same time, realizes the isolation and accuracy of task scheduling, and improves task scheduling efficiency and accuracy.
Smart Images

Figure CN115454606B
Abstract
Description
Technical Field
[0001] The present application relates to the field of task scheduling technology, and in particular to a task scheduling method, device, medium and related equipment under a remote multi-active architecture. Background Art
[0002] xxl-job is a distributed task scheduling platform, which is applicable to the following business scenarios: 1) Scenarios at specific time points: such as sending coupons and text messages at a certain time point; 2) Timed batch processing of data: such as batch statistics of last month's bills and sales data; 3) Scheduled tasks: such as tasks that need to be executed every 5 minutes. The core design goal of xxl-job is rapid development, simple learning, lightweight, easy to expand, and ready to use. It has very good integration with SpringBoot, and the monitoring interface is integrated in the scheduling center, with a friendly interface, simple and easy to use. The source code is now open and connected to the online product lines of many companies. It is not costly for enterprises to maintain, and there are also email alarm functions for failures.
[0003] At present, xxl-job task scheduling management belongs to the central deployment architecture and supports cluster mode. When xxl-job is used for task scheduling, its task scheduling process is as follows: Figure 1 As shown, Figure 1 In the example, computer room 1 and computer room 2 are remote computer rooms with no intranet connection. To ensure the consistency of distributed cluster task scheduling, the dispatch centers corresponding to the two computer rooms use the same MySQL database for task scheduling. However, since xxl-job cannot support the remote multi-active multi-center mode and the uncertainty of task scheduling in the cluster, there will be problems such as Figure 2 The situation shown, Figure 2 In the example, the dispatch center of computer room 1 dispatches the task scheduling node of computer room 2 during task scheduling. Since the intranets of computer rooms in different locations are not interconnected, this scheduling method will cause task scheduling failure, thereby reducing task scheduling efficiency and accuracy. Summary of the invention
[0004] The purpose of this application is to solve at least one of the above-mentioned technical defects, especially the technical defect in the prior art that xxl-job cannot support the multi-active and multi-center mode in different locations, resulting in disorder of remote cluster scheduling tasks, thereby reducing the efficiency and accuracy of task scheduling.
[0005] The present application provides a task scheduling method under a remote multi-active architecture, the method comprising:
[0006] When it is detected that the dispatch centers corresponding to the computer rooms deployed in different regions have met the task triggering conditions, the current dispatch center and the current computer room that successfully triggered the dispatching task are obtained;
[0007] When monitoring that the current dispatch center queries the database for the current dispatch task, determining whether the current dispatch center has a registered target executor, the target executor being an executor node including the computer room identifier of the current computer room;
[0008] If so, when it is detected that the current scheduling center sends the queried scheduling task to the target executor, and when the target executor executes the scheduling task on the current computer room, it is determined whether the computer room identifier contained in the target executor is the computer room identifier of the current computer room;
[0009] If yes, allowing the target executor to execute the scheduling task for the current computer room;
[0010] Otherwise, the target executor is not allowed to execute the scheduling task for the current computer room;
[0011] If not, the current dispatch center and the current computer room are switched, and after the switch, the execution returns to the step of determining whether there is a registered target executor in the current dispatch center when monitoring that the current dispatch center queries the database for the current dispatch task.
[0012] Optionally, the registration process of the executor node includes:
[0013] When any executor node is detected to register with the corresponding dispatch center according to the pre-configured dispatch center address, the SQL statement reported by the executor node during registration is intercepted;
[0014] The computer room identifier corresponding to the computer room of the scheduling center to be registered is added to the SQL statement, so that the executor node registers with the scheduling center to be registered using the SQL statement with the computer room identifier added.
[0015] Optionally, adding a computer room identifier corresponding to a computer room of the dispatching center to be registered in the SQL statement includes:
[0016] Determine whether there is a computer room identifier in the SQL statement;
[0017] If it does not exist, insert the computer room identifier corresponding to the computer room of the dispatch center to be registered into the SQL statement;
[0018] If it exists, determining whether the computer room identifier is the computer room identifier corresponding to the computer room of the dispatch center to be registered;
[0019] If yes, the executor node is allowed to register with the scheduling center to be registered;
[0020] Otherwise, the computer room identifier is updated according to the computer room identifier corresponding to the computer room of the dispatching center to be registered.
[0021] Optionally, the determining whether there is a registered target executor in the current dispatch center includes:
[0022] Intercepting the task list query statement sent by the current scheduling center when querying the database for the current scheduling task, and obtaining the node field in the registration table saved by the database;
[0023] Determine whether the task list query statement contains the node field;
[0024] If included, determining that the current dispatch center has a registered target executor;
[0025] If not, it is determined that there is no registered target executor in the current scheduling center.
[0026] Optionally, the obtaining of the current scheduling center and the current computer room that successfully triggers the scheduling task includes:
[0027] Determine the dispatch center and the corresponding computer room that successfully seize the database lock among the dispatch centers corresponding to computer rooms deployed in different regions, and use the dispatch center and the corresponding computer room that successfully seize the database lock as the current dispatch center and the current computer room that successfully trigger the dispatch task.
[0028] Optionally, after allowing the target executor to execute the scheduling task for the current computer room, the method further includes:
[0029] When it is detected that the target executor completes the scheduled task, the next task scheduling time sent by the database is updated and the database lock is released.
[0030] Optionally, the switching of the current dispatch center and the current computer room includes:
[0031] The database lock seized by the current dispatching center when the dispatching task is successfully triggered is released, and the dispatching center and the corresponding computer room that successfully seized the database lock from the dispatching centers corresponding to computer rooms deployed in different regions are re-acquired;
[0032] The current dispatching center and the current computer room are switched to the dispatching center and the corresponding computer room that successfully seize the database lock in this round.
[0033] The present application also provides a task scheduling device under a remote multi-active architecture, including:
[0034] An acquisition module is used to acquire the current dispatch center and current computer room that successfully trigger the dispatch task when it is detected that the dispatch centers corresponding to computer rooms deployed in different regions have met the task triggering conditions;
[0035] A first judgment module is used to judge whether there is a registered target executor in the current scheduling center when monitoring that the current scheduling center queries the database for the current scheduling task, and the target executor is an executor node including the computer room identifier of the current computer room;
[0036] A second judgment module is used to, if present, determine whether the computer room identifier contained in the target executor is the computer room identifier of the current computer room when it is detected that the current scheduling center sends the queried scheduling task to the target executor and when the target executor executes the scheduling task on the current computer room;
[0037] A first scheduling module, configured to allow the target executor to execute the scheduling task on the current computer room if yes;
[0038] A second scheduling module is used for not allowing the target executor to execute the scheduling task for the current computer room otherwise;
[0039] The switching module is used to switch the current dispatching center and the current computer room if they do not exist, and return to execute the step of determining whether there is a registered target executor in the current dispatching center when monitoring that the current dispatching center queries the database for this dispatching task after switching.
[0040] The present application also provides a storage medium, which stores computer-readable instructions. When the computer-readable instructions are executed by one or more processors, the one or more processors execute the steps of the task scheduling method under the multi-active architecture in different locations as described in any of the above embodiments.
[0041] The present application also provides a computer device, comprising: one or more processors, and a memory;
[0042] The memory stores computer-readable instructions, and when the computer-readable instructions are executed by the one or more processors, the steps of the task scheduling method under the multi-active architecture in different locations as described in any one of the above embodiments are performed.
[0043] It can be seen from the above technical solutions that the embodiments of the present application have the following advantages:
[0044] The task scheduling method, device, medium and related equipment under the remote multi-active architecture provided by the present application can obtain the current scheduling center and the current computer room that successfully triggered the scheduling task when it is detected that the scheduling centers corresponding to the computer rooms deployed in different regions have met the task triggering conditions. This can avoid the phenomenon that multiple scheduling centers query the database for scheduling tasks at the same time, resulting in excessive database access and slow operation. Then, the present application can monitor the actions of the current scheduling center. When it is detected that the current scheduling center queries the database for this scheduling task, it can be determined whether there is a registered target executor in the current scheduling center. Since the target executor contains the computer room identifier of the current computer room, if there is a registered target executor in the current scheduling center, it means that the current scheduling center has been connected to the registration service. At this time, the next action of the current scheduling center can be continued to be monitored, and the queried scheduling task can be sent to the target executor in the current scheduling center, so that when the target executor executes the scheduling task for the current computer room, Continue to determine whether the computer room identifier contained in the target executor is the computer room identifier of the current computer room. When the computer room identifier contained in the target executor is the computer room identifier of the current computer room, the target executor can be allowed to continue to execute the scheduling task for the current computer room. If not, the target executor is not allowed to execute the scheduling task for the current computer room. This can not only achieve task scheduling isolation, but also avoid the phenomenon of task failure caused by cross-scheduling of different computer rooms. In addition, if there is no registered target executor in the current scheduling center, it means that the current scheduling center has not accessed the registration service. If the previous scheduling center is allowed to obtain the scheduling task at this time, since the scheduling task has no corresponding executor, this will cause scheduling failure. Therefore, the present application can switch the current scheduling center and the corresponding current computer room where there is no registered target executor. This can not only respond to task scheduling requests from other scheduling centers, but also avoid the occurrence of scheduling disorder problems, thereby effectively improving the task scheduling efficiency and task scheduling accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0046] Figure 1 Task scheduling flow chart provided for prior art;
[0047] Figure 2 A schematic diagram of the scheduling results of the task scheduling process provided by the prior art;
[0048] Figure 3A flowchart of a task scheduling method under a remote multi-active architecture provided in an embodiment of the present application;
[0049] Figure 4 A schematic diagram of an application environment provided for an embodiment of the present application;
[0050] Figure 5 A schematic diagram of a process in which multiple scheduling centers seize database locks provided in an embodiment of the present application;
[0051] Figure 6 A schematic diagram of the judgment process of the task scheduling method under the remote multi-active architecture provided in an embodiment of the present application;
[0052] Figure 7 A schematic diagram of the structure of a task scheduling device under a remote multi-active architecture provided in an embodiment of the present application;
[0053] Figure 8 A schematic diagram of the internal structure of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0054] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0055] At present, xxl-job task scheduling management belongs to the central deployment architecture and supports cluster mode. When xxl-job is used for task scheduling, its task scheduling process is as follows: Figure 1 As shown, Figure 1 In the example, computer room 1 and computer room 2 are remote computer rooms with no intranet connection. To ensure the consistency of distributed cluster task scheduling, the dispatch centers corresponding to the two computer rooms use the same MySQL database for task scheduling. However, since xxl-job cannot support the remote multi-active multi-center mode and the uncertainty of task scheduling in the cluster, there will be problems such as Figure 2 The situation shown, Figure 2 In the example, the dispatch center of computer room 1 dispatches the task scheduling node of computer room 2 during task scheduling. Since the intranets of computer rooms in different locations are not interconnected, this scheduling method will cause task scheduling failure, thereby reducing task scheduling efficiency and accuracy.
[0056] Based on this, this application proposes the following technical solutions, see below for details:
[0057] In one embodiment, Figure 3 As shown, Figure 3A flowchart of a task scheduling method under a remote multi-active architecture provided in an embodiment of the present application; the present application provides a task scheduling method under a remote multi-active architecture, and the method may include:
[0058] S110: When it is detected that the dispatching centers corresponding to the computer rooms deployed in different regions have all met the task triggering conditions, the current dispatching center and the current computer room that have successfully triggered the dispatching task are obtained.
[0059] In this step, when this application uses the xxl-job distributed task scheduling platform to schedule tasks for remote center clusters, it can first detect whether the scheduling centers corresponding to computer rooms deployed in different regions have met the preset task trigger conditions. If so, the current scheduling center and current computer room that successfully triggered the scheduling task are obtained. In this way, it is possible to determine whether the task scheduling conditions are met based on the next action of the current scheduling center.
[0060] Specifically, the scheduling center in the xxl-job distributed task scheduling platform can support multi-node deployment. Therefore, the present application can deploy corresponding scheduling centers in computer rooms in different regions respectively, and realize unified scheduling through a data center to avoid scheduling disorder problems, thereby ensuring that tasks are not repeated or missed. When the data center detects that the scheduling centers corresponding to computer rooms deployed in different regions have met the task triggering conditions, it can be based on the database lock to ensure that only one scheduling center triggers the scheduling task at the same time. When the scheduling center that successfully triggers the scheduling task is obtained, the scheduling center can be used as the current scheduling center, and the computer room corresponding to the scheduling center can be used as the current computer room.
[0061] It can be understood that the xxl-job distributed task scheduling platform abstracts the scheduling behavior to form a public platform called "scheduling center", while the platform itself does not bear the business logic. The "scheduling center" is responsible for initiating scheduling requests; tasks are abstracted into scattered JobHandlers and handed over to the "executor" for unified management. The "executor" is responsible for receiving scheduling requests and executing the corresponding business logic in the JobHandler; therefore, the "scheduling" and "task" parts can be decoupled from each other to improve the overall stability and scalability of the system; the scheduling center of this application is responsible for managing the scheduling information of the corresponding computer room, issuing scheduling requests according to the scheduling configuration, and does not bear the business code itself. The scheduling center supports visual, simple and dynamic management of scheduling information, including task creation, update, deletion, task alarm, etc. All of the above operations will take effect in real time, and support monitoring of scheduling results and execution logs, and support executor failover.
[0062] S120: When monitoring that the current dispatch center queries the database for the current dispatch task, determine whether there is a registered target executor in the current dispatch center. If so, execute S130; if not, execute S160.
[0063] In this step, after obtaining the current dispatching center and the current computer room that successfully triggered the dispatching task through S110, this application can continue to monitor the next action of the current dispatching center, and query the database for this dispatching task at the current dispatching center to determine whether there is a registered target executor in the current dispatching center. In this way, it can be determined whether to trigger the dispatching task of the current dispatching center.
[0064] Specifically, if the current scheduling center successfully triggers the scheduling task, at this time, the current scheduling center can query the database for this scheduling task. For example, when the current scheduling center is deployed in the reconciliation system, the scheduling task can be a batch statistics of last month's bills and sales data, etc. Since the scheduling task is executed regularly, the operation and maintenance personnel can pre-write the execution code and trigger conditions related to the scheduling task in the database, and form the corresponding scheduling task. When the trigger condition is reached, the scheduling center will query the database for this scheduling task. However, if the current scheduling center that successfully triggers the scheduling task at this time is not connected to the registration service, it will cause the scheduling center to obtain this scheduling task and be unable to execute it. Therefore, when the present application monitors that the current scheduling center queries the database for this scheduling task, it can determine whether the current scheduling center has a registered target executor. If it does, it means that the current scheduling center can execute it through the target executor after obtaining the scheduling task. If it does not exist, it means that the current scheduling center cannot successfully execute the task after obtaining the scheduling task.
[0065] Among them, the target executor of the present application is mainly responsible for receiving scheduling requests and executing task logic, as well as receiving execution requests, termination requests and log requests from the scheduling center. In addition, the general executor node will periodically send registration commands to the scheduling center according to the pre-configured scheduling center address, so that the scheduling center can obtain the online executor list. During the registration process of the target executor of the present application, the computer room identifier corresponding to the computer room of the scheduling center to be registered can be added to the SQL statement reported when the target executor is registered. The target executor obtained in this way will contain the executor node of the computer room identifier of the current computer room, so that the present application can determine whether there is a registered target executor in the current scheduling center through the computer room identifier of the current computer room.
[0066] It is understandable that the computer room identifier here is the IP address of the computer room. The dispatching and scheduling of xxl-job tasks is related to the registration information of its access service. xxl-job mainly obtains the IP address of the application from the database registry to dispatch and schedule tasks. Therefore, this application can add a node field of a registered node in the database registry to indicate which computer room the registered node belongs to and determine the corresponding IP address. For example, the node field corresponding to computer room 1 is computer room 1. When scheduling tasks, it can be scheduled differently according to the node fields of different scheduling centers to ensure successful execution of tasks.
[0067] S130: When monitoring that the current dispatching center sends the queried dispatching task to the target executor, and when the target executor executes the dispatching task for the current computer room, determine whether the computer room identifier contained in the target executor is the computer room identifier of the current computer room; if so, execute S140; otherwise, execute S150.
[0068] In this step, after S120 determines whether there is a registered target executor in the current scheduling center, if so, continue to monitor the next action of the current scheduling center, and when it is monitored that the current scheduling center sends the queried scheduling task to the target executor, and when the target executor executes the scheduling task for the current computer room, determine whether the computer room identifier contained in the target executor is the computer room identifier of the current computer room. If so, the scheduling task can continue to be executed, otherwise, the scheduling task is not triggered.
[0069] It can be understood that this application ensures that the current scheduling center can only schedule the target executor containing the computer room identifier of the current computer room by judging whether the computer room identifier contained in the target executor is the computer room identifier of the current computer room during the task scheduling stage. This can not only achieve task scheduling isolation, but also avoid the phenomenon of task failure caused by cross-scheduling of different computer rooms.
[0070] S140: Allow the target executor to execute the scheduling task for the current computer room.
[0071] In this step, after S130 determines whether the computer room identifier contained in the target executor is the computer room identifier of the current computer room, if the computer room identifier contained in the target executor is the computer room identifier of the current computer room, it means that the executor during this task execution corresponds to the current computer room. Therefore, the data center can allow the target executor to execute the scheduling task for the current computer room. After the target executor completes the scheduling task, it can put the execution result into the memory queue and write the execution log into the log file. In addition, the callback thread of the target executor can also consume the execution result in the memory queue and actively report the execution result to the current scheduling center. When the user views the task log in the current scheduling center, the current scheduling center can request the target executor. After receiving the log request, the target executor can read the task log file and return the log details.
[0072] S150: The target executor is not allowed to execute the scheduling task for the current computer room.
[0073] In this step, after S130 determines whether the computer room identifier contained in the target executor is the computer room identifier of the current computer room, if the computer room identifier contained in the target executor is not the computer room identifier of the current computer room, it means that the target executor does not correspond to the current computer room. If task scheduling is performed at this time, it will cause task scheduling failure. Therefore, the present application can prohibit the target executor from executing scheduling tasks for the current computer room when the computer room identifier contained in the target executor is not the computer room identifier of the current computer room, thereby ensuring that the current scheduling center can only schedule the target executor containing the computer room identifier of the current computer room.
[0074] S160: Switch the current dispatch center and the current computer room, and return to execute steps S120 to S150 after the switch.
[0075] In this step, after S120 determines whether there is a registered target executor in the current scheduling center, if not, it means that the current scheduling center cannot successfully execute the task after obtaining the scheduling task. Therefore, in response to this situation, the present application can switch the current scheduling center and the current computer room to other scheduling centers and other computer rooms. This can avoid the situation where other scheduling centers that meet the trigger conditions delay processing tasks due to the inability of the current scheduling center to execute tasks, and can ensure the orderliness of task scheduling, thereby effectively improving the efficiency of task scheduling.
[0076] Indicatively, if Figure 4 As shown, Figure 4 A schematic diagram of the application environment provided by the embodiment of the present application, Figure 4In the embodiment, when the task scheduling method of the present application is used, when the service is started, the service registration is successful, the xxl-job of computer room 1 will only schedule service A, and the xxl-job of computer room 2 will only schedule service B, and the tasks will not be lost or repeated; if the xxl-job of computer room 1 is closed, the xxl-job of computer room 2 will always schedule service B; if the xxl-job of computer room 2 is closed, the xxl-job of computer room 1 will always schedule service A; if service A hangs up, the xxl-job of computer room 2 will always schedule service B; if service B hangs up, the xxl-job of computer room 1 will always schedule service A, so as to ensure the orderliness of task scheduling.
[0077] In the above embodiment, when it is detected that the dispatch centers corresponding to the computer rooms deployed in different regions have met the task triggering conditions, the current dispatch center and the current computer room that have successfully triggered the dispatch task can be obtained. This can avoid the phenomenon that multiple dispatch centers query the database for dispatch tasks at the same time, resulting in excessive database access and slow operation. Then, the present application can monitor the actions of the current dispatch center. When it is detected that the current dispatch center queries the database for this dispatch task, it can be determined whether there is a registered target executor in the current dispatch center. Since the target executor contains the computer room identifier of the current computer room, if there is a registered target executor in the current dispatch center, it means that the current dispatch center has access to the registration service. At this time, the next action of the current dispatch center can be continuously monitored, and the queried dispatch task can be sent to the target executor in the current dispatch center, so that when the target executor executes the dispatch task for the current computer room, it can continue to determine whether the target executor contains the computer room identifier of the current computer room. Whether the room identifier is the room identifier of the current computer room. When the computer room identifier contained in the target executor is the computer room identifier of the current computer room, the target executor can be allowed to continue to execute scheduling tasks for the current computer room. If not, the target executor is not allowed to execute scheduling tasks for the current computer room. This can not only achieve task scheduling isolation, but also avoid the phenomenon of task failure caused by cross-scheduling of different computer rooms. In addition, if there is no registered target executor in the current scheduling center, it means that the current scheduling center has not accessed the registration service. If the previous scheduling center is allowed to obtain the scheduling task at this time, since the scheduling task has no corresponding executor, this will cause scheduling failure. Therefore, the present application can switch the current scheduling center and the corresponding current computer room where there is no registered target executor. This can not only respond to task scheduling requests from other scheduling centers, but also avoid the occurrence of scheduling disorder problems, thereby effectively improving the task scheduling efficiency and task scheduling accuracy.
[0078] In one embodiment, the registration process of the executor node may include:
[0079] S101: When it is detected that any executor node registers with the corresponding dispatch center according to a pre-configured dispatch center address, a SQL statement reported when the executor node registers is intercepted.
[0080] S102: Adding a computer room identifier corresponding to the computer room of the scheduling center to be registered in the SQL statement, so that the executor node registers with the scheduling center to be registered using the SQL statement with the computer room identifier added.
[0081] In this embodiment, the executor node will automatically register with the dispatch center at regular intervals, and, at the time of registration, or according to the pre-configured dispatch center address, register with the corresponding dispatch center. In this application, when any executor node registers with the dispatch center to be registered, the sql statement reported by the executor node during registration can be intercepted, and the computer room identification corresponding to the computer room of the dispatch center to be registered can be added to the sql statement, so that the executor node can register with the dispatch center to be registered using the sql statement after adding the computer room identification, and when the dispatch center becomes the current dispatch center, the executor node also becomes the target executor accordingly. The data center can decide whether to allow the target executor to execute the dispatch task for the current computer room according to whether the target executor contains the computer room identification corresponding to the current computer room of the current dispatch center. This can not only realize task scheduling isolation, but also avoid the phenomenon of task failure caused by cross-scheduling of different computer rooms.
[0082] Furthermore, when intercepting the SQL statement reported when the executor node is registered, the application can intercept the query through Java eagent. Using Java eagent for interception can not only achieve code non-intrusion, but also support seamless upgrade of the official website code version. Of course, the application can also use other methods for interception, which is not limited here.
[0083] In one embodiment, adding the computer room identifier corresponding to the computer room of the dispatching center to be registered in the SQL statement in S102 may include:
[0084] S1021: Determine whether there is a computer room identifier in the SQL statement; if not, execute S1022; if so, execute S1023.
[0085] S1022: Insert the computer room identifier corresponding to the computer room of the dispatching center to be registered into the SQL statement.
[0086] S1023: Determine whether the computer room identifier is the computer room identifier corresponding to the computer room of the dispatching center to be registered; if so, execute S1024; otherwise, execute S1025.
[0087] S1024: Allow the executor node to register with the scheduling center to be registered.
[0088] S1025: Update the computer room identifier according to the computer room identifier corresponding to the computer room of the dispatching center to be registered.
[0089] In this embodiment, when any executor node registers with the scheduling center to be registered, the present application can intercept the SQL statement reported by the executor node when registering, and add the computer room identifier corresponding to the computer room of the scheduling center to be registered in the SQL statement, so that the executor node can register with the scheduling center to be registered using the SQL statement with the computer room identifier added.
[0090] Specifically, the present application can first determine whether there is a computer room identifier in the SQL statement. If not, then insert the computer room identifier corresponding to the computer room of the scheduling center to be registered into the SQL statement. If it exists, then continue to determine whether the computer room identifier is the computer room identifier corresponding to the computer room of the scheduling center to be registered. If so, the executor node is allowed to register with the scheduling center to be registered. Otherwise, the present application can update the computer room identifier in the current SQL statement according to the computer room identifier corresponding to the computer room of the scheduling center to be registered, so that the executor node is the node that executes the scheduling task of the scheduling center.
[0091] In one embodiment, determining whether the current dispatch center has a registered target executor in S120 may include:
[0092] S121: intercepting the task list query statement sent by the current scheduling center when querying the database for the current scheduling task, and obtaining the node field in the registration table saved in the database.
[0093] S122: Determine whether the task list query statement contains the node field; if so, execute S123; if not, execute S124.
[0094] S123: Determine whether there is a registered target executor in the current dispatch center.
[0095] S124: Determine that there is no registered target executor in the current dispatch center.
[0096] In this embodiment, when determining whether there is a registered target executor in the current scheduling center, the task list query statement sent by the current scheduling center when querying the database for the current scheduling task can be intercepted first, and then associated with the node field in the registration table of the database. Since the node field is the computer room identifier of the corresponding computer room, when it is detected that the task list query statement contains the node field, it indicates that there is a registered target executor in the current scheduling center. When the node field is not detected in the task list query statement, it indicates that there is no registered target executor in the current scheduling center. At this time, the current scheduling center can be prohibited from triggering the scheduling task.
[0097] In one embodiment, Figure 5 As shown, Figure 5 A schematic diagram of the process of multiple scheduling centers seizing database locks provided in an embodiment of the present application; obtaining the current scheduling center and the current computer room that successfully trigger the scheduling task in S110 may include:
[0098] S111: Determine the dispatch center and the corresponding computer room that successfully seize the database lock among the dispatch centers corresponding to computer rooms deployed in different regions, and use the dispatch center and the corresponding computer room that successfully seize the database lock as the current dispatch center and the current computer room that successfully trigger the dispatch task.
[0099] In this embodiment, when the data center detects that the dispatching centers corresponding to the computer rooms deployed in different regions have all met the task triggering conditions, it can be ensured based on the database lock that only one dispatching center triggers the dispatching task at the same time.
[0100] Specifically, the present application can first determine the dispatch center and the corresponding computer room that successfully seized the database lock among the dispatch centers corresponding to computer rooms deployed in different regions, and then use the dispatch center and the corresponding computer room that successfully seized the database lock as the current dispatch center and the current computer room that successfully triggered the dispatch task. Figure 5 As shown, Figure 5 When the xxl-job of computer room 1 and the xxl-job of computer room 2 deployed in different regions meet the triggering conditions, the MySQL database can use the MySQL exclusive lock to ensure that only one scheduling center triggers the scheduling task at the same time. When the scheduling center corresponding to one of the computer rooms successfully grabs the lock, it can query the MySQL database for this scheduling task and execute the scheduling task on the corresponding computer room through the executor. The computer room that failed to grab the lock can wait for the MySQL exclusive lock to be released before continuing the lock grabbing operation.
[0101] In one embodiment, after allowing the target executor to execute the scheduling task for the current computer room in S140, the following steps may also be included:
[0102] S141: When it is detected that the target executor completes the scheduled task, the next task scheduling time sent by the database is updated, and the database lock is released.
[0103] In this embodiment, the data center can monitor the task execution status of the target executor. When it is monitored that the target executor completes the scheduled task, it can update the next task scheduling time sent by the database and release the database lock so that each scheduling center can determine the triggering conditions for the next task scheduling and seize the database lock when the triggering conditions are met.
[0104] In one embodiment, the switching of the current dispatch center and the current computer room in S160 may include:
[0105] S161: releasing the database lock seized by the current scheduling center when the scheduling task is successfully triggered, and reacquiring the scheduling center and the corresponding computer room that successfully seized the database lock from the scheduling centers corresponding to computer rooms deployed in different regions.
[0106] S162: Switch the current dispatching center and the current computer room to the dispatching center and the corresponding computer room that successfully seize the database lock in this round.
[0107] In this embodiment, when switching the current dispatching center and the current computer room, the database lock seized by the current dispatching center when successfully triggering the dispatching task can be released first, so that the dispatching centers corresponding to other computer rooms that meet the triggering conditions at the same time can seize the database lock. After determining that there is a dispatching center that has successfully seized the database lock, the dispatching center and the corresponding computer room that have successfully seized the database lock will be used as the current dispatching center and the current computer room, and the relevant operations of the data center on the current dispatching center and the current computer room in the previous cycle will be re-executed to complete the dispatching task.
[0108] The following is an example of an embodiment to describe the task scheduling method under the remote multi-active architecture of the present application. Figure 6 As shown, Figure 6 A schematic diagram of the judgment process of the task scheduling method under the remote multi-active architecture provided in an embodiment of the present application; Figure 6In the example, when the xxl-job of computer room 1 and the xxl-job of computer room 2 deployed in different regions meet the triggering conditions, the mysql database can use the mysql exclusive lock to ensure that only one scheduling center triggers the scheduling task at the same time. When the scheduling center corresponding to one of the computer rooms successfully grabs the lock, it can be used as the current scheduling node to query the mysql database for this scheduling task, and the computer room that failed to grab the lock can wait for the mysql exclusive lock to be released before continuing to grab the lock. Further, before performing a task query, the application can first intercept the task list query statement sent by the current scheduling center when querying the database for this scheduling task, and then associate it with the node field in the registration table of the mysql database. Since the node field is the computer room identifier of the corresponding computer room, when the task list query statement contains the node field, it indicates that the current scheduling center has a registered target executor, and when the task list query statement does not contain the node field, it indicates that the current scheduling center does not have a registered target executor, and the current scheduling center can be prohibited from triggering the scheduling task. Furthermore, the present application can also determine whether the computer room identifier contained in the target executor is the computer room identifier of computer room 1 or computer room 2 during the task scheduling stage. If so, the scheduling task can continue to be executed; otherwise, the scheduling task will not be triggered. This can not only achieve task scheduling isolation, but also avoid the phenomenon of task failure caused by cross-scheduling of different computer rooms.
[0109] The task scheduling device under the remote multi-active architecture provided in an embodiment of the present application is described below. The task scheduling device under the remote multi-active architecture described below and the task scheduling method under the remote multi-active architecture described above can be referenced to each other.
[0110] In one embodiment, Figure 7 As shown, Figure 7 A structural diagram of a task scheduling device under a remote multi-active architecture provided in an embodiment of the present application; the present application also provides a task scheduling device under a remote multi-active architecture, which may include an acquisition module 210, a first judgment module 220, a second judgment module 230, a first scheduling module 240, a second scheduling module 250, and a switching module 260, specifically including the following:
[0111] The acquisition module 210 is used to acquire the current scheduling center and the current computer room that successfully triggered the scheduling task when it is detected that the scheduling centers corresponding to the computer rooms deployed in different regions have all met the task triggering conditions;
[0112] The first judgment module 220 is used to judge whether there is a registered target executor in the current scheduling center when monitoring that the current scheduling center queries the database for the current scheduling task, and the target executor is an executor node including the computer room identifier of the current computer room;
[0113] The second judgment module 230 is used to, if present, determine whether the computer room identifier contained in the target executor is the computer room identifier of the current computer room when it is detected that the current scheduling center sends the queried scheduling task to the target executor and when the target executor executes the scheduling task on the current computer room;
[0114] A first scheduling module 240, configured to allow the target executor to execute the scheduling task on the current computer room if yes;
[0115] A second scheduling module 250 is used for not allowing the target executor to execute the scheduling task for the current computer room otherwise;
[0116] The switching module 260 is used to switch the current dispatching center and the current computer room if they do not exist, and return to execute the step of determining whether there is a registered target executor in the current dispatching center when monitoring that the current dispatching center queries the database for this dispatching task after the switching.
[0117] In the above embodiment, when it is detected that the dispatch centers corresponding to the computer rooms deployed in different regions have met the task triggering conditions, the current dispatch center and the current computer room that have successfully triggered the dispatch task can be obtained. This can avoid the phenomenon that multiple dispatch centers query the database for dispatch tasks at the same time, resulting in excessive database access and slow operation. Then, the present application can monitor the actions of the current dispatch center. When it is detected that the current dispatch center queries the database for this dispatch task, it can be determined whether there is a registered target executor in the current dispatch center. Since the target executor contains the computer room identifier of the current computer room, if there is a registered target executor in the current dispatch center, it means that the current dispatch center has access to the registration service. At this time, the next action of the current dispatch center can be continuously monitored, and the queried dispatch task can be sent to the target executor in the current dispatch center, so that when the target executor executes the dispatch task for the current computer room, it can continue to determine whether the target executor contains the computer room identifier of the current computer room. Whether the room identifier is the room identifier of the current computer room. When the computer room identifier contained in the target executor is the computer room identifier of the current computer room, the target executor can be allowed to continue to execute scheduling tasks for the current computer room. If not, the target executor is not allowed to execute scheduling tasks for the current computer room. This can not only achieve task scheduling isolation, but also avoid the phenomenon of task failure caused by cross-scheduling of different computer rooms. In addition, if there is no registered target executor in the current scheduling center, it means that the current scheduling center has not accessed the registration service. If the previous scheduling center is allowed to obtain the scheduling task at this time, since the scheduling task has no corresponding executor, this will cause scheduling failure. Therefore, the present application can switch the current scheduling center and the corresponding current computer room where there is no registered target executor. This can not only respond to task scheduling requests from other scheduling centers, but also avoid the occurrence of scheduling disorder problems, thereby effectively improving the task scheduling efficiency and task scheduling accuracy.
[0118] In one embodiment, the present application also provides a storage medium, which stores computer-readable instructions. When the computer-readable instructions are executed by one or more processors, the one or more processors execute the steps of the task scheduling method under the multi-active architecture in a different location as described in any of the above embodiments.
[0119] In one embodiment, the present application also provides a computer device, including: one or more processors, and a memory.
[0120] The memory stores computer-readable instructions, and when the computer-readable instructions are executed by the one or more processors, the steps of the task scheduling method under the multi-active architecture in different locations as described in any one of the above embodiments are performed.
[0121] Indicatively, Figure 8 As shown, Figure 8This is a schematic diagram of the internal structure of a computer device provided in an embodiment of the present application. The computer device 300 may be provided as a server. Figure 8 , the computer device 300 includes a processing component 302, which further includes one or more processors, and a memory resource represented by a memory 301, for storing instructions executable by the processing component 302, such as an application. The application stored in the memory 301 may include one or more modules, each corresponding to a set of instructions. In addition, the processing component 302 is configured to execute instructions to perform the task scheduling method under the remote multi-active architecture of any of the above embodiments.
[0122] The computer device 300 may further include a power supply component 303 configured to perform power management of the computer device 300, a wired or wireless network interface 304 configured to connect the computer device 300 to a network, and an input / output (I / O) interface 305. The computer device 300 may operate based on an operating system stored in the memory 301, such as Windows Server TM, Mac OS X TM, Unix TM, Linux TM, Free BSD TM, or the like.
[0123] Those skilled in the art will understand that Figure 8 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0124] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0125] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The various embodiments can be combined as needed, and the same or similar parts can refer to each other.
[0126] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A task scheduling method under a remote multi-active architecture, characterized in that: The method comprises: When it is detected that the dispatch centers corresponding to the computer rooms deployed in different regions have met the task triggering conditions, the current dispatch center and the current computer room that successfully triggered the dispatching task are obtained; When monitoring that the current dispatch center queries the database for the current dispatch task, determining whether the current dispatch center has a registered target executor, the target executor being an executor node including the computer room identifier of the current computer room; If so, when it is detected that the current scheduling center sends the queried scheduling task to the target executor, and when the target executor executes the scheduling task on the current computer room, it is determined whether the computer room identifier contained in the target executor is the computer room identifier of the current computer room; If yes, allowing the target executor to execute the scheduling task for the current computer room; Otherwise, the target executor is not allowed to execute the scheduling task for the current computer room; If not, the current dispatch center and the current computer room are switched, and after the switch, the step of determining whether the current dispatch center has a registered target executor when the current dispatch center queries the database for the current dispatch task is returned to be executed; The acquisition of the current dispatch center and the current computer room that successfully triggers the dispatch task includes: Determine the dispatch center and the corresponding computer room that successfully seize the database lock among the dispatch centers corresponding to computer rooms deployed in different regions, and use the dispatch center and the corresponding computer room that successfully seize the database lock as the current dispatch center and the current computer room that successfully trigger the dispatch task.
2. The task scheduling method under the remote multi-active architecture according to claim 1 is characterized in that: The registration process of the executor node includes: When any executor node is detected to register with the corresponding dispatch center according to the pre-configured dispatch center address, the SQL statement reported by the executor node during registration is intercepted; The computer room identifier corresponding to the computer room of the scheduling center to be registered is added to the SQL statement, so that the executor node registers with the scheduling center to be registered using the SQL statement with the computer room identifier added.
3. The task scheduling method under the remote multi-active architecture according to claim 2 is characterized in that: The adding of the computer room identifier corresponding to the computer room of the dispatching center to be registered in the SQL statement includes: Determine whether there is a computer room identifier in the SQL statement; If it does not exist, insert the computer room identifier corresponding to the computer room of the dispatch center to be registered into the SQL statement; If it exists, determining whether the computer room identifier is the computer room identifier corresponding to the computer room of the dispatch center to be registered; If yes, the executor node is allowed to register with the scheduling center to be registered; Otherwise, the computer room identifier is updated according to the computer room identifier corresponding to the computer room of the dispatching center to be registered.
4. The task scheduling method under the remote multi-active architecture according to claim 1 is characterized in that: The determining whether the current dispatch center has a registered target executor includes: Intercepting the task list query statement sent by the current scheduling center when querying the database for the current scheduling task, and obtaining the node field in the registration table saved by the database; Determine whether the task list query statement contains the node field; If included, determining that the current dispatch center has a registered target executor; If not, it is determined that there is no registered target executor in the current scheduling center.
5. The task scheduling method under the remote multi-active architecture according to claim 1 is characterized in that: After allowing the target executor to execute the scheduling task for the current computer room, the method further includes: When it is detected that the target executor completes the scheduled task, the next task scheduling time sent by the database is updated and the database lock is released.
6. The task scheduling method under the remote multi-active architecture according to claim 1 is characterized in that: The switching of the current dispatch center and the current computer room includes: The database lock seized by the current dispatching center when the dispatching task is successfully triggered is released, and the dispatching center and the corresponding computer room that successfully seized the database lock from the dispatching centers corresponding to computer rooms deployed in different regions are re-acquired; The current dispatching center and the current computer room are switched to the dispatching center and the corresponding computer room that successfully seize the database lock in this round.
7. A task scheduling device under a remote multi-active architecture, characterized in that: include: An acquisition module is used to acquire the current dispatch center and current computer room that successfully trigger the dispatch task when it is detected that the dispatch centers corresponding to computer rooms deployed in different regions have met the task triggering conditions; A first judgment module is used to judge whether there is a registered target executor in the current scheduling center when monitoring that the current scheduling center queries the database for the current scheduling task, and the target executor is an executor node including the computer room identifier of the current computer room; A second judgment module is used to, if present, determine whether the computer room identifier contained in the target executor is the computer room identifier of the current computer room when it is detected that the current scheduling center sends the queried scheduling task to the target executor and when the target executor executes the scheduling task on the current computer room; A first scheduling module, configured to allow the target executor to execute the scheduling task on the current computer room if yes; A second scheduling module is used for not allowing the target executor to execute the scheduling task for the current computer room otherwise; A switching module, used for switching the current dispatch center and the current computer room if they do not exist, and returning to the step of determining whether there is a registered target executor in the current dispatch center when the current dispatch center queries the database for the current dispatch task after the switching; The acquisition module comprises: Determine the dispatch center and the corresponding computer room that successfully seize the database lock among the dispatch centers corresponding to computer rooms deployed in different regions, and use the dispatch center and the corresponding computer room that successfully seize the database lock as the current dispatch center and the current computer room that successfully trigger the dispatch task.
8. A storage medium, characterized in that: The storage medium stores computer-readable instructions, and when the computer-readable instructions are executed by one or more processors, the one or more processors execute the steps of the task scheduling method under the multi-active architecture as described in any one of claims 1 to 6.
9. A computer device, characterized in that: include: one or more processors, and memory; The memory stores computer-readable instructions, and when the computer-readable instructions are executed by the one or more processors, the steps of the task scheduling method under the multi-active architecture according to any one of claims 1 to 6 are performed.
