- java.lang.Object
-
- java.util.concurrent.CompletableFuture<PDU>
-
- org.snmp4j.fluent.SnmpCompletableFuture
-
- All Implemented Interfaces:
CompletionStage<PDU>
,Future<PDU>
,EventListener
,ResponseListener
public class SnmpCompletableFuture extends CompletableFuture<PDU> implements ResponseListener
TheSnmpCompletableFuture
implements aCompletableFuture
for aPDU
. It represents the result of an SNMP operation sending aPDU
and receiving its response when the sentPDU
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 responsePDU
with a non-zero error status, timeout, orPDU.REPORT
PDU response. In the latter case, aSnmpCompletableFuture.ReportException
will be returned. For a timeout, aTimeoutException
, and for a SNMP error, aSnmpCompletableFuture.SnmpErrorException
. If sending the SNMP message throws an exception, this exception is directly returned.- Since:
- 3.5.0
- Author:
- Frank Fock
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SnmpCompletableFuture.ReportException
ThisReportException
represents an SNMPPDU.REPORT
PDU.static class
SnmpCompletableFuture.SnmpErrorException
ThisSnmpErrorException
represents an SNMP error status and index.-
Nested classes/interfaces inherited from class java.util.concurrent.CompletableFuture
CompletableFuture.AsynchronousCompletionTask
-
-
Field Summary
Fields Modifier and Type Field Description static String
ERR_TIMEOUT
protected String
timeoutMessage
-
Constructor Summary
Constructors Modifier Constructor Description protected
SnmpCompletableFuture()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ResponseEvent<?>
getResponseEvent()
Object[]
getUserObjects()
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>
SnmpCompletableFuturesend(Snmp snmp, Target<A> target, PDU pdu, Object... userObjects)
-
Methods 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, 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 Detail
-
ERR_TIMEOUT
public static final String ERR_TIMEOUT
- See Also:
- Constant Field Values
-
timeoutMessage
protected String timeoutMessage
-
-
Method Detail
-
onResponse
public <A extends Address> void onResponse(ResponseEvent<A> event)
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
public ResponseEvent<?> 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
public Object[] getUserObjects()
Returns the user objects provided bysend(Snmp, Target, PDU, Object...)
when this future completed.- Returns:
- a list of user objects.
-
-