|
HOME | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.ireasoning.protocol.ListenerManager | +--com.ireasoning.protocol.Session | +--com.ireasoning.protocol.tl1.TL1Session
This class represents an open sesssion between TL1 agent and manager.
Fields inherited from class com.ireasoning.protocol.Session |
_state, _target, _timeout, _transportLayer, _tries, DEFAULT_TIME_OUT, TCP, UDP |
Fields inherited from class com.ireasoning.protocol.ListenerManager |
_listeners |
Fields inherited from interface com.ireasoning.core.jmx.State |
STARTED, STARTING, STATES, STOPPED, STOPPING |
Constructor Summary | |
TL1Session()
Constructs a new TL1Session. |
|
TL1Session(String host,
int port)
Constructs a new TL1Session, and connect to passed host. |
|
TL1Session(String host,
int port,
int transportLayer)
Constructs a new TL1Session, and connect to passed host. |
Method Summary | |
void |
asyncSend(TL1Command request)
Used for asynchronous communication. |
boolean |
isKeepAliveThreadRunning()
Returns true if keep-alive thread is running, which send dummy command to keep connection open |
void |
launchKeepAliveThread(String tl1command,
int interval)
Some TL1 agents terminate idle connection. |
void |
launchKeepAliveThread(String tl1command,
int interval,
boolean syncMode)
Some TL1 agents terminate idle connection. |
protected void |
open(String host,
int port)
Opens a connection to TL1 agent |
protected Object |
receiveObject()
Returns received response message |
TL1ResponseMsg[] |
send(TL1Command request)
Sends out TL1 command to the agent. |
TL1ResponseMsg[] |
send(TL1Command request,
int numOfResponses)
Sends out TL1 command to the agent. |
void |
sendHandShakingCode(String code,
String end)
Some TL1 agents have banner page, such as "... |
void |
setSkipParsing(boolean skipParsing)
Set to skip parsing the incoming messages or not. |
void |
setTimeout(int timeout)
Sets time out value of underlying Socket |
TL1NotificationMsg[] |
waitForNotificationMsg()
Blocked and waits for TL1 notification message |
void |
write(TL1Command request)
Similar to send(TL1Command), but does not block until response comes back. |
Methods inherited from class com.ireasoning.protocol.Session |
close, finalize, getRetries, getState, getStateString, getTarget, getTimeout, getTransportLayer, open, setRetries, setTarget, setTransportLayer, startThread |
Methods inherited from class com.ireasoning.protocol.ListenerManager |
addListener, listenerExists, notifyListeners, notifyListeners, removeListener |
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public TL1Session(String host, int port) throws IOException
host
- host name of TL1 agentport
- port number of TL1 agentIOException
- raised if can't connect to remote hostpublic TL1Session()
public TL1Session(String host, int port, int transportLayer) throws IOException
host
- host name of TL1 agentport
- port number of TL1 agenttransportLayer
- transport layer to use, default is TCP transport
layer.IOException
- raised if can't connect to remote hostTL1Session(String, int)
Method Detail |
protected void open(String host, int port) throws IOException
open
in class Session
host
- host name of TL1 agentport
- port number of TL1 agentpublic void setSkipParsing(boolean skipParsing)
skipParsing
- true if not to parse incoming message.public void launchKeepAliveThread(String tl1command, int interval) throws TL1ParsingException
tl1command
- dummy TL1 command to send to keep connection aliveinterval
- time interval to send dummy tl1 command, in secondsTL1ParsingException
- if the passed tl1command is not valid.isKeepAliveThreadRunning()
public void launchKeepAliveThread(String tl1command, int interval, boolean syncMode) throws TL1ParsingException
tl1command
- dummy TL1 command to send to keep connection aliveinterval
- time interval to send dummy tl1 command, in secondssyncMode
- if true, keep-alive thread uses synchronous send. Default value is 'true'.TL1ParsingException
- if the passed tl1command is not valid.isKeepAliveThreadRunning()
public boolean isKeepAliveThreadRunning()
launchKeepAliveThread(java.lang.String, int)
public TL1NotificationMsg[] waitForNotificationMsg() throws IOException
launchKeepAliveThread(java.lang.String, int)
public void setTimeout(int timeout) throws SocketException
setTimeout
in class Session
timeout
- the specified timeout in millisecondsprotected Object receiveObject() throws IOException
receiveObject
in class Session
public TL1ResponseMsg[] send(TL1Command request) throws IOException
write(TL1Command)
method is
a better choice. If you know how many response messages you'll receive,
send(TL1Command request, int numOfResponses)
method can be
used to receive all expected response messages.request
- the TL1 command to be sentIOException
- if time out (after retries) or socket is not valid.TimeoutException
- if time out after retries (TimeoutException is a subclass of IOException)write(TL1Command)
,
send(TL1Command , int )
,
asyncSend(com.ireasoning.protocol.tl1.TL1Command)
public TL1ResponseMsg[] send(TL1Command request, int numOfResponses) throws IOException
request
- the TL1 command to be sentnumOfResponses
- number of response message expected.IOException
- if time out (after retries) or socket is not valid.TimeoutException
- if time out after retries (TimeoutException is a subclass of IOException)send(TL1Command)
,
write(TL1Command)
,
asyncSend(com.ireasoning.protocol.tl1.TL1Command)
public void asyncSend(TL1Command request) throws IOException
request
- the TL1 command to be sentIOException
- if socket exception occurs.send(TL1Command)
,
tl1asyncsend.java examplepublic void write(TL1Command request) throws IOException
IOException
- if socket exception occurs.send(TL1Command)
public void sendHandShakingCode(String code, String end) throws IOException
code
- the handshaking code to sendend
- after sending handshaking code, when receive "end" string, the
program should get out of receiving. If "end" is an empty string "" or
null, the program won't call receive code.TimeoutException
- if time out after retries (TimeoutException is a subclass of IOException)IOException
- if socket exception occurs.
|
HOME | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |