@Test public void testAppend() { InstallSnapshotRpc firstRpc = new InstallSnapshotRpc(); firstRpc.setLastIndex(3); firstRpc.setLastTerm(2); firstRpc.setOffset(0); firstRpc.setData("test".getBytes()); firstRpc.setDone(false); MemorySnapshotBuilder builder = new MemorySnapshotBuilder(firstRpc); InstallSnapshotRpc secondRpc = new InstallSnapshotRpc(); secondRpc.setLastIndex(3); secondRpc.setLastTerm(2); secondRpc.setOffset(4); secondRpc.setData("foo".getBytes()); secondRpc.setDone(true); builder.append(secondRpc); MemorySnapshot snapshot = builder.build(); Assert.assertEquals(3, snapshot.getLastIncludedIndex()); Assert.assertEquals(2, snapshot.getLastIncludedTerm()); Assert.assertArrayEquals("testfoo".getBytes(), snapshot.getData()); }
@Override public MemorySnapshot build() { return new MemorySnapshot(lastIncludedIndex, lastIncludedTerm, output.toByteArray(), lastConfig); }
MemorySnapshotBuilder extends AbstractSnapshotBuilder<MemorySnapshot> { @Override public MemorySnapshot build() { return new MemorySnapshot(lastIncludedIndex, lastIncludedTerm, output.toByteArray(), lastConfig); } }
MemorySnapshotBuilder extends AbstractSnapshotBuilder<MemorySnapshot> { @Override public MemorySnapshot build() { return new MemorySnapshot(lastIncludedIndex, lastIncludedTerm, output.toByteArray(), lastConfig); } MemorySnapshotBuilder(InstallSnapshotRpc firstRpc); }
MemorySnapshotBuilder extends AbstractSnapshotBuilder<MemorySnapshot> { @Override public MemorySnapshot build() { return new MemorySnapshot(lastIncludedIndex, lastIncludedTerm, output.toByteArray(), lastConfig); } MemorySnapshotBuilder(InstallSnapshotRpc firstRpc); @Override MemorySnapshot build(); @Override void close(); }
MemorySnapshotBuilder extends AbstractSnapshotBuilder<MemorySnapshot> { @Override public MemorySnapshot build() { return new MemorySnapshot(lastIncludedIndex, lastIncludedTerm, output.toByteArray(), lastConfig); } MemorySnapshotBuilder(InstallSnapshotRpc firstRpc); @Override MemorySnapshot build(); @Override void close();  }