提交 1edd5bc9 编写于 作者: L liquidsnake@sapo.pt

Within this commit, the code that implements the checkpoints is completed....

Within this commit, the code that implements the checkpoints is completed. However, it still needs to be tested.
上级 6193f49f
......@@ -24,7 +24,7 @@ package navigators.smart.statemanagment;
* checkpoint together with all the batches of messages received so far, comprises this replica
* current state
*
* @author João Sousa
* @author Jo�o Sousa
*/
public class StateLog {
......@@ -60,6 +60,7 @@ public class StateLog {
position = 0;
nextEid += k;
execCounter++;
this.state = state;
}
......@@ -125,7 +126,7 @@ public class StateLog {
/**
* Constructs a TransferableState using this log information
* @param eid Execution ID correspondent to desired state
* @return
* @return TransferableState Object containing this log information
*/
public TransferableState getTransferableState(int eid) {
......@@ -142,4 +143,20 @@ public class StateLog {
else return null;
}
/**
* Updates this log, according to the information contained in the TransferableState object
* @param transState TransferableState object containing the information which is used to updated this log
*/
public void update(TransferableState transState) {
for (int i = 0; i < transState.getMessageBatches().length; i++, position = i) {
this.messageBatches[i] = transState.getMessageBatches()[i];
}
this.nextEid = transState.getCurrentCheckpointEid() + 1;
this.state = transState.getState();
this.execCounter = this.nextEid + position;
}
}
......@@ -44,6 +44,7 @@ import navigators.smart.paxosatwar.executionmanager.ExecutionManager;
import navigators.smart.paxosatwar.executionmanager.LeaderModule;
import navigators.smart.paxosatwar.executionmanager.Round;
import navigators.smart.paxosatwar.roles.Acceptor;
import navigators.smart.statemanagment.StateLog;
import navigators.smart.tom.TOMRequestReceiver;
import navigators.smart.tom.core.messages.TOMMessage;
import navigators.smart.tom.core.timer.RTInfo;
......@@ -157,6 +158,10 @@ public final class TOMLayer extends Thread implements RequestReceiver {
this.dt = new DeliveryThread(this, receiver, conf); // Create delivery thread
this.dt.start();
/** ISTO E CODIGO DO JOAO, PARA TRATAR DOS CHECKPOINTS */
stateLog = new StateLog(this.conf.getCheckpoint_period());
/*******************************************************/
}
/**
......@@ -888,11 +893,13 @@ public final class TOMLayer extends Thread implements RequestReceiver {
}
/** ISTO E CODIGO DO JOAO, PARA TRATAR DOS CHECKPOINTS */
private StateLog stateLog = null;
public void saveState(byte[] state) {
//TODO: Concretizar o metodo. Possivelmente acrescentar mais parametros
stateLog.newCheckpoint(state);
}
public void saveBatch(byte[] batch) {
//TODO: Concretizar o metodo. Possivelmente acrescentar mais parametros
stateLog.addMessageBatch(batch);
}
/********************************************************/
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册