com.ibm.di.connector
Class SNMPConnector

java.lang.Object
  extended by com.ibm.di.connector.Connector
      extended by com.ibm.di.connector.SNMPConnector
All Implemented Interfaces:
ConnectorInterface, CheckpointRestartInterface, VersionInfoInterface, com.tivoli.snmp.TrapFilter, com.tivoli.snmp.TrapListener, Serializable

public class SNMPConnector
extends Connector
implements com.tivoli.snmp.TrapListener, com.tivoli.snmp.TrapFilter, CheckpointRestartInterface, ConnectorInterface

The SNMPConnector implements get/set/walk and trap-receive operations by means of the IBM Tivoli SNMP Stack.

The connector can operate in two modes: Client and Trap Receiver - Client Mode

In client mode you can use it in iterator mode where the connector will send a getnext request to the snmp agent and return one entry for each OID returned by the agent. In Lookup mode the connector will perform a get request returning the oid/value for the requested oid. The link criteria specifies: oid and optionally server, port and version.

- Trap Receiver Mode

In trap receiver mode the connector can only be used in Iterator mode. The connector will listen for incoming snmp traps and return each as an entry to the caller. Both V1, V2c and V3 traps are handled.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class com.ibm.di.connector.Connector
ALL_MODES, myLog, PROPERTY_MESSAGE, PROPERTY_READER, PROPERTY_WRITER
 
Fields inherited from interface com.ibm.di.server.CheckpointRestartInterface
RESTART_AFTER, RESTART_BEFORE, RESTART_IN
 
Constructor Summary
SNMPConnector()
          Constructor for the SNMPConnector object
 
Method Summary
 boolean filter(com.tivoli.snmp.SnmpTrap trap)
          Trap filter - Returns true if a trap should be sent to this connector.
 Entry findEntry(SearchCriteria search)
          Searches for an entry matching the specified search criteria.
 Entry getCheckpointInformation()
          Returns the state information for the connector.
 Entry getNextEntry()
          Gets the nextEntry attribute of the SNMPConnector object
 String getVersion()
          Return version information
 void handle(com.tivoli.snmp.SnmpTrap trap)
          Trap listener
 void initialize(Object o)
          This methods initializes the SNMP API library, reads the Connector configurations parameters, subscribes for SNMP Traps and opens an SNMP session.
 boolean isCheckpointRestartEnabled(int mode)
          Components that support checkpoint/restart for a specific mode must return TRUE from this method.
 void prepareForRestart(ALState state, Entry restartInfo, int restartPoint)
          Notifies the connector of a restart situation.
 void putEntry(Entry entry)
          Send SNMP data.
 void reconnect()
          Reconnect to the underlying data source.
 Entry returnEntry(Object obj)
           
 void selectEntries()
          This method inits the SNMP PDU (protocol data unit) to be sent on all subsequent getNextEntry calls as part of the get next request.
 void terminate()
          This method unsubscribes from SNMP Trap events, terminates the SNMP API library, i.e.
 
Methods inherited from class com.ibm.di.connector.Connector
addFindEntry, allModes, clearFindEntries, debug, debugMode, deleteEntry, findEntry, getBoolean, getClassInstance, getConfiguration, getContext, getFindEntryCount, getFirstFindEntry, getLog, getMaxDuplicateEntries, getModes, getModes, getName, getNextClient, getNextFindEntry, getParam, getParser, getProperty, getPushbackEntry, getRawConnectorConfiguration, getRSInterface, hasConfigValue, hasParser, initParser, isDeltaSupported, isExceptionFatal, isIOException, logmsg, modEntry, modEntry, pushback, queryOperations, queryReply, querySchema, queryTables, reconnect, registerScriptBeans, replyEntry, setConfiguration, setContext, setCurrent, setLog, setMaxDuplicateEntries, setModes, setModes, setName, setParam, setParser, setProperty, setRSInterface, terminateServer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.ibm.di.connector.ConnectorInterface
deleteEntry, getConfiguration, getContext, getFindEntryCount, getFirstFindEntry, getMaxDuplicateEntries, getName, getNextClient, getNextFindEntry, getParam, getPushbackEntry, getRawConnectorConfiguration, isDeltaSupported, isExceptionFatal, isIOException, modEntry, modEntry, pushback, queryOperations, queryReply, querySchema, reconnect, registerScriptBeans, replyEntry, setConfiguration, setContext, setCurrent, setLog, setMaxDuplicateEntries, setName, setParam, setRSInterface, terminateServer
 

Constructor Detail

SNMPConnector

public SNMPConnector()
Constructor for the SNMPConnector object

Method Detail

getVersion

public String getVersion()
Return version information

Specified by:
getVersion in interface VersionInfoInterface
Returns:
The version value

getNextEntry

public Entry getNextEntry()
                   throws Exception
Gets the nextEntry attribute of the SNMPConnector object

Specified by:
getNextEntry in interface ConnectorInterface
Overrides:
getNextEntry in class Connector
Returns:
The nextEntry value
Throws:
Exception - An exception is thrown if this method fails.
See Also:
Connector.selectEntries()

returnEntry

public Entry returnEntry(Object obj)
                  throws Exception
Throws:
Exception

initialize

public void initialize(Object o)
                throws Exception
This methods initializes the SNMP API library, reads the Connector configurations parameters, subscribes for SNMP Traps and opens an SNMP session.

Specified by:
initialize in interface ConnectorInterface
Overrides:
initialize in class Connector
Parameters:
o - An object the AssemblyLine passes to the Connector on init
Throws:
Exception - An exception is thrown if this method fails.

terminate

public void terminate()
This method unsubscribes from SNMP Trap events, terminates the SNMP API library, i.e. this method cleans up.

Specified by:
terminate in interface ConnectorInterface
Overrides:
terminate in class Connector

selectEntries

public void selectEntries()
                   throws Exception
This method inits the SNMP PDU (protocol data unit) to be sent on all subsequent getNextEntry calls as part of the get next request.

Specified by:
selectEntries in interface ConnectorInterface
Overrides:
selectEntries in class Connector
Throws:
Exception - An exception is thrown if this method fails.

findEntry

public Entry findEntry(SearchCriteria search)
                throws Exception
Searches for an entry matching the specified search criteria.

Specified by:
findEntry in interface ConnectorInterface
Overrides:
findEntry in class Connector
Parameters:
search - the search criteria
Returns:
the entry found
Throws:
Exception - An exception is thrown if this method fails.

putEntry

public void putEntry(Entry entry)
              throws Exception
Send SNMP data.

Specified by:
putEntry in interface ConnectorInterface
Overrides:
putEntry in class Connector
Parameters:
entry - an entry containing the SNMP data to send
Throws:
Exception - An exception is thrown if this method fails.

filter

public boolean filter(com.tivoli.snmp.SnmpTrap trap)
Trap filter - Returns true if a trap should be sent to this connector.

Specified by:
filter in interface com.tivoli.snmp.TrapFilter

handle

public void handle(com.tivoli.snmp.SnmpTrap trap)
Trap listener

Specified by:
handle in interface com.tivoli.snmp.TrapListener

isCheckpointRestartEnabled

public boolean isCheckpointRestartEnabled(int mode)
Components that support checkpoint/restart for a specific mode must return TRUE from this method. If a restart has no meaning for mode then the connector should still return TRUE.

Specified by:
isCheckpointRestartEnabled in interface CheckpointRestartInterface
Parameters:
mode - The mode the connector runs in
Returns:
true if checkpoint is supported in mode
See Also:
ServerConstants

getCheckpointInformation

public Entry getCheckpointInformation()
                               throws Exception
Returns the state information for the connector. If for some reason the connector decidies that a restart is impossible it must throw an exception. The method is called immediatly before any component methods are called. If there is no need to save any state information a null value should be returned. For eventhandlers this method is called by the dispatcher routine.

Specified by:
getCheckpointInformation in interface CheckpointRestartInterface
Returns:
The entry the connector needs to do a restart or null if that is not needed.
Throws:
Exception

prepareForRestart

public void prepareForRestart(ALState state,
                              Entry restartInfo,
                              int restartPoint)
                       throws Exception
Notifies the connector of a restart situation. This method is called after the connector has been loaded and before any other method calls are made to the connector. If the connector decides it cannot restart it must throw an exception.

Specified by:
prepareForRestart in interface CheckpointRestartInterface
Parameters:
restartInfo - The last entry object returned by the connector in the getCheckpointInformation method
state - The ALState object for the AssemblyLine
restartPoint - The relative point where restarting is taking place (e.g. RESTART_BEFORE ...)
Throws:
Exception
Since:

reconnect

public void reconnect()
               throws Exception
Description copied from class: Connector
Reconnect to the underlying data source.

Overrides:
reconnect in class Connector
Throws:
Exception