|
LimeWire Consolidated API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.limewire.mojito.handler.response.AbstractResponseHandler<V>
public abstract class AbstractResponseHandler<V extends Result>
An abstract base class for ResponseHandlers
| Field Summary | |
|---|---|
protected Context |
context
A handle to Context |
protected long |
lastResponseTime
The time of the last response we received |
| Constructor Summary | |
|---|---|
AbstractResponseHandler(Context context)
|
|
AbstractResponseHandler(Context context,
int maxErrors)
|
|
AbstractResponseHandler(Context context,
long timeout)
|
|
AbstractResponseHandler(Context context,
long timeout,
int maxErrors)
|
|
| Method Summary | |
|---|---|
void |
cancel()
Cancels the DHTTask |
protected DHTTimeoutException |
createTimeoutException(KUID nodeId,
SocketAddress address,
RequestMessage request,
long time)
A helper method to create Timeout Exceptions |
protected abstract void |
error(KUID nodeId,
SocketAddress dst,
RequestMessage message,
IOException e)
See handleError() |
protected void |
fireTimeoutException(KUID nodeId,
SocketAddress address,
RequestMessage request,
long time)
A helper method to throw Timeout Exceptions |
protected long |
getElapsedTime()
Returns the total time that has elapsed since this ResponseHandler is active. |
protected int |
getErrors()
Returns the number of errors that have occurred |
protected long |
getLastResponseTime()
Returns the time when the last response was received |
protected Object |
getLock()
Returns the lock Object for the ResponseHandler. |
int |
getMaxErrors()
Returns the maximum number of errors that may occur before we're giving up to re-send a request |
long |
getTimeout()
Returns the timeout (in milliseconds) of this handler. |
long |
getWaitOnLockTimeout()
The maximum time we're waiting on a lock. |
void |
handleError(KUID nodeId,
SocketAddress dst,
RequestMessage message,
IOException e)
Called if an error occurred in handleResponse() or handleTimeout() |
void |
handleResponse(ResponseMessage response,
long time)
Called to handle a response |
void |
handleTick()
Called in periodic intervals while we're waiting for a response. |
void |
handleTimeout(KUID nodeId,
SocketAddress dst,
RequestMessage request,
long time)
Called after the timeout time has elapsed and no response has arrived |
boolean |
isCancelled()
Returns whether or not this handler has been cancelled |
boolean |
isDone()
Returns whether or not this handler is done which means if it has returned a result or threw an Exception |
protected void |
resend(KUID nodeId,
SocketAddress dst,
RequestMessage message)
Resends the given Message to nodeId/dst |
protected void |
resetErrors()
Resets the error counter |
protected abstract void |
response(ResponseMessage message,
long time)
See handleResponse() |
protected void |
setException(DHTException ex)
Sets the Exception which will be thrown by the call() method |
void |
setMaxErrors(int maxErrors)
Sets the maximum number of errors that may occur before we're giving up to re-send a request |
protected void |
setReturnValue(V value)
Sets the return value which will be returned by the call() method |
void |
setTimeout(long timeout)
Sets the timeout of this handler |
protected abstract void |
start()
Override this method to start the ResponseHandler |
void |
start(OnewayExchanger<V,ExecutionException> exchanger)
Starts the DHTTask |
protected void |
tick()
See handleTick() |
protected abstract void |
timeout(KUID nodeId,
SocketAddress dst,
RequestMessage message,
long time)
See handleTimeout() |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected final Context context
protected long lastResponseTime
| Constructor Detail |
|---|
public AbstractResponseHandler(Context context)
public AbstractResponseHandler(Context context,
long timeout)
public AbstractResponseHandler(Context context,
int maxErrors)
public AbstractResponseHandler(Context context,
long timeout,
int maxErrors)
| Method Detail |
|---|
protected Object getLock()
public void start(OnewayExchanger<V,ExecutionException> exchanger)
DHTTask
start in interface DHTTask<V extends Result>
protected abstract void start()
throws DHTException
DHTExceptionpublic void cancel()
DHTTask
cancel in interface DHTTask<V extends Result>public void setTimeout(long timeout)
public long getTimeout()
ResponseHandler
getTimeout in interface ResponseHandlerprotected long getElapsedTime()
protected long getLastResponseTime()
protected void resetErrors()
protected int getErrors()
public void setMaxErrors(int maxErrors)
public int getMaxErrors()
public long getWaitOnLockTimeout()
getWaitOnLockTimeout in interface DHTTask<V extends Result>
protected abstract void response(ResponseMessage message,
long time)
throws IOException
IOException
public void handleResponse(ResponseMessage response,
long time)
throws IOException
ResponseHandler
handleResponse in interface ResponseHandlerresponse - the response messagetime - the round trip time
IOException
protected abstract void timeout(KUID nodeId,
SocketAddress dst,
RequestMessage message,
long time)
throws IOException
IOException
public void handleTimeout(KUID nodeId,
SocketAddress dst,
RequestMessage request,
long time)
throws IOException
ResponseHandler
handleTimeout in interface ResponseHandlernodeId - the Node ID of the Contact (can be null)dst - the address where we sent the requestrequest - the request messagetime - the total time that has elapsed
IOException
protected void resend(KUID nodeId,
SocketAddress dst,
RequestMessage message)
throws IOException
IOException
protected abstract void error(KUID nodeId,
SocketAddress dst,
RequestMessage message,
IOException e)
public void handleError(KUID nodeId,
SocketAddress dst,
RequestMessage message,
IOException e)
ResponseHandler
handleError in interface ResponseHandlernodeId - the Node ID of the Contact (can be null)dst - the address of the Contactmessage - the RequestMessage that failed to be sende - the Exception that was thrownprotected void tick()
public void handleTick()
ResponseHandler
handleTick in interface ResponseHandlerpublic boolean isCancelled()
ResponseHandler
isCancelled in interface ResponseHandlerpublic boolean isDone()
protected void setReturnValue(V value)
protected void setException(DHTException ex)
protected void fireTimeoutException(KUID nodeId,
SocketAddress address,
RequestMessage request,
long time)
protected DHTTimeoutException createTimeoutException(KUID nodeId,
SocketAddress address,
RequestMessage request,
long time)
|
LimeWire Consolidated API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||