import akka.actor.PoisonPill;
import akka.actor.Terminated;
import akka.dispatch.Dispatchers;
+import akka.dispatch.Mailboxes;
import akka.testkit.JavaTestKit;
import akka.testkit.TestActorRef;
import akka.util.Timeout;
public static class TestRaftActor extends MockRaftActor {
- private final TestActorRef<MessageCollectorActor> collectorActor;
+ private final ActorRef collectorActor;
private final Map<Class<?>, Predicate<?>> dropMessages = new ConcurrentHashMap<>();
private TestRaftActor(Builder builder) {
}
if (message instanceof SetPeerAddress) {
- setPeerAddress(((SetPeerAddress) message).getPeerId().toString(),
+ setPeerAddress(((SetPeerAddress) message).getPeerId(),
((SetPeerAddress) message).getPeerAddress());
return;
}
}
public static class Builder extends AbstractBuilder<Builder, TestRaftActor> {
- private TestActorRef<MessageCollectorActor> collectorActor;
+ private ActorRef collectorActor;
- public Builder collectorActor(TestActorRef<MessageCollectorActor> newCollectorActor) {
+ public Builder collectorActor(ActorRef newCollectorActor) {
this.collectorActor = newCollectorActor;
return this;
}
protected long currentTerm;
protected int snapshotBatchCount = 4;
+ protected int snapshotChunkSize = SNAPSHOT_CHUNK_SIZE;
protected List<MockPayload> expSnapshotState = new ArrayList<>();
configParams.setSnapshotBatchCount(snapshotBatchCount);
configParams.setSnapshotDataThresholdPercentage(70);
configParams.setIsolatedLeaderCheckInterval(new FiniteDuration(1, TimeUnit.DAYS));
- configParams.setSnapshotChunkSize(SNAPSHOT_CHUNK_SIZE);
+ configParams.setSnapshotChunkSize(snapshotChunkSize);
return configParams;
}
}
protected TestActorRef<TestRaftActor> newTestRaftActor(String id, TestRaftActor.Builder builder) {
- builder.collectorActor(factory.<MessageCollectorActor>createTestActor(
- MessageCollectorActor.props().withDispatcher(Dispatchers.DefaultDispatcherId()),
- factory.generateActorId(id + "-collector"))).id(id);
+ builder.collectorActor(factory.createActor(
+ MessageCollectorActor.props(), factory.generateActorId(id + "-collector"))).id(id);
InvalidActorNameException lastEx = null;
for (int i = 0; i < 10; i++) {
try {
- return factory.createTestActor(builder.props().withDispatcher(Dispatchers.DefaultDispatcherId()), id);
+ return factory.createTestActor(builder.props().withDispatcher(Dispatchers.DefaultDispatcherId())
+ .withMailbox(Mailboxes.DefaultMailboxId()), id);
} catch (InvalidActorNameException e) {
lastEx = e;
Uninterruptibles.sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
msg -> msg.getToIndex() == expIndex);
}
- @SuppressWarnings("unchecked")
protected void verifySnapshot(String prefix, Snapshot snapshot, long lastAppliedTerm,
long lastAppliedIndex, long lastTerm, long lastIndex)
throws Exception {