use of org.elasticsearch.transport.TestTransportChannel in project crate by crate.
the class NodeJoinTests method joinNodeAsync.
private SimpleFuture joinNodeAsync(final JoinRequest joinRequest) {
final SimpleFuture future = new SimpleFuture("join of " + joinRequest + "]");
logger.debug("starting {}", future);
// disco node object serialized off the network
try {
final RequestHandlerRegistry<JoinRequest> joinHandler = transport.getRequestHandlers().getHandler(JoinHelper.JOIN_ACTION_NAME);
final ActionListener<TransportResponse> listener = new ActionListener<TransportResponse>() {
@Override
public void onResponse(TransportResponse transportResponse) {
logger.debug("{} completed", future);
future.markAsDone();
}
@Override
public void onFailure(Exception e) {
logger.error(() -> new ParameterizedMessage("unexpected error for {}", future), e);
future.markAsFailed(e);
}
};
joinHandler.processMessageReceived(joinRequest, new TestTransportChannel(listener));
} catch (Exception e) {
logger.error(() -> new ParameterizedMessage("unexpected error for {}", future), e);
future.markAsFailed(e);
}
return future;
}
use of org.elasticsearch.transport.TestTransportChannel in project crate by crate.
the class NodeJoinTests method handleStartJoinFrom.
private void handleStartJoinFrom(DiscoveryNode node, long term) throws Exception {
final RequestHandlerRegistry<StartJoinRequest> startJoinHandler = transport.getRequestHandlers().getHandler(JoinHelper.START_JOIN_ACTION_NAME);
startJoinHandler.processMessageReceived(new StartJoinRequest(node, term), new TestTransportChannel(new ActionListener<TransportResponse>() {
@Override
public void onResponse(TransportResponse transportResponse) {
}
@Override
public void onFailure(Exception e) {
fail();
}
}));
deterministicTaskQueue.runAllRunnableTasks();
assertFalse(isLocalNodeElectedMaster());
assertThat(coordinator.getMode(), equalTo(Coordinator.Mode.CANDIDATE));
}
use of org.elasticsearch.transport.TestTransportChannel in project crate by crate.
the class NodeJoinTests method handleFollowerCheckFrom.
private void handleFollowerCheckFrom(DiscoveryNode node, long term) throws Exception {
final RequestHandlerRegistry<FollowersChecker.FollowerCheckRequest> followerCheckHandler = transport.getRequestHandlers().getHandler(FollowersChecker.FOLLOWER_CHECK_ACTION_NAME);
final TestTransportChannel channel = new TestTransportChannel(new ActionListener<TransportResponse>() {
@Override
public void onResponse(TransportResponse transportResponse) {
}
@Override
public void onFailure(Exception e) {
fail();
}
});
followerCheckHandler.processMessageReceived(new FollowersChecker.FollowerCheckRequest(term, node), channel);
// Will throw exception if failed
deterministicTaskQueue.runAllRunnableTasks();
assertFalse(isLocalNodeElectedMaster());
assertThat(coordinator.getMode(), equalTo(Coordinator.Mode.FOLLOWER));
}
Aggregations