|
HOME | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | 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.
Field Summary | |
static int |
SSH
|
Fields inherited from class com.ireasoning.protocol.Session |
_localAddr, _localPort, _state, _target, _thread, _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, UNINITIALIZED |
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. |
|
TL1Session(String host,
int port,
int transportLayer,
int connectionTimeout)
Constructs a new TL1Session, and connect to passed host. |
|
TL1Session(String host,
int port,
String username,
String password)
Constructs a new SSH based TL1Session, and connect to passed host. |
|
TL1Session(String host,
int port,
String username,
String password,
int connectionTimeout)
Constructs a new SSH based 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, getTransportLayer, open, open, open, reopen, setRetries, setTarget, setTransportLayer, 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 |
Field Detail |
public static final int SSH
Constructor Detail |
public TL1Session(String host, int port) throws IOException
host
- host name of TL1 agentport
- port number of TL1 agent
IOException
- raised if can't connect to remote hostpublic TL1Session()
public TL1Session(String host, int port, String username, String password) throws IOException
host
- host name of TL1 agentport
- port number of TL1 agentusername
- SSH login user namepassword
- SSH login passowrd
IOException
- raised if can't connect to remote host
com.ireasoning.core.network.AuthenticationException
- raised if authentication failedpublic TL1Session(String host, int port, String username, String password, int connectionTimeout) throws IOException
host
- host name of TL1 agentport
- port number of TL1 agentusername
- SSH login user namepassword
- SSH login passowrdconnectionTimeout
- Connects this socket to the server with this timeout value, in milliseconds.
A timeout of zero is interpreted as an infinite timeout.
IOException
- raised if can't connect to remote host
com.ireasoning.core.network.AuthenticationException
- raised if authentication failedpublic TL1Session(String host, int port, int transportLayer, int connectionTimeout) throws IOException
host
- host name of TL1 agentport
- port number of TL1 agenttransportLayer
- transport layer to use, default is TCP transport
layer (TransportLayer.TCP
).connectionTimeout
- Connects this socket to the server with this timeout value, in milliseconds.
A timeout of zero is interpreted as an infinite timeout.
IOException
- raised if can't connect to remote hostTL1Session(String, int)
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 (TransportLayer.TCP
).
IOException
- raised if can't connect to remote hostTL1Session(String, int)
Method Detail |
protected void open(String host, int port) throws IOException
host
- host name of TL1 agentport
- port number of TL1 agent
IOException
public 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 seconds
TL1ParsingException
- 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
IOException
launchKeepAliveThread(java.lang.String, int)
public void setTimeout(int timeout) throws SocketException
setTimeout
in class Session
timeout
- the specified timeout in milliseconds
SocketException
protected Object receiveObject() throws IOException
receiveObject
in class Session
TimeoutException
- raised if timeout after retries
IOException
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 sent
IOException
- 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 sent
IOException
- 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 send. If it's null or an empty string, nothing will be sent out first.end
- 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: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |