Java Code Examples for org.elasticsearch.cluster.ClusterName

The following examples show how to use org.elasticsearch.cluster.ClusterName. These examples are extracted from open source projects. 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
public static AuditMessage validAuditMessage(Category category) {

	    ClusterService cs = mock(ClusterService.class);
	    DiscoveryNode dn = mock(DiscoveryNode.class);

        when(dn.getHostAddress()).thenReturn("hostaddress");
        when(dn.getId()).thenReturn("hostaddress");
        when(dn.getHostName()).thenReturn("hostaddress");
        when(cs.localNode()).thenReturn(dn);
        when(cs.getClusterName()).thenReturn(new ClusterName("testcluster"));

		TransportAddress ta = new TransportAddress(new InetSocketAddress("8.8.8.8",80));

		AuditMessage msg = new AuditMessage(category, cs, Origin.TRANSPORT, Origin.TRANSPORT);
		msg.addEffectiveUser("John Doe");
		msg.addRemoteAddress(ta);
		msg.addRequestType("IndexRequest");
		return msg;
	}
 
Example 2
Source Project: anomaly-detection   Source File: ProfileResponse.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Constructor
 *
 * @param clusterName name of cluster
 * @param nodes List of ProfileNodeResponse from nodes
 * @param failures List of failures from nodes
 */
public ProfileResponse(ClusterName clusterName, List<ProfileNodeResponse> nodes, List<FailedNodeException> failures) {
    super(clusterName, nodes, failures);
    totalSizeInBytes = 0L;
    List<ModelProfile> modelProfileList = new ArrayList<>();
    for (ProfileNodeResponse response : nodes) {
        String curNodeId = response.getNode().getId();
        if (response.getShingleSize() >= 0) {
            coordinatingNode = curNodeId;
            shingleSize = response.getShingleSize();
        }
        for (Map.Entry<String, Long> entry : response.getModelSize().entrySet()) {
            totalSizeInBytes += entry.getValue();
            modelProfileList.add(new ModelProfile(entry.getKey(), entry.getValue(), curNodeId));
        }

    }
    if (coordinatingNode == null) {
        coordinatingNode = "";
    }
    this.modelProfile = modelProfileList.toArray(new ModelProfile[0]);
}
 
Example 3
@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    client = mock(Client.class);
    nodeFilter = mock(DiscoveryNodeFilterer.class);
    calendar = mock(Calendar.class);
    resolver = mock(IndexNameExpressionResolver.class);
    clusterService = mock(ClusterService.class);
    when(resolver.concreteIndexNames(any(), any(), any()))
        .thenReturn(
            new String[] { indexWithRequiredError1, indexWithRequiredError2, ".opendistro-anomaly-results-history-2020.04.08-000003" }
        );
    when(clusterService.state()).thenReturn(ClusterState.builder(new ClusterName("test cluster")).build());

    runner = new AnomalyDetectorProfileRunner(client, xContentRegistry(), nodeFilter, resolver, clusterService, calendar);
}
 
Example 4
Source Project: crate   Source File: MasterServiceTests.java    License: Apache License 2.0 6 votes vote down vote up
private TimedMasterService createTimedMasterService(boolean makeMaster) throws InterruptedException {
    DiscoveryNode localNode = new DiscoveryNode("node1", buildNewFakeTransportAddress(), emptyMap(),
        emptySet(), Version.CURRENT);
    TimedMasterService timedMasterService = new TimedMasterService(Settings.builder().put("cluster.name",
        MasterServiceTests.class.getSimpleName()).build(), threadPool);
    ClusterState initialClusterState = ClusterState.builder(new ClusterName(MasterServiceTests.class.getSimpleName()))
        .nodes(DiscoveryNodes.builder()
            .add(localNode)
            .localNodeId(localNode.getId())
            .masterNodeId(makeMaster ? localNode.getId() : null))
        .blocks(ClusterBlocks.EMPTY_CLUSTER_BLOCK).build();
    AtomicReference<ClusterState> clusterStateRef = new AtomicReference<>(initialClusterState);
    timedMasterService.setClusterStatePublisher((event, publishListener, ackListener) -> {
        clusterStateRef.set(event.state());
        publishListener.onResponse(null);
    });
    timedMasterService.setClusterStateSupplier(clusterStateRef::get);
    timedMasterService.start();
    return timedMasterService;
}
 
Example 5
Source Project: crate   Source File: Coordinator.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void doStart() {
    synchronized (mutex) {
        CoordinationState.PersistedState persistedState = persistedStateSupplier.get();
        coordinationState.set(new CoordinationState(settings, getLocalNode(), persistedState));
        peerFinder.setCurrentTerm(getCurrentTerm());
        configuredHostsResolver.start();
        VotingConfiguration votingConfiguration = coordinationState.get().getLastAcceptedState().getLastCommittedConfiguration();
        if (singleNodeDiscovery &&
            votingConfiguration.isEmpty() == false &&
            votingConfiguration.hasQuorum(Collections.singleton(getLocalNode().getId())) == false) {
            throw new IllegalStateException("cannot start with [" + DiscoveryModule.DISCOVERY_TYPE_SETTING.getKey() + "] set to [" +
                DiscoveryModule.SINGLE_NODE_DISCOVERY_TYPE + "] when local node " + getLocalNode() +
                " does not have quorum in voting configuration " + votingConfiguration);
        }
        ClusterState initialState = ClusterState.builder(ClusterName.CLUSTER_NAME_SETTING.get(settings))
            .blocks(ClusterBlocks.builder()
                .addGlobalBlock(STATE_NOT_RECOVERED_BLOCK)
                .addGlobalBlock(noMasterBlockService.getNoMasterBlock()))
            .nodes(DiscoveryNodes.builder().add(getLocalNode()).localNodeId(getLocalNode().getId()))
            .build();
        applierState = initialState;
        clusterApplier.setInitialState(initialState);
    }
}
 
Example 6
Source Project: elastic-crud   Source File: NodeTestConfig.java    License: Apache License 2.0 6 votes vote down vote up
@Bean(destroyMethod="close")
Node newNode() throws NodeValidationException {
  final Path tempDir = createTempDir().toPath();
  final Settings settings = Settings.builder()
    .put(ClusterName.CLUSTER_NAME_SETTING.getKey(), new ClusterName("single-node-cluster" + System.nanoTime()))
    .put(Environment.PATH_HOME_SETTING.getKey(), tempDir)
    .put(Environment.PATH_REPO_SETTING.getKey(), tempDir.resolve("repo"))
    .put(Environment.PATH_SHARED_DATA_SETTING.getKey(), createTempDir().getParent())
    .put("node.name", "single-node")
    .put("script.inline", "true")
    .put("script.stored", "true")
    .put(ScriptService.SCRIPT_MAX_COMPILATIONS_PER_MINUTE.getKey(), 1000)
    .put(EsExecutors.PROCESSORS_SETTING.getKey(), 1)
    .put(NetworkModule.HTTP_ENABLED.getKey(), false)
    .put("discovery.type", "zen")
    .put("transport.type", "local")
    .put(Node.NODE_DATA_SETTING.getKey(), true)
    .put(NODE_ID_SEED_SETTING.getKey(), System.nanoTime())
    .build();
  return new Node(settings).start(); // NOSONAR
}
 
Example 7
Source Project: anomaly-detection   Source File: ADStatsResponseTests.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testToXContent() throws IOException {
    ADStatsResponse adStatsResponse = new ADStatsResponse();
    Map<String, Object> testClusterStats = new HashMap<>();
    testClusterStats.put("test_stat", 1);
    adStatsResponse.setClusterStats(testClusterStats);
    List<ADStatsNodeResponse> responses = Collections.emptyList();
    List<FailedNodeException> failures = Collections.emptyList();
    ADStatsNodesResponse adStatsNodesResponse = new ADStatsNodesResponse(ClusterName.DEFAULT, responses, failures);
    adStatsResponse.setADStatsNodesResponse(adStatsNodesResponse);

    XContentBuilder builder = XContentFactory.jsonBuilder();
    adStatsResponse.toXContent(builder);
    XContentParser parser = createParser(builder);
    assertEquals(1, parser.map().get("test_stat"));
}
 
Example 8
Source Project: anomaly-detection   Source File: TestHelpers.java    License: Apache License 2.0 6 votes vote down vote up
public static ClusterState createIndexBlockedState(String indexName, Settings hackedSettings, String alias) {
    ClusterState blockedClusterState = null;
    IndexMetadata.Builder builder = IndexMetadata.builder(indexName);
    if (alias != null) {
        builder.putAlias(AliasMetadata.builder(alias));
    }
    IndexMetadata indexMetaData = builder
        .settings(
            Settings
                .builder()
                .put(IndexMetadata.SETTING_INDEX_UUID, UUIDs.randomBase64UUID())
                .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
                .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
                .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)
                .put(hackedSettings)
        )
        .build();
    Metadata metaData = Metadata.builder().put(indexMetaData, false).build();
    blockedClusterState = ClusterState
        .builder(new ClusterName("test cluster"))
        .metadata(metaData)
        .blocks(ClusterBlocks.builder().addBlocks(indexMetaData))
        .build();
    return blockedClusterState;
}
 
Example 9
Source Project: anomaly-detection   Source File: FakeNode.java    License: Apache License 2.0 6 votes vote down vote up
public static void connectNodes(FakeNode... nodes) {
    List<DiscoveryNode> discoveryNodes = new ArrayList<DiscoveryNode>(nodes.length);
    DiscoveryNode master = nodes[0].discoveryNode();
    for (int i = 0; i < nodes.length; i++) {
        discoveryNodes.add(nodes[i].discoveryNode());
    }

    for (FakeNode node : nodes) {
        setState(node.clusterService, ClusterCreation.state(new ClusterName("test"), node.discoveryNode(), master, discoveryNodes));
    }
    for (FakeNode nodeA : nodes) {
        for (FakeNode nodeB : nodes) {
            nodeA.transportService.connectToNode(nodeB.discoveryNode());
        }
    }
}
 
Example 10
public NodesFailureDetectionService(Settings settings, ThreadPool threadPool, TransportService transportService, ClusterName clusterName, ClusterService clusterService, 
        RoutingService routingService, JoinClusterAction joinClusterAction, ClusterStateOpLog clusterStateOpLog) {
    super(settings);
    this.pingInterval = settings.getAsTime(SETTING_PING_INTERVAL, timeValueSeconds(1));
    this.pingTimeout = settings.getAsTime(SETTING_PING_TIMEOUT, timeValueSeconds(5));
    this.pingRetryCount = settings.getAsInt(SETTING_PING_RETRIES, 3);
    this.threadPool = threadPool;
    this.transportService = transportService;
    this.clusterName = clusterName;
    this.clusterService = clusterService;
    this.routingService = routingService;
    this.joinClusterAction = joinClusterAction;
    this.clusterStateOpLog = clusterStateOpLog;
    this.localNode = clusterService.localNode();
    logger.debug("[node  ] uses ping_interval [{}], ping_timeout [{}], ping_retries [{}]", pingInterval, pingTimeout, pingRetryCount);
    transportService.registerRequestHandler(PING_ACTION_NAME, PingRequest.class, ThreadPool.Names.SAME, new PingRequestHandler());
}
 
Example 11
Source Project: karaf-decanter   Source File: TestElasticsearchAppender.java    License: Apache License 2.0 6 votes vote down vote up
@Before
public void setup() throws Exception {
    Collection plugins = Arrays.asList(Netty4Plugin.class);
    Settings settings = Settings.builder()
            .put(ClusterName.CLUSTER_NAME_SETTING.getKey(), CLUSTER_NAME)
            .put(Node.NODE_NAME_SETTING.getKey(), "test")
            .put(NetworkModule.HTTP_TYPE_KEY, Netty4Plugin.NETTY_HTTP_TRANSPORT_NAME)
            .put(Environment.PATH_HOME_SETTING.getKey(), "target/data")
            .put(Environment.PATH_DATA_SETTING.getKey(), "target/data")
            .put("network.host", HOST)
            .put("http.port", HTTP_PORT)
            .put(NetworkModule.TRANSPORT_TYPE_KEY, Netty4Plugin.NETTY_TRANSPORT_NAME)
            .put("transport.port", TRANSPORT_PORT)
            .build();
    node = new MockNode(settings, plugins);
    node.start();
}
 
Example 12
Source Project: crate   Source File: LicenseServiceTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testThatMaxNumberOfNodesIsWithinLimit() {
    final ClusterState state = ClusterState.builder(ClusterName.DEFAULT)
        .nodes(DiscoveryNodes.builder()
            .add(new DiscoveryNode("n1", buildNewFakeTransportAddress(),
                Version.CURRENT))
            .add(new DiscoveryNode("n2", buildNewFakeTransportAddress(),
                Version.CURRENT))
            .add(new DiscoveryNode("n3", buildNewFakeTransportAddress(),
                Version.CURRENT))
            .localNodeId("n1")
        )
        .build();
    LicenseData licenseData = new LicenseData(UNLIMITED_EXPIRY_DATE_IN_MS, "test", 3);

    licenseService.onUpdatedLicense(state, licenseData);
    assertThat(licenseService.isMaxNumberOfNodesExceeded(), is(false));
}
 
Example 13
Source Project: crate   Source File: ClusterServiceUtils.java    License: Apache License 2.0 6 votes vote down vote up
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 14
Source Project: crate   Source File: CreateDropRepositoryAnalyzerTest.java    License: Apache License 2.0 6 votes vote down vote up
@Before
public void prepare() {
    RepositoriesMetaData repositoriesMetaData = new RepositoriesMetaData(
        Collections.singletonList(
            new RepositoryMetaData(
                "my_repo",
                "fs",
                Settings.builder().put("location", "/tmp/my_repo").build()
            )));
    ClusterState clusterState = ClusterState.builder(new ClusterName("testing"))
        .metaData(MetaData.builder()
                      .putCustom(RepositoriesMetaData.TYPE, repositoriesMetaData))
        .build();
    ClusterServiceUtils.setState(clusterService, clusterState);
    e = SQLExecutor.builder(clusterService).build();
    plannerContext = e.getPlannerContext(clusterService.state());
    repositoryParamValidator = new RepositoryParamValidator(Map.of(
        "fs", new TypeSettings(FsRepository.mandatorySettings(), FsRepository.optionalSettings())
    ));
}
 
Example 15
@Before
public void prepare() throws IOException {
    String analyzerSettings = FulltextAnalyzerResolver.encodeSettings(
        Settings.builder().put("search", "foobar").build()).utf8ToString();
    MetaData metaData = MetaData.builder()
        .persistentSettings(
            Settings.builder().put(ANALYZER.buildSettingName("ft_search"), analyzerSettings).build())
        .build();
    ClusterState state = ClusterState.builder(ClusterName.DEFAULT)
        .metaData(metaData)
        .build();
    ClusterServiceUtils.setState(clusterService, state);
    e = SQLExecutor.builder(clusterService, 3, Randomness.get(), List.of())
        .enableDefaultTables()
        .build();
    plannerContext = e.getPlannerContext(clusterService.state());
}
 
Example 16
Source Project: Elasticsearch   Source File: TransportClientNodesService.java    License: Apache License 2.0 6 votes vote down vote up
@Inject
public TransportClientNodesService(Settings settings, ClusterName clusterName, TransportService transportService,
                                   ThreadPool threadPool, Headers headers, Version version) {
    super(settings);
    this.clusterName = clusterName;
    this.transportService = transportService;
    this.threadPool = threadPool;
    this.minCompatibilityVersion = version.minimumCompatibilityVersion();
    this.headers = headers;

    this.nodesSamplerInterval = this.settings.getAsTime("client.transport.nodes_sampler_interval", timeValueSeconds(5));
    this.pingTimeout = this.settings.getAsTime("client.transport.ping_timeout", timeValueSeconds(5)).millis();
    this.ignoreClusterName = this.settings.getAsBoolean("client.transport.ignore_cluster_name", false);

    if (logger.isDebugEnabled()) {
        logger.debug("node_sampler_interval[" + nodesSamplerInterval + "]");
    }

    if (this.settings.getAsBoolean("client.transport.sniff", false)) {
        this.nodesSampler = new SniffNodesSampler();
    } else {
        this.nodesSampler = new SimpleNodeSampler();
    }
    this.nodesSamplerFuture = threadPool.schedule(nodesSamplerInterval, ThreadPool.Names.GENERIC, new ScheduledNodeSampler());
}
 
Example 17
Source Project: crate   Source File: NodeJoinTests.java    License: Apache License 2.0 6 votes vote down vote up
private static ClusterState initialState(DiscoveryNode localNode, long term, long version,
                                         VotingConfiguration config) {
    return ClusterState.builder(new ClusterName(ClusterServiceUtils.class.getSimpleName()))
        .nodes(DiscoveryNodes.builder()
            .add(localNode)
            .localNodeId(localNode.getId()))
        .metaData(MetaData.builder()
                .coordinationMetaData(
                    CoordinationMetaData.builder()
                    .term(term)
                    .lastAcceptedConfiguration(config)
                    .lastCommittedConfiguration(config)
                .build()))
        .version(version)
        .blocks(ClusterBlocks.EMPTY_CLUSTER_BLOCK).build();
}
 
Example 18
public void testRemovingNonExistentNodes() throws Exception {
    final NodeRemovalClusterStateTaskExecutor executor =
            new NodeRemovalClusterStateTaskExecutor(null, logger);
    final DiscoveryNodes.Builder builder = DiscoveryNodes.builder();
    final int nodes = randomIntBetween(2, 16);
    for (int i = 0; i < nodes; i++) {
        builder.add(node(i));
    }
    final ClusterState clusterState = ClusterState.builder(new ClusterName("test")).nodes(builder).build();

    final DiscoveryNodes.Builder removeBuilder = DiscoveryNodes.builder();
    for (int i = nodes; i < nodes + randomIntBetween(1, 16); i++) {
        removeBuilder.add(node(i));
    }
    final List<NodeRemovalClusterStateTaskExecutor.Task> tasks =
            StreamSupport
                    .stream(removeBuilder.build().spliterator(), false)
                    .map(node -> new NodeRemovalClusterStateTaskExecutor.Task(node, randomBoolean() ? "left" : "failed"))
                    .collect(Collectors.toList());

    final ClusterStateTaskExecutor.ClusterTasksResult<NodeRemovalClusterStateTaskExecutor.Task> result
            = executor.execute(clusterState, tasks);
    assertThat(result.resultingState, equalTo(clusterState));
}
 
Example 19
Source Project: crate   Source File: InternalTestCluster.java    License: Apache License 2.0 6 votes vote down vote up
private Settings getSettings(int nodeOrdinal, long nodeSeed, Settings others) {
    Builder builder = Settings.builder().put(defaultSettings)
        .put(getRandomNodeSettings(nodeSeed));
    Settings settings = nodeConfigurationSource.nodeSettings(nodeOrdinal);
    if (settings != null) {
        if (settings.get(ClusterName.CLUSTER_NAME_SETTING.getKey()) != null) {
            throw new IllegalStateException("Tests must not set a '" + ClusterName.CLUSTER_NAME_SETTING.getKey()
                    + "' as a node setting set '" + ClusterName.CLUSTER_NAME_SETTING.getKey() + "': ["
                    + settings.get(ClusterName.CLUSTER_NAME_SETTING.getKey()) + "]");
        }
        builder.put(settings);
    }
    if (others != null) {
        builder.put(others);
    }
    builder.put(ClusterName.CLUSTER_NAME_SETTING.getKey(), clusterName);
    return builder.build();
}
 
Example 20
Source Project: Elasticsearch   Source File: TransportCancelTasksAction.java    License: Apache License 2.0 6 votes vote down vote up
@Inject
public TransportCancelTasksAction(Settings settings, ClusterName clusterName, ThreadPool threadPool, ClusterService clusterService,
                                  TransportService transportService, ActionFilters actionFilters, IndexNameExpressionResolver
                                      indexNameExpressionResolver) {
    super(settings, CancelTasksAction.NAME, clusterName, threadPool, clusterService, transportService, actionFilters,
        indexNameExpressionResolver, new Callable<CancelTasksRequest>() {
            @Override
            public CancelTasksRequest call() throws Exception {
                return new CancelTasksRequest();
            }
        }, ThreadPool.Names.MANAGEMENT);
    transportService.registerRequestHandler(BAN_PARENT_ACTION_NAME, new Callable<BanParentTaskRequest>() {
        @Override
        public BanParentTaskRequest call() throws Exception {
            return new BanParentTaskRequest();
        }
    }, ThreadPool.Names.SAME, new
        BanParentRequestHandler());
}
 
Example 21
public static Client createClient(ElasticDataPointer elasticDataPointer) {
  Settings settings = Settings.settingsBuilder()
      .put("client.transport.sniff", elasticDataPointer.isSniff())
      .put(ClusterName.SETTING, elasticDataPointer.getClusterName())
      .build();
  TransportClient client = TransportClient.builder().settings(settings).build();
  client.addTransportAddress(new InetSocketTransportAddress(new InetSocketAddress(elasticDataPointer.getHost(), elasticDataPointer
      .getPort())));
  return client;
}
 
Example 22
@Before
public void setup() {
    when(dn.getHostAddress()).thenReturn("hostaddress");
    when(dn.getId()).thenReturn("hostaddress");
    when(dn.getHostName()).thenReturn("hostaddress");
    when(cs.localNode()).thenReturn(dn);
    when(cs.getClusterName()).thenReturn(new ClusterName("cname"));
}
 
Example 23
Source Project: crate   Source File: TransportService.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Executes a high-level handshake using the given connection
 * and returns the discovery node of the node the connection
 * was established with. The handshake will fail if the cluster
 * name on the target node doesn't match the local cluster name.
 *
 * @param connection       the connection to a specific node
 * @param handshakeTimeout handshake timeout
 * @param clusterNamePredicate cluster name validation predicate
 * @return the handshake response
 * @throws IllegalStateException if the handshake failed
 */
public HandshakeResponse handshake(final Transport.Connection connection,
                                   final long handshakeTimeout,
                                   Predicate<ClusterName> clusterNamePredicate) {
    final HandshakeResponse response;
    final DiscoveryNode node = connection.getNode();
    try {
        PlainTransportFuture<HandshakeResponse> futureHandler = new PlainTransportFuture<>(
            new FutureTransportResponseHandler<>() {
                @Override
                public HandshakeResponse read(StreamInput in) throws IOException {
                    return new HandshakeResponse(in);
                }
            });
        sendRequest(connection, HANDSHAKE_ACTION_NAME, HandshakeRequest.INSTANCE,
            TransportRequestOptions.builder().withTimeout(handshakeTimeout).build(), futureHandler);
        response = futureHandler.txGet();
    } catch (Exception e) {
        throw new IllegalStateException("handshake failed with " + node, e);
    }

    if (!clusterNamePredicate.test(response.clusterName)) {
        throw new IllegalStateException("handshake failed, mismatched cluster name [" + response.clusterName + "] - " + node);
    } else if (response.version.isCompatible(localNode.getVersion()) == false) {
        throw new IllegalStateException("handshake failed, incompatible version [" + response.version + "] - " + node);
    }

    return response;
}
 
Example 24
@Inject
public TransportNodesHotThreadsAction(Settings settings, ClusterName clusterName, ThreadPool threadPool,
                                      ClusterService clusterService, TransportService transportService,
                                      ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
    super(settings, NodesHotThreadsAction.NAME, clusterName, threadPool, clusterService, transportService, actionFilters,
            indexNameExpressionResolver, NodesHotThreadsRequest.class, NodeRequest.class, ThreadPool.Names.GENERIC);
}
 
Example 25
Source Project: anomaly-detection   Source File: ADStatsResponseTests.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testGetAndSetADStatsNodesResponse() {
    ADStatsResponse adStatsResponse = new ADStatsResponse();
    List<ADStatsNodeResponse> responses = Collections.emptyList();
    List<FailedNodeException> failures = Collections.emptyList();
    ADStatsNodesResponse adStatsNodesResponse = new ADStatsNodesResponse(ClusterName.DEFAULT, responses, failures);
    adStatsResponse.setADStatsNodesResponse(adStatsNodesResponse);
    assertEquals(adStatsNodesResponse, adStatsResponse.getADStatsNodesResponse());
}
 
Example 26
private FakeClusterHealthResponse(ClusterHealthStatus clusterHealthStatus) {
    super("fake-cluster", new String[0],
        new ClusterState(new ClusterName("fake-cluster"), 0, null, null, RoutingTable.builder().build(),
            DiscoveryNodes.builder().build(),
            ClusterBlocks.builder().build(), null, false));
    this.status = clusterHealthStatus;
}
 
Example 27
public void testIsWarmNode() {
    HashMap<String, String> attributesForNode1 = new HashMap<>();
    attributesForNode1.put(CommonName.BOX_TYPE_KEY, CommonName.WARM_BOX_TYPE);
    dataNode1 = new DiscoveryNode(dataNode1Id, buildNewFakeTransportAddress(), attributesForNode1, BUILT_IN_ROLES, Version.CURRENT);

    ClusterState warmNodeClusterState = ClusterState
        .builder(new ClusterName(clusterName))
        .nodes(new DiscoveryNodes.Builder().masterNodeId(masterNodeId).localNodeId(dataNode1Id).add(masterNode).add(dataNode1))
        .blocks(ClusterBlocks.builder().addGlobalBlock(GatewayService.STATE_NOT_RECOVERED_BLOCK))
        .build();
    listener.clusterChanged(new ClusterChangedEvent("foo", warmNodeClusterState, oldClusterState));
    assertTrue(testAppender.containsMessage(ADClusterEventListener.NODE_NOT_APPLIED_MSG));
}
 
Example 28
public void testNotRecovered() {
    ClusterState blockedClusterState = ClusterState
        .builder(new ClusterName(clusterName))
        .nodes(new DiscoveryNodes.Builder().masterNodeId(masterNodeId).localNodeId(dataNode1Id).add(masterNode).add(dataNode1))
        .blocks(ClusterBlocks.builder().addGlobalBlock(GatewayService.STATE_NOT_RECOVERED_BLOCK))
        .build();
    listener.clusterChanged(new ClusterChangedEvent("foo", blockedClusterState, oldClusterState));
    assertTrue(testAppender.containsMessage(ADClusterEventListener.NOT_RECOVERED_MSG));
}
 
Example 29
Source Project: crate   Source File: CrateDummyClusterServiceUnitTest.java    License: Apache License 2.0 5 votes vote down vote up
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 30
@Inject
public TransportDeployAction(Settings settings, ClusterName clusterName, ThreadPool threadPool,
                             ClusterService clusterService, TransportService transportService,
                             Environment environment, DeployService deployService) {
    super(settings, clusterName, threadPool, clusterService, transportService);
    this.environment = environment;
    this.deployService = deployService;
}