public class RequestHandler extends java.lang.Object implements PrioRunnable, ByteCounter, RequestSenderListener
Constructor and Description |
---|
RequestHandler(PeerNode source,
long id,
Node n,
short htl,
Key key,
RequestTag tag,
KeyBlock passedInKeyBlock,
boolean realTimeFlag,
boolean needsPubKey) |
Modifier and Type | Method and Description |
---|---|
int |
getPriority() |
void |
onAbortDownstreamTransfers(int reason,
java.lang.String desc)
Abort downstream transfers (not necessarily upstream ones, so not via the PRB).
|
void |
onCHKTransferBegins()
Should return quickly, allocate a thread if it needs to block etc
|
void |
onDataFoundLocally()
Not called by RequestSender, but called if the data was in the store.
|
void |
onNotStarted(boolean internalError)
Not called by RequestSender, but called if localOnly is true and the data
is not in the store.
|
void |
onReceivedRejectOverload()
Should return quickly, allocate a thread if it needs to block etc
|
void |
onRequestSenderFinished(int status,
boolean fromOfferedKey,
RequestSender rs)
Should return quickly, allocate a thread if it needs to block etc
|
void |
receivedBytes(int x) |
void |
run() |
void |
sentBytes(int x)
Sent some bytes.
|
void |
sentPayload(int x)
Sent payload - only include the number of bytes of actual payload i.e.
|
java.lang.String |
toString() |
protected void |
transferFinished(boolean success)
Once the transfer has finished and we have the final status code, either path fold
or just unregister.
|
public RequestHandler(PeerNode source, long id, Node n, short htl, Key key, RequestTag tag, KeyBlock passedInKeyBlock, boolean realTimeFlag, boolean needsPubKey)
source
- id
- n
- htl
- key
- tag
- passedInKeyBlock
- We ALWAYS look up in the datastore before starting a request.
SECURITY: Do not pass messages into handler constructors. See note at top of NodeDispatcher.realTimeFlag
- needsPubKey
- public java.lang.String toString()
toString
in class java.lang.Object
public void run()
run
in interface java.lang.Runnable
public void onReceivedRejectOverload()
RequestSenderListener
onReceivedRejectOverload
in interface RequestSenderListener
public void onCHKTransferBegins()
RequestSenderListener
onCHKTransferBegins
in interface RequestSenderListener
protected void transferFinished(boolean success)
success
- Whether the block transfer succeeded.public void onAbortDownstreamTransfers(int reason, java.lang.String desc)
RequestSenderListener
onAbortDownstreamTransfers
in interface RequestSenderListener
public void onRequestSenderFinished(int status, boolean fromOfferedKey, RequestSender rs)
RequestSenderListener
onRequestSenderFinished
in interface RequestSenderListener
public void sentBytes(int x)
ByteCounter
sentBytes
in interface ByteCounter
public void receivedBytes(int x)
receivedBytes
in interface ByteCounter
public void sentPayload(int x)
ByteCounter
sentPayload
in interface ByteCounter
x
- Number of bytes sentpublic int getPriority()
getPriority
in interface PrioRunnable
public void onNotStarted(boolean internalError)
RequestSenderListener
onNotStarted
in interface RequestSenderListener
internalError
- If true, something broke severely.public void onDataFoundLocally()
RequestSenderListener
onDataFoundLocally
in interface RequestSenderListener