提交 284cc110 编写于 作者: J Joao Sousa

Re-arranged some code in the Default*Recoverable classes.

上级 6288030a
......@@ -165,6 +165,7 @@ public abstract class DefaultRecoverable implements Recoverable, BatchExecutable
}
private StateLog getLog() {
initLog();
return log;
}
......@@ -253,6 +254,7 @@ public abstract class DefaultRecoverable implements Recoverable, BatchExecutable
stateLock.lock();
if (state.getSerializedState() != null) {
System.out.println("The state is not null. Will install it");
initLog();
log.update(state);
installSnapshot(state.getSerializedState());
}
......@@ -369,10 +371,7 @@ public abstract class DefaultRecoverable implements Recoverable, BatchExecutable
return index;
}
@Override
public void setReplicaContext(ReplicaContext replicaContext) {
this.config = replicaContext.getStaticConfiguration();
this.controller = replicaContext.getSVController();
private void initLog() {
if (log == null) {
checkpointPeriod = config.getCheckpointPeriod();
byte[] state = getSnapshot();
......@@ -392,6 +391,13 @@ public abstract class DefaultRecoverable implements Recoverable, BatchExecutable
log = new StateLog(this.config.getProcessId(), checkpointPeriod, state, computeHash(state));
}
}
}
@Override
public void setReplicaContext(ReplicaContext replicaContext) {
this.config = replicaContext.getStaticConfiguration();
this.controller = replicaContext.getSVController();
initLog();
getStateManager().askCurrentConsensusId();
}
......
......@@ -116,8 +116,7 @@ public abstract class DefaultSingleRecoverable implements Recoverable, SingleExe
}
private StateLog getLog() {
if(log == null)
initLog();
initLog();
return log;
}
......@@ -193,8 +192,7 @@ public abstract class DefaultSingleRecoverable implements Recoverable, SingleExe
System.out.println("(DefaultSingleRecoverable.setState) last CID in state: " + state.getLastCID());
logLock.lock();
if(log == null)
initLog();
initLog();
log.update(state);
logLock.unlock();
......@@ -280,7 +278,7 @@ public abstract class DefaultSingleRecoverable implements Recoverable, SingleExe
return stateManager;
}
protected void initLog() {
private void initLog() {
if(log == null) {
checkpointPeriod = config.getCheckpointPeriod();
byte[] state = getSnapshot();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册