public class ScheduledRequest<M> extends java.lang.Object implements Request<M>
Request
and the corresponding Set of
AggregateSubscriptionItem
s making up
that Request
that a driver implementation has optimized.
ScheduledRequests are what make up the bulk of the "subscription" logic for a driver; that is,
repeated and
perpetually self-scheduling read Request
s.
Equality and hash code are based on the Set of AggregateSubscriptionItem
s and the rate.Constructor and Description |
---|
ScheduledRequest(Request<M> request,
RequestCycle<M> requestCycle,
int rate,
java.util.List<AggregateSubscriptionItem> items,
long idealSendTime,
com.codahale.metrics.Timer timer) |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object obj) |
void |
fail(FailureType type,
DriverState state,
java.lang.Exception ex)
Called if the response to the most recently created message is not going to be received.
|
long |
getIdealSendTime() |
java.util.List<AggregateSubscriptionItem> |
getItems() |
java.lang.Object |
getKey() |
long |
getLastPost() |
long |
getLastReceive() |
long |
getLastSend() |
RequestPriority |
getPriority()
Returns the
RequestPriority of this request. |
int |
getRate() |
int |
getTimeout()
Returns the amount of time (in milliseconds) that this request should be given to run, before it is failed out
for a timeout.
|
int |
hashCode() |
boolean |
isCanceled() |
boolean |
isRetryAllowed() |
ReceiveAction |
receiveMessage(M message,
java.lang.Object key)
Called when a response message is received for this Request.
|
boolean |
sendMessage()
Creates and puts the
Request s message "on the wire". |
void |
setCanceled(boolean canceled) |
java.lang.String |
toString() |
public ScheduledRequest(Request<M> request, RequestCycle<M> requestCycle, int rate, java.util.List<AggregateSubscriptionItem> items, long idealSendTime, com.codahale.metrics.Timer timer)
public boolean sendMessage()
Request
Request
s message "on the wire". Each call should send a unique message
(different transaction ID, if applicable), in case the request is re-used.sendMessage
in interface Request<M>
public java.lang.Object getKey()
public ReceiveAction receiveMessage(M message, java.lang.Object key)
Request
ReadItem
s or WriteItem
s that it contains (if applicable).
If you are extending from AbstractSocketDriver
you must do this work on the thread this call arrived on
or risk the byte[] message being returned its pool and reused in the middle of processing it.receiveMessage
in interface Request<M>
message
- The message that was received for this Request.key
- The key used to retrieve this Request.ReceiveAction
that indicates what the driver should do with this request.public void fail(FailureType type, DriverState state, java.lang.Exception ex)
Request
public int getTimeout()
Request
getTimeout
in interface Request<M>
public final boolean isRetryAllowed()
isRetryAllowed
in interface Request<M>
true
if retrying is allowed if Request.sendMessage()
returns false
.public RequestPriority getPriority()
Request
RequestPriority
of this request.getPriority
in interface Request<M>
RequestPriority
of this request.public boolean isCanceled()
public void setCanceled(boolean canceled)
public java.util.List<AggregateSubscriptionItem> getItems()
public int getRate()
public long getIdealSendTime()
public long getLastSend()
public long getLastPost()
public long getLastReceive()
public final int hashCode()
hashCode
in class java.lang.Object
public final boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object