- All Implemented Interfaces:
CompletionStage<PDU>
,Future<PDU>
,EventListener
,ResponseListener
The
SnmpCompletableFuture
implements a CompletableFuture
for a PDU
. It represents
the result of an SNMP operation sending a PDU
and receiving its response when the sent PDU
was a
confirmed one.
This future can be completed normally and exceptionally. A normal completion is a successful SNMP operation.
An unconfirmed operation completes always normally if the sending of the SNMP message was successful.
Any error situation, like a response PDU
with a non-zero error status, timeout, or PDU.REPORT
PDU response. In the latter case, a SnmpCompletableFuture.ReportException
will be returned. For a timeout,
a TimeoutException
, and for a SNMP error, a SnmpCompletableFuture.SnmpErrorException
.
If sending the SNMP message throws an exception, this exception is directly returned.- Since:
- 3.5.0
- Author:
- Frank Fock
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
ThisReportException
represents an SNMPPDU.REPORT
PDU.static class
ThisSnmpErrorException
represents an SNMP error status and index.Nested classes/interfaces inherited from class java.util.concurrent.CompletableFuture
CompletableFuture.AsynchronousCompletionTask
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionObject[]
Returns the user objects provided bysend(Snmp, Target, PDU, Object...)
when this future completed.<A extends Address>
voidonResponse
(ResponseEvent<A> event) Process a SNMP response.static <A extends Address>
SnmpCompletableFutureMethods inherited from class java.util.concurrent.CompletableFuture
acceptEither, acceptEitherAsync, acceptEitherAsync, allOf, anyOf, applyToEither, applyToEitherAsync, applyToEitherAsync, cancel, complete, completeAsync, completeAsync, completedFuture, completedStage, completeExceptionally, completeOnTimeout, copy, defaultExecutor, delayedExecutor, delayedExecutor, exceptionally, exceptionallyAsync, exceptionallyAsync, exceptionallyCompose, exceptionallyComposeAsync, exceptionallyComposeAsync, failedFuture, failedStage, get, get, getNow, getNumberOfDependents, handle, handleAsync, handleAsync, isCancelled, isCompletedExceptionally, isDone, join, minimalCompletionStage, newIncompleteFuture, obtrudeException, obtrudeValue, orTimeout, runAfterBoth, runAfterBothAsync, runAfterBothAsync, runAfterEither, runAfterEitherAsync, runAfterEitherAsync, runAsync, runAsync, supplyAsync, supplyAsync, thenAccept, thenAcceptAsync, thenAcceptAsync, thenAcceptBoth, thenAcceptBothAsync, thenAcceptBothAsync, thenApply, thenApplyAsync, thenApplyAsync, thenCombine, thenCombineAsync, thenCombineAsync, thenCompose, thenComposeAsync, thenComposeAsync, thenRun, thenRunAsync, thenRunAsync, toCompletableFuture, toString, whenComplete, whenCompleteAsync, whenCompleteAsync
-
Field Details
-
ERR_TIMEOUT
- See Also:
-
timeoutMessage
-
-
Constructor Details
-
SnmpCompletableFuture
protected SnmpCompletableFuture()
-
-
Method Details
-
onResponse
Description copied from interface:ResponseListener
Process a SNMP response.- Specified by:
onResponse
in interfaceResponseListener
- Type Parameters:
A
- type of the targetAddress
- Parameters:
event
- aResponseEvent
.
-
getResponseEvent
-
send
public static <A extends Address> SnmpCompletableFuture send(Snmp snmp, Target<A> target, PDU pdu, Object... userObjects) - Type Parameters:
A
- the address type.- Parameters:
snmp
- aSnmp
instance, preferrably created bySnmpBuilder
.target
- the target where to send the message to with pdu as payload.pdu
- the PDU to send.userObjects
- a list of user objects to return with thisCompletableFuture
by callinggetUserObjects()
.- Returns:
- a new
SnmpCompletableFuture
that will receive the result of this operation.
-
getUserObjects
Returns the user objects provided bysend(Snmp, Target, PDU, Object...)
when this future completed.- Returns:
- a list of user objects.
-