|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.basedb.util.jobagent.JobAgentConnection
public class JobAgentConnection
This class is used by client applications to communicate with job agents.
It used to send commands to job agents. For example, it can send
start
, stop
and info
commands.
JobAgentServerConnection
Field Summary | |
---|---|
private static Pattern |
HEADER_REGEXP
Regexp used to parse a typical answer. |
private int |
port
|
private String |
server
|
private int |
timeout
|
Constructor Summary | |
---|---|
JobAgentConnection(int port,
int timeout)
Create a connection to the local job agent running on the specified port. |
|
JobAgentConnection(String server,
int port,
int timeout)
Create a connection to the job agent running on the specified server and listening on the specified port. |
Method Summary | |
---|---|
void |
close()
Close the connection to the job agent. |
private Socket |
connect()
Create a socket connection to the job agent. |
JobAgentInfo |
getInfo(boolean full)
Send an info or status request to the job agent. |
static Map<String,List<String>> |
parseAnswer(String answer)
Utility method for parsing a 'typical' answer from a job agent. |
static Map<String,String> |
parseSimpleAnswer(String answer)
Utility method for parsing a 'typical' answer from a job agent. |
String |
send(String cmd)
Send a remote control command to the job agent. |
private String |
sendCmd(Socket socket,
String cmd)
Send a command to the job agent and return the answer. |
String |
sendPause()
|
String |
sendPing()
Send the ping command to the job agent. |
String |
sendStart()
Send a start request to the job agent. |
String |
sendStop()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final Pattern HEADER_REGEXP
private final String server
private final int port
private final int timeout
Constructor Detail |
---|
public JobAgentConnection(int port, int timeout)
port
- The port the job agent is listening ontimeout
- The timeout in millisecondspublic JobAgentConnection(String server, int port, int timeout)
server
- The server the job agent is running on, or null
to connect to the local hostport
- The port the job agent is listening ontimeout
- The timeout in millisecondsMethod Detail |
---|
public static Map<String,List<String>> parseAnswer(String answer)
answer
- The answer
public static Map<String,String> parseSimpleAnswer(String answer)
answer
- The answer
public String sendPing() throws IOException
ping
command to the job agent. The only
answer to this command is OK
.
IOException
- If there is an errorpublic String sendStart() throws IOException
start
request to the job agent.
IOException
- If there is an errorpublic String sendStop() throws IOException
IOException
public String sendPause() throws IOException
IOException
public JobAgentInfo getInfo(boolean full) throws IOException
info
or status
request to the job agent.
The difference is that a status
request doesn't return
information about cpu, memory or executing jobs.
full
- If TRUE a info
request is sent, othwerwise
a status
request is sent
JobAgentInfo
object containing the
information
IOException
- If there is an errorpublic void close()
public String send(String cmd) throws IOException
cmd
- The command to send
IOException
- If there is an errorprivate Socket connect() throws IOException
IOException
private String sendCmd(Socket socket, String cmd) throws IOException
FAILED
an exception will be thrown.
socket
- The socket used for communicating with the job agentcmd
- The command to send
IOException
- If there is a communications error
|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |