com.dracoware.rsplib
Class RspServer

java.lang.Object
  extended by com.dracoware.rsplib.RspServer

public class RspServer
extends java.lang.Object

An RspServer object represents a single rspd server (which has a related set of modules).


Constructor Summary
RspServer(java.lang.String name)
          Creates an RspServer object with the specified name.
RspServer(java.lang.String name, java.lang.String IP, int port)
          Creates an RspServer object with the specified name, IP, and port.
RspServer(java.lang.String name, java.lang.String IP, int port, int connectionTimeout, int transmissionTimeout)
          Creates an RspServer object with the specified name IP, port and timeouts.
RspServer(java.lang.String name, java.lang.String IP, int port, int connectionTimeout, int transmissionTimeout, boolean persistent)
          Creates an RspServer object with the specified name IP, port, timeouts, and persistent setting.
 
Method Summary
 void connect()
          Connects to an RSPServer (a node) and gathers its current information.
 void disconnect()
          Disconnects from the rspd if persistently connected.
 int getConnectionTimeout()
          Returns the amount of time (in milliseconds) to wait while connecting to this rspd.
 java.util.Vector getData()
          Returns the data for this rspd.
 int getIndex()
          Returns the index value set for this node.
 java.lang.String getIP()
          Returns the IP address of this rspd.
 java.util.Date getLastContacted()
          Returns the time when this rspd was last contacted.
 java.lang.String getName()
          Returns the name of this rspd.
 int getPort()
          Returns the port for this rspd.
 long getTimeToTrialExpire()
          Gets the time (in seconds) until the rspd expires - when in trial mode.
 int getTransmissionTimeout()
          Returns the amount of time (in milliseconds) to wait while sending/receiving data from this rspd.
 boolean isConnected()
          Returns true if this rspd is connected, and false otherwise.
 boolean isPersistent()
          Returns true if this rspd is persistent, and false otherwise.
 boolean isThresholdCrossed()
          Returns true if a threshold has been crossed for any of the modules known to this RspServer.
 void sendKeepAlive()
          Sends a keep alive packet to the rsp server if we have already persistently connected to the server.
 void setConnected(boolean connected)
          Set whether this rspd is connected currently or not.
 void setConnectionTimeout(int connectionTimeout)
          Sets the amount of time to wait (in milliseconds) while connecting to this rspd.
 void setContacted()
          Tells this node to set its lastContacted field to the current time.
 void setData(java.util.Vector data)
          Sets the data for this rspd.
 void setIndex(int index)
          Sets an index value for this node.
 void setIP(java.lang.String ip)
          Sets the IP address of this rspd.
 void setName(java.lang.String n)
          Sets the name of this rspd.
 void setPersistent(boolean persistent)
          Sets whether or not the node is persistent.
 void setPort(int port)
          Sets the port of this rspd.
 void setTransmissionTimeout(int transmissionTimeout)
          Sets the amount of time to wait (in milliseconds) while sending/receiving data from this rspd.
 java.lang.String toString()
          Creates a String representation of this rspd.
 void updateTime()
          Sets the last contacted time to right now.
 void useSSL(java.io.File keyfile)
          Specifies to use SSL communication.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RspServer

public RspServer(java.lang.String name)
Creates an RspServer object with the specified name.

Parameters:
name - Name of this rspd.

RspServer

public RspServer(java.lang.String name,
                 java.lang.String IP,
                 int port)
Creates an RspServer object with the specified name, IP, and port.

Parameters:
name - Name of this rspd.
IP - IP address of this rspd.
port - Port of this rspd.

RspServer

public RspServer(java.lang.String name,
                 java.lang.String IP,
                 int port,
                 int connectionTimeout,
                 int transmissionTimeout)
Creates an RspServer object with the specified name IP, port and timeouts.

Parameters:
name - Name of this rspd.
IP - IP address of this rspd.
port - Port of this rspd.
connectionTimeout - Timeout (in milliseconds) before giving up trying to connect to this rspd.
transmissionTimeout - Timeout (in milliseconds) before giving up sending/receiving data to this rspd.

RspServer

public RspServer(java.lang.String name,
                 java.lang.String IP,
                 int port,
                 int connectionTimeout,
                 int transmissionTimeout,
                 boolean persistent)
Creates an RspServer object with the specified name IP, port, timeouts, and persistent setting.

Parameters:
name - Name of this rspd.
IP - IP address of this rspd.
port - Port of this rspd.
connectionTimeout - Timeout (in milliseconds) before giving up trying to connect to this rspd.
transmissionTimeout - Timeout (in milliseconds) before giving up sending/receiving data to this rspd.
persistent - Whether or not this node should be persistent.
Method Detail

useSSL

public void useSSL(java.io.File keyfile)
            throws java.io.IOException,
                   javax.net.ssl.SSLException
Specifies to use SSL communication.

Parameters:
keyfile - The SSL keyfile. If it doesn't exist, we create it.
Throws:
java.io.IOException - If we are unable to access the keyfile.
javax.net.ssl.SSLException - If SSL errors occur.

connect

public void connect()
             throws java.io.IOException
Connects to an RSPServer (a node) and gathers its current information.

Throws:
java.io.IOException - If there are problems communicating with the rspd.

updateTime

public void updateTime()
Sets the last contacted time to right now.


sendKeepAlive

public void sendKeepAlive()
                   throws java.io.IOException
Sends a keep alive packet to the rsp server if we have already persistently connected to the server.

Throws:
java.io.IOException - If there was a communication problem.

disconnect

public void disconnect()
Disconnects from the rspd if persistently connected.


isThresholdCrossed

public boolean isThresholdCrossed()
Returns true if a threshold has been crossed for any of the modules known to this RspServer.

Returns:
True if a threshold has crossed for any of this rspd's modules (false otherwise).

setName

public void setName(java.lang.String n)
Sets the name of this rspd.

Parameters:
n - The name of this rspd.

getName

public java.lang.String getName()
Returns the name of this rspd.

Returns:
The name of this rspd.

setIP

public void setIP(java.lang.String ip)
Sets the IP address of this rspd.

Parameters:
ip - The IP address of this rspd.

getIP

public java.lang.String getIP()
Returns the IP address of this rspd.

Returns:
The IP address of this rspd.

setPort

public void setPort(int port)
Sets the port of this rspd.

Parameters:
port - The port of this rspd

getPort

public int getPort()
Returns the port for this rspd.

Returns:
The port for this rspd.

setData

public void setData(java.util.Vector data)
Sets the data for this rspd.

Parameters:
data - The data for this rspd.

getData

public java.util.Vector getData()
Returns the data for this rspd.

Returns:
The data for this rspd.

isConnected

public boolean isConnected()
Returns true if this rspd is connected, and false otherwise.

Returns:
True if this rspd is connected, and false otherwise.

setConnected

public void setConnected(boolean connected)
Set whether this rspd is connected currently or not.

Parameters:
connected - Whether this rspd is currently connected or not.

getLastContacted

public java.util.Date getLastContacted()
Returns the time when this rspd was last contacted.

Returns:
The time when this rspd was last contacted.

setContacted

public void setContacted()
Tells this node to set its lastContacted field to the current time.


toString

public java.lang.String toString()
Creates a String representation of this rspd.

Overrides:
toString in class java.lang.Object
Returns:
A String representation of this rspd.

setConnectionTimeout

public void setConnectionTimeout(int connectionTimeout)
Sets the amount of time to wait (in milliseconds) while connecting to this rspd.

Parameters:
connectionTimeout - Amount of time to wait (in milliseconds) while connecting to this rspd.

getConnectionTimeout

public int getConnectionTimeout()
Returns the amount of time (in milliseconds) to wait while connecting to this rspd.

Returns:
The amount of time (in milliseconds) to wait while connecting to this rspd.

setTransmissionTimeout

public void setTransmissionTimeout(int transmissionTimeout)
Sets the amount of time to wait (in milliseconds) while sending/receiving data from this rspd.

Parameters:
transmissionTimeout - The amount of time to wait (in milliseconds) while sending/receiving data from this rspd.

getTransmissionTimeout

public int getTransmissionTimeout()
Returns the amount of time (in milliseconds) to wait while sending/receiving data from this rspd.

Returns:
The amount of time (in milliseconds) to wait while sending/receiving data from this rspd.

setPersistent

public void setPersistent(boolean persistent)
Sets whether or not the node is persistent.

Parameters:
persistent - Whether or not the node is persistent.

isPersistent

public boolean isPersistent()
Returns true if this rspd is persistent, and false otherwise.

Returns:
True if this rspd is persistent, and false otherwise.

getIndex

public int getIndex()
Returns the index value set for this node.

Returns:
The index value set for this node.

setIndex

public void setIndex(int index)
Sets an index value for this node. This value is not used internally, but may be used if for example this node is placed into a tree.

Parameters:
index - The index value.

getTimeToTrialExpire

public long getTimeToTrialExpire()
Gets the time (in seconds) until the rspd expires - when in trial mode. If not in trial mode, returns -1.

Returns:
Time (in seconds) until this rspd expires when in trial mode (-1 if not in trial mode).