public abstract class BaseSingleFileFetcher extends SendableGet implements HasKeyListener
Modifier and Type | Field and Description |
---|---|
protected boolean |
cancelled |
long |
cooldownWakeupTime |
protected FetchContext |
ctx |
protected boolean |
deleteFetchContext |
protected boolean |
finished |
protected ClientKey |
key |
parent
parentGrabArray, persistent, realTimeFlag
Modifier | Constructor and Description |
---|---|
protected |
BaseSingleFileFetcher(ClientKey key,
int maxRetries,
FetchContext ctx,
ClientRequester parent,
boolean deleteFetchContext,
boolean realTimeFlag) |
Modifier and Type | Method and Description |
---|---|
void |
cancel(ClientContext context) |
SendableRequestItem |
chooseKey(KeysFetchingLocally fetching,
ClientContext context)
Choose a key to fetch.
|
long |
countAllKeys(ClientContext context)
All key identifiers.
|
long |
countSendableKeys(ClientContext context)
All key identifiers currently eligible to be sent.
|
RequestClient |
getClient()
Get client context object.
|
ClientRequester |
getClientRequest()
Get the ClientRequest.
|
FetchContext |
getContext()
Get the fetch context (settings) object.
|
long |
getCooldownWakeup(SendableRequestItem token,
ClientContext context)
Get the time at which the key specified by the given token will wake up from the
cooldown queue.
|
ClientKey |
getKey(SendableRequestItem token)
Get a numbered key to fetch.
|
short |
getPriorityClass()
Get the priority class of the request.
|
SendableGet |
getRequest(Key key) |
long |
getWakeupTime(ClientContext context,
long now)
Unless this is a RandomGrabArrayItem, this will return the wakeup time for the subtree
rooted at this node.
|
boolean |
isCancelled()
If true, the request has been cancelled, or has completed, either way it need not
be registered any more.
|
boolean |
isEmpty() |
boolean |
isSSK()
Is this an SSK? For purposes of determining which scheduler to use.
|
Key[] |
listKeys()
What keys are we interested in? For purposes of checking the datastore.
|
KeyListener |
makeKeyListener(ClientContext context,
boolean onStartup)
Create a KeyListener, a transient object used to determine which keys we
want, and to handle any blocks found.
|
protected abstract void |
notFoundInStore(ClientContext context) |
protected abstract void |
onBlockDecodeError(SendableRequestItem token,
ClientContext context) |
void |
onChangedFetchContext(ClientContext context)
Reread the cached cooldown values (and anything else) from the FetchContext
after it changes.
|
protected void |
onEnterFiniteCooldown(ClientContext context) |
void |
onGotKey(Key key,
KeyBlock block,
ClientContext context) |
void |
onResume(ClientContext context) |
abstract void |
onSuccess(ClientKeyBlock block,
boolean fromStore,
java.lang.Object token,
ClientContext context)
Called when/if the low-level request succeeds.
|
void |
onSuccess(KeyBlock lowLevelBlock,
boolean fromStore,
SendableRequestItem token,
ClientContext context) |
boolean |
preRegister(ClientContext context,
boolean toNetwork)
Called after checking the datastore and before registering the request to be
sent.
|
void |
reschedule(ClientContext context) |
protected boolean |
retry(ClientContext context)
Try again - returns true if we can retry
|
void |
schedule(ClientContext context) |
void |
unregister(ClientContext context,
short oldPrio)
Unregister the request.
|
void |
unregisterAll(ClientContext context)
Remove the pendingKeys item and then remove from the queue as well.
|
clearWakeupTime, getClientGetState, getNodeKey, getScheduler, getSender, internalError, isInsert, onFailure, reduceWakeupTime, translateException
getParentGrabArray, getSchedulerGroup, hashCode, knowsParentGrabArray, objectToString, persistent, realTimeFlag, setParentGrabArray
protected final ClientKey key
protected boolean cancelled
protected boolean finished
protected final FetchContext ctx
protected boolean deleteFetchContext
public transient long cooldownWakeupTime
protected BaseSingleFileFetcher(ClientKey key, int maxRetries, FetchContext ctx, ClientRequester parent, boolean deleteFetchContext, boolean realTimeFlag)
public long countAllKeys(ClientContext context)
SendableRequest
countAllKeys
in class SendableRequest
public long countSendableKeys(ClientContext context)
SendableRequest
countSendableKeys
in class SendableRequest
public SendableRequestItem chooseKey(KeysFetchingLocally fetching, ClientContext context)
SendableRequest
chooseKey
in class SendableRequest
public ClientKey getKey(SendableRequestItem token)
SendableGet
getKey
in class SendableGet
public FetchContext getContext()
SendableGet
getContext
in class SendableGet
public boolean isSSK()
SendableRequest
isSSK
in class SendableRequest
protected boolean retry(ClientContext context)
protected void onEnterFiniteCooldown(ClientContext context)
public ClientRequester getClientRequest()
SendableRequest
getClientRequest
in class SendableRequest
public short getPriorityClass()
SendableRequest
getPriorityClass
in class SendableRequest
public void cancel(ClientContext context)
public void unregisterAll(ClientContext context)
public void unregister(ClientContext context, short oldPrio)
SendableRequest
unregister
in class SendableGet
oldPrio
- If we are changing priorities it can matter what the old priority is.
However the parent method, SendableRequest, ignores this. In any case,
(short)-1 means not specified (look it up).public boolean isCancelled()
SendableRequest
isCancelled
in interface HasKeyListener
isCancelled
in class SendableRequest
public boolean isEmpty()
public RequestClient getClient()
SendableRequest
getClient
in class SendableRequest
public void onGotKey(Key key, KeyBlock block, ClientContext context)
public void onSuccess(KeyBlock lowLevelBlock, boolean fromStore, SendableRequestItem token, ClientContext context)
protected abstract void onBlockDecodeError(SendableRequestItem token, ClientContext context)
public abstract void onSuccess(ClientKeyBlock block, boolean fromStore, java.lang.Object token, ClientContext context)
public long getCooldownWakeup(SendableRequestItem token, ClientContext context)
SendableGet
getCooldownWakeup
in class SendableGet
public void schedule(ClientContext context)
public void reschedule(ClientContext context)
public SendableGet getRequest(Key key)
public Key[] listKeys()
SendableGet
listKeys
in class SendableGet
public KeyListener makeKeyListener(ClientContext context, boolean onStartup)
HasKeyListener
makeKeyListener
in interface HasKeyListener
protected abstract void notFoundInStore(ClientContext context)
public boolean preRegister(ClientContext context, boolean toNetwork)
BaseSendableGet
preRegister
in class BaseSendableGet
toNetwork
- If true, we are actually going to send requests (unless we
cancel in this callback). If false, we completed all the work assigned.public long getWakeupTime(ClientContext context, long now)
RequestSelectionTreeNode
getWakeupTime
in interface RequestSelectionTreeNode
getWakeupTime
in interface RandomGrabArrayItem
public void onChangedFetchContext(ClientContext context)
context
- The context object.public void onResume(ClientContext context)