public abstract class ClientRequester extends java.lang.Object implements java.io.Serializable, ClientRequestSchedulerGroup
Modifier and Type | Field and Description |
---|---|
protected boolean |
blockSetFinalized
Has totalBlocks stopped growing?
|
protected boolean |
cancelled
Has the request or insert been cancelled?
|
protected RequestClient |
client
The RequestClient, used to determine whether this request is
persistent, and also we round-robin between different RequestClient's
in scheduling within a given priority class and retry count.
|
long |
creationTime |
protected int |
failedBlocks
Number of blocks which have failed.
|
protected int |
fatallyFailedBlocks
Number of blocks which have failed fatally.
|
protected java.util.Date |
latestFailure |
protected java.util.Date |
latestSuccess
ATTENTION: This may be null for very old databases.
|
protected int |
minSuccessBlocks
Minimum number of blocks required to succeed for success.
|
protected short |
priorityClass
Priority class of the request or insert.
|
protected boolean |
realTimeFlag
Whether this is a real-time request
|
protected boolean |
sentToNetwork
Has at least one block been scheduled to be sent to the network?
Requests can be satisfied entirely from the datastore sometimes.
|
protected int |
successfulBlocks
Number of blocks we have successfully completed a fetch/put for.
|
protected int |
totalBlocks
Total number of blocks this request has tried to fetch/put.
|
Modifier | Constructor and Description |
---|---|
protected |
ClientRequester()
Required because we implement
Serializable . |
protected |
ClientRequester(short priorityClass,
RequestClient requestClient) |
Modifier and Type | Method and Description |
---|---|
void |
addBlock()
Add a block to our estimate of the total.
|
void |
addBlocks(int num)
Add several blocks to our estimate of the total.
|
void |
addMustSucceedBlocks(int blocks)
Add one or more blocks to the number of requires blocks, and don't notify the clients.
|
void |
addRedundantBlocksInsert(int blocks)
Insertors should override this.
|
void |
blockSetFinalized(ClientContext context)
The set of blocks has been finalised, total will not change any
more.
|
protected boolean |
cancel()
Cancel the request.
|
abstract void |
cancel(ClientContext context)
Cancel the request.
|
protected void |
clearCountersOnRestart() |
void |
completedBlock(boolean dontNotify,
ClientContext context)
We completed a block.
|
void |
failedBlock(boolean dontNotify,
ClientContext context)
A block failed.
|
void |
failedBlock(ClientContext context)
A block failed.
|
void |
fatallyFailedBlock(ClientContext context)
A block failed fatally.
|
static ClientRequester[] |
getAll() |
protected abstract ClientBaseCallback |
getCallback() |
RequestClient |
getClient()
Get client context object
|
byte[] |
getClientDetail(ChecksumChecker checker) |
protected static byte[] |
getClientDetail(PersistentClientCallback callback,
ChecksumChecker checker) |
java.util.Date |
getLatestFailure()
UTC Date of latest increase of
failedBlocks or fatallyFailedBlocks .Null if there was no failure yet. |
java.util.Date |
getLatestSuccess()
UTC Date of latest increase of
successfulBlocks .Initialized to current time for usability purposes: This allows the user to sort downloads by last success in the user interface to determine which ones are stalling - those will be the ones with the oldest last success date. |
short |
getPriorityClass()
What is our priority class?
|
ClientRequestSchedulerGroup |
getSchedulerGroup()
Get the group the request belongs to.
|
int |
getTotalBlocks() |
abstract FreenetURI |
getURI()
Get the URI for the request or insert.
|
int |
hashCode()
We need a hash code that persists across restarts.
|
protected abstract void |
innerNotifyClients(ClientContext context)
Notify clients, usually via a SplitfileProgressEvent, of the current progress.
|
protected void |
innerOnResume(ClientContext context)
Called by onResume() once and only once after restarting.
|
protected abstract void |
innerToNetwork(ClientContext context)
Notify clients that a request has gone to the network, for the first time, i.e.
|
boolean |
isCancelled()
Is the request or insert cancelled?
|
boolean |
isCurrentState(ClientGetState state) |
abstract boolean |
isFinished()
Is the request or insert completed (succeeded, failed, or
cancelled, which is a kind of failure)?
|
void |
notifyClients(ClientContext context)
Notify clients by calling innerNotifyClients off-thread.
|
void |
onResume(ClientContext context)
Called for a persistent request after startup.
|
void |
onShutdown(ClientContext context)
Called just before the final write when shutting down the node.
|
abstract void |
onTransition(ClientGetState oldState,
ClientGetState newState,
ClientContext context) |
boolean |
persistent()
Is this request persistent?
|
boolean |
realTimeFlag() |
protected void |
resetBlocks() |
void |
setPriorityClass(short newPriorityClass,
ClientContext ctx)
Change the priority class of the request (request includes inserts here).
|
void |
toNetwork(ClientContext context)
Called when we first send a request to the network.
|
protected short priorityClass
protected final boolean realTimeFlag
protected boolean cancelled
protected transient RequestClient client
protected int totalBlocks
protected int successfulBlocks
protected java.util.Date latestSuccess
protected int failedBlocks
protected int fatallyFailedBlocks
protected java.util.Date latestFailure
getLatestFailure()
protected int minSuccessBlocks
protected boolean blockSetFinalized
protected boolean sentToNetwork
public final long creationTime
protected ClientRequester()
Serializable
.protected ClientRequester(short priorityClass, RequestClient requestClient)
public abstract void onTransition(ClientGetState oldState, ClientGetState newState, ClientContext context)
public short getPriorityClass()
protected boolean cancel()
public abstract void cancel(ClientContext context)
context
- The ClientContext object including essential but
non-persistent objects such as the schedulers.public boolean isCancelled()
public abstract FreenetURI getURI()
public abstract boolean isFinished()
public int hashCode()
hashCode
in class java.lang.Object
public int getTotalBlocks()
public java.util.Date getLatestSuccess()
successfulBlocks
.public java.util.Date getLatestFailure()
failedBlocks
or fatallyFailedBlocks
.protected void resetBlocks()
public void blockSetFinalized(ClientContext context)
context
- The ClientContext object including essential but
non-persistent objects such as the schedulers.public void addBlock()
public void addBlocks(int num)
public void completedBlock(boolean dontNotify, ClientContext context)
public void failedBlock(boolean dontNotify, ClientContext context)
public void failedBlock(ClientContext context)
public void fatallyFailedBlock(ClientContext context)
public void addMustSucceedBlocks(int blocks)
public void addRedundantBlocksInsert(int blocks)
public final void notifyClients(ClientContext context)
protected abstract void innerNotifyClients(ClientContext context)
public void toNetwork(ClientContext context)
protected abstract void innerToNetwork(ClientContext context)
protected void clearCountersOnRestart()
public RequestClient getClient()
public void setPriorityClass(short newPriorityClass, ClientContext ctx)
newPriorityClass
- The new priority class for the request or insert.ctx
- The ClientContext, contains essential transient objects such as the schedulers.public boolean realTimeFlag()
public boolean persistent()
public static ClientRequester[] getAll()
public byte[] getClientDetail(ChecksumChecker checker) throws java.io.IOException
checker
- Used to checksum and isolate large components where we can recover if they
fail.java.io.IOException
protected static byte[] getClientDetail(PersistentClientCallback callback, ChecksumChecker checker) throws java.io.IOException
java.io.IOException
public final void onResume(ClientContext context) throws ResumeFailedException
ResumeFailedException
protected void innerOnResume(ClientContext context) throws ResumeFailedException
ResumeFailedException
protected abstract ClientBaseCallback getCallback()
public void onShutdown(ClientContext context)
public boolean isCurrentState(ClientGetState state)
public ClientRequestSchedulerGroup getSchedulerGroup()