org.snmp4j.agent.agentx.subagent
Class AgentXSharedMOTableSupport

java.lang.Object
  extended by org.snmp4j.agent.agentx.subagent.AgentXSharedMOTableSupport
All Implemented Interfaces:
java.util.EventListener, org.snmp4j.agent.mo.MOTableRowListener

public class AgentXSharedMOTableSupport
extends java.lang.Object
implements org.snmp4j.agent.mo.MOTableRowListener

The AgentXSharedMOTableSupport provides helper functions for shared table implementations to register rows and indexes at a master agent.

Version:
1.0
Author:
Frank Fock

Field Summary
static int INDEX_MODE_ALLOCATE
           
static int INDEX_MODE_ANY_INDEX
           
static int INDEX_MODE_NEW_INDEX
           
 
Constructor Summary
AgentXSharedMOTableSupport(AgentX agentX, AgentXSession session, org.snmp4j.smi.OctetString context)
          Creates a shared table support object for a AgentX connection, session, and context.
AgentXSharedMOTableSupport(AgentX agentX, AgentXSession session, org.snmp4j.smi.OctetString context, byte priority, byte indexAllocationMode)
          Creates a shared table support object for a AgentX connection, session, and context.
 
Method Summary
 int allocateIndex(org.snmp4j.smi.OctetString context, org.snmp4j.agent.mo.MOTableIndex indexDef, byte indexAllocationMode, org.snmp4j.smi.OID allocatedIndex)
          Allocate a new or any index at the master agent and return its value in allocateIndex.
 int deallocateIndex(org.snmp4j.smi.OctetString context, org.snmp4j.agent.mo.MOTableIndex indexDef, org.snmp4j.smi.OID allocatedIndex)
          Deallocate an index at the master agent.
 AgentX getAgentX()
           
 org.snmp4j.smi.OctetString getContext()
           
 byte getIndexMode()
           
 byte getPriority()
           
 AgentXSession getSession()
          Gets the AgentX session used by this shared table support object.
 int registerRow(org.snmp4j.agent.mo.MOTable table, org.snmp4j.agent.mo.MOTableRow row2Register)
           
 void rowChanged(org.snmp4j.agent.mo.MOTableRowEvent event)
          Process shared table row events.
 void setContext(org.snmp4j.smi.OctetString context)
           
 void setIndexMode(byte indexMode)
          Sets the index mode to be used by this shared table support object.
 void setPriority(byte priority)
           
 void setSession(AgentXSession session)
          Sets the AgentX session to be used for this shared table support.
 int unregisterRow(org.snmp4j.agent.mo.MOTable table, org.snmp4j.agent.mo.MOTableRow row2Unregister)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INDEX_MODE_ALLOCATE

public static final int INDEX_MODE_ALLOCATE
See Also:
Constant Field Values

INDEX_MODE_ANY_INDEX

public static final int INDEX_MODE_ANY_INDEX
See Also:
Constant Field Values

INDEX_MODE_NEW_INDEX

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

AgentXSharedMOTableSupport

public AgentXSharedMOTableSupport(AgentX agentX,
                                  AgentXSession session,
                                  org.snmp4j.smi.OctetString context)
Creates a shared table support object for a AgentX connection, session, and context.

Parameters:
agentX - an AgentX connection.
session - an AgentXSession session (does not need to be open at creation time).
context - a context ("" by default).

AgentXSharedMOTableSupport

public AgentXSharedMOTableSupport(AgentX agentX,
                                  AgentXSession session,
                                  org.snmp4j.smi.OctetString context,
                                  byte priority,
                                  byte indexAllocationMode)
Creates a shared table support object for a AgentX connection, session, and context.

Parameters:
agentX - an AgentX connection.
session - an AgentXSession session (does not need to be open at creation time).
context - a context ("" by default).
priority - the registration priority used for this shared table support.
indexAllocationMode - the index allocation mode to be used as default for this shared table.
Method Detail

rowChanged

public void rowChanged(org.snmp4j.agent.mo.MOTableRowEvent event)
Process shared table row events. If index mode is INDEX_MODE_ALLOCATE this method will do nothing if the associated AgentX session is closed. For other index modes, the event's veto status will be set to the AgentX error AgentXProtocol.AGENTX_NOT_OPEN.

If the index OID of a created row has zero length then, depending on the current index mode, a new or any new index is allocated at the master agent.

Specified by:
rowChanged in interface org.snmp4j.agent.mo.MOTableRowListener
Parameters:
event - a MOTableRowEvent indicating a row change in an AgentX shared table.

allocateIndex

public int allocateIndex(org.snmp4j.smi.OctetString context,
                         org.snmp4j.agent.mo.MOTableIndex indexDef,
                         byte indexAllocationMode,
                         org.snmp4j.smi.OID allocatedIndex)
Allocate a new or any index at the master agent and return its value in allocateIndex.

Parameters:
context - the context for which to allocate the index. Specify an empty OctetString for the default context.
indexDef - the index definition with OID values for sub-index definitions.
indexAllocationMode - one of AgentXProtocol.FLAG_ANY_INDEX, AgentXProtocol.FLAG_NEW_INDEX, or 0 (if index value is supplied by allocateIndex).
allocatedIndex - the index value to allocate or if indexAllocationMode is not zero then an (arbitrary non-null OID) which returns the allocated new index value. If allocateIndex is an instance of AnyNewIndexOID or NewIndexOID the index value of the row will be replaced by a globally unique index value allocated by the master agent. The caller is responsible for changing the rows index in the table model of the shared table.
Returns:
AgentXProtocol.AGENTX_SUCCESS if the index could be allocated or an AgentX protocol error code if allocation failed and allocateIndex is not altered.

deallocateIndex

public int deallocateIndex(org.snmp4j.smi.OctetString context,
                           org.snmp4j.agent.mo.MOTableIndex indexDef,
                           org.snmp4j.smi.OID allocatedIndex)
Deallocate an index at the master agent.

Parameters:
context - the context for which to allocate the index. Specify an empty OctetString for the default context.
indexDef - the index definition with OID values for sub-index definitions.
allocatedIndex - the index value of the previously allocated index.
Returns:
AgentXProtocol.AGENTX_SUCCESS if the index could be deallocated or an AgentX protocol error code if deallocation failed.

registerRow

public int registerRow(org.snmp4j.agent.mo.MOTable table,
                       org.snmp4j.agent.mo.MOTableRow row2Register)

unregisterRow

public int unregisterRow(org.snmp4j.agent.mo.MOTable table,
                         org.snmp4j.agent.mo.MOTableRow row2Unregister)

setPriority

public void setPriority(byte priority)

setSession

public void setSession(AgentXSession session)
Sets the AgentX session to be used for this shared table support.

Parameters:
session - an AgentXSession instance.

setIndexMode

public void setIndexMode(byte indexMode)
Sets the index mode to be used by this shared table support object. INDEX_MODE_ALLOCATE simply allocates index values at the master agent, whereas INDEX_MODE_ANY_INDEX fetches any currently unique index value from the master agent for a new row and INDEX_MODE_NEW_INDEX fetches a new index (never used before by the master).

Parameters:
indexMode - an index mode to be used for shared tables supported by this object.

setContext

public void setContext(org.snmp4j.smi.OctetString context)

getPriority

public byte getPriority()

getSession

public AgentXSession getSession()
Gets the AgentX session used by this shared table support object.

Returns:
an AgentXSession instance or null if there is no connection/session established with the master agent.

getIndexMode

public byte getIndexMode()

getContext

public org.snmp4j.smi.OctetString getContext()

getAgentX

public AgentX getAgentX()

Copyright 2005-2011 Frank Fock (SNMP4J.org)

Copyright © 2011 SNMP4J.org. All Rights Reserved.