public class ReplicableClientRequest extends JSONPacket implements ReplicableRequest, ClientRequest, ReconfigurableRequest, Byteable
| Modifier and Type | Field and Description |
|---|---|
java.lang.String |
CHARSET
Default charset used to encode this packet to bytes.
|
static boolean |
DEFAULT_COORDINATION_MODE |
PACKET_TYPE, typeSTOP| Constructor and Description |
|---|
ReplicableClientRequest(byte[] buf,
AppRequestParser parser) |
ReplicableClientRequest(byte[] buf,
NIOHeader header,
AppRequestParserBytes parser) |
ReplicableClientRequest(org.json.JSONObject json,
Stringifiable<?> unstringer) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(java.lang.Object o) |
java.net.InetSocketAddress |
getClientAddress() |
int |
getEpochNumber() |
Request |
getRequest() |
Request |
getRequest(AppRequestParser parser) |
Request |
getRequest(AppRequestParserBytes parser,
NIOHeader header) |
java.lang.String |
getRequestAsString() |
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. |
IntegerPacketType |
getRequestType() |
ClientRequest |
getResponse() |
java.lang.String |
getServiceName() |
boolean |
isStop() |
boolean |
needsCoordination() |
ReplicableClientRequest |
setClientAddress(java.net.InetSocketAddress csa) |
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 org.json.JSONObject |
toJSONObjectImpl() |
java.lang.String |
toString()
Note: This method returns the stringified form of the underlying request.
|
static ReplicableClientRequest |
wrap(Request request) |
static ReplicableClientRequest |
wrap(Request request,
boolean coord) |
static ReplicableClientRequest |
wrap(Request request,
long requestID) |
couldBeJSON, couldBeJSON, couldBeJSON, couldBeJSONArray, couldBeJSONObject, getPacketType, putPacketType, putPacketType, toJSONObjectclone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitsetNeedsCoordinationgetSummarygetSummarypublic static final boolean DEFAULT_COORDINATION_MODE
public final java.lang.String CHARSET
public ReplicableClientRequest(byte[] buf,
NIOHeader header,
AppRequestParserBytes parser)
buf - header - parser - public ReplicableClientRequest(byte[] buf,
AppRequestParser parser)
buf - parser - public ReplicableClientRequest(org.json.JSONObject json,
Stringifiable<?> unstringer)
throws org.json.JSONException,
java.io.UnsupportedEncodingException
json - unstringer - org.json.JSONExceptionjava.io.UnsupportedEncodingExceptionpublic static ReplicableClientRequest wrap(Request request)
request - public static ReplicableClientRequest wrap(Request request, long requestID)
request - requestID - public static ReplicableClientRequest wrap(Request request, boolean coord)
request - coord - If true, the request will be coordinated, else it will not be
coordinated. If the coord flag is specified, it
determines the coordination mode even if the underlying
request is a ReplicableRequest and its
ReplicableRequest.needsCoordination() method returns a
conflicting value.public Request getRequest(AppRequestParser parser) throws java.io.UnsupportedEncodingException, RequestParseException
parser - java.io.UnsupportedEncodingExceptionRequestParseExceptionpublic Request getRequest()
public Request getRequest(AppRequestParserBytes parser, NIOHeader header) throws java.io.UnsupportedEncodingException, RequestParseException
parser - header - java.io.UnsupportedEncodingExceptionRequestParseExceptionpublic IntegerPacketType getRequestType()
getRequestType in interface Requestpublic java.lang.String getServiceName()
getServiceName in interface Requestpublic 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 int getEpochNumber()
getEpochNumber in interface ReconfigurableRequestpublic boolean isStop()
isStop in interface ReconfigurableRequestpublic 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 boolean needsCoordination()
needsCoordination in interface ReplicableRequestprotected org.json.JSONObject toJSONObjectImpl()
throws org.json.JSONException
toJSONObjectImpl in class JSONPacketorg.json.JSONExceptionpublic byte[] toBytes()
RequestAppRequestParser.getRequest(byte[], edu.umass.cs.nio.nioutils.NIOHeader)
, i.e., invoking getRequest(request.toBytes(), header).equals(request).public ReplicableClientRequest setClientAddress(java.net.InetSocketAddress csa)
csa - thispublic java.net.InetSocketAddress getClientAddress()
getClientAddress in interface ClientRequestAbstractReplicaCoordinator already knows the sending client's
address anyway.public java.lang.String getRequestAsString()
public java.lang.String toString()
ReplicableClientRequest, use
JSONPacket.toJSONObject().toString().toString in interface RequesttoString in class JSONPacketpublic boolean equals(java.lang.Object o)
equals in class java.lang.Object