use of org.neo4j.causalclustering.core.consensus.log.RaftLogCursor in project neo4j by neo4j.
the class InFlightLogEntryReaderTest method startingFromIndexReturnEntries.
private void startingFromIndexReturnEntries(ReadableRaftLog raftLog, long startIndex, RaftLogEntry entry, RaftLogEntry... otherEntries) throws IOException {
RaftLogCursor cursor = mock(RaftLogCursor.class);
when(raftLog.getEntryCursor(startIndex)).thenReturn(cursor, (RaftLogCursor) null);
Boolean[] bools = new Boolean[otherEntries.length + 1];
Arrays.fill(bools, Boolean.TRUE);
bools[otherEntries.length] = Boolean.FALSE;
when(cursor.next()).thenReturn(true, bools);
Long[] indexes = new Long[otherEntries.length + 1];
for (int offset = 0; offset < indexes.length; offset++) {
indexes[offset] = startIndex + 1 + offset;
}
indexes[otherEntries.length] = -1L;
when(cursor.index()).thenReturn(startIndex, indexes);
RaftLogEntry[] raftLogEntries = Arrays.copyOf(otherEntries, otherEntries.length + 1);
when(cursor.get()).thenReturn(entry, raftLogEntries);
}
use of org.neo4j.causalclustering.core.consensus.log.RaftLogCursor in project neo4j by neo4j.
the class LogPrinter method print.
public void print(PrintStream out) throws IOException {
out.println(String.format("%1$8s %2$5s %3$2s %4$s", "Index", "Term", "C?", "Content"));
long index = 0L;
try (RaftLogCursor cursor = raftLog.getEntryCursor(0)) {
while (cursor.next()) {
RaftLogEntry raftLogEntry = cursor.get();
out.printf("%8d %5d %s", index, raftLogEntry.term(), raftLogEntry.content());
index++;
}
}
}
Aggregations