public void destroyAgent ( AgentObject agent ) { FoundAgent found = resolve ( null , agent . getOid ( ) , "destroyAgent" ) ; if ( found == null ) { return ; } log . info ( "Destroying agent" , "agent" , agent . which ( ) ) ; // transition the agent to a new state and perform the effect of the transition if ( found . state == AgentState . PENDING ) { found . bureau . agentStates . remove ( found . agent ) ; _omgr . destroyObject ( found . agent . getOid ( ) ) ; } else if ( found . state == AgentState . STARTED ) { found . bureau . agentStates . put ( found . agent , AgentState . STILL_BORN ) ; } else if ( found . state == AgentState . RUNNING ) { // TODO: have a timeout for this in case the client is misbehaving or hung BureauSender . destroyAgent ( found . bureau . clientObj , agent . getOid ( ) ) ; found . bureau . agentStates . put ( found . agent , AgentState . DESTROYED ) ; } else if ( found . state == AgentState . DESTROYED || found . state == AgentState . STILL_BORN ) { log . warning ( "Ignoring request to destroy agent in unexpected state" , "state" , found . state , "agent" , found . agent . which ( ) ) ; } found . bureau . summarize ( ) ; }
Destroys a previously started agent using the data in the given object .