public class NoopApp extends AbstractReconfigurablePaxosApp<java.lang.String> implements Replicable, Reconfigurable, ClientMessenger, AppRequestParserBytes
Constructor and Description |
---|
NoopApp(java.lang.String[] args)
Constructor used to create app replica via reflection.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
checkpoint(java.lang.String name)
Checkpoints the current application state and returns it.
|
boolean |
execute(Request request) |
boolean |
execute(Request request,
boolean doNotReplyToClient)
This method must handle the request atomically and return true if
successful or throw an exception or return false.
|
java.util.Set<IntegerPacketType> |
getMutualAuthRequestTypes() |
Request |
getRequest(byte[] bytes,
NIOHeader header)
The implementation of this method is tied to and must be the inverse of
Request.toBytes() , , i.e., invoking getRequest(request.toBytes(),
header).equals(request). |
Request |
getRequest(java.lang.String stringified)
An application must support string-to-
Request conversion and
back. |
java.util.Set<IntegerPacketType> |
getRequestTypes() |
boolean |
restore(java.lang.String name,
java.lang.String state)
Resets the current application state for
name to state . |
void |
setClientMessenger(SSLMessenger<?,org.json.JSONObject> msgr)
An interface to supply a messenger to the app so that it can directly
send responses for executed requests back to the app.
|
static java.util.Set<IntegerPacketType> |
staticGetMutualAuthRequestTypes() |
static Request |
staticGetRequest(byte[] bytes,
NIOHeader header) |
static Request |
staticGetRequest(java.lang.String stringified)
We use this method also at the client, so it is static.
|
static java.util.Set<IntegerPacketType> |
staticGetRequestTypes()
We use this method also at the client, so it is static.
|
java.lang.String |
toString() |
deleteFinalState, getEpoch, getFinalState, getStopRequest, putInitialState
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
deleteFinalState, getEpoch, getFinalState, getStopRequest, putInitialState
getServerAuthRequestTypes
public NoopApp(java.lang.String[] args)
args
- public void setClientMessenger(SSLMessenger<?,org.json.JSONObject> msgr)
ClientMessenger
setClientMessenger
in interface ClientMessenger
public boolean execute(Request request, boolean doNotReplyToClient)
Replicable
execute
in interface Replicable
execute
in class AbstractReconfigurablePaxosApp<java.lang.String>
doNotReplyToClient
- If true, the application is expected to not send a response
back to the originating client (say, because this request is
part of a post-crash roll-forward or only the "entry replica"
that received the request from the client is expected to
respond back. If false, the application is expected to either
send a response (if any) back to the client via the
ClientMessenger
interface or delegate response
messaging to paxos via the ClientRequest.getResponse()
interface.request.getServiceName()
) altogether after a limited
number of retries, so the replica group may get stuck unless it
returns true after a limited number of retries. Thus, with paxos
as the replica coordination protocol, returning false is not
really an option as paxos has no way to "roll back" a request
whose global order has already been agreed upon.
With replica coordination protocols other than paxos, the boolean
return value could be used in protocol-specific ways, e.g., a
primary-backup protocol might normally execute a request at just
one replica but relay the request to one or more backups if the
return value of Application.execute(Request)
is false.
public Request getRequest(java.lang.String stringified) throws RequestParseException
AppRequestParser
Request
conversion and
back. Furthermore, the conversion to a string and back must preserve the
return values of all Request
methods, i.e.,
Application.getRequest
(request.toString())).equals(request)
must be true.getRequest
in interface AppRequestParser
Request
corresponding to stringified
.RequestParseException
public static Request staticGetRequest(java.lang.String stringified) throws RequestParseException, org.json.JSONException
stringified
- RequestParseException
org.json.JSONException
public Request getRequest(byte[] bytes, NIOHeader header) throws RequestParseException
AppRequestParser
Request.toBytes()
, , i.e., invoking getRequest(request.toBytes(),
header).equals(request).getRequest
in interface AppRequestParser
getRequest
in interface AppRequestParserBytes
message
.RequestParseException
public static Request staticGetRequest(byte[] bytes, NIOHeader header) throws RequestParseException
bytes
- header
- RequestParseException
public java.util.Set<IntegerPacketType> getRequestTypes()
getRequestTypes
in interface AppRequestParser
public java.util.Set<IntegerPacketType> getMutualAuthRequestTypes()
getMutualAuthRequestTypes
in interface AppRequestParser
public static java.util.Set<IntegerPacketType> staticGetRequestTypes()
public static java.util.Set<IntegerPacketType> staticGetMutualAuthRequestTypes()
public boolean execute(Request request)
execute
in interface Application
public java.lang.String checkpoint(java.lang.String name)
Replicable
checkpoint
in interface Replicable
Note that state
may simply be an app-specific handle,
e.g., a file name, representing the state as opposed to the
actual state. The application is responsible for interpreting the
state returned by Replicable.checkpoint(String)
and that supplied
in Replicable.restore(String, String)
in a consistent manner.
public boolean restore(java.lang.String name, java.lang.String state)
Replicable
name
to state
.
Note that state
may simply be an app-specific handle, e.g., a
file name, representing the state as opposed to the actual state. The
application is responsible for interpreting the state returned by
Replicable.checkpoint(String)
and that supplied in
Replicable.restore(String, String)
in a consistent manner.
restore
in interface Replicable
public java.lang.String toString()
toString
in class java.lang.Object