com.h3c.of.lib.msg

## Class DefaultMessageFuture

- java.lang.Object
- - com.h3c.of.lib.msg.DefaultMessageFuture

- All Implemented Interfaces:
    MessageFuture
  Direct Known Subclasses:
    DataPathMessageFuture

      public class DefaultMessageFuture
      extends Object
      implements MessageFuture

  Default implementation of a `MessageFuture`.

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface com.h3c.of.lib.msg.MessageFuture

      `MessageFuture.Result`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DefaultMessageFuture(OpenflowMessage request)` Constructs a default message future for the given request.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `MessageFuture` | `await()` Waits for this future to be completed.
    `boolean` | `await(long timeoutMs)` Waits for this future to be completed within the specified time limit.
    `MessageFuture` | `awaitUninterruptibly()` Waits for this future to be completed without interruption.
    `boolean` | `awaitUninterruptibly(long timeoutMs)` Waits for this future to be completed within the specified time limit without interruption.
    `Throwable` | `cause()` Returns the cause of failure if an exception was thrown.
    `OpenflowMessage` | `reply()` Returns the reply resulting from the asynchronous request.
    `OpenflowMessage` | `request()` Returns the original request message.
    `MessageFuture.Result` | `result()` Returns the future's result.
    `boolean` | `setFailure(OfmError error)` Marks this future as a failure, attaching the specified error response message, and notifies all listeners.
    `boolean` | `setFailure(Throwable cause)` Marks this future as a failure, caused by the specified exception, and notifies all listeners.
    `boolean` | `setSuccess()` Marks this future as a success (with no expected reply) and notifies all listeners.
    `boolean` | `setSuccess(OpenflowMessage msg)` Marks this future as a success, attaching the specified reply message, and notifies all listeners.
    `String` | `toString()`
    `long` | `xid()` Returns the xid (message sequence number) associated with this future.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### DefaultMessageFuture

          public DefaultMessageFuture(OpenflowMessage request)

      Constructs a default message future for the given request.
      Parameters:
        `request` - the out-bound request associated with this future
      Throws:
        `IllegalArgumentException` - if the xid is 0 or negative

  - ### Method Detail

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### xid

          public long xid()

      Description copied from interface: `MessageFuture`
      Returns the xid (message sequence number) associated with this future.
      Specified by:
        `xid` in interface `MessageFuture`
      Returns:
        the transaction id

    - #### request

          public OpenflowMessage request()

      Description copied from interface: `MessageFuture`
      Returns the original request message.
      Specified by:
        `request` in interface `MessageFuture`
      Returns:
        the OpenFlow message

    - #### reply

          public OpenflowMessage reply()

      Description copied from interface: `MessageFuture`
      Returns the reply resulting from the asynchronous request. If the request was successful, the message will be the corresponding reply. If the request was successful (but no reply was expected), this will be null. If the request failed, the message will be the corresponding `OfmError` message.

      This will be null if the future has not yet been satisfied.

      Specified by:
        `reply` in interface `MessageFuture`
      Returns:
        the OpenFlow message

    - #### cause

          public Throwable cause()

      Description copied from interface: `MessageFuture`
      Returns the cause of failure if an exception was thrown.
      Specified by:
        `cause` in interface `MessageFuture`
      Returns:
        the cause of failure

    - #### result

          public MessageFuture.Result result()

      Description copied from interface: `MessageFuture`
      Returns the future's result.
      Specified by:
        `result` in interface `MessageFuture`
      Returns:
        the future's result

    - #### setSuccess

          public boolean setSuccess()

      Description copied from interface: `MessageFuture`
      Marks this future as a success (with no expected reply) and notifies all listeners. `true` is returned if this future is successfully marked as a success; `false` is returned if this future was already marked as either success or failure.
      Specified by:
        `setSuccess` in interface `MessageFuture`
      Returns:
        `true` if successfully marked as a success; `false` otherwise

    - #### setSuccess

          public boolean setSuccess(OpenflowMessage msg)

      Description copied from interface: `MessageFuture`
      Marks this future as a success, attaching the specified reply message, and notifies all listeners. `true` is returned if this future is successfully marked as a success; `false` is returned if this future was already marked as either success or failure.
      Specified by:
        `setSuccess` in interface `MessageFuture`
      Parameters:
        `msg` - the OpenFlow message reply to the original request
      Returns:
        `true` if successfully marked as a success; `false` otherwise

    - #### setFailure

          public boolean setFailure(OfmError error)

      Description copied from interface: `MessageFuture`
      Marks this future as a failure, attaching the specified error response message, and notifies all listeners. `true` is returned if this future is successfully marked as a success; `false` is returned if this future was already marked as either success or failure.
      Specified by:
        `setFailure` in interface `MessageFuture`
      Parameters:
        `error` - the OpenFlow error message resulting from the original request
      Returns:
        `true` if successfully marked as a success; `false` otherwise

    - #### setFailure

          public boolean setFailure(Throwable cause)

      Description copied from interface: `MessageFuture`
      Marks this future as a failure, caused by the specified exception, and notifies all listeners. `true` is returned if this future is successfully marked as a success; `false` is returned if this future was already marked as either success or failure.
      Specified by:
        `setFailure` in interface `MessageFuture`
      Parameters:
        `cause` - the cause of the failure
      Returns:
        `true` if successfully marked as a success; `false` otherwise

    - #### await

          public MessageFuture await()
                              throws InterruptedException

      Description copied from interface: `MessageFuture`
      Waits for this future to be completed. This call blocks until the future is marked as success or failure.
      Specified by:
        `await` in interface `MessageFuture`
      Returns:
        self (for method chaining)
      Throws:
        `InterruptedException` - if the current thread was interrupted

    - #### awaitUninterruptibly

          public MessageFuture awaitUninterruptibly()

      Description copied from interface: `MessageFuture`
      Waits for this future to be completed without interruption. This call blocks until the future is marked as success or failure. This method catches `InterruptedException`s and discards them silently.
      Specified by:
        `awaitUninterruptibly` in interface `MessageFuture`
      Returns:
        self (for method chaining)

    - #### await

          public boolean await(long timeoutMs)
                        throws InterruptedException

      Description copied from interface: `MessageFuture`
      Waits for this future to be completed within the specified time limit. This call blocks until the future is marked as success or failure, or until the specified amount of time has elapsed. `true` is returned if the future was satisfied within the time limit; `false` is returned if the timeout expired.
      Specified by:
        `await` in interface `MessageFuture`
      Parameters:
        `timeoutMs` - timeout expressed in milliseconds
      Returns:
        `true` if the future was completed within the specified time limit; `false` otherwise
      Throws:
        `InterruptedException` - if the current thread was interrupted

    - #### awaitUninterruptibly

          public boolean awaitUninterruptibly(long timeoutMs)

      Description copied from interface: `MessageFuture`
      Waits for this future to be completed within the specified time limit without interruption. This call blocks until the future is marked as success or failure, or until the specified amount of time has elapsed. `true` is returned if the future was satisfied within the time limit; `false` is returned if the timeout expired. This method catches `InterruptedException`s and discards them silently.
      Specified by:
        `awaitUninterruptibly` in interface `MessageFuture`
      Parameters:
        `timeoutMs` - timeout expressed in milliseconds
      Returns:
        `true` if the future was completed within the specified time limit; `false` otherwise

Copyright © 2014. All Rights Reserved.