use of org.elasticsearch.transport.ConnectionManager in project crate by crate.
the class PeerFinderTests method setup.
@Before
public void setup() {
capturingTransport = new CapturingTransport();
transportAddressConnector = new MockTransportAddressConnector();
providedAddresses = new ArrayList<>();
addressResolveDelay = 0L;
final Settings settings = Settings.builder().put(NODE_NAME_SETTING.getKey(), "node").build();
deterministicTaskQueue = new DeterministicTaskQueue(settings, random());
localNode = newDiscoveryNode("local-node");
ConnectionManager innerConnectionManager = new ConnectionManager(settings, capturingTransport);
StubbableConnectionManager connectionManager = new StubbableConnectionManager(innerConnectionManager, settings, capturingTransport, deterministicTaskQueue.getThreadPool());
connectionManager.setDefaultNodeConnectedBehavior(cm -> {
assertTrue(Sets.haveEmptyIntersection(connectedNodes, disconnectedNodes));
return connectedNodes;
});
connectionManager.setDefaultGetConnectionBehavior((cm, discoveryNode) -> capturingTransport.createConnection(discoveryNode));
transportService = new TransportService(settings, capturingTransport, deterministicTaskQueue.getThreadPool(), boundTransportAddress -> localNode, null, connectionManager);
transportService.start();
transportService.acceptIncomingRequests();
lastAcceptedNodes = DiscoveryNodes.builder().localNodeId(localNode.getId()).add(localNode).build();
peerFinder = new TestPeerFinder(settings, transportService, transportAddressConnector);
foundPeersFromNotification = emptyList();
}
use of org.elasticsearch.transport.ConnectionManager in project crate by crate.
the class MockTransport method createTransportService.
public TransportService createTransportService(Settings settings, ThreadPool threadPool, Function<BoundTransportAddress, DiscoveryNode> localNodeFactory, @Nullable ClusterSettings clusterSettings) {
StubbableConnectionManager connectionManager = new StubbableConnectionManager(new ConnectionManager(settings, this), settings, this, threadPool);
connectionManager.setDefaultNodeConnectedBehavior(cm -> Collections.emptySet());
connectionManager.setDefaultGetConnectionBehavior((cm, discoveryNode) -> createConnection(discoveryNode));
return new TransportService(settings, this, threadPool, localNodeFactory, clusterSettings, connectionManager);
}
Aggregations