public static SnapshotSyncRequest fromBytes(byte[] bytes){ ByteBuffer buffer = ByteBuffer.wrap(bytes); long lastLogIndex = buffer.getLong(); long lastLogTerm = buffer.getLong(); int configSize = buffer.getInt(); ClusterConfiguration config = ClusterConfiguration.fromBytes(ByteBuffer.wrap(bytes, buffer.position(), configSize)); buffer.position(buffer.position() + configSize); long offset = buffer.getLong(); int dataSize = buffer.getInt(); byte[] data = new byte[dataSize]; buffer.get(data); boolean done = buffer.get() == 1; return new SnapshotSyncRequest(new Snapshot(lastLogIndex, lastLogTerm, config), offset, data, done); } }
public static SnapshotSyncRequest fromBytes(byte[] bytes){ ByteBuffer buffer = ByteBuffer.wrap(bytes); long lastLogIndex = buffer.getLong(); long lastLogTerm = buffer.getLong(); int configSize = buffer.getInt(); ClusterConfiguration config = ClusterConfiguration.fromBytes(ByteBuffer.wrap(bytes, buffer.position(), configSize)); buffer.position(buffer.position() + configSize); long offset = buffer.getLong(); int dataSize = buffer.getInt(); byte[] data = new byte[dataSize]; buffer.get(data); boolean done = buffer.get() == 1; return new SnapshotSyncRequest(new Snapshot(lastLogIndex, lastLogTerm, config), offset, data, done); } }
public static SnapshotSyncRequest fromBytes(byte[] bytes){ ByteBuffer buffer = ByteBuffer.wrap(bytes); long lastLogIndex = buffer.getLong(); long lastLogTerm = buffer.getLong(); int configSize = buffer.getInt(); ClusterConfiguration config = ClusterConfiguration.fromBytes(ByteBuffer.wrap(bytes, buffer.position(), configSize)); buffer.position(buffer.position() + configSize); long offset = buffer.getLong(); int dataSize = buffer.getInt(); byte[] data = new byte[dataSize]; buffer.get(data); boolean done = buffer.get() == 1; return new SnapshotSyncRequest(new Snapshot(lastLogIndex, lastLogTerm, config), offset, data, done); } }
byte[] configData = Files.readAllBytes(this.snapshotStore.resolve(String.format("%d.cnf", maxLastLogIndex))); ClusterConfiguration config = ClusterConfiguration.fromBytes(configData); return new Snapshot(maxLastLogIndex, term, config, latestSnapshot.toFile().length());
byte[] configData = Files.readAllBytes(this.snapshotStore.resolve(String.format("%d.cnf", maxLastLogIndex))); ClusterConfiguration config = ClusterConfiguration.fromBytes(configData); return new Snapshot(maxLastLogIndex, term, config, latestSnapshot.toFile().length());
Snapshot snapshot = new Snapshot(indexToCompact, logTermToCompact, config); this.stateMachine.createSnapshot(snapshot).whenCompleteAsync((Boolean result, Throwable error) -> { try{
Snapshot snapshot = new Snapshot(indexToCompact, logTermToCompact, config); this.stateMachine.createSnapshot(snapshot).whenCompleteAsync((Boolean result, Throwable error) -> { try{
Snapshot snapshot = new Snapshot(indexToCompact, logTermToCompact, config); this.stateMachine.createSnapshot(snapshot).whenCompleteAsync((Boolean result, Throwable error) -> { try{