public class ClientRequestScheduler extends java.lang.Object implements RequestScheduler
Modifier and Type | Field and Description |
---|---|
ClientContext |
clientContext |
java.lang.String |
name |
static java.lang.String |
PRIORITY_HARD |
static java.lang.String |
PRIORITY_NONE |
static java.lang.String |
PRIORITY_SOFT |
COOLDOWN_PERIOD, COOLDOWN_RETRIES
Constructor and Description |
---|
ClientRequestScheduler(boolean forInserts,
boolean forSSKs,
boolean forRT,
RandomSource random,
RequestStarter starter,
Node node,
NodeClientCore core,
java.lang.String name,
ClientContext context) |
Modifier and Type | Method and Description |
---|---|
boolean |
addRunningInsert(SendableInsert insert,
SendableRequestItemKey token) |
boolean |
addToFetching(Key key) |
void |
callFailure(SendableGet get,
LowLevelGetException e,
int prio,
boolean persistent) |
void |
callFailure(SendableInsert insert,
LowLevelPutException e,
int prio,
boolean persistent) |
long |
countPersistentWaitingKeys() |
long |
countQueuedRequests() |
void |
dequeueOfferedKey(Key key) |
KeysFetchingLocally |
fetchingKeys() |
java.lang.String |
getChoosenPriorityScheduler() |
ClientContext |
getContext() |
KeySalter |
getGlobalKeySalter(boolean persistent) |
ClientRequestSelector |
getSelector() |
ChosenBlock |
grabRequest()
Called by RequestStarter to find a request to run.
|
boolean |
hasFetchingKey(Key key,
BaseSendableGet getterWaiting,
boolean persistent)
Check whether a key is already being fetched.
|
boolean |
isInsertScheduler() |
boolean |
isRunningOrQueuedPersistentRequest(SendableRequest request)
This only works for persistent requests, because transient requests are not
selected on a SendableRequest level, they are selected on a {SendableRequest, token} level.
|
void |
queueOfferedKey(Key key,
boolean realTime)
Queue the offered key
|
void |
register(HasKeyListener hasListener,
SendableGet[] getters,
boolean persistent,
BlockSet blocks,
boolean noCheckStore)
Register a group of requests (not inserts): a GotKeyListener and/or one
or more SendableGet's.
|
void |
registerInsert(SendableRequest req,
boolean persistent) |
void |
removeFetchingKey(Key key) |
void |
removePendingKeys(HasKeyListener getter,
boolean complain)
Remove a KeyListener from the list of KeyListeners.
|
void |
removePendingKeys(KeyListener getter,
boolean complain)
Remove a KeyListener from the list of KeyListeners.
|
void |
removeRunningInsert(SendableInsert insert,
SendableRequestItemKey token) |
void |
removeRunningRequest(SendableRequest request) |
void |
reregisterAll(ClientRequester request,
short oldPrio) |
byte[] |
saltKey(boolean persistent,
Key key) |
void |
setPriorityScheduler(java.lang.String val)
Called by the config.
|
void |
startCore(byte[] globalSaltPersistent) |
void |
succeeded(BaseSendableGet succeeded,
boolean persistent)
Tell the scheduler that a request from a specific RandomGrabArray succeeded.
|
void |
tripPendingKey(KeyBlock block) |
void |
wakeStarter() |
boolean |
wantKey(Key key) |
public final java.lang.String name
public final ClientContext clientContext
public static final java.lang.String PRIORITY_NONE
public static final java.lang.String PRIORITY_SOFT
public static final java.lang.String PRIORITY_HARD
public ClientRequestScheduler(boolean forInserts, boolean forSSKs, boolean forRT, RandomSource random, RequestStarter starter, Node node, NodeClientCore core, java.lang.String name, ClientContext context)
public void startCore(byte[] globalSaltPersistent)
public void setPriorityScheduler(java.lang.String val)
val
- public void registerInsert(SendableRequest req, boolean persistent)
public void register(HasKeyListener hasListener, SendableGet[] getters, boolean persistent, BlockSet blocks, boolean noCheckStore)
hasListener
- Listens for specific keys. Can be null if the listener
is already registered i.e. on retrying.getters
- The actual requests to register to the request sender queue.persistent
- True if the request is persistent.onDatabaseThread
- True if we are running on the database thread.
NOTE: delayedStoreCheck/probablyNotInStore is unnecessary because we only
register the listener once.FetchException
public void removeRunningRequest(SendableRequest request)
removeRunningRequest
in interface RequestScheduler
public boolean isRunningOrQueuedPersistentRequest(SendableRequest request)
RequestScheduler
isRunningOrQueuedPersistentRequest
in interface RequestScheduler
public ChosenBlock grabRequest()
grabRequest
in interface RequestScheduler
public void removePendingKeys(KeyListener getter, boolean complain)
getter
- complain
- public void removePendingKeys(HasKeyListener getter, boolean complain)
getter
- complain
- public void reregisterAll(ClientRequester request, short oldPrio)
public java.lang.String getChoosenPriorityScheduler()
public void succeeded(BaseSendableGet succeeded, boolean persistent)
RequestScheduler
succeeded
in interface RequestScheduler
succeeded
- The request we ran, which must be deleted.public void tripPendingKey(KeyBlock block)
public boolean wantKey(Key key)
wantKey
in interface RequestScheduler
public void queueOfferedKey(Key key, boolean realTime)
public void dequeueOfferedKey(Key key)
public long countQueuedRequests()
countQueuedRequests
in interface RequestScheduler
public KeysFetchingLocally fetchingKeys()
fetchingKeys
in interface RequestScheduler
public void removeFetchingKey(Key key)
removeFetchingKey
in interface RequestScheduler
public void removeRunningInsert(SendableInsert insert, SendableRequestItemKey token)
removeRunningInsert
in interface RequestScheduler
public void callFailure(SendableGet get, LowLevelGetException e, int prio, boolean persistent)
callFailure
in interface RequestScheduler
public void callFailure(SendableInsert insert, LowLevelPutException e, int prio, boolean persistent)
callFailure
in interface RequestScheduler
public ClientContext getContext()
getContext
in interface RequestScheduler
public boolean addToFetching(Key key)
addToFetching
in interface RequestScheduler
public boolean addRunningInsert(SendableInsert insert, SendableRequestItemKey token)
addRunningInsert
in interface RequestScheduler
public boolean hasFetchingKey(Key key, BaseSendableGet getterWaiting, boolean persistent)
RequestScheduler
hasFetchingKey
in interface RequestScheduler
public long countPersistentWaitingKeys()
public boolean isInsertScheduler()
public void wakeStarter()
wakeStarter
in interface RequestScheduler
public byte[] saltKey(boolean persistent, Key key)
public KeySalter getGlobalKeySalter(boolean persistent)
public ClientRequestSelector getSelector()
getSelector
in interface RequestScheduler