Disclosure of Invention
The embodiment of the application provides a multi-activity method and a multi-activity system for software unit deployment, and aims to improve the resource utilization rate in a distributed system for software unit deployment.
In a first aspect, an embodiment of the present application provides a multi-activity method for software unit deployment, including: the method is applied to a first processing unit and a second processing unit which is in communication connection with the first processing unit, wherein the first processing unit comprises a database and a plurality of application programs, the second processing unit comprises a database and a plurality of application programs, the database of the first processing unit periodically synchronizes data to the database of the second processing unit, and the method comprises the following steps;
the first processing unit acquires a request task and determines the running state of a current application program currently used for executing the request task in the process of executing the request task;
if the current application program is down, the first processing unit calls a target application program corresponding to the current application program from the second processing unit;
under the condition that the target application program is successfully called, the first processing unit sends the subtasks processed by the current application program in the request task to the target application program;
the second processing unit executes the subtask through the target application program and sends a result of executing the subtask to the first processing unit;
and the first processing unit receives the result of the subtask, and calls a corresponding application program from the plurality of application programs based on the remaining uncompleted subtasks in the request task to complete the uncompleted subtasks.
Optionally, the first processing unit and the second processing unit are communicatively connected through a gateway, and the method further includes:
when the gateway transmits the subtask, writing a unit identifier for processing the first processing unit into the subtask;
sending a result of executing the subtask to the first processing unit, including:
and the second processing unit sends the result of the subtask to the first processing unit based on the unit identifier of the first processing unit.
Optionally, the second processing unit executes the subtasks through the target application, including:
and when the target application program processes the subtasks, calling related data from the database, and executing the subtasks based on the called data.
Optionally, the method further comprises the step of,
acquiring timeliness marks of a task to be processed, wherein the timeliness marks comprise strong timeliness marks and weak timeliness marks, and the timeliness marks are preset in the task to be processed;
judging the timeliness of the adjusting task based on the timeliness identification;
and distributing the task to be processed to a first processing unit or a second processing unit based on the timeliness of the task to be processed.
Optionally, the allocating the to-be-processed task to the first processing unit or the second processing unit based on the timeliness of the to-be-processed task includes:
if the timeliness of the task to be processed is the first timeliness, the task to be processed is distributed to a first processing unit;
and if the timeliness of the task to be processed is the second timeliness, distributing the task to be processed to the first processing unit and the second processing unit based on a fixed proportion value.
Optionally, the method further comprises the step of,
if all the application programs in the first processing unit are down, the first processing unit sends the request task to the second processing unit, the second processing unit processes the request task sent by the first processing unit, and the second processing unit calls the database of the first processing unit.
In a second aspect, a software unitized deployment multi-active system in an embodiment of the present application includes an operating state obtaining module, a calling module, a subtask sending module, a result returning module, a remaining task executing module, a timeliness allocating module, and an overall calling module;
the running state acquisition module is used for acquiring a request task at the first processing unit and determining the running state of a current application program currently used for executing the request task in the process of executing the request task;
the calling module is used for calling a target application program corresponding to the current application program from the second processing unit by the first processing unit when the current application program is down;
the subtask sending module is used for sending the subtask processed by the current application program in the request task to the target application program by the first processing unit under the condition that the target application program is called successfully;
a result returning module, configured to execute the subtask by the second processing unit through the target application program, and send a result of executing the subtask to the first processing unit;
the first processing unit receives the result of the subtask, and calls a corresponding application program from the plurality of application programs to complete the uncompleted subtask based on the remaining uncompleted subtask in the request task;
the timeliness allocation module is used for acquiring timeliness marks of the tasks to be processed, wherein the timeliness marks comprise strong timeliness marks and weak timeliness marks, and the timeliness marks are preset in the tasks to be processed; judging the timeliness of the adjusting task based on the timeliness identification; and distributing the task to be processed to a first processing unit or a second processing unit based on the timeliness of the task to be processed.
And the integral calling module is used for sending the request task of the first processing unit to the second processing unit, the second processing unit processes the request task sent by the first processing unit, and the second processing unit calls the database of the first processing unit.
Has the advantages that: according to the method, after the first processing unit acquires the request task, the running state of the current application program for executing the request task is determined, and if the running state of the current application program is in a problem, the first processing unit cannot process the request task; then the first processing unit calls a target application program corresponding to the current application program from the second processing unit, and sends the subtasks processed by the first processing unit to the target application program for processing, the target application program in the second processing unit returns the result obtained by processing the subtasks to the first processing unit, and the first processing unit can continue processing based on the result to complete the uncompleted subtasks to complete the request task; when a problem occurs in a current application program in a first processing unit, a request task is divided into a plurality of subtasks, and a target application program corresponding to the current application program in a second processing unit is called to process a part of subtasks, in the process of processing the request task, the first processing unit only calls a part of application programs in the second processing unit, and the application program which does not have the problem in the first processing unit does not run empty, so that the continuity of the request task is ensured, and the effect of improving the resource utilization rate in a distributed system deployed in a software unitization mode is achieved.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are some, but not all, embodiments of the present application. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
Example one
Referring to fig. 1, a flowchart illustrating steps of a multi-activity method for software unit deployment in an embodiment of the present invention is shown, where, as shown in fig. 1, the multi-activity method is applied to a first processing unit and a second processing unit communicatively connected to the first processing unit, the first processing unit includes a database and a plurality of applications, the second processing unit includes a database and a plurality of applications, and the database of the first processing unit periodically synchronizes data to the database of the second processing unit;
the first processing unit and the second processing unit are distributed software systems, and a plurality of application programs in the first processing unit and the second processing unit are consistent, can complete the same processing logic, and have high availability; and the database of the second processing unit is regarded as a backup of the database of the first processing unit, and the database of the first processing unit synchronizes data to the database of the second processing unit periodically.
The multi-activity method may specifically include the following steps;
s101, the first processing unit acquires a request task and determines the running state of a current application program currently used for executing the request task in the process of executing the request task;
the first processing unit is a main processing unit in the distributed software system, under normal conditions, the request tasks are processed by the first processing unit, and the second processing unit is generally regarded as a standby processing unit in the distributed software system; when processing a request task, firstly, a first processing unit is considered to be adopted to process the request task; in the processing process, it is necessary to determine whether the application program in the first processing unit has a problem when executing the request task, and if the running state of the current application program in the first processing unit for executing the request task has a problem, further processing is necessary.
S102, if the current application program is down, the first processing unit calls a target application program corresponding to the current application program from the second processing unit;
through the application state obtained in step S101, if the current application program is down, the first processing unit cannot continue to execute the request task, and in order to complete the request task, the target application program corresponding to the current application program in the second processing unit needs to be called for processing.
S103, under the condition that the target application program is successfully called, the first processing unit sends the subtasks processed by the current application program in the request task to the target application program;
by dividing the request task into a plurality of subtasks, when the target application program in the second processing unit is called to process the request task, the whole request task does not need to be transferred to the second processing unit, but only the subtask which is in the process of being executed by the current application program and has a problem in the first processing unit needs to be sent to the target application program in the second processing unit.
S104, the second processing unit executes the subtasks through the target application program and sends the result of executing the subtasks to the first processing unit;
and after receiving the subtasks which cannot be processed in the first processing unit, the second processing program calls the target application program to execute the subtasks, only calls the target application program corresponding to the subtasks in the second processing unit in the process of executing the subtasks, and simultaneously connects the database of the first processing unit with the target application program to call corresponding data so as to prevent no data call caused by data synchronization delay.
S105, the first processing unit receives the result of the subtasks, and calls corresponding application programs from the plurality of application programs based on the remaining uncompleted subtasks in the request task to complete the uncompleted subtasks.
After the second processing unit calls the target application program to complete the subtasks, the first processing unit can call the corresponding application program from the plurality of application programs to continue to complete the unfinished subtasks in the request task through the received result of the subtasks so as to complete the processing of the request task.
In this embodiment, after the first processing unit obtains the request task, the running state of the current application program for executing the request task is determined first, and if the running state of the current application program is in a problem, the first processing unit cannot process the request task; then the first processing unit calls a target application program corresponding to the current application program from the second processing unit, and sends the subtasks processed by the first processing unit to the target application program for processing, the target application program in the second processing unit returns the result obtained by processing the subtasks to the first processing unit, and the first processing unit can continue processing based on the result to complete the uncompleted subtasks to complete the request task; when the current application program in the first processing unit has a problem, the request task is divided into a plurality of subtasks, and a target application program corresponding to the current application program in the second processing unit is called to process a part of subtasks.
In the process of processing the request task, the first processing unit only calls part of the application programs in the second processing unit, and the application programs which have no problem in the first processing unit do not run empty, so that the continuity of the request task is ensured, and the effect of improving the resource utilization rate in the software unit-based deployed distributed system is achieved.
Example two
The embodiment provides a multi-activity method for software unit deployment, which is applied to a distributed software system for software unit deployment.
Software unitization deployment is a high-availability scheme of a commonly used distributed software system at present, and the principle of the software unitization deployment is that a plurality of application programs supporting complete business logic form a unit, then a request task is divided into a plurality of parts according to a certain rule, and each part is handled by one unit.
For example, if a trading system includes a plurality of trading units, each trading unit is composed of five application programs; when the transaction system is deployed in a unitized mode, dividing according to regions; all transaction request tasks of the Xian area are handed to one transaction unit deployed in the Xian area for processing, and all transactions of the Beijing area are processed by the other unit deployed in the background area. In this way, even if a certain unit fails, the influence degree is only one region corresponding to the unit, and the user in the whole country cannot be influenced.
As shown in fig. 2, fig. 2 illustrates a structure of a distributed system deployed by software unitization according to an embodiment of the present application; the system comprises a first processing unit, a second processing unit and a gateway; the first processing unit and the second processing unit are in communication connection through a gateway, the first processing unit comprises a database, an application program A, an application program B, an application program C and an application program D, the second processing unit also comprises a database, an application program A, an application program B, an application program C and an application program D, the first processing unit and the second processing unit are consistent in structure, and the combined request tasks of the application program A, the application program B, the application program C and the application program D can be consistent; however, the first processing unit and the second processing unit are deployed in different regions, and the processing request tasks are different during the use process, so that the data in the databases of the first processing unit and the second processing unit are different. The gateway is used in the system to complete communication, access and distribute the request tasks.
Referring to fig. 1, a flowchart illustrating steps of a multi-activity method for software unit deployment according to an embodiment of the present application is shown, and as shown in fig. 1, the multi-activity method may specifically include the following steps:
s101, the first processing unit acquires a request task and determines the running state of a current application program currently used for executing the request task in the process of executing the request task;
when the request task is obtained, the request task firstly enters the system through the gateway and then enters the distribution through the gateway; after the first processing unit receives the task, the first processing unit processes the request task through an application program A, an application program B, an application program C and an application program D in the first processing unit, in the processing process, the running states of a plurality of application programs in the first processing unit in the processing process need to be continuously determined, and in the determining process, the state of the application program needs to be determined according to where the request task is processed.
S102, if the current application program is down, the first processing unit calls a target application program corresponding to the current application program from the second processing unit;
if the request task is processed in the application program B, the application program B is the current application program; if the application program B can be determined to be down through the step S101, the down of the application program B may cause that the requested task cannot be completed only by the first processing unit, and at this time, the application program B in the second processing unit needs to be called to process the requested task; the application program B in the second processing unit corresponds to the application program B in the first processing unit, and in the process of processing the request task, the work that the application program B in the first processing unit and the application program B in the second processing unit can complete is the same, and at this time, the application program B in the second processing unit is the target application program.
S103, under the condition that the target application program is successfully called, the first processing unit sends the subtasks processed by the current application program in the request task to the target application program;
in the first processing unit, dividing the request task into a plurality of sub-tasks for processing, and when an application program B in the first processing unit is down, the first processing unit calls the application program B in the second processing unit to process the sub-tasks; when the application program B is called, the first processing unit directly sends the subtask which is being processed by the application program B in the first processing unit to the second processing unit, and the subtask is processed by the target application program in the second processing unit.
S104, the second processing unit executes the subtasks through the target application program and sends the result of executing the subtasks to the first processing unit;
and after the second processing unit receives the subtasks sent by the first processing unit, the second processing unit executes the subtasks through the target application program in the second processing unit, and sends the execution result to the first processing unit after the execution is finished.
And when the target application program processes the subtasks, related data are called from the database, and the subtasks are executed based on the called data.
The subtask processed by the second processing unit is separated from the request task processed by the first processing unit, and at this time, the second processing unit does not have data for processing the request task, and at this time, the second processing unit needs to be connected to the database of the first processing unit, and the gateway calls the relevant data in the first processing unit to complete the execution of the subtask.
S105, the first processing unit receives the result of the subtasks, and calls corresponding application programs from the plurality of application programs based on the remaining uncompleted subtasks in the request task to complete the uncompleted subtasks.
In the whole process of processing the request task, because only the application program B in the first processing unit is down, other application programs may be still in a live state at this time, and after the result of calling the application program in the second processing unit to process the sub-task is obtained through the above scheme, the application program in the first processing unit that is still in the live state can continue to process the request task following the result of calling the application program in the second processing unit to process the sub-task; the application programs in the first processing unit which are still in the survival state can not be wasted, and therefore the resource utilization rate of the distributed system deployed in the software unitization mode is improved.
In this implementation, the multi-activity method further comprises:
when the gateway transmits the subtask, writing a unit identifier for processing the first processing unit into the subtask;
sending a result of executing the subtask to the first processing unit, including:
and the second processing unit sends the result of the subtask to the first processing unit based on the unit identifier of the first processing unit.
By writing the unit identifier of the first processing unit into the subtask, the application program in the second processing unit can determine the source of the subtask when processing the subtask, determine that the requested task that is separated from the subtask is processed in the first processing unit, and return the result generated by processing the subtask to the first processing unit.
Acquiring timeliness marks of a task to be processed, wherein the timeliness marks comprise strong timeliness marks and weak timeliness marks, and the timeliness marks are preset in the task to be processed;
in this embodiment, the task to be processed is a request task; in a distributed system deployed in software unitization, because the required data of each task to be processed is different, the data in the first processing unit is updated more than the data in the second processing unit most of the time; therefore, when the timeliness identification of the tasks to be processed is preset, the timeliness of each task to be processed is set.
Judging the timeliness of the adjusting task based on the timeliness identification;
the timeliness of the tasks to be processed is divided into two types, the first type is the task to be processed with extremely strong timeliness, and the task to be processed can be processed only when updated data is needed, and is preset as the first timeliness; the second is a task to be processed with a low timeliness, and data that is a little bit behind can be processed compared with the first. But as long as the database update frequency between the first processing unit and the second processing unit is high, the data difference between the databases of the first processing unit and the second processing unit is not too large, and even the second processing unit can process most of the tasks to be processed.
Distributing the task to be processed to a first processing unit or a second processing unit based on the timeliness of the task to be processed; the method comprises the following steps:
if the timeliness of the task to be processed is the first timeliness, the task to be processed is distributed to a first processing unit;
and if the timeliness of the task to be processed is the second timeliness, distributing the task to be processed to the first processing unit and the second processing unit based on a fixed proportion value.
The first timeliness is a task to be processed with extremely strong timeliness in the embodiment, corresponds to a strong timeliness identifier, and needs to be processed in a shorter time; the first processing unit is preset as a processing unit with stronger processing capacity in the embodiment, and can process more request tasks in shorter time compared with the second processing unit; the second timeliness corresponds to the weak timeliness identification, and the processing time is longer; the first time-efficient tasks to be processed are all allocated to the first processing unit and the second time-efficient tasks to be processed are allocated to the second processing unit.
The fixed proportion value can be a proportion preset by maintenance personnel and is judged according to actual conditions; for example, if the first timeliness task to be processed is less in the area where the first processing unit is deployed within a period of time, the fixed proportion value is set to be larger, and the second timeliness task is allocated to the first processing unit and the second processing unit for processing according to the fixed proportion value of 2: 1; if the first timeliness tasks to be processed are more in the area where the first processing unit is deployed within a period of time, the fixed proportion value is set to be smaller, and the second timeliness tasks are distributed to the first processing unit and the second processing unit according to the fixed proportion value of 1: 2; by performing allocation in this manner, the computational resources in the first processing unit can be utilized to the maximum extent, and the resource utilization rate can be improved.
The multi-activity method further includes that if all the applications in the first processing unit are down, the first processing unit sends the request task to the second processing unit, the second processing unit processes the request task sent by the first processing unit, and the second processing unit calls the database of the first processing unit.
When all the application programs in the first processing unit are down, and the first processing unit cannot process the request tasks distributed to the first processing unit at the moment, the request tasks are wholly transferred to the second processing unit for processing, and the processing of the request tasks cannot be influenced.
If the database of the first processing unit cannot be used at the same time, the second processing unit calls the database of the second processing unit to execute the query operation, and because the database of the second processing unit is used as the backup database of the first processing unit and the content of the database is backward than that of the database of the first processing unit, the adding, deleting and changing operations are prohibited from being executed.
In this embodiment, after the first processing unit obtains the request task, the running state of the current application program for executing the request task is determined first, and if the running state of the current application program is in a problem, the first processing unit cannot process the request task; then the first processing unit calls a target application program corresponding to the current application program from the second processing unit, and sends the subtasks processed by the first processing unit to the target application program for processing, the target application program in the second processing unit returns the result obtained by processing the subtasks to the first processing unit, and the first processing unit can continue processing based on the result to complete the uncompleted subtasks to complete the request task; when the current application program in the first processing unit has a problem, the request task is divided into a plurality of subtasks, and a target application program corresponding to the current application program in the second processing unit is called to process a part of subtasks.
In the process of processing the request task, the first processing unit only calls part of the application programs in the second processing unit, and the application programs which have no problem in the first processing unit do not run empty, so that the continuity of the request task is ensured, and the effect of improving the resource utilization rate in the software unit-based deployed distributed system is achieved.
EXAMPLE III
Based on the same inventive concept, fig. 3 is a schematic diagram of a multi-active system deployed by software unitization, and referring to fig. 3, the multi-active system may include:
the system comprises a running state acquisition module, a calling module, a subtask sending module, a result returning module, a residual task execution module, a timeliness distribution module and an overall calling module;
the running state acquisition module is used for acquiring a request task at the first processing unit and determining the running state of a current application program currently used for executing the request task in the process of executing the request task;
the calling module is used for calling a target application program corresponding to the current application program from the second processing unit by the first processing unit when the current application program is down;
the subtask sending module is used for sending the subtask processed by the current application program in the request task to the target application program by the first processing unit under the condition that the target application program is called successfully;
a result returning module, configured to execute the subtask by the second processing unit through the target application program, and send a result of executing the subtask to the first processing unit;
the first processing unit receives the result of the subtask, and calls a corresponding application program from the plurality of application programs to complete the uncompleted subtask based on the remaining uncompleted subtask in the request task;
the timeliness allocation module is used for acquiring timeliness marks of the tasks to be processed, wherein the timeliness marks comprise strong timeliness marks and weak timeliness marks, and the timeliness marks are preset in the tasks to be processed; judging the timeliness of the adjusting task based on the timeliness identification; and distributing the task to be processed to a first processing unit or a second processing unit based on the timeliness of the task to be processed.
And if all the application programs in the first processing unit are down, the first processing unit sends the request task to the second processing unit, the second processing unit processes the request task sent by the first processing unit, and the second processing unit calls the database of the first processing unit.
For the device embodiment, since it is basically similar to the method embodiment, the description is simple, and for the relevant points, refer to the partial description of the method embodiment.
The embodiments in the present specification are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other.
As will be appreciated by one of skill in the art, embodiments of the present application may be provided as a method, apparatus, or computer program product. Accordingly, embodiments of the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, embodiments of the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
Embodiments of the present application are described with reference to flowchart illustrations and/or block diagrams of methods, terminal devices (systems), and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing terminal to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing terminal, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing terminal to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing terminal to cause a series of operational steps to be performed on the computer or other programmable terminal to produce a computer implemented process such that the instructions which execute on the computer or other programmable terminal provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
While preferred embodiments of the present application have been described, additional variations and modifications of these embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. Therefore, it is intended that the appended claims be interpreted as including the preferred embodiment and all such alterations and modifications as fall within the true scope of the embodiments of the application.
Finally, it should also be noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or terminal that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or terminal. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or terminal that comprises the element.
The principle and the implementation of the present application are explained herein by applying specific examples, and the above description of the embodiments is only used to help understand the method and the core idea of the present application; meanwhile, for a person skilled in the art, according to the idea of the present application, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present application.