public class MockRaftActor extends RaftActor implements RaftActorRecoveryCohort, RaftActorSnapshotCohort {
+ public static final short PAYLOAD_VERSION = 5;
+
final RaftActor actorDelegate;
final RaftActorRecoveryCohort recoveryCohortDelegate;
final RaftActorSnapshotCohort snapshotCohortDelegate;
public MockRaftActor(String id, Map<String, String> peerAddresses, Optional<ConfigParams> config,
DataPersistenceProvider dataPersistenceProvider) {
- super(id, peerAddresses, config);
+ super(id, peerAddresses, config, PAYLOAD_VERSION);
state = new ArrayList<>();
this.actorDelegate = mock(RaftActor.class);
this.recoveryCohortDelegate = mock(RaftActorRecoveryCohort.class);
@Override
public void applyRecoverySnapshot(byte[] bytes) {
recoveryCohortDelegate.applyRecoverySnapshot(bytes);
+ applySnapshotBytes(bytes);
+ }
+
+ private void applySnapshotBytes(byte[] bytes) {
try {
Object data = toObject(bytes);
if (data instanceof List) {
public void applySnapshot(byte [] snapshot) {
LOG.info("{}: applySnapshot called", persistenceId());
snapshotCohortDelegate.applySnapshot(snapshot);
+ applySnapshotBytes(snapshot);
}
@Override