Package jade.tools.sniffer
Class Sniffer
- java.lang.Object
-
- jade.core.Agent
-
- jade.tools.ToolAgent
-
- jade.tools.sniffer.Sniffer
-
- All Implemented Interfaces:
TimerListener,Serializable,Serializable,Runnable
public class Sniffer extends ToolAgent
This is the Sniffer agent.
This class implements the low level part of the Sniffer, interacting with Jade environment and with the sniffer GUI.
At startup, the sniffer subscribes itself as an rma to be informed every time an agent is born or dead, a container is created or deleted.
For more information see Introduction to the Sniffer.A properties file while may be used to control different sniffer properties. These optional properties are as follows:
- preload - A list of preload descriptions seperated by a semi-colon. Each description
consists of an agent name match string and optional list of performatives each seperated by a space.
For details on the agent name match string, see the method isMatch().
If there is no @ in the agent name, it assumes the current HAP for it.
If the performative list is not present, then the sniffer will display all messages;
otherwise, only those messages that have a matching performative mentioned will be displayed.
Examples:preload=da0;da1 inform propose preload=agent?? inform preload=*
- clip - A list of agent name prefixes seperated by a semi-colon which will be removed when
showing the agent's name in the agent box. This is helpful to eliminate common agent prefixes.
Example:clip=com.hp.palo-alto.;helper.
The original implementation processed a .inf file. For backward compatability this has been preserved but its usage should be converted to use the new .properties file. The format of the .inf file is each line contains an agent name and optional list of performatives.
Example:da0 da1 inform propose
Notes:
- If a message is one that is to be ignored, then it is dropped totally. If you look at the sniffer dump of messages, it will not be there. Might want to change this.
- Should develop a GUI to allow dynamically setting which messages are filtered instead of forcing them to be in the properties file.
- Probably should allow one to turn on and off the display of the performative name. Although, it seems pretty nice to have this information and although one might consider that it clutters the display, it sure provides a lot of information with it.
- Version:
- $Date$ $Revision$
- Author:
- Alessandro Beneventi (Developement), Gianluca Tanca (Concept & Early Version), Robert Kessler University of Utah (preload configuration, don't scroll agent boxes), Martin Griss HP Labs (display additional message information), Dick Cowan HP Labs (property handling, display full agent name when mouse over)
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class jade.tools.ToolAgent
ToolAgent.AMSListenerBehaviour, ToolAgent.EventHandler
-
Nested classes/interfaces inherited from class jade.core.Agent
Agent.Interrupted
-
-
Field Summary
Fields Modifier and Type Field Description static booleanSNIFF_OFFstatic booleanSNIFF_ON-
Fields inherited from class jade.core.Agent
AP_ACTIVE, AP_DELETED, AP_IDLE, AP_INITIATED, AP_MAX, AP_MIN, AP_SUSPENDED, AP_WAITING, D_ACTIVE, D_MAX, D_MIN, D_RETIRED, D_SUSPENDED, D_UNKNOWN, MSG_QUEUE_CLASS
-
-
Constructor Summary
Constructors Constructor Description Sniffer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ACLMessagegetSniffMsg(List agents, boolean onFlag)Creates the ACLMessage to be sent to the Ams with the list of the agents to be sniffed/unsniffed.protected booleanisMatch(String aMatchExpression, String aString)Given two strings determine if they match.protected StringpreloadContains(String agentName)voidsniffMsg(List agents, boolean onFlag)This method adds an AMSClientBehaviour that performs a request to the AMS for sniffing/unsniffing list of agents.voidtoolSetup()ACLMessages for subscription and unsubscription as rma are created and corresponding behaviours are set up.protected voidtoolTakeDown()Cleanup during agent shutdown.-
Methods inherited from class jade.tools.ToolAgent
afterClone, afterLoad, afterMove, afterReload, afterThaw, beforeFreeze, beforeMove, beforeReload, beforeSave, getCancel, getRequest, getSubscribe, setup, takeDown
-
Methods inherited from class jade.core.Agent
addBehaviour, beforeClone, blockingReceive, blockingReceive, blockingReceive, blockingReceive, changeStateTo, clean, createMessageQueue, doActivate, doClone, doDelete, doMove, doSuspend, doTimeOut, doWait, doWait, doWake, getAgentState, getAID, getAID, getAMS, getArguments, getBehavioursCnt, getBootProperties, getContainerController, getContentManager, getCurQueueSize, getDefaultDF, getExecutedBehavioursCnt, getGenerateBehaviourEvents, getGenerateMessageEvents, getHap, getHelper, getLocalName, getName, getO2AInterface, getO2AObject, getPostedMessagesCnt, getProperty, getQueueSize, getReceivedMessagesCnt, getSentMessagesCnt, getState, here, isAlive, isRestarting, join, notifyChangeBehaviourState, notifyRestarted, postMessage, putBack, putO2AObject, receive, receive, receive, registerO2AInterface, removeBehaviour, removeTimer, restartLater, restoreBufferedState, restoreFields, run, send, setArguments, setEnabledO2ACommunication, setGenerateBehaviourEvents, setGenerateMessageEvents, setO2AManager, setQueueSize, waitUntilStarted, write
-
-
-
-
Field Detail
-
SNIFF_ON
public static final boolean SNIFF_ON
- See Also:
- Constant Field Values
-
SNIFF_OFF
public static final boolean SNIFF_OFF
- See Also:
- Constant Field Values
-
-
Method Detail
-
isMatch
protected boolean isMatch(String aMatchExpression, String aString)
Given two strings determine if they match. We iterate over the match expression string from left to right as follows:- If we encounter a '*' in the expression token they match.
- If there aren't any more characters in the subject string token they don't match.
- If we encounter a '?' in the expression token we ignore the subject string's character and move on to the next iteration.
- If the character in the expression token isn't equal to the character in the subject string they don't match.
- Parameters:
aMatchExpression- An expression string with special significance to '?' and '*'.aString- The subject string.- Returns:
- True if they match, false otherwise.
-
toolSetup
public void toolSetup()
ACLMessages for subscription and unsubscription as rma are created and corresponding behaviours are set up.
-
toolTakeDown
protected void toolTakeDown()
Cleanup during agent shutdown. This method cleans things up when Sniffer agent is destroyed, disconnecting from AMS agent and closing down the Sniffer administration GUI. Currently sniffed agents are also unsniffed to avoid errors.- Overrides:
toolTakeDownin classToolAgent
-
sniffMsg
public void sniffMsg(List agents, boolean onFlag)
This method adds an AMSClientBehaviour that performs a request to the AMS for sniffing/unsniffing list of agents.
-
getSniffMsg
public ACLMessage getSniffMsg(List agents, boolean onFlag)
Creates the ACLMessage to be sent to the Ams with the list of the agents to be sniffed/unsniffed. The internal list of sniffed agents is also updated.- Parameters:
agentVect- vector containing TreeData item representing the agentsonFlag- can be:- Sniffer.SNIFF_ON to activate sniffer on an agent/group
- Sniffer.SNIFF_OFF to deactivate sniffer on an agent/group
-
-