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, type
STOP
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, toJSONObject
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
setNeedsCoordination
getSummary
getSummary
public 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.JSONException
java.io.UnsupportedEncodingException
public 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.UnsupportedEncodingException
RequestParseException
public Request getRequest()
public Request getRequest(AppRequestParserBytes parser, NIOHeader header) throws java.io.UnsupportedEncodingException, RequestParseException
parser
- header
- java.io.UnsupportedEncodingException
RequestParseException
public IntegerPacketType getRequestType()
getRequestType
in interface Request
public java.lang.String getServiceName()
getServiceName
in interface Request
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 int getEpochNumber()
getEpochNumber
in interface ReconfigurableRequest
public boolean isStop()
isStop
in interface ReconfigurableRequest
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 boolean needsCoordination()
needsCoordination
in interface ReplicableRequest
protected org.json.JSONObject toJSONObjectImpl() throws org.json.JSONException
toJSONObjectImpl
in class JSONPacket
org.json.JSONException
public byte[] toBytes()
Request
AppRequestParser.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
- this
public java.net.InetSocketAddress getClientAddress()
getClientAddress
in interface ClientRequest
AbstractReplicaCoordinator
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 Request
toString
in class JSONPacket
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object