com.adventnet.cli
Class CLIResourceManager

java.lang.Object
  |
  +--com.adventnet.cli.CLIResourceManager

public class CLIResourceManager
extends java.lang.Object

This class is to manage System-wide resources associated with the CLI APIs within the same Java Virtual Machine (JVM). This would allow control of parameters such as the system-wide default number of connections that can be opened at any given instant, default value of connection keepAlive timeout, and other parameters.


Method Summary
 void closeAllConnections()
          Closes all the connections associated with the multiplexed (non-dedicated) session in the connection pool.
 int getAliveConnectionsCount()
          Gets the total number of connections that have been established
static CLIResourceManager getInstance()
          Gets an instance of the CLIResourceManager.
 int getKeepAliveTimeout()
          Gets the keepAlive timeout in seconds.
 int getMaxConnections()
          Gets the maximum number of CLI Connections that can exist for any session opened.
 int getSystemWideMaxConnections()
          Gets the maximum number of connections System Wide that can exist at any given instant.
 boolean isSetPooling()
          Gets the pooling Flag common to CLI sessions.
 void setKeepAliveTimeout(int timeout)
          Sets the keepAlive timeout in seconds.
 void setMaxConnections(int connections)
          Sets the maximum number of CLI Connections that can exist per device for any session opened.
 void setPooling(boolean poolFlag)
          Enables/Disables the pooling/sharing of the CLITransport Providers among CLI sessions.
 void setSystemWideMaxConnections(int connections)
          Sets the maximum number of connections System Wide that can exist at any given instant of time.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static CLIResourceManager getInstance()
Gets an instance of the CLIResourceManager. The Resource Manager Manages the various resources like the Maximum number of CLI connections which can be opened, timeout parameter on a per device basis,etc. These parameters can be set on the CLISession when instantiated either by the constructor where the CLIProtocolOptions is passed as an argument or both the CLIProtocolOptions and enable pooling flag are passed as arguments.
Returns:
the CLIResourceManager instance.
See Also:
CLISession.CLISession(CLIProtocolOptions cliProtOpt), CLISession.CLISession(CLIProtocolOptions cliProtOpt, boolean enablePooling)

setSystemWideMaxConnections

public void setSystemWideMaxConnections(int connections)
Sets the maximum number of connections System Wide that can exist at any given instant of time. Default is 3. When a zero value is assigned, any number of connections can be opened (infinite).
Parameters:
connections - number of maximum allowed connections System Wide. When a negative value is given, it is not accepted.

getSystemWideMaxConnections

public int getSystemWideMaxConnections()
Gets the maximum number of connections System Wide that can exist at any given instant. When a zero value is given, there is no limit on the number of connections that can be opened.
Returns:
the maximum number of connections allowed System Wide.

getAliveConnectionsCount

public int getAliveConnectionsCount()
Gets the total number of connections that have been established
Returns:
the total number of connections that has been established at the time of calling this method.

setKeepAliveTimeout

public void setKeepAliveTimeout(int timeout)
Sets the keepAlive timeout in seconds. This is the time for which a particular CLI connection remains idle. This parameter is common to a group of connections with the same device. Setting it here makes it available globally (for all the sessions opened). But this parameter when set on the CLISession will override the value set here.
Parameters:
timeout - the time-out value (in seconds).

getKeepAliveTimeout

public int getKeepAliveTimeout()
Gets the keepAlive timeout in seconds. This is the time for which a particular CLI connection remains idle. This parameter is common to a group of connections with the same device.
Returns:
the timeout value (in seconds).

setMaxConnections

public void setMaxConnections(int connections)
Sets the maximum number of CLI Connections that can exist per device for any session opened. Default is 1. Setting it here makes it available globally (for all the sessions opened). If a zero value is set, any number of connections that can be opened to the device. This parameter when set on the CLISession will override the value set here.
Parameters:
connections - number of maximum allowed connections. Negative values are not accepted.

getMaxConnections

public int getMaxConnections()
Gets the maximum number of CLI Connections that can exist for any session opened.
Returns:
the maximum number of connections allowed for this Session.

setPooling

public void setPooling(boolean poolFlag)
Enables/Disables the pooling/sharing of the CLITransport Providers among CLI sessions. Setting it here will enable Transport pooling for all the sessions opened. This can be overridden by setting the pooling Flag on the CLISession.
Parameters:
poolFlag - boolean to indicate whether pooling is enabled or disabled.

isSetPooling

public boolean isSetPooling()
Gets the pooling Flag common to CLI sessions.
Returns:
the pooling Flag.

closeAllConnections

public void closeAllConnections()
Closes all the connections associated with the multiplexed (non-dedicated) session in the connection pool. Usually any connection associated with a non-dedicated session remains open for a time interval of KeepAliveTimeout after its use and even a call of close() on the associated session does not close the connection. Hence, this method can be used to close all such open connections.


Copyright (c)2010 ZOHO Corp., All Rights Reserved.