public class RequestPacket extends PaxosPacket implements Request, ClientRequest, Byteable
Modifier and Type | Class and Description |
---|---|
static class |
RequestPacket.Keys
These JSON keys are rather specific to RequestPacket or for debugging, so
they are here as opposed to PaxosPacket.
|
static class |
RequestPacket.ResponseCodes |
PaxosPacket.NodeIDKeys, PaxosPacket.PaxosPacketType
Modifier and Type | Field and Description |
---|---|
protected byte[] |
digest |
static java.lang.String |
NO_OP |
protected static java.net.InetSocketAddress |
NULL_SOCKADDR
We use this address instead of a null client socket address or listen address
so that a null address doesn't get overwritten by a bad legitimate address
when a request is forwarded across servers.
|
long |
requestID
A unique requestID for each request.
|
java.lang.String |
requestValue
The actual request body.
|
static int |
SIZE_ESTIMATE
We need this estimate to use it in
RequestBatcher.dequeueImpl() . |
protected static int |
SIZEOF_REQUEST_FIXED |
boolean |
stop
Whether this request is a stop request.
|
BYTEIFICATION, CHARSET, packetType, paxosID, SIZEOF_PAXOSPACKET_FIXED, version
PACKET_TYPE, type
Constructor and Description |
---|
RequestPacket(byte[] bytes) |
RequestPacket(java.nio.ByteBuffer bbuf) |
RequestPacket(org.json.JSONObject json) |
RequestPacket(net.minidev.json.JSONObject json) |
RequestPacket(long reqID,
java.lang.String value,
boolean stop) |
RequestPacket(long reqID,
java.lang.String value,
boolean stop,
java.net.InetSocketAddress csa) |
RequestPacket(long reqID,
java.lang.String value,
boolean stop,
RequestPacket req) |
RequestPacket(RequestPacket req) |
RequestPacket(java.lang.String value,
boolean stop) |
RequestPacket(java.lang.String value,
boolean stop,
java.net.InetSocketAddress csa) |
Modifier and Type | Method and Description |
---|---|
static boolean |
addDebugInfo(org.json.JSONObject msg,
java.lang.String str,
int nodeID) |
RequestPacket |
addDebugInfo(java.lang.String str) |
RequestPacket |
addDebugInfo(java.lang.String str,
int nodeID) |
RequestPacket |
addDebugInfoDeep(java.lang.String str) |
RequestPacket |
addDebugInfoDeep(java.lang.String str,
int nodeID) |
int |
batchSize() |
boolean |
digestEquals(RequestPacket req,
java.security.MessageDigest md) |
static void |
doubleCheckFields() |
boolean |
equals(java.lang.Object obj) |
RequestPacket |
getACK() |
RequestPacket[] |
getBatched() |
protected byte[] |
getByteifiedSelf() |
java.net.InetSocketAddress |
getClientAddress() |
int |
getClientID() |
java.lang.String |
getDebugInfo(boolean get) |
byte[] |
getDigest(java.security.MessageDigest md) |
int |
getEntryReplica() |
RequestPacket[] |
getEntryReplicaRequestsAsBatch(int id) |
long |
getEntryTime() |
protected RequestPacket |
getFirstOnly() |
int |
getForwardCount() |
int |
getForwarderID() |
java.net.InetSocketAddress |
getListenAddress() |
static java.security.MessageDigest |
getMessageDigest() |
RequestPacket |
getNACK() |
static PValuePacket |
getRandomPValue(java.lang.String paxosID,
int version,
int slot,
Ballot ballot) |
long |
getRequestID()
The uniqueness of this identifier across all requests to a replica group
is important for safety when
PaxosConfig.PC.PREVENT_DOUBLE_EXECUTION is
enabled as gigapaxos may otherwise assume that the duplicate request
identifier corresponds to a retransmission and will send back the
response if any corresponding to the first execution. |
RequestPacket[] |
getRequestPackets() |
IntegerPacketType |
getRequestType() |
java.lang.String |
getRequestValue() |
java.lang.String[] |
getRequestValues() |
ClientRequest |
getResponse() |
static PValuePacket |
getSamplePValue() |
java.lang.String |
getServiceName() |
java.lang.String |
getStringifiedSelf() |
java.lang.Object |
getSummary()
Implementations are encouraged to return an inline created new Object()
whose toString() method will return the actual String instead of just
returning the String directly.
|
protected java.lang.String |
getSummaryString() |
boolean |
hasRequestValue() |
boolean |
isBroadcasted() |
boolean |
isMetaValue() |
boolean |
isNoop() |
boolean |
isPingPonging() |
static boolean |
isPingPonging(org.json.JSONObject msg) |
boolean |
isStopRequest() |
RequestPacket |
latchToBatch(RequestPacket[] reqs) |
int |
lengthEstimate() |
static void |
main(java.lang.String[] args) |
RequestPacket |
makeNewRequest() |
RequestPacket |
makeNoop() |
java.lang.String |
printBatched() |
RequestPacket |
setBroadcasted() |
protected void |
setByteifiedSelf(byte[] bytes) |
RequestPacket |
setDigest(byte[] d) |
RequestPacket |
setEntryReplica(int id) |
int |
setEntryReplicaAndReturnCount(int id) |
void |
setEntryTime() |
RequestPacket |
setForwarderID(int id) |
void |
setResponse(java.lang.String response) |
RequestPacket |
setReturnRequestValue() |
RequestPacket |
setStringifiedSelf(java.lang.String s) |
boolean |
shouldBroadcast() |
boolean |
shouldDigest() |
boolean |
shouldReturnRequestValue() |
byte[] |
toBytes()
The implementation of this method is tied to and must be the inverse of
AppRequestParser.getRequest(byte[], edu.umass.cs.nio.nioutils.NIOHeader)
, i.e., invoking getRequest(request.toBytes(), header).equals(request). |
protected byte[] |
toBytes(boolean instrument)
The weird constant above is to try to avoid mistakes in the painful (but
totally worth it) byte'ification method below.
|
byte[] |
toBytesInstrument() |
org.json.JSONObject |
toJSONObjectImpl() |
net.minidev.json.JSONObject |
toJSONSmartImpl() |
java.lang.String |
toString()
Learned the hard way that using org.json to stringify is an order of
magnitude slower with large request values compared to manually inserting
the string like below.
|
getPaxosID, getPaxosIDVersion, getPaxosPacket, getPaxosPacket, getPaxosPacketType, getPaxosPacketType, getSummary, getType, getType, getVersion, isParseable, isRecovery, isRecovery, isStatic, markRecovered, putPaxosID, toBytes, toJSONObject, toJSONSmart, toSingletonArray
couldBeJSON, couldBeJSON, couldBeJSON, couldBeJSONArray, couldBeJSONObject, getPacketType, putPacketType, putPacketType
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getSummary
public static final java.lang.String NO_OP
public final long requestID
public final boolean stop
protected byte[] digest
public final java.lang.String requestValue
protected static final int SIZEOF_REQUEST_FIXED
public static final int SIZE_ESTIMATE
RequestBatcher.dequeueImpl()
.
The value needs to be an upper bound on the sum total of all of the gunk
in PValuePacket other than the requestValue itself, i.e., the size of a
no-op decision.protected static final java.net.InetSocketAddress NULL_SOCKADDR
public RequestPacket(java.lang.String value, boolean stop)
public RequestPacket(long reqID, java.lang.String value, boolean stop)
public RequestPacket(long reqID, java.lang.String value, boolean stop, java.net.InetSocketAddress csa)
public RequestPacket(java.lang.String value, boolean stop, java.net.InetSocketAddress csa)
public RequestPacket(RequestPacket req)
public RequestPacket(long reqID, java.lang.String value, boolean stop, RequestPacket req)
public RequestPacket(org.json.JSONObject json) throws org.json.JSONException
org.json.JSONException
public RequestPacket(net.minidev.json.JSONObject json) throws org.json.JSONException
org.json.JSONException
public RequestPacket(byte[] bytes) throws java.io.UnsupportedEncodingException, java.net.UnknownHostException
java.io.UnsupportedEncodingException
java.net.UnknownHostException
public RequestPacket(java.nio.ByteBuffer bbuf) throws java.io.UnsupportedEncodingException, java.net.UnknownHostException
java.io.UnsupportedEncodingException
java.net.UnknownHostException
public static java.security.MessageDigest getMessageDigest()
public RequestPacket makeNoop()
public RequestPacket makeNewRequest()
public RequestPacket setReturnRequestValue()
public int getClientID()
public boolean isNoop()
public int getForwardCount()
public RequestPacket setEntryReplica(int id)
public void setEntryTime()
public int setEntryReplicaAndReturnCount(int id)
public boolean shouldDigest()
public int getEntryReplica()
public RequestPacket setForwarderID(int id)
public int getForwarderID()
public RequestPacket addDebugInfo(java.lang.String str)
public RequestPacket addDebugInfoDeep(java.lang.String str)
public RequestPacket addDebugInfo(java.lang.String str, int nodeID)
public RequestPacket addDebugInfoDeep(java.lang.String str, int nodeID)
public static boolean addDebugInfo(org.json.JSONObject msg, java.lang.String str, int nodeID) throws org.json.JSONException
org.json.JSONException
public java.lang.String getDebugInfo(boolean get)
public static boolean isPingPonging(org.json.JSONObject msg)
public boolean isPingPonging()
public java.lang.String getStringifiedSelf()
public RequestPacket setStringifiedSelf(java.lang.String s)
public org.json.JSONObject toJSONObjectImpl() throws org.json.JSONException
toJSONObjectImpl
in class PaxosPacket
org.json.JSONException
public net.minidev.json.JSONObject toJSONSmartImpl() throws org.json.JSONException
toJSONSmartImpl
in class PaxosPacket
org.json.JSONException
public byte[] toBytesInstrument()
public byte[] toBytes()
Request
AppRequestParser.getRequest(byte[], edu.umass.cs.nio.nioutils.NIOHeader)
, i.e., invoking getRequest(request.toBytes(), header).equals(request).protected byte[] toBytes(boolean instrument)
RequestPacket
,
AcceptPacket
, BatchedAcceptReply
and
BatchedCommit
.public java.lang.String toString()
toString
in interface Request
toString
in class PaxosPacket
public java.net.InetSocketAddress getClientAddress()
getClientAddress
in interface ClientRequest
AbstractReplicaCoordinator
already knows the sending client's
address anyway.public java.net.InetSocketAddress getListenAddress()
public boolean isStopRequest()
public long getEntryTime()
public RequestPacket latchToBatch(RequestPacket[] reqs)
public boolean isMetaValue()
public RequestPacket[] getBatched()
protected RequestPacket getFirstOnly()
public RequestPacket getACK()
public RequestPacket getNACK()
public java.lang.String getRequestValue()
public java.lang.String[] getRequestValues()
public RequestPacket[] getRequestPackets()
public int batchSize()
public RequestPacket[] getEntryReplicaRequestsAsBatch(int id)
public IntegerPacketType getRequestType()
getRequestType
in interface Request
public java.lang.String getServiceName()
getServiceName
in interface Request
protected java.lang.String getSummaryString()
getSummaryString
in class PaxosPacket
public static PValuePacket getRandomPValue(java.lang.String paxosID, int version, int slot, Ballot ballot)
public static PValuePacket getSamplePValue()
public boolean hasRequestValue()
public int lengthEstimate()
public java.lang.String printBatched()
public ClientRequest getResponse()
getResponse
in interface ClientRequest
AbstractReplicaCoordinator
, e.g.,
PaxosManager
, will invoke this method immediately after
Application.execute(Request)
and, if the returned response
is non-null, will send it back to the client that issued that
request. Applications are expected to internally implement logic
that sets the response at the end of
Application.execute(Request)
as follows:
public boolean Replicable
.execute(Request request)} {
// execute request to obtain response
request.setResponse(response);
}
public void setResponse(java.lang.String response)
public boolean shouldReturnRequestValue()
public long getRequestID()
RequestIdentifier
PaxosConfig.PC.PREVENT_DOUBLE_EXECUTION
is
enabled as gigapaxos may otherwise assume that the duplicate request
identifier corresponds to a retransmission and will send back the
response if any corresponding to the first execution. With
PaxosConfig.PC.PREVENT_DOUBLE_EXECUTION
disabled, the uniqueness is important for liveness as duplicate request
identifiers may result in the client not receiving a response for the
latter request; this is because gigapaxos stores request execution
callbacks indexed by the request identifier, so there must be at most one
outstanding request with a given identifier for a given replica group.getRequestID
in interface RequestIdentifier
public byte[] getDigest(java.security.MessageDigest md)
public boolean digestEquals(RequestPacket req, java.security.MessageDigest md)
public RequestPacket setDigest(byte[] d)
public RequestPacket setBroadcasted()
public boolean shouldBroadcast()
public boolean isBroadcasted()
public java.lang.Object getSummary()
Summarizable
getSummary
in interface Request
getSummary
in interface Summarizable
getSummary
in class PaxosPacket
protected byte[] getByteifiedSelf()
protected void setByteifiedSelf(byte[] bytes)
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public static void doubleCheckFields()
public static void main(java.lang.String[] args) throws java.io.UnsupportedEncodingException, java.net.UnknownHostException
java.io.UnsupportedEncodingException
java.net.UnknownHostException