Example #1
0
  protected ApplicationState loadDurableState() {
    FileRecoverer fr = new FileRecoverer(id, DEFAULT_DIR);
    lastCkpPath = fr.getLatestFile(".ckp");
    logPath = fr.getLatestFile(".log");
    byte[] checkpoint = null;
    if (lastCkpPath != null) checkpoint = fr.getCkpState(lastCkpPath);
    CommandsInfo[] log = null;
    if (logPath != null) log = fr.getLogState(0, logPath);
    int ckpLastConsensusId = fr.getCkpLastConsensusId();
    int logLastConsensusId = fr.getLogLastConsensusId();
    System.out.println("log last consensus di: " + logLastConsensusId);
    ApplicationState state =
        new DefaultApplicationState(
            log, ckpLastConsensusId, logLastConsensusId, checkpoint, fr.getCkpStateHash());
    if (logLastConsensusId > ckpLastConsensusId) {
      super.setLastEid(logLastConsensusId);
    } else super.setLastEid(ckpLastConsensusId);
    super.setLastCheckpointEid(ckpLastConsensusId);

    return state;
  }