com.adventnet.snmp.snmp2.agent
Class BaseSnmpStore

java.lang.Object
  |
  +--com.adventnet.snmp.snmp2.agent.Cache
        |
        +--com.adventnet.snmp.snmp2.agent.BaseSnmpStore
Direct Known Subclasses:
BaseSnmpAgent, BaseSnmpTrapService, SnmpStore

public abstract class BaseSnmpStore
extends Cache

This class intialises api thread and session required for SnmpAgent,SnmpProxy and SnmpTrapService.

Cleans up the common session and associated API thread if no one is using it.

Both SnmpStore and MicroSnmpStore extend this class.

See Also:
SnmpStore, MicroSnmpStore, Serialized Form

Field Summary
protected  int debugLevel
          this indicates the debugLevel of the agent.
protected  java.lang.String localAddress
          local address of the agent.
(package private)  java.lang.String oldAddress
           
(package private)  int oldPort
           
protected  int protocol
           
protected  SnmpSession session
          session is the main SnmpSession which waits for requests or it can be SnmpSession which can be used for asynchronous sending of PDU .
static Log snmpLog
           
 
Fields inherited from class com.adventnet.snmp.snmp2.agent.Cache
cache, debug
 
Constructor Summary
protected BaseSnmpStore()
          The no arg constructor which initialises the SnmpStore and the API thread.
protected BaseSnmpStore(int port)
          The one arg(port) constructor which initialises the SnmpStore and the API thread.
protected BaseSnmpStore(java.lang.String ipAddress)
          The one arg(ipAddress) constructor which initialises the SnmpStore and the API thread.
protected BaseSnmpStore(java.lang.String ipAddress, int port)
          The two arg(ipAddress, port) constructor which initialises the SnmpStore and the API thread.
 
Method Summary
 void closeAll()
          This method closes all the open sessions which are controlled by the common SnmpAPI thread Sets the api thread to null.
protected  ProtocolOptions createProtocolOptions(java.lang.String remoteHost, int remotePort, int localPort)
           
protected  void finalize()
          This cleans up the common session if no one is using it.
 SnmpAPI getSnmpAPI()
          Gets the SnmpAPI.
 SnmpSession getSnmpSession()
          This is the main Session which waits for requests and notifies interested SnmpClient (SnmpAgent).
 SnmpSession getSnmpSession(java.lang.String ipAddress)
          This is the main Session which waits for requests and notifies interested SnmpClient (SnmpAgent).
protected  void initSession()
          Initialises the SnmpSession and put it into Cache after assigning the default community as "public" and version as SnmpAPI.SNMP_VERSION_3.
protected  void initSnmpStore(BaseSnmpStore store)
           
 boolean isAlive()
          This method lets you know if the Agent and related threads used for monitoring requests are alive
 boolean isDebug()
          Gets the status of the debug mode.
static void killSnmpAgent()
          This method will close all the sessions and api thread including the TrapSession.
 void setDebug(boolean val)
          sets the debug messages true for SnmpAPI.
 
Methods inherited from class com.adventnet.snmp.snmp2.agent.Cache
getFromCache, getMibOperations, putInCache, setMibOperations
 
Methods inherited from class java.lang.Object
, clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

protocol

protected int protocol

localAddress

protected java.lang.String localAddress
local address of the agent.

oldAddress

java.lang.String oldAddress

oldPort

int oldPort

session

protected transient SnmpSession session
session is the main SnmpSession which waits for requests or it can be SnmpSession which can be used for asynchronous sending of PDU .

This purely depends upon the implementation of SnmpStore extended classes.

See Also:
SnmpSession

debugLevel

protected int debugLevel
this indicates the debugLevel of the agent. It can take different level of values defined in utils class.
See Also:
utils

snmpLog

public static Log snmpLog
Constructor Detail

BaseSnmpStore

protected BaseSnmpStore()
The no arg constructor which initialises the SnmpStore and the API thread.

Doesn't open sessions This must be done explicitly by classes which extend SnmpStore


BaseSnmpStore

protected BaseSnmpStore(java.lang.String ipAddress)
The one arg(ipAddress) constructor which initialises the SnmpStore and the API thread.

Doesn't open sessions This must be done explicitly by classes which extend SnmpStore


BaseSnmpStore

protected BaseSnmpStore(int port)
The one arg(port) constructor which initialises the SnmpStore and the API thread.

Doesn't open sessions This must be done explicitly by classes which extend SnmpStore


BaseSnmpStore

protected BaseSnmpStore(java.lang.String ipAddress,
                        int port)
The two arg(ipAddress, port) constructor which initialises the SnmpStore and the API thread.

Doesn't open sessions This must be done explicitly by classes which extend SnmpStore

Method Detail

getSnmpAPI

public SnmpAPI getSnmpAPI()
Gets the SnmpAPI.
Returns:
the SnmpAPI which has been intialised

getSnmpSession

public SnmpSession getSnmpSession()
This is the main Session which waits for requests and notifies interested SnmpClient (SnmpAgent). Used by SnmpAgent and SnmpTrapService.
Returns:
null if no SnmpSession has been instantiated
See Also:
SnmpClient

getSnmpSession

public SnmpSession getSnmpSession(java.lang.String ipAddress)
This is the main Session which waits for requests and notifies interested SnmpClient (SnmpAgent). Used by SnmpAgent and SnmpTrapService.
Parameters:
The - IpAddress at which the session is started.
Returns:
null if no SnmpSession has been instantiated
See Also:
SnmpClient

createProtocolOptions

protected ProtocolOptions createProtocolOptions(java.lang.String remoteHost,
                                                int remotePort,
                                                int localPort)

initSnmpStore

protected void initSnmpStore(BaseSnmpStore store)

initSession

protected void initSession()
Initialises the SnmpSession and put it into Cache after assigning the default community as "public" and version as SnmpAPI.SNMP_VERSION_3.

isAlive

public boolean isAlive()
This method lets you know if the Agent and related threads used for monitoring requests are alive
Returns:
true if the API thread and session is alive otherwise false

closeAll

public void closeAll()
              throws java.lang.Throwable
This method closes all the open sessions which are controlled by the common SnmpAPI thread Sets the api thread to null.

Use this method only when you know that nobody else is using the sessions.

Throws:
java.lang.Throwable - in case of error

finalize

protected void finalize()
                 throws java.lang.Throwable
This cleans up the common session if no one is using it.
Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable - in case of finalization errors

setDebug

public void setDebug(boolean val)
sets the debug messages true for SnmpAPI.
Overrides:
setDebug in class Cache
Parameters:
val - true or false .
See Also:
SnmpAPI

isDebug

public boolean isDebug()
Gets the status of the debug mode.
Overrides:
isDebug in class Cache
Returns:
true if debug is on otherwise false

killSnmpAgent

public static void killSnmpAgent()
This method will close all the sessions and api thread including the TrapSession. It is strongly recommended not to use this method unless the user wishes to shutdown the agent and its related threads