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, versionPACKET_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, toSingletonArraycouldBeJSON, couldBeJSON, couldBeJSON, couldBeJSONArray, couldBeJSONObject, getPacketType, putPacketType, putPacketTypeclone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetSummarypublic 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.JSONExceptionpublic RequestPacket(net.minidev.json.JSONObject json)
              throws org.json.JSONException
org.json.JSONExceptionpublic RequestPacket(byte[] bytes)
              throws java.io.UnsupportedEncodingException,
                     java.net.UnknownHostException
java.io.UnsupportedEncodingExceptionjava.net.UnknownHostExceptionpublic RequestPacket(java.nio.ByteBuffer bbuf)
              throws java.io.UnsupportedEncodingException,
                     java.net.UnknownHostException
java.io.UnsupportedEncodingExceptionjava.net.UnknownHostExceptionpublic 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.JSONExceptionpublic 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 PaxosPacketorg.json.JSONExceptionpublic net.minidev.json.JSONObject toJSONSmartImpl()
                                            throws org.json.JSONException
toJSONSmartImpl in class PaxosPacketorg.json.JSONExceptionpublic byte[] toBytesInstrument()
public byte[] toBytes()
RequestAppRequestParser.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 RequesttoString in class PaxosPacketpublic java.net.InetSocketAddress getClientAddress()
getClientAddress in interface ClientRequestAbstractReplicaCoordinator 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 Requestpublic java.lang.String getServiceName()
getServiceName in interface Requestprotected java.lang.String getSummaryString()
getSummaryString in class PaxosPacketpublic 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 ClientRequestAbstractReplicaCoordinator, 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()
RequestIdentifierPaxosConfig.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 RequestIdentifierpublic 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()
SummarizablegetSummary in interface RequestgetSummary in interface SummarizablegetSummary in class PaxosPacketprotected byte[] getByteifiedSelf()
protected void setByteifiedSelf(byte[] bytes)
public boolean equals(java.lang.Object obj)
equals in class java.lang.Objectpublic static void doubleCheckFields()
public static void main(java.lang.String[] args)
                 throws java.io.UnsupportedEncodingException,
                        java.net.UnknownHostException
java.io.UnsupportedEncodingExceptionjava.net.UnknownHostException