use of org.elasticsearch.cluster.coordination.PeersResponse in project crate by crate.
the class PeerFinderTests method testTimesOutAndRetriesConnectionsToBlackholedNodes.
public void testTimesOutAndRetriesConnectionsToBlackholedNodes() {
final DiscoveryNode otherNode = newDiscoveryNode("node-from-hosts-list");
final DiscoveryNode nodeToFind = newDiscoveryNode("node-to-find");
providedAddresses.add(otherNode.getAddress());
transportAddressConnector.addReachableNode(otherNode);
transportAddressConnector.addReachableNode(nodeToFind);
peerFinder.activate(lastAcceptedNodes);
while (true) {
deterministicTaskQueue.advanceTime();
// MockTransportAddressConnector verifies no multiple connection attempts
runAllRunnableTasks();
if (capturingTransport.getCapturedRequestsAndClear().length > 0) {
break;
}
}
final long timeoutAtMillis = deterministicTaskQueue.getCurrentTimeMillis() + PeerFinder.DISCOVERY_REQUEST_PEERS_TIMEOUT_SETTING.get(Settings.EMPTY).millis();
while (deterministicTaskQueue.getCurrentTimeMillis() < timeoutAtMillis) {
assertFoundPeers(otherNode);
deterministicTaskQueue.advanceTime();
runAllRunnableTasks();
}
// need to wait for the connection to timeout, then for another wakeup, before discovering the peer
final long expectedTime = timeoutAtMillis + PeerFinder.DISCOVERY_FIND_PEERS_INTERVAL_SETTING.get(Settings.EMPTY).millis();
while (deterministicTaskQueue.getCurrentTimeMillis() < expectedTime) {
deterministicTaskQueue.advanceTime();
runAllRunnableTasks();
}
respondToRequests(node -> {
assertThat(node, is(otherNode));
return new PeersResponse(Optional.empty(), singletonList(nodeToFind), randomNonNegativeLong());
});
deterministicTaskQueue.advanceTime();
runAllRunnableTasks();
assertFoundPeers(nodeToFind, otherNode);
}
use of org.elasticsearch.cluster.coordination.PeersResponse in project crate by crate.
the class PeerFinderTests method testAddsReachablePeersFromResponse.
public void testAddsReachablePeersFromResponse() {
final DiscoveryNode otherNode = newDiscoveryNode("node-from-hosts-list");
providedAddresses.add(otherNode.getAddress());
transportAddressConnector.addReachableNode(otherNode);
peerFinder.activate(lastAcceptedNodes);
runAllRunnableTasks();
assertFoundPeers(otherNode);
final DiscoveryNode discoveredNode = newDiscoveryNode("discovered-node");
transportAddressConnector.addReachableNode(discoveredNode);
respondToRequests(node -> {
assertThat(node, is(otherNode));
return new PeersResponse(Optional.empty(), singletonList(discoveredNode), randomNonNegativeLong());
});
runAllRunnableTasks();
assertFoundPeers(otherNode, discoveredNode);
}
use of org.elasticsearch.cluster.coordination.PeersResponse in project crate by crate.
the class PeerFinderTests method testHandlesDiscoveryOfMasterFromResponseFromMaster.
public void testHandlesDiscoveryOfMasterFromResponseFromMaster() {
final DiscoveryNode otherNode = newDiscoveryNode("node-from-hosts-list");
providedAddresses.add(otherNode.getAddress());
transportAddressConnector.addReachableNode(otherNode);
peerFinder.activate(lastAcceptedNodes);
runAllRunnableTasks();
assertFoundPeers(otherNode);
final long term = randomNonNegativeLong();
respondToRequests(node -> {
assertThat(node, is(otherNode));
return new PeersResponse(Optional.of(otherNode), emptyList(), term);
});
runAllRunnableTasks();
assertFoundPeers(otherNode);
assertThat(peerFinder.discoveredMasterNode, is(otherNode));
assertThat(peerFinder.discoveredMasterTerm, is(OptionalLong.of(term)));
}
Aggregations