public void doLocalSetup() throws AgentInitializationException {
super.doLocalSetup();
try {
String[] amaName = { "net.hivecell.hive.agent.cell.AgentMonitoringAgent" };
AgentSet ds = myCell.queryAgents( this, amaName, null );
ama = (AgentMonitoringAgent)ds.pickOne();
String[] slaName = { "net.hivecell.hive.agent.cell.CellListAgent" };
ds = myCell.queryAgents( this, slaName, null );
sla = (CellListAgent)ds.pickOne();
if( !connectTo( sla ) ) { // subscribe to the event stream
Debug.warning( "Could not subscribe to local server list agent" );
myCell.killAgent( (AgentImpl)this );
}
} catch( ClassNotFoundException error ) {
Debug.critical( "Huh? This should -never- happen!!", error );
}
try {
Enumeration cells = sla.listCells( this ).elements();
while( cells.hasMoreElements() ) {
CellListInfo cli = (CellListInfo)cells.nextElement();
if( cli.isUp() ) {
try {
ama.monitorCell( this, cli.getAddress() );
} catch( RemoteException error ) {
Debug.warning( "Remote exception while trying to ask the agent monitoring agent to monitor " + cli.getAddress(), error );
} catch( UnableToMonitorCellException error ) {
Debug.warning( "Agent monitoring agent unable to monitor cell at " + cli.getAddress(), error );
}
}
}
} catch( RemoteException error ) {
Debug.warning( "Could not retrieve the list of cells which are up from the server list agent", error );
}
}
|