V
- return type of the asynchronous callD
- type of the IO handlepublic abstract class AbstractAsyncIOCallable<V,D extends Closeable> extends Object implements StoppableCallbackCallable<V>
Constructor and Description |
---|
AbstractAsyncIOCallable() |
Modifier and Type | Method and Description |
---|---|
V |
call()
This method implements the strategy for the actual IO operation:
1) Open the IO handle
2) Perform IO operation
3) Close IO handle
|
void |
done(boolean canceled)
Optional callback that subclasses can implement.
|
protected D |
getIoHandle()
Returns the IO handle.
|
IOException |
getStopException()
Returns Exception that might happen on stop.
|
boolean |
isStopped()
Check if the IO operation is stopped
|
protected abstract D |
openIOHandle()
Open the IO Handle (e.g.
|
protected abstract V |
performOperation()
Implements the actual IO operation on the opened IO handle.
|
void |
stop()
Stops the I/O operation by closing the I/O handle.
|
public V call() throws Exception
protected abstract D openIOHandle() throws Exception
Exception
protected abstract V performOperation() throws Exception
Exception
public void stop()
stop
in interface AsyncStoppable
protected D getIoHandle()
public void done(boolean canceled)
done
in interface AsyncDoneCallback
canceled
- true if the callback is done, but was canceledpublic boolean isStopped()
isStopped
in interface AsyncStoppable
public IOException getStopException()
getStopException
in interface AsyncStoppable
Copyright © 2014–2018 The Apache Software Foundation. All rights reserved.