public final class RequestSender extends BaseSender implements PrioRunnable
BaseSender.DO
dontDecrementHTLThisTime, gotMessages, hasForwarded, htl, lastMessage, lastNode, nodesRoutedTo, origHTL, rejectOverloads, routeAttempts, startTime
Constructor and Description |
---|
RequestSender(Key key,
DSAPublicKey pubKey,
short htl,
long uid,
RequestTag tag,
Node n,
PeerNode source,
boolean offersOnly,
boolean canWriteClientCache,
boolean canWriteDatastore,
boolean realTimeFlag)
RequestSender constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
abortedDownstreamTransfers() |
void |
addListener(RequestSenderListener l) |
protected Message |
createDataRequest() |
long |
fetchTimeout() |
protected void |
forwardRejectedOverload()
Forward RejectedOverload to the request originator
|
protected long |
getAcceptedTimeout() |
byte[] |
getHeaders() |
short |
getHTL() |
PartiallyReceivedBlock |
getPRB() |
int |
getPriority() |
SSKBlock |
getSSKBlock() |
int |
getStatus() |
int |
getTotalReceivedBytes() |
int |
getTotalSentBytes() |
protected void |
handleAcceptedRejectedTimeout(PeerNode next,
UIDTag origTag) |
protected boolean |
isInsert() |
boolean |
isLocalRequestSearch() |
boolean |
isTransferCoalesced() |
protected MessageFilter |
makeAcceptedRejectedFilter(PeerNode next,
long acceptedTimeout,
UIDTag tag)
Construct a filter to wait the specified time for accepted or rejected.
|
protected void |
onAccepted(PeerNode next) |
protected void |
onAccepted(PeerNode next,
boolean forked,
short htl)
If we handled a timeout, and forked, we need to know the original HTL.
|
void |
receivedBytes(int x) |
protected void |
routeRequests()
Route requests.
|
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.
|
void |
setTransferCoalesced() |
void |
start() |
PeerNode |
successFrom() |
protected void |
timedOutWhileWaiting(double load)
We timed out while waiting for a slot from any node.
|
java.lang.String |
toString() |
PeerNode |
transferringFrom() |
boolean |
transferStarted() |
byte[] |
waitForOpennetNoderef() |
short |
waitUntilStatusChange(short mask)
Wait until either the transfer has started, we receive a
RejectedOverload, or we get a terminal status code.
|
calculateTimeout, calculateTimeout, getLongSlotWaiterTimeout, getShortSlotWaiterTimeout, hopsForFatalTimeoutWaitingForPeer, ignoreLowBackoff, innerRouteRequests, innerRouteRequestsNew, innerRouteRequestsOld, isAccepted, routedLast, sourceForRouting, timeSinceSent
public RequestSender(Key key, DSAPublicKey pubKey, short htl, long uid, RequestTag tag, Node n, PeerNode source, boolean offersOnly, boolean canWriteClientCache, boolean canWriteDatastore, boolean realTimeFlag)
key
- The key to request. Its public key should have been looked up
already; RequestSender will not look it up.realTimeFlag
- If enabled,public java.lang.String toString()
toString
in class java.lang.Object
public void start()
public void run()
run
in interface java.lang.Runnable
protected void routeRequests()
routeRequests
in class BaseSender
protected MessageFilter makeAcceptedRejectedFilter(PeerNode next, long acceptedTimeout, UIDTag tag)
BaseSender
makeAcceptedRejectedFilter
in class BaseSender
next
- The peer we are waiting for a response from.acceptedTimeout
- The time to wait.tag
- Use the UID from this tag. Some requests may change the tag
after some hops, and if e.g. waiting for confirmation after a timeout,
we need to use the old tag.protected Message createDataRequest()
createDataRequest
in class BaseSender
protected void forwardRejectedOverload()
forwardRejectedOverload
in class BaseSender
public PartiallyReceivedBlock getPRB()
public boolean transferStarted()
public short waitUntilStatusChange(short mask)
mask
- Bitmask indicating what NOT to wait for i.e. the situation when this function
exited last time (see WAIT_ constants above). Bits can also be set true even though they
were not valid, to indicate that the caller doesn't care about that bit.
If zero, function will throw an IllegalArgumentException.public byte[] waitForOpennetNoderef() throws freenet.node.OpennetManager.WaitedTooLongForOpennetNoderefException
freenet.node.OpennetManager.WaitedTooLongForOpennetNoderefException
public PeerNode successFrom()
public byte[] getHeaders()
public int getStatus()
public short getHTL()
public SSKBlock getSSKBlock()
public void sentBytes(int x)
ByteCounter
sentBytes
in interface ByteCounter
public int getTotalSentBytes()
public void receivedBytes(int x)
receivedBytes
in interface ByteCounter
public int getTotalReceivedBytes()
public void sentPayload(int x)
ByteCounter
sentPayload
in interface ByteCounter
x
- Number of bytes sentpublic boolean isLocalRequestSearch()
public void addListener(RequestSenderListener l)
public int getPriority()
getPriority
in interface PrioRunnable
public PeerNode transferringFrom()
public boolean abortedDownstreamTransfers()
public long fetchTimeout()
public void setTransferCoalesced()
public boolean isTransferCoalesced()
protected void onAccepted(PeerNode next)
onAccepted
in class BaseSender
protected void onAccepted(PeerNode next, boolean forked, short htl)
protected long getAcceptedTimeout()
getAcceptedTimeout
in class BaseSender
protected void timedOutWhileWaiting(double load)
BaseSender
timedOutWhileWaiting
in class BaseSender
load
- The proportion of requests getting timed out, on average,
across the nodes we are waiting for. This is used to decide how long the
RecentlyFailed should be for.protected boolean isInsert()
isInsert
in class BaseSender
protected void handleAcceptedRejectedTimeout(PeerNode next, UIDTag origTag)
handleAcceptedRejectedTimeout
in class BaseSender