NodeIDType
- This class is the reconfigurator "application", essentially a
database. It is Replicable
and Reconfigurable
and
ReconfiguratorDB
. SQLReconfiguratorDB
is an
example of a class concretizing this class.
It is actually not important for this database to be persistent
for safety reasons when paxos provides fault recovery, but we use
the disk because all records may not fit in memory. In fact,
SQLReconfiguratorDB
currently uses DiskMap
as the
default option that asynchronously swaps to disk in the
background.
This class relies on reflection to automatically map incoming
reconfiguration packets to their respective handlers, but it only
expects to process two types of packets RCRecordRequest
and StopEpoch
.public abstract class AbstractReconfiguratorDB<NodeIDType> extends java.lang.Object implements Repliconfigurable, ReconfiguratorDB<NodeIDType>
Modifier and Type | Class and Description |
---|---|
static class |
AbstractReconfiguratorDB.RecordNames
Constant RC record name keys.
|
Modifier and Type | Field and Description |
---|---|
protected ConsistentReconfigurableNodeConfig<NodeIDType> |
consistentNodeConfig |
protected NodeIDType |
myID |
protected boolean |
recovering |
protected static boolean |
TWO_PAXOS_RC |
Constructor and Description |
---|
AbstractReconfiguratorDB(NodeIDType myID,
ConsistentReconfigurableNodeConfig<NodeIDType> nc) |
Modifier and Type | Method and Description |
---|---|
protected java.lang.String |
areRCChangesCompleteDebug() |
protected static java.lang.Object |
autoInvokeMethod(java.lang.Object target,
BasicReconfigurationPacket<?> rcPacket,
boolean recovery,
Stringifiable<?> unstringer) |
boolean |
deleteFinalState(java.lang.String name,
int epoch)
Garbage-collects the final state for name, epoch.
|
boolean |
execute(Request request) |
boolean |
execute(Request request,
boolean doNotReplyToClient)
Paxos related methods below
|
java.lang.Integer |
getEpoch(java.lang.String name)
Returns the current (unique) epoch for name.
|
java.lang.String |
getFinalState(java.lang.String name,
int epoch)
Return the final checkpointed state for name, epoch.
|
protected java.util.Set<java.lang.String> |
getMergeList(java.lang.String newRCGroupName) |
protected java.util.HashMap<java.lang.String,java.util.Set<java.lang.String>> |
getMergeLists() |
protected ConsistentHashing<NodeIDType> |
getNewConsistentHashRing() |
protected java.util.Map<java.lang.String,java.util.Set<NodeIDType>> |
getNewRCGroups() |
protected static Request |
getNoopRequest(java.lang.String stringified) |
protected ConsistentHashing<NodeIDType> |
getOldConsistentHashRing() |
protected java.util.Map<java.lang.String,java.util.Set<NodeIDType>> |
getOldRCGroups() |
protected java.lang.String |
getRCGroupName(NodeIDType node) |
protected java.lang.String |
getRCGroupName(java.lang.String name) |
protected java.util.Map<java.lang.String,java.util.Set<NodeIDType>> |
getRCGroups(NodeIDType rc,
java.util.Set<NodeIDType> allRCs) |
protected java.util.Map<java.lang.String,java.util.Set<NodeIDType>> |
getRCGroups(NodeIDType rc,
java.util.Set<NodeIDType> allRCs,
boolean print) |
ReconfigurationRecord<NodeIDType> |
getReconfigurationRecord(java.lang.String name,
int epoch) |
Request |
getRequest(java.lang.String stringified)
An application must support string-to-
Request conversion and
back. |
java.util.Set<IntegerPacketType> |
getRequestTypes() |
ReconfigurableRequest |
getStopRequest(java.lang.String name,
int epoch)
Returns a stop request that when executed by the app ensures that no
subsequent request after the stop is executed in that epoch.
|
boolean |
handleDemandReport(DemandReport<NodeIDType> report,
boolean recovery) |
boolean |
handleRCRecordRequest(RCRecordRequest<NodeIDType> rcRecReq,
boolean recovery)
If a reconfiguration intent is being registered, a protocol task must be
started that ensures that the reconfiguration completes successfully.
|
protected boolean |
handleRequestActiveReplicas(RequestActiveReplicas requestActives,
boolean recovery) |
boolean |
handleStopEpoch(StopEpoch<NodeIDType> stopEpoch,
boolean recovery) |
protected boolean |
isAffected(NodeIDType rcNode,
NodeIDType addOrDelNode) |
protected boolean |
isRCGroupName(java.lang.String name) |
void |
putInitialState(java.lang.String name,
int epoch,
java.lang.String state)
Inserts the specified state as the initial state for name, epoch.
|
void |
setCallback(ReconfiguratorCallback callback) |
protected java.util.Set<NodeIDType> |
setRCEpochs(java.util.Set<NodeIDType> addNodes,
java.util.Set<NodeIDType> deleteNodes) |
java.lang.String |
toString() |
protected boolean |
updateActiveDBNodeConfig(int version) |
protected boolean |
updateDBNodeConfig(int version) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
checkpoint, restore
getMutualAuthRequestTypes, getRequest, getServerAuthRequestTypes
addActiveReplica, addReconfigurator, clearMerged, close, closeReadActiveRecords, createReconfigurationRecord, createReconfigurationRecords, delayedDeleteComplete, deleteReconfigurationRecord, fetchAndAggregateMergeeStates, garbageCollectedDeletedNode, garbageCollectOldReconfigurators, getDemandStats, getPendingReconfigurations, getRCGroupNames, getRCGroups, getReconfigurationRecord, initiateReadActiveRecords, markDeleteReconfigurationRecord, mergeIntent, mergeState, readNextActiveRecord, removePending, setRCEpochs, setState, setStateInitReconfiguration, setStateInitReconfiguration, setStateMerge, setStateMerge, updateDemandStats
protected final NodeIDType myID
protected final ConsistentReconfigurableNodeConfig<NodeIDType> consistentNodeConfig
protected boolean recovering
protected static final boolean TWO_PAXOS_RC
public AbstractReconfiguratorDB(NodeIDType myID, ConsistentReconfigurableNodeConfig<NodeIDType> nc)
myID
- nc
- public ReconfigurationRecord<NodeIDType> getReconfigurationRecord(java.lang.String name, int epoch)
name
- epoch
- name:epoch
.public boolean execute(Request request, boolean doNotReplyToClient)
execute
in interface Replicable
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.
protected static final java.lang.Object autoInvokeMethod(java.lang.Object target, BasicReconfigurationPacket<?> rcPacket, boolean recovery, Stringifiable<?> unstringer)
public boolean handleDemandReport(DemandReport<NodeIDType> report, boolean recovery)
report
- public void setCallback(ReconfiguratorCallback callback)
setCallback
in interface ReconfiguratorDB<NodeIDType>
public boolean handleRCRecordRequest(RCRecordRequest<NodeIDType> rcRecReq, boolean recovery)
rcRecReq
- recovery
- public java.lang.String toString()
toString
in class java.lang.Object
public boolean execute(Request request)
execute
in interface Application
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
protected static final Request getNoopRequest(java.lang.String stringified)
public java.util.Set<IntegerPacketType> getRequestTypes()
getRequestTypes
in interface AppRequestParser
public ReconfigurableRequest getStopRequest(java.lang.String name, int epoch)
Reconfigurable
getStopRequest
in interface Reconfigurable
name:epoch
.public java.lang.Integer getEpoch(java.lang.String name)
Reconfigurable
getEpoch
in interface Reconfigurable
name
- public java.lang.String getFinalState(java.lang.String name, int epoch)
Reconfigurable
getFinalState
in interface Reconfigurable
public void putInitialState(java.lang.String name, int epoch, java.lang.String state)
Reconfigurable
putInitialState
in interface Reconfigurable
public boolean deleteFinalState(java.lang.String name, int epoch)
Reconfigurable
deleteFinalState
in interface Reconfigurable
name:epoch
was deleted or did not
exist to begin with.protected java.lang.String areRCChangesCompleteDebug()
protected java.util.Map<java.lang.String,java.util.Set<NodeIDType>> getNewRCGroups()
protected java.util.Map<java.lang.String,java.util.Set<NodeIDType>> getOldRCGroups()
protected java.util.Set<java.lang.String> getMergeList(java.lang.String newRCGroupName)
protected java.util.HashMap<java.lang.String,java.util.Set<java.lang.String>> getMergeLists()
protected java.util.Map<java.lang.String,java.util.Set<NodeIDType>> getRCGroups(NodeIDType rc, java.util.Set<NodeIDType> allRCs, boolean print)
protected java.util.Map<java.lang.String,java.util.Set<NodeIDType>> getRCGroups(NodeIDType rc, java.util.Set<NodeIDType> allRCs)
public boolean handleStopEpoch(StopEpoch<NodeIDType> stopEpoch, boolean recovery)
stopEpoch
- recovery
- stopEpoch
was handled successfully.protected boolean handleRequestActiveReplicas(RequestActiveReplicas requestActives, boolean recovery)
requestActives
- recovery
- protected java.lang.String getRCGroupName(NodeIDType node)
protected java.lang.String getRCGroupName(java.lang.String name)
protected boolean isRCGroupName(java.lang.String name)
protected boolean updateDBNodeConfig(int version)
protected boolean updateActiveDBNodeConfig(int version)
protected java.util.Set<NodeIDType> setRCEpochs(java.util.Set<NodeIDType> addNodes, java.util.Set<NodeIDType> deleteNodes)
protected boolean isAffected(NodeIDType rcNode, NodeIDType addOrDelNode)
protected ConsistentHashing<NodeIDType> getOldConsistentHashRing()
protected ConsistentHashing<NodeIDType> getNewConsistentHashRing()