Disclosure of Invention
The invention aims to overcome the defect of high coupling degree of a plug-in of an integrated system in the prior art, and provides a plug-in loading method, a device, electronic equipment and a storage medium.
The invention solves the technical problems by the following technical scheme:
in a first aspect, a plug-in loading method is provided, and the plug-in loading method is applied to an integrated system, wherein the integrated system comprises a plurality of mutually independent plug-ins, each plug-in is used for realizing a service function, and each plug-in comprises an execution task for realizing the service function; the plug-in loading method comprises the following steps:
Determining a target plug-in for responding to the business service request under the condition of receiving the business service request;
And activating the execution task of the target plug-in to start a thread by the activated execution task, so as to realize the response to the business service request.
Optionally, the executing the task includes: built-in tasks and custom tasks;
Logic codes of built-in tasks of all plug-ins are the same;
the logic code of the custom task corresponds to the business function of the plug-in unit to which the logic code belongs.
Optionally, the number of built-in tasks is a plurality; activating the execution task of the target plug-in, including:
activating all or part of the built-in tasks in the plurality of built-in tasks, wherein each activated built-in task starts a thread;
and/or the number of the custom tasks is a plurality of; activating the execution task of the target plug-in, including:
All or part of built-in tasks in the custom tasks are activated, and each activated custom task starts a thread.
Optionally, the method further comprises:
And modifying the custom task according to the first modification request under the condition that the first modification request aiming at the custom task is received.
Optionally, each plug-in further includes configuration information;
The configuration information is used for determining adjustable parameters in the logic code for executing the task.
Optionally, the method further comprises:
in the case of receiving a second modification request for the configuration information, modifying the configuration information according to the second modification request.
In a second aspect, a plug-in loading device is provided, and is applied to an integrated system, wherein the integrated system comprises a plurality of mutually independent plug-ins, each plug-in is used for realizing a service function, and each plug-in comprises an execution task for realizing the service function; the plug-in loading method comprises the following steps:
The system comprises a determining module, a determining module and a processing module, wherein the determining module is used for determining a target plug-in for responding to a business service request under the condition of receiving the business service request;
And the activation module is used for activating the execution task of the target plug-in to start a thread by the activated execution task and realize the response to the business service request.
Optionally, the executing the task includes: built-in tasks and custom tasks;
Logic codes of built-in tasks of all plug-ins are the same;
the logic code of the custom task corresponds to the business function of the plug-in unit to which the logic code belongs.
Optionally, the number of built-in tasks is a plurality; the activation module is specifically configured to:
activating all or part of the built-in tasks in the plurality of built-in tasks, wherein each activated built-in task starts a thread;
and/or the number of the custom tasks is a plurality of; the activation module is specifically used for:
All or part of built-in tasks in the custom tasks are activated, and each activated custom task starts a thread.
Optionally, the method further comprises:
And the first modification module is used for modifying the custom task according to the first modification request under the condition that the first modification request aiming at the custom task is received.
Optionally, each plug-in further includes configuration information;
The configuration information is used for determining adjustable parameters in the logic code for executing the task.
Optionally, the method further comprises:
and the second modification module is used for modifying the configuration information according to the second modification request under the condition that the second modification request aiming at the configuration information is received.
In a third aspect, an electronic device is provided, including a memory, a processor, and a computer program stored on the memory and executable on the processor, the processor implementing any of the above plug-in loading methods when executing the computer program.
In a fourth aspect, a computer readable storage medium is provided, on which a computer program is stored, which when executed by a processor implements the plug-in loading method according to any of the preceding claims.
The invention has the positive progress effects that: in the embodiment of the invention, the plug-in loaded by the integrated system has no dependency relationship with other plug-ins, namely, each plug-in is mutually independent, and each plug-in only realizes one service function, so that the modification or failure of one plug-in does not influence other plug-ins, does not influence or has little influence on the whole integrated system, and ensures the running stability of the integrated system.
Detailed Description
The invention is further illustrated by means of the following examples, which are not intended to limit the scope of the invention.
The embodiment of the invention provides a plug-in loading method, which is applied to an integrated system, wherein the integrated system can be but is not limited to a SCADA (Supervisory Control And Data Acquisition, data acquisition and monitoring control) system. The integrated system comprises a plurality of mutually independent plug-ins, each plug-in is used for realizing one business function, and each plug-in comprises an execution task for realizing the business function. Each plug-in may also include configuration information for determining adjustable parameters in the logic code that performs the task, such as the execution frequency, execution conditions, execution times, etc. of the task. The configuration information may be recorded in a configuration file of the plug-in.
In the embodiment of the invention, when developing the plugins of the integrated system, a developer splits the functions required to be expanded of the integrated system into the minimum functional units which can be independently realized by one plugin, and writes logic codes of the plugins for realizing the minimum functional units for each minimum functional unit, so that each plugin only realizes one service function, and each plugin is mutually independent, namely each plugin and other plugins have no dependency relationship. Because each plug-in unit only realizes one service function, and each plug-in unit is mutually independent, the function decoupling and service isolation of the plug-in units are realized, the plug-in units can be hot plugged, and the start and stop of one plug-in unit can not influence other plug-in units.
Fig. 1 is a flowchart of a plug-in loading method according to an exemplary embodiment of the present invention, where the plug-in loading method is implemented using the plug-ins developed as described above, and referring to fig. 1, the plug-in loading method includes the following steps:
step 101, in the case of receiving the business service request, determining a target plug-in for responding to the business service request.
Different business service requests, different implemented business functions and different required plug-ins. For example, for a business service request for data transmission, the required plug-in is a data transmission plug-in; for business service requests of data storage, the required plug-in is a data storage plug-in; for business service requests for data processing, the required plug-ins are data processing plug-ins.
In one embodiment, a correspondence between the business service request and the plugin may be preconfigured, and when the business service request is received, a target plugin corresponding to the received business service request is determined according to the correspondence.
It should be noted that, one business service request may correspond to one plug-in, or may correspond to a plurality of plug-ins, which is not limited in particular by the embodiment of the present invention.
And 102, activating an execution task of the target plug-in to start a thread by the activated execution task, so as to realize the response to the business service request.
In the embodiment of the invention, the plug-in loaded by the integrated system has no dependency relationship with other plug-ins, namely, each plug-in is mutually independent, and each plug-in only realizes one business function, namely, each plug-in works independently, so that the modification or failure of one plug-in does not influence other plug-ins, the whole integrated system is not influenced or influenced little, and the running stability of the integrated system is ensured. In addition, the mutually independent plug-ins are convenient to develop and maintain.
In one embodiment, performing the task includes: built-in tasks (actors) and custom tasks (tasks). Logic codes of built-in tasks of all plug-ins are the same; the logical code of the custom task corresponds to the business function of the plug-in to which it belongs.
When the plug-in is developed, the execution task is divided into a built-in task and a custom task, logic codes of the built-in task are written by a developer of the plug-in, and interfaces for editing all or part of logic codes of the custom task are provided for operation and maintenance personnel of the integrated system to write or modify the logic codes of the custom task according to actual requirements, so that personalized definition of service functions of the plug-in is realized, the functions are expanded, and the requirements of various use scenes are met.
The number of built-in tasks may be one or more. Also, the number of custom tasks may be one or more.
In one embodiment, the number of built-in tasks is multiple, and multiple built-in tasks can be activated simultaneously to start multiple threads, so as to realize service multithreading execution. Wherein each activated built-in task starts a thread.
In one embodiment, the number of custom tasks is multiple, and multiple custom tasks can be activated simultaneously to start multiple threads, so as to implement service multithreading. Wherein each activated custom task starts a thread.
In one embodiment, a modification interface of the custom task is opened for an operator of the integrated system, so that the operator can modify the logic code of the custom system. Specifically, the operation and maintenance personnel can send a first modification request for the custom task to the integrated system through the interface, and the integrated system modifies the custom task according to the first modification request under the condition that the first modification request for the custom task is received.
In one embodiment, a modification interface of the configuration information is opened for an operation and maintenance person of the integrated system, so that the operation and maintenance person can modify the configuration information of the execution task. Specifically, the operation and maintenance personnel can send a second modification request for the configuration information to the integrated system through the interface, and the integrated system modifies the configuration information according to the second modification request under the condition that the second modification request for the configuration information is received.
The modification interface of the custom task and the modification interface of the configuration information can adopt the same interface or two interfaces. The interface may be, for example, a page API (Application Programming Interface, application program interface) interface.
Fig. 2 is a schematic diagram of a scenario of a plug-in loading method according to an exemplary embodiment of the present invention, where a file transmission scenario is taken as an example, and a process of plug-in loading is further described through interaction of 2 plug-ins.
In the file transmission scenario, the file transmission service integrates FRAMWORK (integration), and at least two plug-ins are needed to realize file transmission, one plug-in is deployed at CLIENT for sending the file, and one plug-in is deployed at SERVER for receiving the file.
When a service request of file transmission is received, the SCADA system of the client determines that a target plug-in for responding to the service request is plug-in a for transmitting a file, then the plug-in a is started, ACTOR of the plug-in is activated when the plug-in a is started, a plurality of ACTOR can be simultaneously activated, and each of the activated plurality of ACTOR starts a thread to transmit a real-time data file of the SCADA, thereby realizing multi-thread transmission of the file and improving file transmission efficiency. Alternatively, a ACTOR may be activated to initiate a thread to monitor whether the historical data transmission is clear, and a ACTOR may be activated to initiate a thread to monitor the operating conditions of the SCADA system of the client.
If necessary, plug-in a also activates its TASK when started to ensure other special TASKs, such as sending the history data file of the SCADA system, ACTOR and TASK are independent.
When a service request of file transmission is received, the SCADA system of the service end determines that a target plug-in for responding to the service request is plug-in b for receiving the file, then the plug-in b is started, ACTOR of the plug-in b is activated when the plug-in b is started, a plurality of ACTOR can be simultaneously activated, and each of the plurality of ACTOR to be activated starts a thread to receive the real-time data file of the SCADA, thereby realizing the multithreading transmission of the file and improving the file transmission efficiency. In addition, a ACTOR may be activated to initiate a thread to reply whether the received real-time data file is clear, and a ACTOR may be activated to initiate a thread to monitor the operation of the SCADA system at the server.
The TASK of the plug-in is also activated when the plug-in b is started according to the requirement, so as to ensure other special TASKs, such as receiving the history data file of the SCADA system, storing the history data file in a designated directory and recording information.
Until the completion of the start of the complete file transfer service.
The process of loading the plug-in will be further described using the data processing scenario as an example.
In the data processing scene, a plug-in is needed for realizing data processing, and the SCADA system of which the plug-in is deployed at a server side is taken as an example.
When the SCADA system of the service end receives the business service request of data processing, the target plug-in for responding to the business service request is determined to be the plug-in c for data processing, the plug-in c is started, ACTOR of the plug-in c is started, a plurality of ACTOR can be simultaneously activated, a plurality of ACTOR which are activated respectively start a thread to process data, for example, a ACTOR which is partly activated starts a thread to process data generated by a consumer, and a ACTOR which is partly activated starts a thread to process data generated by a producer.
The producer only generates a piece of data to be processed, the data quantity is small and the processing is simple, and one or a small quantity of activated ACTOR can be used for processing the data generated by the producer. The data generated by the consumers are complex, the data amount is large, a plurality of activated ACTOR can be used for processing the data generated by the consumers, and a plurality of TASK can be activated to process the data generated by the consumers, so that the multithreading data processing is realized, and the data processing efficiency is improved.
The data processing service is started to complete.
And in the file transmission scene and the data processing scene, different plug-ins are adopted to realize corresponding service functions, and as the plug-in a and the plug-in b are mutually independent and do not influence each other, the service of both parties is not influenced between the plug-in a and the plug-in b. The activation mechanism such as activation time, number and the like of ACTOR and/or TASK may be defined in the configuration file of the plug-in, so that when the plug-in is started, ACTOR and/or TASK is activated according to configuration information in the configuration file.
Corresponding to the embodiment of the plug-in loading method, the invention also provides an embodiment of the plug-in loading device.
FIG. 3 is a block diagram of a plug-in loading device according to an exemplary embodiment of the present invention, where the plug-in loading device is applied to an integrated system, and the integrated system includes a plurality of plug-ins that are independent from each other, each plug-in is configured to implement a service function, and each plug-in includes an execution task for implementing the service function; the plug-in loading method comprises the following steps:
A determining module 31, configured to determine, in a case where a business service request is received, a target plug-in for responding to the business service request;
and the activating module 32 is used for activating the execution task of the target plug-in to start a thread by the activated execution task and realize the response to the business service request.
Optionally, the executing the task includes: built-in tasks and custom tasks;
Logic codes of built-in tasks of all plug-ins are the same;
the logic code of the custom task corresponds to the business function of the plug-in unit to which the logic code belongs.
Optionally, the number of built-in tasks is a plurality; the activation module is specifically configured to:
activating all or part of the built-in tasks in the plurality of built-in tasks, wherein each activated built-in task starts a thread;
and/or the number of the custom tasks is a plurality of; the activation module is specifically used for:
All or part of built-in tasks in the custom tasks are activated, and each activated custom task starts a thread.
Optionally, the method further comprises:
And the first modification module is used for modifying the custom task according to the first modification request under the condition that the first modification request aiming at the custom task is received.
Optionally, each plug-in further includes configuration information;
The configuration information is used for determining adjustable parameters in the logic code for executing the task.
Optionally, the method further comprises:
and the second modification module is used for modifying the configuration information according to the second modification request under the condition that the second modification request aiming at the configuration information is received.
For the device embodiments, reference is made to the description of the method embodiments for the relevant points, since they essentially correspond to the method embodiments. The apparatus embodiments described above are merely illustrative, wherein the elements illustrated as separate elements may or may not be physically separate, and the elements shown as elements may or may not be physical elements, may be located in one place, or may be distributed over a plurality of network elements. Some or all of the modules may be selected according to actual needs to achieve the purposes of the present invention. Those of ordinary skill in the art will understand and implement the present invention without undue burden.
Fig. 4 is a schematic diagram of an electronic device, showing an exemplary embodiment of the invention, showing a block diagram of an exemplary electronic device 40 suitable for use in implementing embodiments of the invention. The electronic device 40 shown in fig. 4 is merely an example and should not be construed as limiting the functionality and scope of use of embodiments of the present invention.
As shown in fig. 4, the electronic device 40 may be embodied in the form of a general purpose computing device, which may be a server device, for example. Components of electronic device 40 may include, but are not limited to: the at least one processor 41, the at least one memory 42, a bus 43 connecting the different system components, including the memory 42 and the processor 41.
The bus 43 includes a data bus, an address bus, and a control bus.
Memory 42 may include volatile memory such as Random Access Memory (RAM) 421 and/or cache memory 422, and may further include Read Only Memory (ROM) 423.
Memory 42 may also include a program tool 425 (or utility) having a set (at least one) of program modules 424, such program modules 424 including, but not limited to: an operating system, one or more application programs, other program modules, and program data, each or some combination of which may include an implementation of a network environment.
The processor 41 executes various functional applications and data processing, such as the methods provided in any of the embodiments described above, by running a computer program stored in the memory 42.
The electronic device 40 may also communicate with one or more external devices 44 (e.g., keyboard, pointing device, etc.). Such communication may be through an input/output (I/O) interface 45. Also, model-generated electronic device 40 may also communicate with one or more networks such as a Local Area Network (LAN), a Wide Area Network (WAN), and/or a public network such as the internet via network adapter 46. As shown, the network adapter 46 communicates with the other modules of the model-generated electronic device 40 via the bus 43. It should be appreciated that although not shown, other hardware and/or software modules may be used in connection with model-generating electronic device 40, including, but not limited to: microcode, device drivers, redundant processors, external disk drive arrays, RAID (disk array) systems, tape drives, data backup storage systems, and the like.
It should be noted that although several units/modules or sub-units/modules of an electronic device are mentioned in the above detailed description, such a division is merely exemplary and not mandatory. Indeed, the features and functionality of two or more units/modules described above may be embodied in one unit/module in accordance with embodiments of the present invention. Conversely, the features and functions of one unit/module described above may be further divided into ones that are embodied by a plurality of units/modules.
The present embodiment provides a computer readable storage medium having stored thereon a computer program which when executed by a processor implements the steps of the method provided by any of the above embodiments.
More specifically, among others, readable storage media may be employed including, but not limited to: portable disk, hard disk, random access memory, read only memory, erasable programmable read only memory, optical storage device, magnetic storage device, or any suitable combination of the foregoing.
In a possible implementation manner, the invention may also be implemented in the form of a program product comprising program code for causing a terminal device to carry out the steps of implementing the method provided by any of the embodiments described above, when said program product is run on the terminal device.
Wherein the program code for carrying out the invention may be written in any combination of one or more programming languages, which program code may execute entirely on the user device, partly on the user device, as a stand-alone software package, partly on the user device and partly on the remote device or entirely on the remote device.
While specific embodiments of the invention have been described above, it will be appreciated by those skilled in the art that this is by way of example only, and the scope of the invention is defined by the appended claims. Various changes and modifications to these embodiments may be made by those skilled in the art without departing from the principles and spirit of the invention, but such changes and modifications fall within the scope of the invention.