use of org.apache.ignite.raft.jraft.Closure in project ignite-3 by apache.
the class IteratorImpl method runTheRestClosureWithError.
protected void runTheRestClosureWithError() {
for (long i = Math.max(this.currentIndex, this.firstClosureIndex); i <= this.committedIndex; i++) {
final Closure done = this.closures.get((int) (i - this.firstClosureIndex));
if (done != null) {
Requires.requireNonNull(this.error, "error");
Requires.requireNonNull(this.error.getStatus(), "error.status");
final Status status = this.error.getStatus();
Utils.runClosureInThread(options.getCommonExecutor(), done, status);
}
}
}
use of org.apache.ignite.raft.jraft.Closure in project ignite-3 by apache.
the class AddPeerRequestProcessorTest method verify.
@Override
public void verify(String interest, Node node, ArgumentCaptor<Closure> doneArg) {
assertEquals(AddPeerRequest.class.getName(), interest);
Mockito.verify(node).addPeer(eq(new PeerId("test", 8181)), doneArg.capture());
Closure done = doneArg.getValue();
assertNotNull(done);
done.run(Status.OK());
assertNotNull(this.asyncContext.getResponseObject());
assertEquals("[localhost:8081, localhost:8082, localhost:8083]", this.asyncContext.as(AddPeerResponse.class).oldPeersList().toString());
assertEquals("[localhost:8081, localhost:8082, localhost:8083, test:8181]", this.asyncContext.as(AddPeerResponse.class).newPeersList().toString());
}
use of org.apache.ignite.raft.jraft.Closure in project ignite-3 by apache.
the class ChangePeersRequestProcessorTest method verify.
@Override
public void verify(String interest, Node node, ArgumentCaptor<Closure> doneArg) {
assertEquals(ChangePeersRequest.class.getName(), interest);
Mockito.verify(node).changePeers(eq(JRaftUtils.getConfiguration("localhost:8084,localhost:8085")), doneArg.capture());
Closure done = doneArg.getValue();
assertNotNull(done);
done.run(Status.OK());
assertNotNull(this.asyncContext.getResponseObject());
assertEquals("[localhost:8081, localhost:8082, localhost:8083]", this.asyncContext.as(ChangePeersResponse.class).oldPeersList().toString());
assertEquals("[localhost:8084, localhost:8085]", this.asyncContext.as(ChangePeersResponse.class).newPeersList().toString());
}
use of org.apache.ignite.raft.jraft.Closure in project ignite-3 by apache.
the class RemoveLearnersRequestProcessorTest method verify.
@Override
public void verify(final String interest, final Node node, final ArgumentCaptor<Closure> doneArg) {
assertEquals(interest, RemoveLearnersRequest.class.getName());
Mockito.verify(node).removeLearners(eq(Arrays.asList(new PeerId("learner", 8082), new PeerId("test", 8183))), doneArg.capture());
Closure done = doneArg.getValue();
assertNotNull(done);
done.run(Status.OK());
assertNotNull(this.asyncContext.getResponseObject());
assertEquals("[learner:8081, learner:8082, learner:8083]", this.asyncContext.as(LearnersOpResponse.class).oldLearnersList().toString());
assertEquals("[learner:8081, learner:8083]", this.asyncContext.as(LearnersOpResponse.class).newLearnersList().toString());
}
use of org.apache.ignite.raft.jraft.Closure in project ignite-3 by apache.
the class ResetLearnersRequestProcessorTest method verify.
@Override
public void verify(final String interest, final Node node, final ArgumentCaptor<Closure> doneArg) {
assertEquals(interest, ResetLearnersRequest.class.getName());
Mockito.verify(node).resetLearners(eq(Arrays.asList(new PeerId("learner", 8082), new PeerId("test", 8182), new PeerId("test", 8183))), doneArg.capture());
Closure done = doneArg.getValue();
assertNotNull(done);
done.run(Status.OK());
assertNotNull(this.asyncContext.getResponseObject());
assertEquals("[learner:8081, learner:8082, learner:8083]", this.asyncContext.as(LearnersOpResponse.class).oldLearnersList().toString());
assertEquals("[learner:8082, test:8182, test:8183]", this.asyncContext.as(LearnersOpResponse.class).newLearnersList().toString());
}
Aggregations