Method and apparatus for invoking multi-server timed tasks
Patent Information
- Application Number
- CN202111079768.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-15
- Publication Date
- 2025-08-01
- Estimated Expiration
- 2041-09-15
AI Technical Summary
[0005]如图2所示,现拓展为每个Node上部署两个server,那么,每个node上的两个server就会读取相同的配置文件,从而导致定时任务执行时间一致,引发重复执行的问题
[0016] In an embodiment of the present invention, in the multi-server timed task invocation solution, the application system includes at least two nodes, at least two application servers are installed on each node, and applications for realizing various service requirements are deployed on each application server. By: acquiring the pre-defined Java virtual machine (JVM) parameter information in the corresponding application server for each application; parsing out the corresponding timed task invocation parameter from the pre-defined JVM parameter information in the corresponding application server for each application; invoking the timed task according to the corresponding timed task invocation parameter for each application to perform relevant service processing, it can be realized that the timed parameter no longer depends on the traditional configuration file, but depends on the system JVM parameter of the application server. Furthermore, it is not necessary to pay attention to the differences of the configuration files, but to pay attention to the parameter configuration of the server itself, and the concurrent execution of multi-server timed tasks under the same configuration file is realized.
Smart Images

Figure CN113722049B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of distributed technologies, and in particular, to a method and device for invoking multi-server timed tasks. Background Art
[0002] This section aims to provide background or context for the embodiments of the present invention stated in the claims. The description herein is not admitted to be prior art merely because it is included in this section.
[0003] The application system is deployed through the WAS method. To ensure the normal provision of external services and maintain load balancing, there were originally two nodes, and one server (application server) was installed on each node. To prevent a single server from having problems and being unable to provide external services normally, each node now needs to be expanded to install two servers.
[0004] As Figure 1 shown, each application server reads its corresponding config.properties configuration file. Since the application needs to read the configuration file to execute timed tasks, to ensure that there is no duplicate execution, it is necessary to ensure that the configuration contents in the two config.properties are different. After the application is deployed, it is necessary to stop the application and modify the corresponding configuration file content, and at the same time, it is necessary to ensure that the nodes are not synchronized.
[0005] As Figure 2 shown, it is now expanded to deploy two servers on each node. Then, the two servers on each node will read the same configuration file, resulting in the same execution time for timed tasks and causing the problem of duplicate execution. Summary of the Invention
[0006] Embodiments of the present invention provide a method for invoking multi-server timed tasks to achieve concurrent execution of multi-server timed tasks under the same configuration file. The application system includes at least two nodes, at least two application servers are installed on each node, and applications for implementing various business requirements are deployed on each application server. The method includes:
[0007] Each application obtains the Java virtual machine jvm parameter information predefined in the corresponding application server;
[0008] Each application parses the corresponding timed task invocation parameter from the predefined jvm parameter information in the corresponding application server;
[0009] Each application invokes the timed task according to the corresponding timed task invocation parameter and performs relevant business processing.
[0010] An embodiment of the present invention further provides a multi-server timed task invocation device for realizing the concurrent execution of multi-server timed tasks under the same configuration file. The application system includes at least two nodes, at least two application servers are installed on each node, and applications for realizing various service requirements are deployed on each application server. The device includes:
[0011] An acquisition unit for acquiring the pre-defined Java virtual machine (JVM) parameter information in the corresponding application server for each application;
[0012] A determination unit for parsing out the corresponding timed task invocation parameter from the pre-defined JVM parameter information in the corresponding application server for each application;
[0013] An invocation unit for invoking the timed task according to the corresponding timed task invocation parameter for each application to perform relevant service processing.
[0014] An embodiment of the present invention further provides a computer device, including a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the computer program, the above-mentioned multi-server timed task invocation method is implemented.
[0015] An embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored. When the program is executed by a processor, the steps of the above-mentioned multi-server timed task invocation method are implemented.
[0016] In an embodiment of the present invention, in the multi-server timed task invocation solution, the application system includes at least two nodes, at least two application servers are installed on each node, and applications for realizing various service requirements are deployed on each application server. By: acquiring the pre-defined Java virtual machine (JVM) parameter information in the corresponding application server for each application; parsing out the corresponding timed task invocation parameter from the pre-defined JVM parameter information in the corresponding application server for each application; invoking the timed task according to the corresponding timed task invocation parameter for each application to perform relevant service processing, it can be realized that the timed parameter no longer depends on the traditional configuration file, but depends on the system JVM parameter of the application server. Furthermore, it is not necessary to pay attention to the differences of the configuration files, but to pay attention to the parameter configuration of the server itself, and the concurrent execution of multi-server timed tasks under the same configuration file is realized. Description of the Drawings
[0017] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the accompanying drawings required for the description of the embodiments or the prior art. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other drawings can be obtained based on these drawings. In the drawings:
[0018] Figure 1 It is a schematic diagram of the scheduling of timed tasks when installing one server on each node in the prior art;
[0019] Figure 2 It is a schematic diagram of the scheduling of timed tasks when deploying two servers on each Node in the prior art;
[0020] Figure 3 It is a schematic diagram of the scheduling of timed tasks when deploying two servers on each Node in the embodiment of the present invention;
[0021] Figure 4 It is a schematic flowchart of the method for scheduling timed tasks of multiple servers in the embodiment of the present invention;
[0022] Figure 5 It is a schematic structural diagram of the device for scheduling timed tasks of multiple servers in the embodiment of the present invention. Detailed implementation manners
[0023] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer and more understandable, the following will further describe the embodiments of the present invention in detail with reference to the accompanying drawings. Herein, the illustrative embodiments of the present invention and their descriptions are used to explain the present invention, but not to limit the present invention.
[0024] Before introducing the embodiments of the present invention, the terms related to the embodiments of the present invention will be introduced first.
[0025] 1. WAS: Websphere Application Server, which is a set of application server environments based on Java Enterprise Edition (Java EE) Runtimes provided by IBM.
[0026] 2. profile: A profile file that physically separates the files of WAS itself from the user's data files to strengthen management and reduce the possibility of errors.
[0027] 3. server: An application server, which is the smallest processing unit.
[0028] 4. Node: A node is a group of one or more Servers. A Node can only exist on one physical machine and cannot span multiple machines. It is basically equivalent to a Profile. A Node is a management concept, while a Profile is an actual profile file.
[0029] 5. Cell: A cell is a group of one or more Nodes and is the largest scope.
[0030] 6. Application: An application. Multiple applications can be deployed on each server application server.
[0031] The technical problem discovered by the inventor is as follows: It can be considered that each server is deployed on a different node. After the application is deployed, stop the application and modify the config.properties configuration file in each server's deployed application, ensuring that the content is different and the nodes cannot be synchronized, so as to achieve the concurrent execution of multi-server timed tasks. However, this will increase the workload during the deployment process and is prone to repeated execution due to operation errors.
[0032] Since the inventor discovered the above technical problem, a multi-server timed task invocation scheme is proposed, as Figure 3 shown. This scheme modifies the timed task trigger parameter (such as the timed task trigger time) from originally reading the config.properties configuration file parameter to obtaining it through the jvm parameter information defined in the server, thereby shielding the differences in parameter information that cause different configuration files, and then solving the problem of concurrent execution of multi-server timed tasks. The applications on each node can be synchronized, and there is no need to stop the application and modify the configuration file separately. The following is a detailed introduction to this multi-server timed task invocation scheme.
[0033] Figure 4 This is a schematic flowchart of the multi-server timed task invocation method in an embodiment of the present invention. The application system includes at least two nodes. At least two application servers are installed on each node, and applications for implementing various business requirements are deployed on each application server, as Figure 4 shown. The method includes the following steps:
[0034] Step 101: Each application obtains the Java virtual machine jvm parameter information predefined in the corresponding application server.
[0035] Step 102: Each application parses the corresponding timed task invocation parameter from the jvm parameter information predefined in the corresponding application server.
[0036] Step 103: Each application invokes the timed task according to the corresponding timed task invocation parameter and performs relevant business processing.
[0037] In an embodiment of the present invention, in the multi-server timed task invocation scheme, the application system includes at least two nodes, at least two application servers are installed on each node, and applications for implementing various service requirements are deployed on each application server. By: each application obtains the Java virtual machine (JVM) parameter information predefined in the corresponding application server; each application parses out the corresponding timed task invocation parameter from the predefined JVM parameter information in the corresponding application server; each application invokes the timed task according to the corresponding timed task invocation parameter to perform relevant service processing, it can be realized that the timed parameters no longer depend on the traditional configuration file, but depend on the system JVM parameters of the application server. Furthermore, there is no need to pay attention to the differences in the configuration files, but to pay attention to the parameter configuration of the server itself, realizing the concurrent execution of multi-server timed tasks under the same configuration file. The following is a detailed introduction.
[0038] In one embodiment, the above multi-server timed task invocation method may further include predefined JVM parameter information in each application server according to the following method: before starting or deploying the application, define relevant JVM parameter information in the application server corresponding to the application.
[0039] In specific implementation, applications are deployed on the server, and the applications implement various service requirements. Before the application starts or is deployed, relevant JVM parameter information needs to be defined in the server. In the application, the corresponding timed task is invoked by obtaining the corresponding JVM parameter information.
[0040] In specific implementation, the characteristic parameters of the applications on each server are extracted into the JVM (JVM is the abbreviation of Java Virtual Machine) parameter information corresponding to the server, which is convenient for parameter maintenance, shields the differences of each configuration file, reduces the error rate of manual operations, and saves the deployment cost at the same time.
[0041] In one embodiment, the timed task invocation parameter may include: the timed task invocation time.
[0042] In specific implementation, relevant parameters such as the timed task invocation time are defined in the server JVM parameters.
[0043] In one embodiment, the number of the nodes may be two, and two application servers may be installed on each node.
[0044] In specific implementation, as Figure 3 shown, in the embodiment of the present invention, the number of nodes may be two, and two application servers may be installed on each node, with reasonable configuration.
[0045] In specific implementation, in the above step 103, the JVM parameter information is used to trigger the scheduled task for relevant service processing. When obtaining the scheduled parameters in the application, the original method of obtaining from the configuration file is modified to obtain the relevant parameter information through the JVM parameters, and then the scheduled task is triggered for relevant service processing.
[0046] In summary, the method for triggering the multi-server scheduled task provided by the embodiment of the present invention no longer depends on the traditional configuration file for the scheduled parameters, but instead depends on the system JVM parameters of the server, thus eliminating the need to pay attention to the differences in the configuration files and focusing on the parameter configuration of the server itself, reducing the error rate of manual operations.
[0047] An embodiment of the present invention also provides a device for triggering a multi-server scheduled task, as described in the following embodiments. Since the principle of the device for solving the problem is similar to that of the method for triggering a multi-server scheduled task, the implementation of the device can refer to the implementation of the method for triggering a multi-server scheduled task, and the repeated parts will not be elaborated.
[0048] Figure 5 It is a schematic structural diagram of the device for triggering a multi-server scheduled task in an embodiment of the present invention. The application system includes at least two nodes, at least two application servers are installed on each node, and applications for implementing various service requirements are deployed on each application server; as Figure 5 shown, the device for triggering a multi-server scheduled task includes:
[0049] An obtaining unit 01, configured to obtain the pre-defined Java virtual machine JVM parameter information in the corresponding application server for each application;
[0050] A determining unit 02, configured to parse the corresponding scheduled task triggering parameter from the pre-defined JVM parameter information in the corresponding application server for each application;
[0051] A triggering unit 03, configured to trigger the scheduled task for relevant service processing according to the corresponding scheduled task triggering parameter for each application.
[0052] In one embodiment, the scheduled task triggering parameter may include: the scheduled task triggering time.
[0053] In one embodiment, the above device for triggering a multi-server scheduled task may further include a pre-defining unit, configured to pre-define the JVM parameter information in each application server according to the following method: before starting or deploying the application, define the relevant JVM parameter information in the application server corresponding to the application.
[0054] In one embodiment, the number of nodes may be two, and two application servers may be installed on each node.
[0055] An embodiment of the present invention further provides a computer device, including a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the computer program, the above-mentioned multi-server timed task invocation method is implemented.
[0056] An embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored. When the program is executed by a processor, the steps of the above-mentioned multi-server timed task invocation method are implemented.
[0057] In an embodiment of the present invention, in the multi-server timed task invocation solution, the application system includes at least two nodes. At least two application servers are installed on each node, and applications for implementing various service requirements are deployed on each application server. By: each application obtains the Java virtual machine (JVM) parameter information predefined in the corresponding application server; each application parses the corresponding timed task invocation parameter from the predefined JVM parameter information in the corresponding application server; each application invokes the timed task according to the corresponding timed task invocation parameter to perform relevant service processing, it can be realized that the timed parameters no longer depend on the traditional configuration file, but instead depend on the system JVM parameters of the application server. Furthermore, there is no need to pay attention to the differences in the configuration files, but instead focus on the parameter configuration of the server itself, and the concurrent execution of multi-server timed tasks under the same configuration file is achieved.
[0058] Those skilled in the art should understand that the embodiments of the present invention can be provided as a method, a system, or a computer program product. Therefore, the present invention can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present invention can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0059] The present invention is described with reference to the flowcharts and / or block diagrams of methods, apparatuses (systems), and computer program products according to embodiments of the present invention. It should be understood that each flow and / or block in the flowcharts and / or block diagrams, as well as the combination of flows and / or blocks in the flowcharts and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing devices to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing devices generate means for implementing the functions specified in one Figure 1 one flow or multiple flows and / or blocks Figure 1 one block or multiple blocks.
[0060] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to operate in a particular manner, such that the instructions stored in the computer-readable memory produce a manufacture including an instruction means that implements the functions specified in one or more of the processes Figure 1 or blocks. Figure 1
[0061] These computer program instructions can also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer-implemented process, whereby the instructions executed on the computer or other programmable apparatus provide steps for implementing the functions specified in one or more of the processes Figure 1 or blocks. Figure 1
[0062] The specific embodiments described above further elaborate on the objectives, technical solutions, and beneficial effects of the present invention. It should be understood that the above are only specific embodiments of the present invention and are not used to limit the protection scope of the present invention. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present invention shall be included within the protection scope of the present invention.
Claims
1. A method for invoking multi-server timed tasks, characterized in that, The application system includes at least two nodes, at least two application servers are installed on each node, and applications for implementing various business requirements are deployed on each application server; the multi-server scheduled task invocation method includes: Each application obtains the predefined Java virtual machine jvm parameter information in the corresponding application server; wherein, the characteristic parameters of the applications on each application server are extracted into the jvm parameter information corresponding to the application server; before starting or deploying the application, the relevant jvm parameter information is defined in the application server corresponding to the application. Each application parses out the corresponding scheduled task invocation parameter from the predefined jvm parameter information in the corresponding application server. Each application invokes the scheduled task according to the corresponding scheduled task invocation parameter to perform relevant business processing. Wherein, the scheduled task invocation parameter includes: the scheduled task invocation time.
2. The multi-server timed task invocation method according to claim 1, wherein The number of the nodes is two, and two application servers are installed on each node.
3. A multi-server timed task invocation device, characterized in that, The application system includes at least two nodes, at least two application servers are installed on each node, and applications for implementing various business requirements are deployed on each application server; the multi-server scheduled task invocation device includes: An acquisition unit, configured to obtain, for each application, the predefined Java virtual machine jvm parameter information in the corresponding application server. A determination unit, configured to parse out the corresponding scheduled task invocation parameter from the predefined jvm parameter information in the corresponding application server for each application. An invocation unit, configured to invoke the scheduled task according to the corresponding scheduled task invocation parameter for each application to perform relevant business processing. It further includes a predefined unit, configured to predefine the jvm parameter information in each application server according to the following method: extract the characteristic parameters of the applications on each application server into the jvm parameter information corresponding to the application server; before starting or deploying the application, define the relevant jvm parameter information in the application server corresponding to the application. Wherein, the scheduled task invocation parameter includes: the scheduled task invocation time.
4. The multi-server timed task invocation device according to claim 3, wherein The number of the nodes is two, and two application servers are installed on each node.
5. A computer device, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the method according to claim 1 or 2.
6. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the steps of the method according to claim 1 or 2.
Citation Information
Patent Citations
A data processing method and apparatus
CN109032796A