3, summary of the invention
The objective of the invention is to realize in the following manner, it is the state machine that will meet different operating flow process business demand, abstract is one group of execution class of moving the associative operation that defines in rule and the migration rule, finish the management of a plurality of state machines by the mode of configuration, the user generates the session of designated state machine by the user interface of state machine management engine, and give original state, when the user when this session sends event request, the state machine management engine will find relevant operation according to the incident that sends, and carry out this operation, drive session status according to operating result then and move to next designated state, and executing state changes the operation that causes, finish the event-driven that the user sends to this session, concrete steps are as follows:
Step 1: according to the demand of big data quantity configuration management function, the migration rule of the up funtion part of big data quantity configuration file that takes out each state is as follows:
1) state is in transition process, original state, final state, cause the incident of state transition, the operation that incident caused, state changes operation and the state machine name information that is caused, with its form storage with database table, as the 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, after this asynchronous operation is called successfully, the final state of migration is 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 considered as calling success, after the upload operation runs succeeded, will be by triggering the UPLOAD_COMPLETED incident, it is upload_completed that the current state of session is moved by upload_in_progress;
2) execution failure back is same by trigger event, and it is upload_failed that the current state of session is moved by upload_in_progress; If current sessions is being carried out the upload operation, at this moment send interrupt event to this session, then will carry out the abort operation, session status will be upload_failed by the upload_in_progress migration after the abort operation runs succeeded, and so just finish the work of business diagnosis.
Step 2: with the form storage of the maximum number of sessions of the original state of state machine, final state, support and state machine title with database table, with state machine current sessions state also with the form storage 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 to realize in the class then; Realize the formal definition operation of specified interface, be for convenience of state machine management engine calling to operation, the operation that relates in the up function of big data quantity configuration file has two, one is the operation that thread pool is put in the upload operation, one is upload operation itself, because upload operation is the asynchronous operation that need be managed, be carried out by thread pool,, finish exploitation to state machine by 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 finished, user mode machine management engine drives the session status migration of the up functional status machine of big data quantity configuration file, at first add the session of this state machine by the user interface of state machine management engine, transmit the incident of appointment then to the driving session status changing method of state machine management engine user interface, the state machine management engine will be according to the state machine title, the session status of current appointment finds relevant migration rule with incident, and carry out and move the operation that incident causes in the rule, state according to the operating result current sessions is set to move the state that mates with operating result in the rule, if have state to change the operation that causes in the migration rule, will carry out this operation; So far an incident is finished the driving of session;
A session is from initially passing through the driving of a plurality of incidents to termination, and when incident is urged to the final state of state machine with session, the state machine management engine will be deleted this session automatically; Simultaneously the state machine management engine also by user interface to the user Force Deletion to certain session is provided, to the state information searching and the necessary authentication function of all kinds session.
Session 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 session statuss of a plurality of state machines, according to the incident that sends to specified session, carry out corresponding operating, and finish migration task this session status according to operating result.
The state machine management engine adopts single instance mode to realize, can manage, drive the session of a plurality of state machines simultaneously by the mode of configuration, and finish the extraction and the execution of associative operation, when specified session is carried out state transition, adopt atomic operation, thread pool is transferred in the operation that can not finish 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 session 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 at the designed driven by engine device of the state machine of different business demand, it can be finished the state-driven based on the task of different conditions machine, and the extraction of associative operation, carry out, 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 the control of concrete state transition, carry out, and the application of resource, discharge, save the cost of development of state machine in a large number, simplified the design complexities of state machine.
5, embodiment
With reference to the configuring management method of Figure of description, explain below the work managing multimode machine supervising engine of the present invention.
The present invention is for solving its technical matters, and the technical scheme that is adopted as shown in Figure 1.User interface by the state machine management engine is realized the operation to the state machine management engine, when the user specifies the specified session of state machine to send the allocate event request in the state machine management engine by user interface, the state machine management engine at first will be according to the state machine title, the operation that session status and event request find incident to cause in database, operating result, next state, state changes the relevant state machine migration informations such as operation that cause, 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 session status, be operating as sky if incident causes, then the directly next state of state machine is set to current session 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 session status to the designated state machine drives migration, but around this Core Feature, the state machine management engine also needs to 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, as shown in Figure 2.One class 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, there are six, are respectively the interpolation session, drive the state that session status changes, deletes all sessions in session, the state of inquiry specified session, the state of inquiring about all sessions of designated state machine, the query State machine management engine.Whether the state machine of verifying appointment in addition exists, verifies whether the session of appointment exists, whether the current number of sessions 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, as shown in Figure 3.Below will construe the module relationship of state machine management engine with the Core Feature that drives the session status variation.The migration of session status is by event driven in the state machine management engine, the user passes to event message " control center " by " user's application interface ", and " control center " obtains the current state of specified session in " session status administrative center " according to state machine title and session id." control center " passes to " state machine administrative center " with the current state and the incident of state machine title, session, 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 " by 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, then to " session status administrative center " current state that this follow-up state is set is specified session.After the session state setting success, " 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 session status, the step and the result of various operations can be write corresponding journal file by 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 by " 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 moves in thread pool changes the state of session, need to send " event message " to the state machine management engine again.
The flow process that state machine management engine driving session status changes as shown in Figure 4, when driving the session status variation, after " control center " obtains the current state of specified session from " state machine administrative center ", the state machine management engine will lock to this session, preventing this session status of other operation changes, thereby realize the atomicity of its operation.In driving the session status change procedure, take place unusual or after this session completes successfully state transition, with this session of release, so that other operations can continue to drive this session.
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, BulkCM (big data quantity configuration management function) and PM (performance management function) are exactly two kinds in these standards, 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.Exploitation for standard and simplification 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, finish 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 clearer and more definite simultaneously, simply, 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 take out each link of work from business demand are just passable, and other driven management etc. can be transferred to the state machine management engine and finish.
With the big data quantity configuration management function is that example illustrates concrete application of the present invention, and concrete execution in step is as follows:
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 form storage with database table.As the 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, after this asynchronous operation is called successfully, the final state of migration is upload_in_progress, and 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 by triggering the UPLOAD_COMPLETED incident, is upload_completed with the current state of session by the upload_in_progress migration, also pass through trigger event after carrying out failure, it is upload_failed that the current state of session is moved by upload_in_progress.If current sessions is being carried out the upload operation, at this moment send interrupt event to this session, then will carry out the abort operation, session status will be upload_failed by the upload_in_progress migration after the abort operation runs succeeded.It more than is exactly the migration rule of the up funtion part of big data quantity configuration file.So just finished the work of business diagnosis.
Step 2: with the form storage of the maximum number of sessions of the original state of state machine, final state, support and state machine title with database table, with state machine current sessions state also with the form storage 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 for convenience of state machine management engine calling to operation.The operation that relates in the up function of big data quantity configuration file 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 be managed, be carried out by thread pool, so this operation will be defined as a thread pool task.By preceding 3 steps, we have easily finished 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 finished, the session 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 session of this state machine by the user interface of state machine management engine, transmit the incident of appointment then to the driving session 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 session status of state machine title, current appointment, and carry out and move the operation that incident causes in the rule, state according to the operating result current sessions is set to move the state that mates with operating result in the rule, if have state to change the operation that causes in the migration rule, will carry out this operation.So far an incident is finished the driving of session.A session is from initially passing through the driving of a plurality of incidents to termination, and when incident is urged to the final state of state machine with session, the state machine management engine will be deleted this session automatically.Simultaneously the state machine management engine also by user interface to the user Force Deletion to certain session is provided, to the state information searching and the necessary authentication function of all kinds session.
According to above description, as can be seen, the user just is abstracted into operation flow the migration rule to the exploitation of state machine, and write the operation that causes working link conversion that defines in the business, 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 are finished 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 widely used in the exploitation of event driven various complex work flow processs, and 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.