Summary of the invention
The object of the invention is the technical problem for above-mentioned Agent method for parallel processing degraded performance of the prior art, a kind of the Agent method for parallel processing and the structure that are applicable to distributed communication middleware are provided.
Object of the present invention is realized by following technical proposals:
Be applicable to a method for parallel processing for distributed communication middleware, will combine relation between Agent collection and resources bank, be mapped in geometric graph opinion, Modling model, finds out the maximum weight matching of former figure.
Preferably, the above-mentioned method finding out the maximum weight matching of former figure is specially
Step 1 creates proxy server collection Agents and needs the resources bank collection Libs of access, and its concrete steps are:
Proxy server collection Agents={ag1, ag2 ... agN}, represents the set of Agent; Need access resources bank collection Libs=Lib1, Lib2 ..., LibN}, represents the set of resources bank; <Agents, Libs> representative agency with resources bank between combine relation;
If the top mark of vertex set Agents is Agent [i], the top mark of vertex set Libs is lib [j], initialization is carried out to top mark, even the value of Agent [i] is the most authority on all limits associated with summit Agent, lib [j]=0, limit power between Agent and Lib of summit is W [i, j];
For arbitrary limit (i, j), Agent [i]+Lib [j] >=W [i, j];
Step 2 asks Agent [i], and the Perfect matching of the subgraph M that lib [j] is formed, its concrete steps are
(1) subgraph M is put for empty;
(2) find out an augmenting path P, obtain larger coupling M ' by xor operation and replace M;
(3) (2) operation is repeated until can not find augmenting path;
Step 3 judges the Perfect matching by whether finding subgraph M after step 2, if found, then terminates to run; Otherwise the top mark on Agent [i] summit existed is reduced d, the top mark on Lib [j] summit increases d, turn back to step 2, wherein d=Min{Agent [i]+Lib [j]-w [i, j] | Agent [i] is in alternating tree, and Lib [j] is not in alternating tree }.
The invention also discloses a kind of Agent parallel processing structure being applicable to distributed communication middleware, comprise Agent performance element, event message queue, synchronous performance element, persistence performance element, the performance element that cooperates, carry the performance element of thread, carry the performance element list of thread; Described Agent performance element and event message queue form Agent pool of execution units;
Described Agent performance element is for completing the major function of agency: process the request from system layer; The request of repeater system layer is to the managed object of application layer; Forward application layer managed object to request response to system layer administrative unit; The parsing of demarcation and filtering function in software;
Described event message queue, plays the effect of message queue in Agent pool of execution units;
Described synchronous performance element is responsible for processing the locking to application layer object;
Described cooperation performance element passes to Agent performance element the request from application layer, and in Agent, performs each act on behalf of load balance function between performance element;
The described sub agent carrying the chartered Agent of performance element representative of thread, and be responsible for the communication between process agency and sub agent;
The described performance element list carrying thread comprises the information of the performance element of all band threads;
Described Agent pool of execution units, be used for dynamic creation and delete performance element.
Preferably, above-mentioned performance element can dynamically produce and delete, various performance element performs different functions respectively, and different performance elements can perform simultaneously, described performance element is event driven, each performance element has oneself thread and finite state machine status, in a program class, each performance element can and other performance element share code.
Agent based on distributed communication middleware produces and an initial method, specifically comprises following steps:
Create the data structure of Agent self, after then starting Agent root thread, create and coordinate performance element and synchronous performance element, then coordinate performance element and create pool of execution units and corresponding performance element;
Coordinate performance element and send specific event signal to one of them performance element, after receiving this particular event signal, this performance element is by communication point interconnection network management object;
Whole Agent initial work completes, and can process the request from system and perform.
Beneficial effect of the present invention: the Agent method for parallel processing of distributed communication middleware provided by the invention and structure make the network hardware (i.e. the network equipment) parallel processing capability greatly strengthen.Complete the maximum weight matching of this figure, that is, set up Agent parallel process model in systems in which, make each Agent to greatest extent while executing the task, do not conflict ground calling system resources bank.
Embodiment
Below in conjunction with specific embodiments and the drawings, the present invention is further illustrated.
In the communication system of reality, multiple Agent needs to process multiple task simultaneously, Agent wants treatment system task to need to call limited system resource storehouse, and therefore multiple Agent does not use system resource storehouse to be the key realizing parallel processing with how conflicting to greatest extent.
Bipartite graph in graph theory is defined as: establish G=(V, E) be a non-directed graph, if summit V may be partitioned into two mutually disjoint subset (A, B), and the every bar limit (i in figure, j) two summit i and j associated by belong to these two different vertex sets (i in A, j in B) respectively, then title figure G is a bipartite graph.
A given bipartite graph G, in a subgraph M of G, any two limits that the limit of M is concentrated do not depend on same summit, then claim M to be a coupling.
Select the maximum subset of such limit number to be called the maximum weight matching problem of figure, generally, be exactly that most probable finds two limits manyly, they do not depend on same summit.
If in a coupling, certain limit is associated in each summit in figure and figure, then this coupling is claimed to be Perfect matching.
If P be in figure G one be communicated with two paths of not mating summit, and the limit belonging to M and the limit (namely having mated and limit to be matched) that do not belong to M alternately occur on P, then title P is an augmenting path relative to M.
Obtain the maximum weight matching of figure, following two variable need be used:
Theorem 1: set the top mark of summit Xi in bipartite graph G as A [i], the top mark of summit Yj is B [j], the limit power between Xi and the Yj of summit is W [i, j].If in the subgraph M of figure G, all limits all meet the subgraph of equal value that A [i]+B [j]==W [i, j], M is called as G.
Theorem 2: if the subgraph (being called equal subgraph) be made up of limits (i, j) meeting A [i]+B [j]=w [i, j] all in bipartite graph has Perfect matching, so this Perfect matching is exactly the maximum weight matching of bipartite graph.
<Agents, Libs> correspond to two vertex sets in bipartite graph, if can find the maximum weight matching of figure, are exactly use system resource storehouse with making Agent not conflict to greatest extent.
In the present invention, a kind of method for parallel processing being applicable to distributed communication middleware is will combine relation between Agent collection and resources bank, be mapped in geometric graph opinion, Modling model, find out the maximum weight matching of former figure, namely set up in systems in which and act on behalf of parallel process model, make each Agent to greatest extent while executing the task, do not conflict ground calling system resources bank.It specifically comprises the following steps
Step 1 creates Agent collection Agents and needs the resources bank collection Libs of access, and its concrete steps are:
Agent collection Agents={ag1, ag2 ... agN}, represents the set of Agent; Need access resources bank collection Libs=Lib1, Lib2 ..., LibN}, represents the set of resources bank; <Agents, Libs> representative agency with resources bank between combine relation;
If the top mark of vertex set Agents is Agent [i], the top mark of vertex set Libs is lib [j], initialization is carried out to top mark, even the value of Agent [i] is the most authority on all limits associated with summit Agent, lib [j]=0, limit power between Agent and Lib of summit is W [i, j];
For arbitrary limit (i, j), Agent [i]+Lib [j] >=W [i, j];
Step 2 asks Agent [i], the Perfect matching of the subgraph M that lib [j] is formed, and concrete steps are as follows:
(1) subgraph M is put for empty;
(2) find out an augmenting path P, obtain larger coupling M ' by xor operation and replace M;
(3) (2) operation is repeated until can not find augmenting path;
Step 3 judges the Perfect matching by whether finding subgraph M after step 2, if found, then terminates to run; Otherwise the top mark that the top mark on Agent [i] summit existed reduces d, Lib [j] summit is increased d, turns back to step 2; Wherein d=Min{Agent [i]+Lib [j]-w [i, j] | Agent [i] is in alternating tree, and Lib [j] is not in alternating tree }.
The Perfect matching of subgraph of equal value, the namely maximum weight matching of former figure, completes this maximum weight matching, that is, set up Agent parallel process model in systems in which, make each Agent to greatest extent while executing the task, do not conflict ground calling system resources bank.
Accomplish the event that parallel processing is efficiently a large amount of and request, except establishing Agent parallel process model as stated above, Agent itself also needs to have the internal structure adapting to parallel processing.Its main points are: each Agent comprises multiple performance element (EU), performance element is exactly the processing unit that can intercom mutually, can operationally dynamically be set up and be deleted, there is the control thread of oneself or share thread with other processing units.Each performance element has been responsible for the required function of the Some features of Agent in network activity, such as: the mutual communication function between agency; Load-balancing function; Persistence function in database access; The synchronous protection function etc. of distributed objects, described method has efficiently, high reliability, feature applied widely, supports parallel processing framework and multi-process.Solve for complex communication and parallel processing efficiency shortcoming on the low side under existing architecture, the event enabling platform parallel processing efficiently a large amount of and request, support the network communicating system software development based on parallel framework better.
A kind of distributed communications platform composer (Distributed Communication as shown in Figure 1
Constructor is called for short DCPC) Agent cut-away view, dotted line is the internal structure of a communication Agent with upper part, it is made up of multiple performance element entity (EU), this performance element (Executing Unit, be called for short EU) utilize distributed object technology in Agent internal build, can dynamically be set up when running software and delete, they be coordinated mutually, jointly complete the function of Agent.
The invention also discloses a kind of be applicable to distributed communication middleware act on behalf of parallel processing structure, comprise act on behalf of performance element (Agent EU), event message queue Event Message Queue (being called for short EMQ), synchronous EU, persistence EU, the EU that cooperates, the performance element Proxy Sub-Agent(that carries thread be called for short PSA), carry the performance element list Proxy Sub-Agent List (being called for short PSAL) of thread; Described Agent EU(is called for short AE) and event message queue Event Message Queue (being called for short EMQ) form Agent pool of execution units Agent EU Pool (abbreviation AEP).The described performance element Agent EU that acts on behalf of is for completing the major function acting on behalf of Agent: process the request from system layer; The request of repeater system layer is to the managed object of application layer; Forward application layer managed object to request response to system layer administrative unit; The parsing of demarcation and filtering function in software.Described event message queue (EMQ), plays the effect of message queue in Agent pool of execution units, and namely when all AE are busy with processing various request, come if any new request, these requests will be placed into EMQ, wait for idle AE to process.Described synchronous EU is responsible for processing the locking to application layer object, and when the multiple request of this subject undergoes, this locking ensures that object can be accessed in order by these requests, thus ensures its fail safe of accessing.Described persistence EU performs the function of the persistence relevant to lock unit, thus makes lock unit be absorbed in object synchronization work, and the persistence work with concrete consumes resources departs from comes.Described cooperation EU passes to Agent EU the request from application layer, and the load balance function performed in Agent between each Agent EU, namely once the request receiving application layer, which AE this unit determines by as the case may be to process these requests.The described performance element Proxy Sub-Agent(carrying thread is called for short PSA) sub agent (Sub-Agent) of the chartered Agent of representative, and the communication be responsible between process Agent and sub agent (Sub-Agent), it is as gateway, resolve the details in communication, such as protocol stack etc.Communication protocol between PSA and Sub-Agent is general management information (CMIP) agreement.Described Proxy Sub-Agent List (PSAL) is the list of PSA, comprises the information of all PSA.Described Agent EU Pool (AEP) is Agent pool of execution units, be used for dynamic creation and delete performance element, comprise the configuration information of performance element.
In Agent structure of the present invention, performance element (EU) is the most basic functional unit, it can dynamically produce and delete, and there is following characteristics: 1. various EU performs different functions respectively, and different EU can perform simultaneously, can this system in parallel processing capacity greatly be improved.2.EU is event driven.3. each EU has thread and finite state machine (FSM) state of oneself.4., in a program " class " (class), each EU can share code with other EU.
All performance elements (EU) are all created by Agent, and after EU produces, only have when Agent self withers away (namely Agent root process terminates), performance element (EU) just can disappear.
Fig. 2 is the generation and initialize flow that Agent is complete.Can see from the graph: the invention also discloses a kind of agency based on distributed communication middleware and produce and initial method; first system creates the data structure of Agent self; then after starting Agent root thread; create and coordinate EU and synchronous EU, then coordinate EU and create pool of execution units (AEP) and corresponding performance element (EU); Next step is coordinated EU and sends specific event signal to one of them performance element (EU), and after receiving this particular event, this performance element (EU) is by communication point SAP interconnection network management object (MO); Finally, whole Agent initial work completes, and can process the request from system and perform.
The angle of parallel processing from network service illustrates how Agent realizes parallel processing below.Suppose in network, have three network equipment network elements 1, network element 2, network element 3, for each network element, DCPC composer disposes a series of Agent (affairs agent, safe agent, communication Agent) it is responsible for, the Agent that wherein communicates completes the transmission from request in net element communication, and receive, the communication that is established to of communication completes whole process.
The structural representation of Agent parallel processing in network service as shown in Figure 3, first Agent produces the various performance elements (EU) of oneself according to flow process described in Fig. 2, when network element 1 receives the communication request of network element 2 and network element 3 simultaneously, the cooperation EU (Coordinating EU) be responsible in the Agent of network element 1 ranks the event message queue (EMQ) that Agent is put in these two requests; Then the EU that cooperates selects two idle Agent EU (AE) to process these two requests in Agent, completes communicating to network element 2 and network element 3 respectively.Because these two communication processs carry out simultaneously, so just achieve the parallel processing of communication with two Agent EU (AE), it is synchronously the key issue in parallel process, as above in illustration 3, Agent EU (AE) in network element 1 wants executive communication function, need system resource storehouse relevant to communication in calling system (containing various communications protocols, usually object approach calls for user in a distributed manner), if two communication processs carried out all will call such resources bank and will clash simultaneously, the function of synchronous EU is to ensure that the safety of system call is carried out: when there to be two requests from different AE for system resource storehouse simultaneously, these two requests are put into event message queue Event Message Queue (being called for short EMQ) by Agent EU, then system resource storehouse is given one of them request, when processing this request, synchronous EU makes system resource storehouse be in the lock state, refuse other request.Only have when first request has been processed, synchronous EU unlocks system resource storehouse, and second request in event message queue (EMQ) is just fed to resources bank.
DCPC is a kind of distributed middleware, and it is closely related with the development and application of network communicating system, and Fig. 4 is the application of DCPC communications platform composer in network communicating system.The use of DCPC makes the network hardware (i.e. the network equipment) parallel processing capability greatly strengthen, and the implementation method of DCPC communications platform component device comprises following steps:
Dispose DCPC communications platform composer: between operating system layer and application layer, settle middleware server, DCPC composer is deployed in middleware server.
DCPC provides CommAPI to the network equipment: DCPC is integrated with various communications protocols stack, comprise communication (ICC) and intersystem communications (ISC) between intercell communication (IWC), inter-thread communication (ITC), interprocess communication (IPC), CPU, DCPC constructs API on the basis of these communication protocols, and API is supplied to application layer.In network communicating system, DCPC provides asynchronous (clog-free) and synchronous (obstruction) in fully-integrated mode, SCCP connection-oriented and connectionless communication API.Make that user can be suitable in conjunction with various API to set up cost-effective communication modes.Identical communications infrastructure API is all provided at the top layer of each protocol stack (comprising TCP/IP, OSI etc.).
Dispose Agent in the network equipment, improve its parallel processing capability: first, build best Agent parallel process model according to maximum matching algorithm, make each Agent to greatest extent and the ground calling system resources bank that do not conflict.Secondly, for each Network element object (switch of network application layer in Fig. 3 in network, the network equipments such as router), DCPC disposes a series of Agent, create various performance element (EU) according to the flow process of Fig. 2 in Agent inside, complete and relevant the communicating of Network element object, network management, database access persistence, the functions such as security affairs.
Developer makes full use of two features of DCPC (based on the Agent parallel process model that maximum matching algorithm builds in the exploitation of communication system; Special Agent structure), substantially increase the ability of network communication equipment parallel processing communication event.
More than above are only preferred embodiment of the present invention, not in order to limit the present invention, all any amendments done within the spirit and principles in the present invention, equivalent replacement and improvement etc., all should be included within protection scope of the present invention.