Package net.sf.basedb.clients.jobagent
Class AgentController
- java.lang.Object
-
- net.sf.basedb.clients.jobagent.AgentController
-
public class AgentController extends Object
This is the command line controller class for the job agent application. It is responsible for starting up and managing a running job agent. The agent itself will be started in separate thread.- Version:
- 2.0
- Author:
- nicklas
- Last modified
- $Date: 2014-04-09 14:21:20 +0200 (on, 09 apr 2014) $
-
-
Field Summary
Fields Modifier and Type Field Description private static org.slf4j.Logger
log
Log job agent events.private int
port
private Properties
properties
private int
timeout
-
Constructor Summary
Constructors Constructor Description AgentController(Properties p)
Create a new controller for controlling the job agent specified by the given properties.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private Agent
createAgent(Properties p)
JobAgentInfo
getInfo()
Get info about running job agent by sending an info request to the agents remote control service.JobAgentInfo
getStatus()
Get status info about running job agent by sending an info request to the agents r emote control service.static void
main(String[] args)
void
pauseAgent()
Pause a running job agent by sending a stop request to the agents remote control service.private static void
printHelp()
private static void
printUsage()
void
registerAgent()
void
startAgent()
Start the agent this controller is controlling.void
stopAgent()
Stop a running job agent by sending a stop request to the agents remote control service.void
unregisterAgent()
-
-
-
Field Detail
-
log
private static final org.slf4j.Logger log
Log job agent events.
-
properties
private final Properties properties
-
port
private final int port
-
timeout
private final int timeout
-
-
Constructor Detail
-
AgentController
public AgentController(Properties p)
Create a new controller for controlling the job agent specified by the given properties.- Parameters:
p
- The properties for the job agent to control
-
-
Method Detail
-
main
public static void main(String[] args)
-
printUsage
private static void printUsage()
-
printHelp
private static void printHelp()
-
startAgent
public void startAgent() throws IOException
Start the agent this controller is controlling. If no agent is running a new one is created in another thread in this virtual machine. The thread must be stopped before the virtual machine exits.- Throws:
IOException
- If there is an error- See Also:
JobAgentConnection.sendStart()
-
stopAgent
public void stopAgent() throws IOException
Stop a running job agent by sending a stop request to the agents remote control service. The agent may be running in this or in another virtual machine.- Throws:
IOException
- If there is an error- See Also:
JobAgentConnection.sendStop()
-
pauseAgent
public void pauseAgent() throws IOException
Pause a running job agent by sending a stop request to the agents remote control service. The agent may be running in this or in another virtual machine.- Throws:
IOException
- If there is an error- See Also:
JobAgentConnection.sendPause()
-
getInfo
public JobAgentInfo getInfo() throws IOException
Get info about running job agent by sending an info request to the agents remote control service. The agent may be running in this or in another virtual machine.- Returns:
- A
JobAgentInfo
object - Throws:
IOException
- If there is an error- See Also:
JobAgentConnection.getInfo(boolean)
-
getStatus
public JobAgentInfo getStatus() throws IOException
Get status info about running job agent by sending an info request to the agents r emote control service. The agent may be running in this or in another virtual machine.- Returns:
- A
JobAgentInfo
object - Throws:
IOException
- If there is an error- Since:
- 2.5
- See Also:
JobAgentConnection.getInfo(boolean)
-
registerAgent
public void registerAgent()
-
unregisterAgent
public void unregisterAgent()
-
createAgent
private Agent createAgent(Properties p)
-
-