|KATO||Everyone needs a sidekick|
Here is the architecture for KATO. The Data Model presents the Entity Relationship Diagram for KATO and describes the roles of the various tables in the database. The Logical View presents a class diagram and describes what each class does. The Process View presents a sequence diagram to illustrate typical control flow in KATO. The deployment Views imparts a good understanding of where each component lives in KATO.
Here is the data model for KATO development.
The catalog is where the information for all available agents are stored.
The schedule holds information about the agents from the catalog that have been tasked to perform work.
Users can give ratings to agents within the catalog as a way of indicating to the community which agents are most effective.
The catalog of agents is organized into a hierarchy for search and browse purposes.
Each agent has a set of parameters that it must be invoked with. This is how you communicate with the agent.
Each agent also has a set of events that it is registered to handle.
When a scheduled agent starts its run. It has access to the specific parameter values that it uses to perform work for each particular user.
Agents can trigger events which cause other agents to start running. These events are logged for purposes of historical analysis.
A message log is also retained for debugging purposes.
When an agent needs to persist data from one run to the next, it uses the schedule data table.
Here is the logical view of the KATO architecture.
This is the class hierarchy diagram for extending KATO with your own agents when written in PHP. You agent class should be a sub class of the Handler class. The watch method just polls web resources looking for conditions that are ripe for what the agent, acting as the user, is on the lookout for. The watch method should return the number of seconds that the engine should wait before calling the watch method again or zero to indicate that the agent's task is done and that the engine should not call it anymore for this task. The respond method is called to perform the desired action once the qualifying conditions has been met.
Java developers enjoy a different environment when writing agents for KATO. That is because we leverage another open source project called JADE by extending their environment. Your agent should be a sub class of the SuopfAgent which, in turn, is a sub class of the Agent class in the JADE framework. The SuopfAgent interacts with the rest of the KATO system to provide your agent all the parameter information that it will need. All you have to do is call the base class constructor passing in a string containing the code for your agent as represented in the KATO catalog.
You need to override the setup method from the Agent class to put all of your initialization code within it. That includes calling the addBehavior method with an instance of a class of yours that extends one of the jade core behavior classes. May I recommend the TickerBehaviour class because that will get called repeatedly after a specified period of time. If you do extend the TickerBehaviour class, then the onTick method is where you put your code that does what the interesting part that your agent is all about.
Here is the process view of the KATO architecture.
What follows is an illustrative sequence diagram showing how it all fits together. The RunEngine.php file creates the engine object and calls it twice, once for the polling cycle and the other time for handling events. When the polling cycle commences, each scheduled agent gets awakened to watch for whatever it is that the user wants it to look for. Once the proper condition has been met, it fires a new event with the engine. Later on, the engine looks up the right event handler or handlers and calls the respond method on every registered agent for each event fired.
Here is the deployment view of the KATO architecture.
The user on their work station launches a web browser and points the address to a running instance of KATO where they access the PHP files responsible for generating the web pages of the maintenance site.
Those web pages also interact with the relational database tables of KATO.
When the user clicks the process link in the horizontal navigation bar near the top of the page, the engine will then invoke the agents scheduled to run at this time. Those agents will also access the relational database tables.
Something very similar happens with the Java agents except those agents are hosted by the JADE server.
Both the PHP and the Java agents will most likely need to be able to access various resources on the Internet.