public class AppRequest extends JSONPacket implements ReconfigurableRequest, ReplicableRequest, ClientRequest
A class like this is necessary if the app wants to use its own packet
types to send requests and responses (as opposed to just using
RequestPacket
. The main requirements of application requests
is that they must implement at least InterfaceRequest, and must
implement InterfaceReplicable, InterfaceReconfigurable, and
InterfceClientRequest in order to respectively support replication,
reconfiguration, and the ability to delegate client response
messaging to gigapaxos.
Modifier and Type | Class and Description |
---|---|
static class |
AppRequest.Keys
These app keys by design need not be the same as those in
BasicReconfigurationPacket
|
static class |
AppRequest.PacketType
Packet type class for NoopApp requests.
|
static class |
AppRequest.ResponseCodes |
PACKET_TYPE, type
STOP
Constructor and Description |
---|
AppRequest(org.json.JSONObject json) |
AppRequest(java.lang.String value,
AppRequest req) |
AppRequest(java.lang.String name,
int epoch,
long id,
java.lang.String value,
IntegerPacketType type,
boolean stop) |
AppRequest(java.lang.String name,
long id,
java.lang.String value,
IntegerPacketType type,
boolean stop) |
AppRequest(java.lang.String name,
java.lang.String value,
IntegerPacketType type,
boolean stop) |
Modifier and Type | Method and Description |
---|---|
java.net.InetSocketAddress |
getClientAddress() |
int |
getEpochNumber() |
static AppRequest |
getObliviousPaxosStopRequest(java.lang.String name,
int epoch)
Deprecated.
|
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.net.InetSocketAddress |
getSenderAddress() |
java.lang.String |
getServiceName() |
java.lang.String |
getValue() |
boolean |
isStop() |
static void |
main(java.lang.String[] args) |
boolean |
needsCoordination() |
AppRequest |
setEpoch(int epoch) |
void |
setNeedsCoordination(boolean b)
After this method returns,
ReplicableRequest.needsCoordination() should
subsequently return b . |
void |
setResponse(java.lang.String response) |
org.json.JSONObject |
toJSONObjectImpl() |
couldBeJSON, couldBeJSON, couldBeJSON, couldBeJSONArray, couldBeJSONObject, getPacketType, putPacketType, putPacketType, toJSONObject, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getSummary
getSummary
public AppRequest(java.lang.String name, java.lang.String value, IntegerPacketType type, boolean stop)
name
- value
- type
- stop
- public AppRequest(java.lang.String name, int epoch, long id, java.lang.String value, IntegerPacketType type, boolean stop)
name
- epoch
- id
- value
- type
- stop
- public AppRequest(java.lang.String name, long id, java.lang.String value, IntegerPacketType type, boolean stop)
name
- id
- value
- type
- stop
- public AppRequest(java.lang.String value, AppRequest req)
value
- req
- public AppRequest(org.json.JSONObject json) throws org.json.JSONException
json
- org.json.JSONException
public IntegerPacketType getRequestType()
getRequestType
in interface Request
public java.lang.String getServiceName()
getServiceName
in interface Request
public java.lang.String getValue()
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 org.json.JSONObject toJSONObjectImpl() throws org.json.JSONException
toJSONObjectImpl
in class JSONPacket
org.json.JSONException
public java.net.InetSocketAddress getSenderAddress()
public int getEpochNumber()
getEpochNumber
in interface ReconfigurableRequest
public boolean isStop()
isStop
in interface ReconfigurableRequest
public boolean needsCoordination()
needsCoordination
in interface ReplicableRequest
public void setNeedsCoordination(boolean b)
ReplicableRequest
ReplicableRequest.needsCoordination()
should
subsequently return b
. This method is invoked by
AbstractReplicaCoordinator
with a false
argument just
before coordinating the request so that coordinated packets are not
coordinated again infinitely. For example, if a replica coordinator's
coordination strategy is to simply flood the request to all replicas,
there needs to be a way for a recipient of a copy of this already once
coordinated request to know that it should not coordinate it again. This
method provides AbstractReplicaCoordinator
a placeholder in the
application request to prevent such infinite coordination loops.
This method is now deprecated and does not need to be overridden by implementing classes. It's original purpose was really only to be able to easily do lazy propagation replica coordination without introducing an additional type (just to distinguish between the original request at the entry replica and the replicated request so as to avoid an infinite propagation loop), but introducing an additional type is the clean way to do this. Paxos for example already has its own types, so it doesn't need this method.
setNeedsCoordination
in interface ReplicableRequest
b
- True if subsequent invocations of ReplicableRequest.needsCoordination()
must return true, false otherwise.public java.net.InetSocketAddress getClientAddress()
getClientAddress
in interface ClientRequest
AbstractReplicaCoordinator
already knows the sending client's
address anyway.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)
response
- @Deprecated public static AppRequest getObliviousPaxosStopRequest(java.lang.String name, int epoch)
Application.execute(Request)
. It is generally not a good
idea to use an oblivious stop request as the app won't know that the
current epoch has been stopped and will not be in a position to do any
garbage collection if needed right away.
This method is deprecated. gigapaxos currently generates its own oblivous
stop request and subsequently invokes
Replicable.restore(String, String)
with a null state argument to
indicate to the app that the current epoch is over. For coordination
protocols other than paxos,
Reconfigurable.getStopRequest(String, int)
suffices.name
- epoch
- public AppRequest setEpoch(int epoch)
epoch
- public static void main(java.lang.String[] args)
args
-