SnmpService
, TransactionManager
public class LocalSnmpService extends Object implements SnmpService, TransactionManager
SnmpService
implementation that
sends directly (from the local device) SNMP request to the specified targets.Modifier and Type | Class | Description |
---|---|---|
protected class |
LocalSnmpService.LocalTableListener |
Constructor | Description |
---|---|
LocalSnmpService() |
Creates a local
SnmpService with USM and
TSM security models, the MPv3 message processing model,
and the DefaultUdpTransportMapping transport mapping. |
LocalSnmpService(org.snmp4j.MessageDispatcher messageDispatcher,
List<org.snmp4j.TransportMapping> transportMappings,
List<org.snmp4j.mp.MessageProcessingModel> messageProcessingModels,
org.snmp4j.security.SecurityModels securityModels,
org.snmp4j.security.SecurityProtocols securityProtocols) |
Creates a local
SnmpService with the given message dispatcher,
transport mappings, message processing and security models, and security protocols. |
Modifier and Type | Method | Description |
---|---|---|
List<? extends SnmpCommitResult> |
commit(SnmpTransaction transaction,
SnmpCommitListener commitListener) |
Commits the transaction to the agent.
|
List<? extends org.snmp4j.smi.VariableBinding> |
get(org.snmp4j.Target target,
List<org.snmp4j.smi.OID> oidList) |
Gets the SNMP values for the specified OIDs.
|
List<? extends org.snmp4j.smi.VariableBinding> |
getNext(org.snmp4j.Target target,
List<org.snmp4j.smi.OID> oidList) |
Gets the next following SNMP values for the specified OIDs.
|
org.snmp4j.util.PDUFactory |
getPduFactory() |
Gets the
PDUFactory of this SNMP service. |
org.snmp4j.Snmp |
getSnmp() |
Returns the
Snmp instance used by this local SnmpService . |
SnmpTransaction |
getSnmpTransaction(SnmpTransactionStrategy transactionStrategy) |
|
List<? extends org.snmp4j.smi.VariableBinding> |
getSubTree(org.snmp4j.Target target,
org.snmp4j.smi.OID oid) |
Gets the SNMP values for the specified sub-tree root OID.
|
List<? extends SnmpRow> |
getTable(org.snmp4j.Target target,
List<org.snmp4j.smi.OID> columnOIDs,
org.snmp4j.smi.OID minIndexOID,
org.snmp4j.smi.OID maxIndexOID) |
Gets the rows of a SNMP table synchronously.
|
void |
getTable(org.snmp4j.Target target,
List<org.snmp4j.smi.OID> columnOIDs,
org.snmp4j.smi.OID minIndex,
org.snmp4j.smi.OID maxIndex,
SnmpRowListener callback,
Object userObject) |
Gets the rows of a SNMP table asynchronously.
|
void |
initTransports() |
Initializes the transports associated with this service.
|
boolean |
isAtomic(SnmpTransaction transaction) |
Checks if this transaction can be committed with atomicity.
|
void |
rollback(SnmpTransaction transaction) |
|
void |
setPduFactory(org.snmp4j.util.PDUFactory pduFactory) |
Sets the
PDUFactory of this SNMP service. |
void |
update(SnmpTransaction snmpTransaction,
org.snmp4j.Target target,
SnmpValuesChangeSet variableBindings,
SnmpCommitListener commitListener) |
Updates (SETs) a set of changes with an atomic SET operation asynchronously.
|
public LocalSnmpService()
SnmpService
with USM
and
TSM
security models, the MPv3
message processing model,
and the DefaultUdpTransportMapping
transport mapping.public LocalSnmpService(org.snmp4j.MessageDispatcher messageDispatcher, List<org.snmp4j.TransportMapping> transportMappings, List<org.snmp4j.mp.MessageProcessingModel> messageProcessingModels, org.snmp4j.security.SecurityModels securityModels, org.snmp4j.security.SecurityProtocols securityProtocols)
SnmpService
with the given message dispatcher,
transport mappings, message processing and security models, and security protocols.messageDispatcher
- the message dispatcher to be used by this local SNMP service. Cannot be null
.transportMappings
- the transport mappings to be used. If null
is given, a new
DefaultUdpTransportMapping
will be created and used.messageProcessingModels
- the message processing models to be used by the service. If null
is given, a new
MPv3
is created and used (without any SNMPv1 or v2c models).securityModels
- the security models to be used with the provided message processing models. If there is no
message processing model, that requires a security model (i.e., MPv1
and
MPv2c
only) then this value can be null
.securityProtocols
- the security protocols to be used with the provided message processing models. If there is no
message processing model, that requires a security protocol (i.e., MPv1
and
MPv2c
only) then this value can be null
.public org.snmp4j.Snmp getSnmp()
Snmp
instance used by this local SnmpService
.Snmp
instance.public void initTransports() throws IOException
SnmpService
initTransports
in interface SnmpService
IOException
- if an IO error occurred during initialization.public org.snmp4j.util.PDUFactory getPduFactory()
PDUFactory
of this SNMP service.PDUFactory
instance.public void setPduFactory(org.snmp4j.util.PDUFactory pduFactory)
PDUFactory
of this SNMP service. The factory is used to create any SNMP
PDU
created on behalf of this service. By default, this is the
DefaultPDUFactory
with the PDU type PDU.GET
.pduFactory
- the PDUFactory
to be used by this local SNMP service.public List<? extends org.snmp4j.smi.VariableBinding> get(org.snmp4j.Target target, List<org.snmp4j.smi.OID> oidList) throws SnmpException
SnmpService
get
in interface SnmpService
target
- the SNMP target to send the SNMP PDUs to.oidList
- the instance object identifiers to GET values for.SnmpException
- if an SNMP error or timeout occurred.public List<? extends org.snmp4j.smi.VariableBinding> getNext(org.snmp4j.Target target, List<org.snmp4j.smi.OID> oidList) throws SnmpException
SnmpService
getNext
in interface SnmpService
target
- the SNMP target to send the SNMP PDUs to.oidList
- the instance object identifiers to GET-NEXT values for.SnmpException
- if an SNMP error or timeout occurred.public List<? extends org.snmp4j.smi.VariableBinding> getSubTree(org.snmp4j.Target target, org.snmp4j.smi.OID oid) throws SnmpException
SnmpService
getSubTree
in interface SnmpService
target
- the SNMP target to send the SNMP PDUs to.oid
- the root OID of the sub-tree to get values for (using GETBULK or GETNEXT).SnmpException
- if an SNMP error or timeout occurred.public List<? extends SnmpRow> getTable(org.snmp4j.Target target, List<org.snmp4j.smi.OID> columnOIDs, org.snmp4j.smi.OID minIndexOID, org.snmp4j.smi.OID maxIndexOID) throws SnmpException
SnmpService
getTable
in interface SnmpService
target
- the SNMP target to send the SNMP PDUs to.columnOIDs
- the OIDs of the columns to retrieve (columns might be combined from several tables although the indexes
of the included tables should then contain a common prefix).minIndexOID
- the minimum index to return (or null
for no limit).maxIndexOID
- the maximum index to return (or null
for no limit).SnmpRow
instances.SnmpException
- if an SNMP error or timeout occurred.public void getTable(org.snmp4j.Target target, List<org.snmp4j.smi.OID> columnOIDs, org.snmp4j.smi.OID minIndex, org.snmp4j.smi.OID maxIndex, SnmpRowListener callback, Object userObject) throws SnmpException
SnmpService
getTable
in interface SnmpService
target
- the SNMP target to send the SNMP PDUs to.columnOIDs
- the OIDs of the columns to retrieve (columns might be combined from several tables although the indexes
of the included tables should then contain a common prefix).minIndex
- the minimum index to return (or null
for no limit).maxIndex
- the maximum index to return (or null
for no limit).callback
- the callback that receives the retrieved rows.userObject
- an optinal user object to be associated with this retrieval.SnmpException
- if an SNMP error or timeout occurred.public void update(SnmpTransaction snmpTransaction, org.snmp4j.Target target, SnmpValuesChangeSet variableBindings, SnmpCommitListener commitListener)
SnmpService
update
in interface SnmpService
snmpTransaction
- the transaction that controls this update.target
- the SNMP target.variableBindings
- the change set to commit to the agent identified by target
.commitListener
- a listener for commit events.public List<? extends SnmpCommitResult> commit(SnmpTransaction transaction, SnmpCommitListener commitListener)
TransactionManager
commit
in interface TransactionManager
transaction
- the transaction to commit.commitListener
- the optional listener that is immediately informed during this commit call about
failures and successful committed change sets.SnmpErrorStatus
indicating success or failure reason
of the transaction.public void rollback(SnmpTransaction transaction)
rollback
in interface TransactionManager
public boolean isAtomic(SnmpTransaction transaction)
TransactionManager
false
.isAtomic
in interface TransactionManager
transaction
- the transaction to test.true
if this transaction can be committed by using a single
SET PDU. Thus, the variables to set do not exceed the target's maximum
size PDU length (including estimated SNMP message overhead).public SnmpTransaction getSnmpTransaction(SnmpTransactionStrategy transactionStrategy)
getSnmpTransaction
in interface TransactionManager
Copyright © 2020 SNMP4J.org. All rights reserved.