public class BlockReceiver extends java.lang.Object implements AsyncMessageFilterCallback
Modifier and Type | Class and Description |
---|---|
static interface |
BlockReceiver.BlockReceiverCompletion |
static interface |
BlockReceiver.BlockReceiverTimeoutHandler |
Modifier and Type | Field and Description |
---|---|
static long |
ACK_TRANSFER_FAILED_TIMEOUT
sendAborted is not sent at the realtime/bulk priority.
|
static long |
CLEANUP_TIMEOUT |
static int |
MAX_CONSECUTIVE_MISSING_PACKET_REPORTS |
long |
MAX_ROUND_TRIP_TIME |
static int |
MAX_SEND_INTERVAL |
long |
RECEIPT_TIMEOUT |
static long |
RECEIPT_TIMEOUT_BULK |
static long |
RECEIPT_TIMEOUT_REALTIME |
static long |
TOO_LONG_TIMEOUT |
Constructor and Description |
---|
BlockReceiver(MessageCore usm,
PeerContext sender,
long uid,
PartiallyReceivedBlock prb,
ByteCounter ctr,
Ticker ticker,
boolean doTooLong,
boolean realTime,
BlockReceiver.BlockReceiverTimeoutHandler timeoutHandler,
boolean completeAfterAckedAllReceived) |
Modifier and Type | Method and Description |
---|---|
static int |
getRunningReceives() |
void |
onDisconnect(PeerContext ctx)
Called when the filter is dropped because a connection is dropped.
|
void |
onMatched(Message m)
Used to discard leftover messages, usually just packetTransmit and allSent.
|
void |
onRestarted(PeerContext ctx)
Called when the filter is dropped because a connection is restarted.
|
void |
onTimeout()
Called when the filter times out and is removed from the list of filters to match.
|
void |
receive(BlockReceiver.BlockReceiverCompletion callback) |
boolean |
senderAborted() |
boolean |
shouldTimeout()
Check whether the filter should be removed.
|
java.lang.String |
toString() |
public final long RECEIPT_TIMEOUT
public static final long RECEIPT_TIMEOUT_REALTIME
public static final long RECEIPT_TIMEOUT_BULK
public final long MAX_ROUND_TRIP_TIME
public static final int MAX_CONSECUTIVE_MISSING_PACKET_REPORTS
public static final int MAX_SEND_INTERVAL
public static final long CLEANUP_TIMEOUT
public static final long TOO_LONG_TIMEOUT
public static final long ACK_TRANSFER_FAILED_TIMEOUT
public BlockReceiver(MessageCore usm, PeerContext sender, long uid, PartiallyReceivedBlock prb, ByteCounter ctr, Ticker ticker, boolean doTooLong, boolean realTime, BlockReceiver.BlockReceiverTimeoutHandler timeoutHandler, boolean completeAfterAckedAllReceived)
usm
- sender
- uid
- prb
- ctr
- ticker
- doTooLong
- realTime
- timeoutHandler
- completeAfterAckedAllReceived
- If true, we need to call completion
only after we have received an ack to the allReceived message. Generally,
handlers want to complete early (=false), so the slot is freed up and can
be reused by the other side; senders want to complete late, so they don't
end up reusing the slot before the handler has completed (=true).public void receive(BlockReceiver.BlockReceiverCompletion callback)
public void onMatched(Message m)
onMatched
in interface AsyncMessageFilterCallback
m
- The message which matched the filter.public boolean shouldTimeout()
AsyncMessageFilterCallback
shouldTimeout
in interface AsyncMessageFilterCallback
public void onTimeout()
AsyncMessageFilterCallback
onTimeout
in interface AsyncMessageFilterCallback
public void onDisconnect(PeerContext ctx)
AsyncMessageFilterCallback
onDisconnect
in interface AsyncMessageFilterCallback
public void onRestarted(PeerContext ctx)
AsyncMessageFilterCallback
onRestarted
in interface AsyncMessageFilterCallback
public boolean senderAborted()
public static int getRunningReceives()
public java.lang.String toString()
toString
in class java.lang.Object