com.tivoli.twg.snmp
Class SNMPRemoteRequest

java.lang.Object
  extended bycom.tivoli.twg.libs.ServiceNode
      extended bycom.tivoli.twg.snmp.SNMPRemoteRequest
All Implemented Interfaces:
CommandReceivedListener, java.lang.Runnable

public class SNMPRemoteRequest
extends ServiceNode
implements CommandReceivedListener

This class will allow access to the SNMP Stack (V1, V2, or V3) on the Director Server. It allows the execution of the primary SNMP requests Get, GetNext, Set, GetBulk, and Inform to be executed remotely on the Director Server from the console.

See Also:
SNMPRemoteResponse

Field Summary
static int DEFAULT
           
static int SNMP_V1
           
static int SNMP_V2
           
static int SNMP_V3
           
 
Fields inherited from class com.tivoli.twg.libs.ServiceNode
SVCNODE_DISABLE_TRACING_CMD, SVCNODE_ENABLE_TRACING_CMD, SVCNODE_GET_STATUS_CMD, SVCNODE_KILL_SERVICE_CMD
 
Constructor Summary
SNMPRemoteRequest()
          Construct an instance of the remote services.
SNMPRemoteRequest(int version)
          Construct an instance of the remote services for SNMP V1, V2, or V3.
 
Method Summary
 void close()
          Close this remote requester.
 boolean CommandReceived(ServiceNode CallBackSN, Command cmd)
          INTERNAL USE ONLY
 void iCommandReceived(Command cmd)
          INTERNAL USE ONLY
 boolean isClosed()
          Test whether this remote requester is closed.
 long sendGetBulkRequest(long targetMoid, java.lang.String[] oids, int maxRepetitions, int nonRepeaters, SNMPRemoteResponse responseClass)
          Called to perform a Get Bulk Request operation on the target Managed Object ID.
 long sendGetNextRequest(long targetMoid, java.lang.String[] oids, SNMPRemoteResponse responseClass)
          Called to perform an SNMP GetNext request operation on the target Managed Object ID.
 long sendGetNextRequest(long targetMoid, java.lang.String oid, SNMPRemoteResponse responseClass)
           
 long sendGetRequest(long targetMoid, java.lang.String[] oids, SNMPRemoteResponse responseClass)
          Called to perform an SNMP Get Request operation on the target Managed Object ID.
 long sendGetRequest(long targetMoid, java.lang.String oid, SNMPRemoteResponse responseClass)
           
 long sendInformRequest(long targetMoid, VariableBinding[] vbl, SNMPRemoteResponse responseClass)
          Called to perform an Inform Request operation on the target Managed Object ID.
 long sendSetRequest(long targetMoid, VariableBinding[] vbl, SNMPRemoteResponse responseClass)
          Called to perform an SNMP Set operation on the target Managed Object ID.
 long sendTrap(long targetMoid, java.lang.String agentAddress, VariableBinding[] vbl)
          Called to perform an SNMP V1 Trap operation on the target Managed Object ID.
 long sendV2Trap(long targetMoid, VariableBinding[] vbl)
          Called to perform an SNMP V2 Trap operation on the target Managed Object ID.
 void setVersion(int version)
          Set the SNMP version.
 
Methods inherited from class com.tivoli.twg.libs.ServiceNode
Close, CommandReceived, ConnectionActive, Create, DeregisterCommandListener, DeregisterDefaultCommandListener, EnqueueCommandFail, EnqueueReceiveBuffer, formatCommandCode, formatReturnCode, GetFeatureFlags, GetServiceNodeFactory, getTS, IsActive, IsRawMode, LocalMACAddress, LocalMacAddressList, LocalSystemName, LocalUniqueID, Name, PeriodicCallback, ProcessCommands, ReceiveData, RegisterAsServiceBase, RegisterCommandListener, RegisterDefaultCommandListener, run, SendAsynchCommand, SendBuffer, SendCommand, SendLocalAsyncCommand, SendLocalCommand, SendPostponedReply, SetActive, setCommandDebugString, SetFeatureFlags, SetGlobalNetworkTimeout, SetLocalSystemName, SetPeriodicCallback, SetServiceNodeFactory, ThreadInit, ThreadTerm, toString, traceCommandCompleteCall, traceCommandReceived, traceCommandReceivedReturn, traceCommandSend, traceError
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT

public static final int DEFAULT
See Also:
Constant Field Values

SNMP_V1

public static final int SNMP_V1
See Also:
Constant Field Values

SNMP_V2

public static final int SNMP_V2
See Also:
Constant Field Values

SNMP_V3

public static final int SNMP_V3
See Also:
Constant Field Values
Constructor Detail

SNMPRemoteRequest

public SNMPRemoteRequest()
                  throws BadServiceNodeImplException,
                         ServiceNodeClosedException,
                         ServiceNodeException
Construct an instance of the remote services. It will attempt to initialize communications with the Director Server. In this case, it will use the default version of the device.

Throws:
BadServiceNodeImplException
ServiceNodeClosedException
ServiceNodeException

SNMPRemoteRequest

public SNMPRemoteRequest(int version)
                  throws BadServiceNodeImplException,
                         ServiceNodeClosedException,
                         ServiceNodeException
Construct an instance of the remote services for SNMP V1, V2, or V3. It will attempt to initialize communications with the Director Server. This forces the request to a certain version even if it's different than the device's version.

Parameters:
version - SNMPRemoteRequest.DEFAULT, SNMPRemoteRequest.SNMP_V1, SNMPRemoteRequest.SNMP_V2, SNMPRemoteRequest.SNMP_V3
Throws:
BadServiceNodeImplException
ServiceNodeClosedException
ServiceNodeException
Method Detail

sendGetRequest

public long sendGetRequest(long targetMoid,
                           java.lang.String[] oids,
                           SNMPRemoteResponse responseClass)
                    throws ServiceNodeException
Called to perform an SNMP Get Request operation on the target Managed Object ID.

Parameters:
targetMoid - The Managed Object ID of the TWGSNMPDevice that the operation was targeted at.
oids - An array of SNMP object identifiers that are to be used as a target for this operation.
responseClass - An instance of a class that implements the SNMPRemoteResponse interface. This instance will be called at the appropriate method when this Get operation either completes successfully, or fails.
Returns:
long if > 0 then the long is the PDU request ID, if <=0, then it's one of the error codes listed in SNMPRemoteResponse
Throws:
ServiceNodeException
See Also:
SNMPRemoteResponse

sendGetRequest

public long sendGetRequest(long targetMoid,
                           java.lang.String oid,
                           SNMPRemoteResponse responseClass)
                    throws ServiceNodeException
Throws:
ServiceNodeException

sendGetNextRequest

public long sendGetNextRequest(long targetMoid,
                               java.lang.String[] oids,
                               SNMPRemoteResponse responseClass)
                        throws ServiceNodeException
Called to perform an SNMP GetNext request operation on the target Managed Object ID.

Parameters:
targetMoid - The Managed Object ID of the TWGSNMPDevice that the operation was targeted at.
oids - A array of SNMP OIDs that are to be used as a target for this operation. A GetNext will return the OID that follows this one, in lexigraphical order, in the target systems MIB tree.
responseClass - An instance of a class that implements the SNMPRemoteResponse interface. This instance will be called at the appropriate method when this GetNext operation either completes successfully, or fails.
Returns:
long if > 0 then the long is the PDU request ID, if <=0, then it's one of the error codes listed in SNMPRemoteResponse
Throws:
ServiceNodeException
See Also:
SNMPRemoteResponse

sendGetNextRequest

public long sendGetNextRequest(long targetMoid,
                               java.lang.String oid,
                               SNMPRemoteResponse responseClass)
                        throws ServiceNodeException
Throws:
ServiceNodeException

sendSetRequest

public long sendSetRequest(long targetMoid,
                           VariableBinding[] vbl,
                           SNMPRemoteResponse responseClass)
                    throws ServiceNodeException
Called to perform an SNMP Set operation on the target Managed Object ID.

Parameters:
targetMoid - The Managed Object ID of the TWGSNMPDevice that the operation was targeted at.
vbl - The VariableBinding that is to be used as a target for this operation. A Set will return the success of the set of these OIDs to SetResponse.
responseClass - An instance of a class that implements the SNMPRemoteResponse interface. This instance will be called at the appropriate method when this Set operation either completes successfully, or fails.
Returns:
long if > 0 then the long is the PDU request ID, if <=0, then it's one of the error codes listed in SNMPRemoteResponse
Throws:
ServiceNodeException
See Also:
SNMPRemoteResponse

sendGetBulkRequest

public long sendGetBulkRequest(long targetMoid,
                               java.lang.String[] oids,
                               int maxRepetitions,
                               int nonRepeaters,
                               SNMPRemoteResponse responseClass)
                        throws ServiceNodeException
Called to perform a Get Bulk Request operation on the target Managed Object ID.

Parameters:
targetMoid - The Managed Object ID of the TWGSNMPDevice that the operation was targeted at.
oids - The SNMP OIDs that are to be used as a target for this operation.
maxRepetitions - The maximum number of repetitions.
nonRepeaters - The number of non-repeaters
responseClass - An instance of a class that implements the SNMPRemoteResponse interface. This instance will be called at the appropriate method when this Get Bulk operation either completes successfully, or fails.
Returns:
long if > 0 then the long is the PDU request ID, if <=0, then it's one of the error codes listed in SNMPRemoteResponse
Throws:
ServiceNodeException
See Also:
SNMPRemoteResponse

sendInformRequest

public long sendInformRequest(long targetMoid,
                              VariableBinding[] vbl,
                              SNMPRemoteResponse responseClass)
                       throws ServiceNodeException
Called to perform an Inform Request operation on the target Managed Object ID.

Parameters:
targetMoid - The Managed Object ID of the TWGSNMPDevice that the operation was targeted at.
vbl - The VariableBinding that is to be used as a target for this operation. A Inform will return the success of the inform of these OIDs to InformResponse.
responseClass - An instance of a class that implements the SNMPRemoteResponse interface. This instance will be called at the appropriate method when this Inform operation either completes successfully, or fails.
Returns:
long if > 0 then the long is the PDU request ID, if <=0, then it's one of the error codes listed in SNMPRemoteResponse
Throws:
ServiceNodeException
See Also:
SNMPRemoteResponse

sendTrap

public long sendTrap(long targetMoid,
                     java.lang.String agentAddress,
                     VariableBinding[] vbl)
              throws ServiceNodeException
Called to perform an SNMP V1 Trap operation on the target Managed Object ID.

Parameters:
targetMoid - The Managed Object ID of the TWGSNMPDevice that the operation was targeted at.
agentAddress - IP address of the SNNP agent who is the source of the trap
vbl - The VariableBinding that is to be used as a target for this operation.
Returns:
long if > 0 then the long is the PDU request ID, if <=0, then it's one of the error codes listed in SNMPRemoteResponse
Throws:
ServiceNodeException
See Also:
SNMPRemoteResponse

sendV2Trap

public long sendV2Trap(long targetMoid,
                       VariableBinding[] vbl)
                throws ServiceNodeException
Called to perform an SNMP V2 Trap operation on the target Managed Object ID.

Parameters:
targetMoid - The Managed Object ID of the TWGSNMPDevice that the operation was targeted at.
vbl - The VariableBinding that is to be used as a target for this operation.
Returns:
long if > 0 then the long is the PDU request ID, if <=0, then it's one of the error codes listed in SNMPRemoteResponse
Throws:
ServiceNodeException
See Also:
SNMPRemoteResponse

setVersion

public void setVersion(int version)
Set the SNMP version. Valid choices are SNMP_V1 or SNMP_V2. This will force the version sent, instead of choosing the default version for the device.

Parameters:
version - SNMP_V1 or SNMP_v2

isClosed

public boolean isClosed()
Test whether this remote requester is closed. Once closed, request will no longer work.

Returns:
true if remote requester is closed

close

public void close()
Close this remote requester. Every intance of SNMPRemoteRequest must be closed, otherwise a thread will be left running. So be sure to call close() when finished with this object.


CommandReceived

public boolean CommandReceived(ServiceNode CallBackSN,
                               Command cmd)
INTERNAL USE ONLY

Specified by:
CommandReceived in interface CommandReceivedListener
Parameters:
CallBackSN - - ServiceNode instance which received Command
cmd - - Instance of Command received
Returns:
true if ServiceNode should stay active, false if it should terminate

iCommandReceived

public void iCommandReceived(Command cmd)
INTERNAL USE ONLY