|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.adventnet.snmp.snmp2.agent.Cache
com.adventnet.snmp.snmp2.agent.BaseSnmpStore
com.adventnet.snmp.snmp2.agent.SnmpStore
com.adventnet.snmp.snmp2.agent.SnmpTrapReceiverService
public class SnmpTrapReceiverService
This class listens for the Traps at the specified port by opening a new Receiver Snmp Session.
This can be instantiated in the Master Agent's so that the Traps sent by the SubAgents can be listened and forwarded to the MasterAgent's Managers.
API users can use this class to listen for Traps at a Specific Port and forward them to the Managers in the SnmpTrapService, which should be set for this class using the addTrapRequestListener method.
| Field Summary | |
|---|---|
(package private) boolean |
callbackThread
Used to facilitate CallBacks |
(package private) SnmpSession |
receiverSession
|
(package private) AgentTableModel |
tModelComplete
|
protected TrapRequestListener |
trapListener
|
| Fields inherited from class com.adventnet.snmp.snmp2.agent.BaseSnmpStore |
|---|
debugLevel, localAddress, oldAddress, oldPort, protocol, session |
| Fields inherited from class com.adventnet.snmp.snmp2.agent.Cache |
|---|
cache, debug |
| Constructor Summary | |
|---|---|
SnmpTrapReceiverService(int port)
Constructor with the port argument. |
|
| Method Summary | |
|---|---|
void |
addTrapRequestListener(TrapRequestListener trapListener)
Method to add a SnmpTrapService with this TrapReceiverService to forward the received Traps. |
boolean |
authenticate(SnmpPDU pdu,
java.lang.String community)
This method is called before the callback and related processing methods are called has a simple checks based on the community of the pdu which has been received. |
boolean |
callback(SnmpSession session,
SnmpPDU pdu,
int reqid)
The callback of SnmpClient interface for incoming Snmp Trap PDUs which is implemented by this Service. |
void |
debugPrint(java.lang.String s)
To print errors in Error Output stream for debug. |
int |
getPort()
The port on which the Trap Receiver Service is running |
long |
getUpTime()
gets the up time of the agent |
(package private) void |
initTrapReceiverSession()
|
boolean |
isAgentAddressFlag()
Gets the subagent's agent address flag which says to send the subagent's agent address to the manager. |
boolean |
isCallbackThread()
getter for Callback Thread |
boolean |
isStarted()
Getter of the receiver status. |
boolean |
restartTrapReceiverService()
Restarts the receiver Thread for receiving requests |
void |
setAgentAddressFlag(boolean flag)
Sets the subagent's agent address flag which says to send the subagent's agent address to the manager. |
void |
setAgentTableModel(AgentTableModel tModelComplete)
Method to set the TrapFiltering Table's Model. |
void |
setCallbackThread(boolean callbackThread)
setter for Callback Thread. |
void |
setPort(int port)
The port on which the TrapReceiverService is going to run. |
void |
setPort(int port,
boolean restart)
The port on which the TrapReceiverService is going to run. |
void |
stopTrapReceiverService()
Stops the receiver Thread and closes the socket used by this TrapReceiverService. |
| Methods inherited from class com.adventnet.snmp.snmp2.agent.SnmpStore |
|---|
getProxySession, getTrapReceiverSession, initSnmpStore |
| Methods inherited from class com.adventnet.snmp.snmp2.agent.BaseSnmpStore |
|---|
closeAll, createProtocolOptions, finalize, getSnmpAPI, getSnmpSession, getSnmpSession, initSession, initSnmpStore, isAlive, isDebug, killSnmpAgent, setDebug |
| 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 |
|---|
SnmpSession receiverSession
boolean callbackThread
protected TrapRequestListener trapListener
AgentTableModel tModelComplete
| Constructor Detail |
|---|
public SnmpTrapReceiverService(int port)
port - the port which has to be listened for Traps.| Method Detail |
|---|
public long getUpTime()
public void setCallbackThread(boolean callbackThread)
When the callbackThread is set to false, the callback method is called in the context of the SnmpSession receiver thread. When callbackThread is set to true, the callback method is invoked in the context of a separate callback thread. API users can set the value of callbackThread based on whether they want callback's to be invoked from a seperate thread or from the SnmpSession receiver thread itself.
callbackThread - the value to set enable or false the Callback Thread.isCallbackThread(),
SnmpCallbackpublic boolean isCallbackThread()
()public void debugPrint(java.lang.String s)
debugPrint in interface SnmpClients - the debug message
public boolean callback(SnmpSession session,
SnmpPDU pdu,
int reqid)
When a pdu reached at the session for which this SnmpTrapReceiverService is registered as SnmpClient, then the client(here SnmpAgent) callback is called.
callback in interface SnmpClientsession - the session on which agent is communicating.pdu - the Snmp PDU.reqid - the value of reqid.
public void setAgentAddressFlag(boolean flag)
flag - true if the subagent's agent address has to be passed to the manager, false otherwise.public boolean isAgentAddressFlag()
public boolean authenticate(SnmpPDU pdu,
java.lang.String community)
authenticate in interface SnmpClientpdu - the Snmp PDU.community - the value of the community.
SnmpClientpublic boolean isStarted()
restartSnmpTrapReceiverService(),
stopSnmpTrapReceiverService(),
setStarted(boolean flag)
public boolean restartTrapReceiverService()
throws AgentRuntimeException
AgentRuntimeExceptionBaseSnmpStore.isAlive(),
restartSnmpAgent()public void stopTrapReceiverService()
This thread doesn't kill all the threads and sessions.
SnmpStore
public void setPort(int port)
throws AgentRuntimeException
This restarts the SnmpTrapReceiverService at the specified port.
port - the udp port number to whcih the SnmpSession is start.
AgentRuntimeExceptiongetPort()
public void setPort(int port,
boolean restart)
throws AgentRuntimeException
This restarts the SnmpTrapReceiverService at the specified port.
port - the udp port number to whcih the SnmpSession is start.restart - specifies whether the TrapReceiverService needs to be restarted
after setting the port.
AgentRuntimeExceptiongetPort(),
setPort(int port)public int getPort()
setPort(int port),
setPort(int port, boolean restart)public void addTrapRequestListener(TrapRequestListener trapListener)
trapListener - The SnmpTrapService instance.
void initTrapReceiverSession()
throws SnmpException
SnmpExceptionpublic void setAgentTableModel(AgentTableModel tModelComplete)
tModelComplete - The AgentTableModel Instance of TrapFiltering
Table.TrapFilteringTable
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||