Summary of the invention
The objective of the invention is to realize by following mode, is with the state machine that meets different operating flow process business demand, and abstract is the execution class of the associative operation that defines in one group of migration rule and the migration rule; Accomplish the management of a plurality of state machines through the mode of configuration; The user interface of user through the state machine management engine generates the communication of designated state machine, and gives original state, when the user when event request is sent in this communication; The state machine management engine will find relevant operation according to the incident of sending; And carry out and should operate, drive communications status according to operating result then and move to next designated state, and executing state changes the operation that causes; Accomplish the event-driven that the user sends to this communication, concrete steps are following:
Step 1: according to the demand of big data quantity configuration management function, take out each state the up funtion part of big data quantity configuration file migration rule as follows:
1) state is in transition process, and original state, final state, the operation that incident, incident caused that causes state transition, state change operation and the state machine name information that is caused, with its stored in form with database table; The up function of big data quantity configuration file wherein, original state be idle, when by " up " event-driven, need carry out the upload operation; This is operating as an asynchronous operation, and after this asynchronous operation was called successfully, the final state of migration was upload_in_progress; When this asynchronous operation malloc failure malloc; The final state of migration still is idle, thread pool is put in the upload operation be regarded as calling success, after the upload operation runs succeeded; To be upload_completed with communications status by the upload_in_progress migration through triggering the UPLOAD_COMPLETED incident;
2) carrying out the same trigger event that passes through in failure back, is upload_failed with communications status by the upload_in_progress migration; If the upload operation is being carried out in current communication; At this moment send interrupt event to this communication; Then will carry out the abort operation, communications status will be upload_failed by the upload_in_progress migration after the abort operation runs succeeded, and so just accomplish the work of business diagnosis.
Step 2: with the maximum number of communications of the original state of state machine, final state, support and state machine title stored in form with database table, with the current communications status of state machine also with the stored in form of database table;
Step 3: operation that incident caused in the development status machine and state change the operation that is caused; For these operations; The state machine management engine has been stipulated unified operation-interface, and the user only need realize this operation-interface, content of operation is defined into realizes in the class then; Realize the formal definition operation of specified interface; Be that the state machine management engine calls what operate for ease, the operation that in the up function of big data quantity configuration file, relates to has two, and one is the operation that thread pool is put in the upload operation; One is upload operation itself; Because the upload operation is the asynchronous operation that need managed, carried out by thread pool,, accomplish exploitation to state machine through preceding 3 steps so this operation will be defined as a thread pool task;
Step 4: realize the DAO interface of state machine management engine, in this interface, stipulated to the parameter that reads, needs when reading of the data of storage in step 1,2 and the type of rreturn value, so that the state machine management engine uses.
Step 5: after above step is accomplished; User mode machine management engine drives the communications status migration of the up functional status machine of big data quantity configuration file; At first add the communication of this state machine through the user interface of state machine management engine; Transmit the incident of appointment then to the driving communications status changing method of state machine management engine user interface; The state machine management engine will find relevant migration rule with incident according to the communications status of state machine title, current appointment, and carry out the operation that incident causes in the migration rule, be set to move the state that matees with operating result in the rule according to the current communications status of operating result; If have state to change the operation that causes in the migration rule, will carry out this operation; So far an incident is accomplished communication drivers;
To stopping passing through the driving of a plurality of incidents, when incident during with the final state of communication drivers to state machine, the state machine management engine will be deleted this communication automatically from initially for communication; Simultaneously the state machine management engine also through user interface to the user Force Deletion to certain communication is provided, to inquiry of all kinds communicate status information and necessary authentication function.
Communication is meant the state recording of state machine representative workflow; Be applied to management, control and driving to each link in the complex work flow process; The state machine management engine is managed a plurality of communications status of a plurality of state machines; According to sending to the designated communication incident, carry out corresponding operating, and accomplish migration task this communications status according to operating result.
The state machine management engine adopts single instance mode to realize; Can manage, drive the communication of a plurality of state machines simultaneously through the mode of configuration; And the extraction and the execution of completion associative operation; When designated communication is carried out state transition, adopt atomic operation, thread pool is transferred in the operation that can not accomplish moment managed, carry out.
The state machine management engine adopts the configurability of state machine management engine status migration rule, to a plurality of state machines with to the management of the communications status of the same state machine of a plurality of uses.
The invention has the beneficial effects as follows: the state machine management engine is the driven by engine device that state machine designed to the different business demand; It can be accomplished the state-driven based on the task of different conditions machine; And the extraction of associative operation, execution, make the developer of state machine only need consider the business demand of state machine, therefrom take out the state transition rule that meets this state machine and design the associative operation task; And needn't be concerned about control, the execution of concrete state transition; And the application of resource, release, the cost of development of having saved state machine has in a large number been simplified the design complexities of state machine.
Embodiment
With reference to the configuring management method of Figure of description to managing multimode machine supervising engine of the present invention, explanation at length below the work.
The present invention is for solving its technical matters, and the technical scheme that is adopted is as shown in Figure 1.User interface through the state machine management engine is realized the operation to the state machine management engine; When the user specifies the designated communication of state machine to send the allocate event request in the state machine management engine through user interface, the state machine management engine at first will change the relevant state machine migration informations such as operation that cause according to operation, operating result, next state, the state that state machine title, communications status and event request find incident to cause in database, put into internal memory; Carry out the operation that this incident causes then; And find corresponding next state according to operating result, and it is set to current communications status, if incident cause be operating as sky; Then the directly next state of state machine is set to current communications status; If the operation that the state change causes in the state machine migration information is not empty, then will carry out this state and change the operation that causes, return user interface then; If state changes the sky that is operating as that causes, then directly return user interface.
It more than is the Core Feature of state machine management engine; Promptly the communications status to the designated state machine drives migration; But around this Core Feature, the state machine management engine also need design other subsidiary function, for this reason; The user interface of state machine management engine provides three major types totally ten two functional methods to the user, and is as shown in Figure 2.One type is the systemic-function method, the startup of state machine management engine is arranged and close two functions.Another kind of is the business function method, has six, is respectively all communications status in the state that adds communication, drives communications status variation, deleting communication, inquiry designated communication, all communications status of inquiring about the designated state machine, the query State machine management engine.Whether the state machine of verifying appointment in addition exists, verifies whether the communication of appointment exists; Whether the current amount of communications of checking designated state machine reaches maximal value, whether checking designated state machine can trigger allocate event, the function of these four Authentication-Types under designated state.
This state machine management engine adopts OO modular design, and is as shown in Figure 3.Below will construe the module relationship of state machine management engine with the Core Feature that drives the communications status variation.The migration of communications status is by event driven in the state machine management engine; The user passes to event message " control center " through " user's application interface ", and " control center " obtains the designated communication state with the ID that communicates by letter according to the state machine title in " communications status administrative center "." control center " passes to state machine title, communications status and incident " state machine administrative center ", obtains migration informations such as operation that incident causes and follow-up state from " state machine administrative center "." control center " goes to call this operation in " operation class libraries " through the action name that incident causes; And find corresponding follow-up state in the migration information of return results from internal memory according to operation, to " communications status administrative center " this follow-up state being set then is the designated communication state.After communications status was provided with successfully, " control center " can call " operation that state causes " in the migration information.So far, whole event driving flow performing finishes.
When the state machine management engine drives certain communications status, can the step and the result of various operations can be write corresponding journal file through peripheral " log management module ".When calling " operation that incident causes " and " state changes the operation that causes ", concrete operation also can be carried out the log record operation through " log management module ".
The operation that incident causes can be divided into two kinds: a kind of is can be complete in the short time, and a kind of is to need to start background thread carry out asynchronous execution.The latter just relates to the operation of system thread pool module to external world.When the action need that in thread pool, moves changes communications status, need to send " event message " to the state machine management engine again.
The flow process that state machine management engine driving communications status changes is as shown in Figure 4; When driving the communications status variation; After " control center " obtains the current state of designated communication from " state machine administrative center "; The state machine management engine will lock to this communication, preventing this communications status of other operation changes, thereby realize the atomicity of its operation.After in driving the communications status change procedure, sending out a sexual abnormality maybe this communication completing successfully state transition, should communication with release, so that other operations can continue to drive this communication.
Embodiment
In field of telecommunications; Virtual network operator has proposed a series of interface specifications to the equipment supplier; The northbound interface of OMC designs in order to realize these standards, and BulkCM (big data quantity configuration management function) and PM (performance management function) are exactly two kinds in these standards, and the realization of these functions all is made up of a plurality of working links; By event-driven work from a link to next link, the execution of operation also depends on current state.For each link that makes work can be driven, manage the position of present located working link by incident, and carry out associative operation, select the user mode machine to drive and manage each working link.For standard and the exploitation of simplifying state machine, state machine reusable, we have proposed the notion of state machine management engine; State machine each link to work is driven, and the execution of associative operation, from state machine, detach out; Accomplish related work by the state machine management engine; So just state transition exploitation and concrete business development are separated, when the state machine of a plurality of different business demands of exploitation, will save a large amount of codes, make full use of the reusability of code; Make the exploitation of state machine clear and definite more, simple simultaneously; The user only need be placed on energy on the business when the development status machine, and the migration rule and the relevant operation task of carrying out of exploitation that from business demand, take out each link of work are just passable, and other driven management etc. can be transferred to the state machine management engine and accomplish.
With the big data quantity configuration management function is that example is explained concrete application of the present invention, and concrete execution in step is following:
Step 1:, take out the migration rule of each state according to the demand of big data quantity configuration management function.State is in transition process; Original state, final state, the operation that incident, incident caused that causes state transition, state change operation and the state machine title information such as (this mainly are that consideration state machine management engine will be carried out the management to a plurality of state machines to add the state machine title) that is caused, with its stored in form with database table.
up function of big data quantity configuration file wherein; Original state is idle, when by " up " event-driven; Need carry out the upload operation; This is operating as an asynchronous operation, and after this asynchronous operation was called successfully, the final state of migration was upload_in_progress; When this asynchronous operation malloc failure malloc, the final state of migration still is idle.Note just calling success here, do not run succeeded, call success even if thread pool is put in upload operation soon.
After the upload operation runs succeeded; Will be through triggering the UPLOAD_COMPLETED incident; The current state of will communicating by letter is upload_completed by the upload_in_progress migration; Carry out after the failure also through trigger event, with current state be upload_failed by the upload_in_progress migration.If the upload operation is being carried out in current communication, at this moment send interrupt event to this communication, then will carry out the abort operation, it will be upload_failed by the upload_in_progress migration that abort operates the back communications status that runs succeeded.It more than is exactly the migration rule of the up funtion part of big data quantity configuration file.So just accomplished the work of business diagnosis.
Step 2: with the maximum number of communications of the original state of state machine, final state, support and state machine title stored in form with database table, with the current communications status of state machine also with the stored in form of database table.
Step 3: operation that incident caused in the development status machine and state change the operation that is caused; For these operations; The state machine management engine has been stipulated unified operation-interface, and the user only need realize this operation-interface, is defined in the realization class content of operation just passable.To realize the formal definition operation of specified interface, be that the state machine management engine calling what operate for ease.The operation that in the up function of big data quantity configuration file, relates to has two; One is the operation that thread pool is put in the upload operation; One is upload operation itself; Because the upload operation is the asynchronous operation that need managed, carried out by thread pool, so this operation will be defined as a thread pool task.Through preceding 3 steps, we have easily accomplished the exploitation to state machine.
Step 4: realize the DAO interface of state machine management engine, in this interface, stipulated to the parameter that reads, needs when reading of the data of storage in step 1,2 and the type of rreturn value, so that the state machine management engine uses.
Step 5: after above step was accomplished, the communications status that drives the up functional status machine of big data quantity configuration file with regard to serviceable condition machine management engine had moved.At first add the communication of this state machine through the user interface of state machine management engine; Transmit the incident of appointment then to the driving communications status changing method of state machine management engine user interface; The state machine management engine will find relevant migration rule with incident according to the communications status of state machine title, current appointment; And carry out and move the operation that incident causes in the rule; Be set to move the state that matees with operating result in the rule according to the operating result current state,, will carry out this operation if having state to change the operation that causes in the migration rule.So far an incident is accomplished the driving of communication.To stopping passing through the driving of a plurality of incidents, when incident during with the final state of communication drivers to state machine, the state machine management engine will be deleted this communication automatically from initially for communication.Simultaneously the state machine management engine also through user interface to the user Force Deletion to certain communication is provided, to inquiry of all kinds communicate status information and necessary authentication function.
According to above description; Can find out; The user just is abstracted into the migration rule with operation flow to the exploitation of state machine, and writes the operation that causes the working link conversion that defines in the business, and this all is only limited to the understanding to business; Do not relate to the execution of use, the operation of moving rule and how by technical matterss such as incident drive, these all are to be accomplished by the state machine management engine.
In sum, the exploitation of user to the service condition machine simplified in the invention of state machine management engine greatly, makes the user have more energy to consider service logic, and needn't too much be concerned about technical realization.The state machine management engine can be adaptable across the exploitation of event driven various complex work flow processs, for example: the finance reimbursement in the financial system is examined, and the worker in the office system singly signs and issues, examines, the kinds of goods flow direction of goods entry, stock and sales system etc.