Java Code Examples for org.elasticsearch.cluster.service.ClusterService#setNodeConnectionsService()
The following examples show how to use
org.elasticsearch.cluster.service.ClusterService#setNodeConnectionsService() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ClusterServiceUtils.java From crate with Apache License 2.0 | 6 votes |
public static ClusterService createClusterService(ThreadPool threadPool, DiscoveryNode localNode, ClusterSettings clusterSettings) { Settings settings = Settings.builder() .put("node.name", "test") .put("cluster.name", "ClusterServiceTests") .build(); ClusterService clusterService = new ClusterService(settings, clusterSettings, threadPool); clusterService.setNodeConnectionsService(createNoOpNodeConnectionsService()); ClusterState initialClusterState = ClusterState.builder(new ClusterName(ClusterServiceUtils.class.getSimpleName())) .nodes(DiscoveryNodes.builder() .add(localNode) .localNodeId(localNode.getId()) .masterNodeId(localNode.getId())) .blocks(ClusterBlocks.EMPTY_CLUSTER_BLOCK).build(); clusterService.getClusterApplierService().setInitialState(initialClusterState); clusterService.getMasterService().setClusterStatePublisher( createClusterStatePublisher(clusterService.getClusterApplierService())); clusterService.getMasterService().setClusterStateSupplier(clusterService.getClusterApplierService()::state); clusterService.start(); return clusterService; }
Example 2
Source File: CrateDummyClusterServiceUnitTest.java From crate with Apache License 2.0 | 5 votes |
protected ClusterService createClusterService(Collection<Setting<?>> additionalClusterSettings, Version version) { Set<Setting<?>> clusterSettingsSet = Sets.newHashSet(ClusterSettings.BUILT_IN_CLUSTER_SETTINGS); clusterSettingsSet.addAll(additionalClusterSettings); ClusterSettings clusterSettings = new ClusterSettings(Settings.EMPTY, clusterSettingsSet); ClusterService clusterService = new ClusterService( Settings.builder() .put("cluster.name", "ClusterServiceTests") .put(Node.NODE_NAME_SETTING.getKey(), NODE_NAME) .build(), clusterSettings, THREAD_POOL ); clusterService.setNodeConnectionsService(createNoOpNodeConnectionsService()); DiscoveryNode discoveryNode = new DiscoveryNode( NODE_NAME, NODE_ID, buildNewFakeTransportAddress(), Collections.emptyMap(), new HashSet<>(Arrays.asList(DiscoveryNode.Role.values())), version ); DiscoveryNodes nodes = DiscoveryNodes.builder() .add(discoveryNode) .localNodeId(NODE_ID) .masterNodeId(NODE_ID) .build(); ClusterState clusterState = ClusterState.builder(new ClusterName(this.getClass().getSimpleName())) .nodes(nodes).blocks(ClusterBlocks.EMPTY_CLUSTER_BLOCK).build(); ClusterApplierService clusterApplierService = clusterService.getClusterApplierService(); clusterApplierService.setInitialState(clusterState); MasterService masterService = clusterService.getMasterService(); masterService.setClusterStatePublisher(createClusterStatePublisher(clusterApplierService)); masterService.setClusterStateSupplier(clusterApplierService::state); clusterService.start(); return clusterService; }
Example 3
Source File: CoordinatorTests.java From crate with Apache License 2.0 | 4 votes |
private void setUp() { mockTransport = new DisruptableMockTransport(localNode, logger) { @Override protected void execute(Runnable runnable) { deterministicTaskQueue.scheduleNow(onNode(runnable)); } @Override protected ConnectionStatus getConnectionStatus(DiscoveryNode destination) { return Cluster.this.getConnectionStatus(getLocalNode(), destination); } @Override protected Optional<DisruptableMockTransport> getDisruptableMockTransport(TransportAddress address) { return clusterNodes.stream().map(cn -> cn.mockTransport) .filter(transport -> transport.getLocalNode().getAddress().equals(address)).findAny(); } }; final Settings settings = nodeSettings.hasValue(DiscoveryModule.DISCOVERY_TYPE_SETTING.getKey()) ? nodeSettings : Settings.builder().put(nodeSettings) .putList(ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING.getKey(), ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING.get(Settings.EMPTY)).build(); // suppress auto-bootstrap transportService = mockTransport.createTransportService( settings, deterministicTaskQueue.getThreadPool(this::onNode), NOOP_TRANSPORT_INTERCEPTOR, a -> localNode, null ); masterService = new AckedFakeThreadPoolMasterService(localNode.getId(), "test", runnable -> deterministicTaskQueue.scheduleNow(onNode(runnable))); final ClusterSettings clusterSettings = new ClusterSettings(settings, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS); clusterApplierService = new DisruptableClusterApplierService(localNode.getId(), settings, clusterSettings, deterministicTaskQueue, this::onNode); clusterService = new ClusterService(settings, clusterSettings, masterService, clusterApplierService); clusterService.setNodeConnectionsService( new NodeConnectionsService(clusterService.getSettings(), deterministicTaskQueue.getThreadPool(this::onNode), transportService)); final Collection<BiConsumer<DiscoveryNode, ClusterState>> onJoinValidators = Collections.singletonList((dn, cs) -> extraJoinValidators.forEach(validator -> validator.accept(dn, cs))); coordinator = new Coordinator("test_node", settings, clusterSettings, transportService, writableRegistry(), ESAllocationTestCase.createAllocationService(Settings.EMPTY, clusterSettings, random()), masterService, this::getPersistedState, Cluster.this::provideSeedHosts, clusterApplierService, onJoinValidators, Randomness.get()); masterService.setClusterStatePublisher(coordinator); logger.trace("starting up [{}]", localNode); transportService.start(); transportService.acceptIncomingRequests(); coordinator.start(); clusterService.start(); coordinator.startInitialJoin(); }