org.snmp4j.agent.agentx.subagent.test
Class TestSubagent

java.lang.Object
  extended by org.snmp4j.agent.agentx.subagent.test.TestSubagent
All Implemented Interfaces:
java.lang.Runnable, java.util.EventListener, RegistrationCallback, org.snmp4j.transport.TransportStateListener

public class TestSubagent
extends java.lang.Object
implements java.lang.Runnable, org.snmp4j.transport.TransportStateListener, RegistrationCallback

The TestSubagent is an example implementation of a simple AgentX subagent with shared tables and multi context registration.

Version:
1.1
Author:
Frank Fock

Field Summary
static org.snmp4j.smi.OID SUBAGENT_ID
           
 
Constructor Summary
TestSubagent(org.snmp4j.smi.Address masterAddress, org.snmp4j.smi.Address localAddress)
           
 
Method Summary
 void connectionStateChanged(org.snmp4j.transport.TransportStateEvent change)
           
static void main(java.lang.String[] args)
           
protected  void register()
           
protected  void registerSessionDependent()
           
 void registrationEvent(org.snmp4j.smi.OctetString context, org.snmp4j.agent.ManagedObject mo, int status)
          The registration attempt of a ManagedObject succeeded or failed.
 void run()
           
 boolean tableRegistrationEvent(org.snmp4j.smi.OctetString context, org.snmp4j.agent.mo.MOTable mo, org.snmp4j.agent.mo.MOTableRow row, boolean indexAllocation, int status, int retryCount)
          The registration attempt of a ManagedObject succeeded or failed.
 void tableUnregistrationEvent(org.snmp4j.smi.OctetString context, org.snmp4j.agent.mo.MOTable mo, org.snmp4j.agent.mo.MOTableRow row, boolean indexAllocation, int status)
          The unregistration attempt of a ManagedObject succeeded or failed.
protected  void unregisterFailed(java.util.List failedRegistrations)
          Remove objects from the server, which could not be registered with the master agent.
protected  void unregisterSessionDependent()
           
 void unregistrationEvent(org.snmp4j.smi.OctetString context, org.snmp4j.agent.ManagedObject mo, int status)
          The unregistration attempt of a ManagedObject succeeded or failed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SUBAGENT_ID

public static final org.snmp4j.smi.OID SUBAGENT_ID
Constructor Detail

TestSubagent

public TestSubagent(org.snmp4j.smi.Address masterAddress,
                    org.snmp4j.smi.Address localAddress)
Method Detail

main

public static void main(java.lang.String[] args)

register

protected void register()
                 throws org.snmp4j.agent.DuplicateRegistrationException
Throws:
org.snmp4j.agent.DuplicateRegistrationException

unregisterSessionDependent

protected void unregisterSessionDependent()

registerSessionDependent

protected void registerSessionDependent()
                                 throws org.snmp4j.agent.DuplicateRegistrationException
Throws:
org.snmp4j.agent.DuplicateRegistrationException

run

public void run()
Specified by:
run in interface java.lang.Runnable

unregisterFailed

protected void unregisterFailed(java.util.List failedRegistrations)
Remove objects from the server, which could not be registered with the master agent.

Parameters:
failedRegistrations - a List of ManagedObjects and MOTableRows which failed to register.

connectionStateChanged

public void connectionStateChanged(org.snmp4j.transport.TransportStateEvent change)
Specified by:
connectionStateChanged in interface org.snmp4j.transport.TransportStateListener

registrationEvent

public void registrationEvent(org.snmp4j.smi.OctetString context,
                              org.snmp4j.agent.ManagedObject mo,
                              int status)
Description copied from interface: RegistrationCallback
The registration attempt of a ManagedObject succeeded or failed.

Specified by:
registrationEvent in interface RegistrationCallback
Parameters:
context - the registration context.
mo - the ManagedObject that was subject to the registration process.
status - the AgentX status of the registration response.

tableRegistrationEvent

public boolean tableRegistrationEvent(org.snmp4j.smi.OctetString context,
                                      org.snmp4j.agent.mo.MOTable mo,
                                      org.snmp4j.agent.mo.MOTableRow row,
                                      boolean indexAllocation,
                                      int status,
                                      int retryCount)
Description copied from interface: RegistrationCallback
The registration attempt of a ManagedObject succeeded or failed.

Specified by:
tableRegistrationEvent in interface RegistrationCallback
Parameters:
context - the registration context.
mo - the MOTable that was subject to the registration process.
row - the row whose index or region was subject to the allocation/registration.
indexAllocation - true if this event relates to an index allocation request and false if it relates to a row region registration.
status - the AgentX status of the registration response.
retryCount - the number of retries already processed. This value can be used to avoid endless loops.
Returns:
true if the caller should retry the registration operation, false otherwise.

unregistrationEvent

public void unregistrationEvent(org.snmp4j.smi.OctetString context,
                                org.snmp4j.agent.ManagedObject mo,
                                int status)
Description copied from interface: RegistrationCallback
The unregistration attempt of a ManagedObject succeeded or failed.

Specified by:
unregistrationEvent in interface RegistrationCallback
Parameters:
context - the registration context.
mo - the ManagedObject that was subject to the registration process.
status - the AgentX status of the registration response.

tableUnregistrationEvent

public void tableUnregistrationEvent(org.snmp4j.smi.OctetString context,
                                     org.snmp4j.agent.mo.MOTable mo,
                                     org.snmp4j.agent.mo.MOTableRow row,
                                     boolean indexAllocation,
                                     int status)
Description copied from interface: RegistrationCallback
The unregistration attempt of a ManagedObject succeeded or failed.

Specified by:
tableUnregistrationEvent in interface RegistrationCallback
Parameters:
context - the registration context.
mo - the MOTable that was subject to the registration process.
row - the row whose index or region was subject to the allocation/registration.
indexAllocation - true if this event relates to an index allocation request and false if it relates to a row region registration.
status - the AgentX status of the registration response.

Copyright 2005-2011 Frank Fock (SNMP4J.org)

Copyright © 2011 SNMP4J.org. All Rights Reserved.