Search in sources :

Example 1 with MemoryRaftLog

use of org.apache.ratis.server.raftlog.memory.MemoryRaftLog in project incubator-ratis by apache.

the class ServerState method initRaftLog.

private static RaftLog initRaftLog(RaftGroupMemberId memberId, RaftServerImpl server, RaftStorage storage, Consumer<LogEntryProto> logConsumer, LongSupplier getSnapshotIndexFromStateMachine, RaftProperties prop) throws IOException {
    final RaftLog log;
    if (RaftServerConfigKeys.Log.useMemory(prop)) {
        log = new MemoryRaftLog(memberId, getSnapshotIndexFromStateMachine, prop);
    } else {
        log = new SegmentedRaftLog(memberId, server, server.getStateMachine(), server::notifyTruncatedLogEntry, server::submitUpdateCommitEvent, storage, getSnapshotIndexFromStateMachine, prop);
    }
    log.open(log.getSnapshotIndex(), logConsumer);
    return log;
}
Also used : MemoryRaftLog(org.apache.ratis.server.raftlog.memory.MemoryRaftLog) SegmentedRaftLog(org.apache.ratis.server.raftlog.segmented.SegmentedRaftLog) RaftLog(org.apache.ratis.server.raftlog.RaftLog) SegmentedRaftLog(org.apache.ratis.server.raftlog.segmented.SegmentedRaftLog) MemoryRaftLog(org.apache.ratis.server.raftlog.memory.MemoryRaftLog)

Example 2 with MemoryRaftLog

use of org.apache.ratis.server.raftlog.memory.MemoryRaftLog in project incubator-ratis by apache.

the class MiniRaftCluster method printAllLogs.

public String printAllLogs() {
    StringBuilder b = new StringBuilder("\n#servers = " + servers.size() + "\n");
    for (RaftServer.Division s : iterateDivisions()) {
        b.append("  ");
        b.append(s).append("\n");
        final RaftLog log = s.getRaftLog();
        if (log instanceof MemoryRaftLog) {
            b.append("    ");
            b.append(((MemoryRaftLog) log).getEntryString());
        }
    }
    return b.toString();
}
Also used : MemoryRaftLog(org.apache.ratis.server.raftlog.memory.MemoryRaftLog) RaftServer(org.apache.ratis.server.RaftServer) MemoryRaftLog(org.apache.ratis.server.raftlog.memory.MemoryRaftLog) RaftLog(org.apache.ratis.server.raftlog.RaftLog)

Aggregations

RaftLog (org.apache.ratis.server.raftlog.RaftLog)2 MemoryRaftLog (org.apache.ratis.server.raftlog.memory.MemoryRaftLog)2 RaftServer (org.apache.ratis.server.RaftServer)1 SegmentedRaftLog (org.apache.ratis.server.raftlog.segmented.SegmentedRaftLog)1