net.floodlightcontroller.core.internal
Class OFMessageFuture<V>
java.lang.Object
net.floodlightcontroller.core.internal.OFMessageFuture<V>
- All Implemented Interfaces:
- java.util.concurrent.Future<V>
- Direct Known Subclasses:
- OFFeaturesReplyFuture, OFStatisticsFuture
public abstract class OFMessageFuture<V>
- extends java.lang.Object
- implements java.util.concurrent.Future<V>
A Future object used to retrieve asynchronous OFMessage replies. Unregisters
and cancels itself by default after 60 seconds. This class is meant to be
sub-classed and proper behavior added to the handleReply method, and
termination of the Future to be handled in the isFinished method.
- Author:
- David Erickson (daviderickson@cs.stanford.edu)
Method Summary |
boolean |
cancel(boolean mayInterruptIfRunning)
|
void |
deliverFuture(IOFSwitch sw,
OFMessage msg)
|
V |
get()
|
V |
get(long timeout,
java.util.concurrent.TimeUnit unit)
|
int |
getTransactionId()
|
protected abstract void |
handleReply(IOFSwitch sw,
OFMessage msg)
Used to handle the specific expected message this Future was reigstered
for, the specified msg parameter is guaranteed to match the type and
transaction id specified. |
boolean |
isCancelled()
|
boolean |
isDone()
|
protected abstract boolean |
isFinished()
Called directly after handleReply, subclasses implement this method to
indicate when the future can deregister itself from receiving future
messages, and when it is safe to return the results to any waiting
threads. |
void |
setTransactionId(int transactionId)
|
protected void |
unRegister()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
threadPool
protected IThreadPoolService threadPool
canceled
protected volatile boolean canceled
latch
protected java.util.concurrent.CountDownLatch latch
responseType
protected OFType responseType
result
protected volatile V result
sw
protected IOFSwitch sw
timeoutTimer
protected java.lang.Runnable timeoutTimer
transactionId
protected int transactionId
DEFAULT_TIMEOUT
protected static final long DEFAULT_TIMEOUT
- See Also:
- Constant Field Values
DEFAULT_TIMEOUT_UNIT
protected static final java.util.concurrent.TimeUnit DEFAULT_TIMEOUT_UNIT
OFMessageFuture
public OFMessageFuture(IThreadPoolService tp,
IOFSwitch sw,
OFType responseType,
int transactionId)
OFMessageFuture
public OFMessageFuture(IThreadPoolService tp,
IOFSwitch sw,
OFType responseType,
int transactionId,
long timeout,
java.util.concurrent.TimeUnit unit)
unRegister
protected void unRegister()
deliverFuture
public void deliverFuture(IOFSwitch sw,
OFMessage msg)
handleReply
protected abstract void handleReply(IOFSwitch sw,
OFMessage msg)
- Used to handle the specific expected message this Future was reigstered
for, the specified msg parameter is guaranteed to match the type and
transaction id specified.
- Parameters:
sw
- msg
-
isFinished
protected abstract boolean isFinished()
- Called directly after handleReply, subclasses implement this method to
indicate when the future can deregister itself from receiving future
messages, and when it is safe to return the results to any waiting
threads.
- Returns:
- when this Future has completed its work
cancel
public boolean cancel(boolean mayInterruptIfRunning)
- Specified by:
cancel
in interface java.util.concurrent.Future<V>
isCancelled
public boolean isCancelled()
- Specified by:
isCancelled
in interface java.util.concurrent.Future<V>
isDone
public boolean isDone()
- Specified by:
isDone
in interface java.util.concurrent.Future<V>
get
public V get()
throws java.lang.InterruptedException,
java.util.concurrent.ExecutionException
- Specified by:
get
in interface java.util.concurrent.Future<V>
- Throws:
java.lang.InterruptedException
java.util.concurrent.ExecutionException
get
public V get(long timeout,
java.util.concurrent.TimeUnit unit)
throws java.lang.InterruptedException,
java.util.concurrent.ExecutionException,
java.util.concurrent.TimeoutException
- Specified by:
get
in interface java.util.concurrent.Future<V>
- Throws:
java.lang.InterruptedException
java.util.concurrent.ExecutionException
java.util.concurrent.TimeoutException
getTransactionId
public int getTransactionId()
setTransactionId
public void setTransactionId(int transactionId)