Package org.snmp4j.model.snmp.proxy.impl
Class SnmpProxyAdapter
java.lang.Object
org.snmp4j.model.snmp.proxy.impl.SnmpProxyAdapter
- All Implemented Interfaces:
SnmpProxyCommitter
,SnmpProxyReloader
,SnmpTransactionStrategy
public class SnmpProxyAdapter
extends Object
implements SnmpProxyCommitter, SnmpProxyReloader, SnmpTransactionStrategy
The
SnmpProxyAdapter
is the central implementation of the mapping between the
SnmpService
and a SnmpProxyObject
. The adapter is responsible to map changes
collection by the proxy objects to change sets queued on the SNMP service. In addition,
the adapter provides the mapping of the SNMP values and the corresponding model values.
For read operations, this mapping is actually handled by the proxy objects themselves using
the {}@link VariableBindingMapper} provided by this adapter.- Author:
- Frank Fock
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected class
protected class
protected class
-
Constructor Summary
ConstructorsConstructorDescriptionSnmpProxyAdapter
(SnmpService snmpService, org.snmp4j.Target target, VariableBindingMapper variableBindingMapper) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addChange
(SnmpProxyObject proxyObject, SnmpValuesChangeSet change) Adds a change on the specified proxy object to the queue.commitChanges
(SnmpCommitListener commitListener) Commit the changes in the current queue asynchronously in the background.Gets the isolation level for this transaction.int
Gets the total number of changes in the queue (independently of a particular proxy object).processReloadQueue
(SnmpProxyReloadListener reloadListener) void
queueReload
(SnmpProxyObject proxyObject) Queue a proxy object for reload.reloadQueued
(SnmpProxyReloadListener reloadListener) Actually reload all queued proxy objects asynchronously in background.removeAllChanges
(SnmpProxyObject proxyObject) Remove all changes for a given proxy object.removeLastChangeSet
(SnmpProxyObject proxyObject) Remove the last change from the queue for the specified proxy object.validateChange
(SnmpValuesChangeSet change) Validate the change set provided.
-
Constructor Details
-
SnmpProxyAdapter
public SnmpProxyAdapter(SnmpService snmpService, org.snmp4j.Target target, VariableBindingMapper variableBindingMapper) - Parameters:
snmpService
- the SNMP service to use for reloading and updating SNMP values.target
- the target (i.e., address of the SNMP agent) that act as SNMP command responder.variableBindingMapper
- the variable binding mapper that maps between model values and SNMP values and vice versa.
-
-
Method Details
-
validateChange
Description copied from interface:SnmpProxyCommitter
Validate the change set provided.- Specified by:
validateChange
in interfaceSnmpProxyCommitter
- Parameters:
change
- a change set.- Returns:
true
if the change set is valid that is, if all model values in the change can be mapped (converted) to SNMP values.
-
addChange
Description copied from interface:SnmpProxyCommitter
Adds a change on the specified proxy object to the queue.- Specified by:
addChange
in interfaceSnmpProxyCommitter
- Parameters:
proxyObject
- the proxy object that changed.change
- the values change set that describes the changes that should be applied to the proxy and its remote object.
-
removeLastChangeSet
Description copied from interface:SnmpProxyCommitter
Remove the last change from the queue for the specified proxy object.- Specified by:
removeLastChangeSet
in interfaceSnmpProxyCommitter
- Parameters:
proxyObject
- the proxy object for which the change to remove was added withSnmpProxyCommitter.addChange(SnmpProxyObject, SnmpValuesChangeSet)
.- Returns:
- the removed change set or
null
if there is no such change.
-
removeAllChanges
Description copied from interface:SnmpProxyCommitter
Remove all changes for a given proxy object.- Specified by:
removeAllChanges
in interfaceSnmpProxyCommitter
- Parameters:
proxyObject
- the proxy object for which all changes should be removed from the queue.- Returns:
- the removed changes (could be an empty list).
-
commitChanges
Description copied from interface:SnmpProxyCommitter
Commit the changes in the current queue asynchronously in the background. Note: changes that are queued after this call returns will not be committed.- Specified by:
commitChanges
in interfaceSnmpProxyCommitter
- Parameters:
commitListener
- a callback listener for commit status events.- Returns:
- the task ID for this commit operation.
-
getNumberOfPendingChanges
public int getNumberOfPendingChanges()Description copied from interface:SnmpProxyCommitter
Gets the total number of changes in the queue (independently of a particular proxy object).- Specified by:
getNumberOfPendingChanges
in interfaceSnmpProxyCommitter
- Returns:
- the number of changes in the queue.
-
queueReload
Description copied from interface:SnmpProxyReloader
Queue a proxy object for reload. No communication with the SNMP target will be performed yet, untilSnmpProxyReloader.reloadQueued(SnmpProxyReloadListener)
is called.- Specified by:
queueReload
in interfaceSnmpProxyReloader
- Parameters:
proxyObject
- the proxy object to reload.
-
reloadQueued
Description copied from interface:SnmpProxyReloader
Actually reload all queued proxy objects asynchronously in background.- Specified by:
reloadQueued
in interfaceSnmpProxyReloader
- Parameters:
reloadListener
- the callback listener which receives updates on the reload process.- Returns:
- a list of
TaskId
instances for the each affected proxy object. If a reload for a proxy object failed to start (because of network issues or incorrect target definitions),null
is returned for that element.
-
processReloadQueue
-
getIsolationLevel
Description copied from interface:SnmpTransactionStrategy
Gets the isolation level for this transaction. In SNMP isolation of SET requests is managed by TestAndIncr managed objects or not managed at all.- Specified by:
getIsolationLevel
in interfaceSnmpTransactionStrategy
- Returns:
- the isolation level.
-