当前位置: 首页>>代码示例>>Java>>正文


Java NodesInfoResponse.getNodes方法代码示例

本文整理汇总了Java中org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse.getNodes方法的典型用法代码示例。如果您正苦于以下问题:Java NodesInfoResponse.getNodes方法的具体用法?Java NodesInfoResponse.getNodes怎么用?Java NodesInfoResponse.getNodes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse的用法示例。


在下文中一共展示了NodesInfoResponse.getNodes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testClusterUpdateSettingsNoAcknowledgement

import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse; //导入方法依赖的package包/类
public void testClusterUpdateSettingsNoAcknowledgement() {
    client().admin().indices().prepareCreate("test")
            .setSettings(Settings.builder()
                    .put("number_of_shards", between(cluster().numDataNodes(), DEFAULT_MAX_NUM_SHARDS))
                    .put("number_of_replicas", 0)).get();
    ensureGreen();

    // now that the cluster is stable, remove timeout
    removePublishTimeout();

    NodesInfoResponse nodesInfo = client().admin().cluster().prepareNodesInfo().get();
    String excludedNodeId = null;
    for (NodeInfo nodeInfo : nodesInfo.getNodes()) {
        if (nodeInfo.getNode().isDataNode()) {
            excludedNodeId = nodeInfo.getNode().getId();
            break;
        }
    }
    assertNotNull(excludedNodeId);

    ClusterUpdateSettingsResponse clusterUpdateSettingsResponse = client().admin().cluster().prepareUpdateSettings().setTimeout("0s")
            .setTransientSettings(Settings.builder().put("cluster.routing.allocation.exclude._id", excludedNodeId)).get();
    assertThat(clusterUpdateSettingsResponse.isAcknowledged(), equalTo(false));
    assertThat(clusterUpdateSettingsResponse.getTransientSettings().get("cluster.routing.allocation.exclude._id"), equalTo(excludedNodeId));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:26,代码来源:AckClusterUpdateSettingsIT.java

示例2: testTransportClient

import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse; //导入方法依赖的package包/类
public void testTransportClient() throws Exception {
    NodesInfoResponse nodeInfos = client().admin().cluster().prepareNodesInfo().get();
    List<NodeInfo>  nodes = nodeInfos.getNodes();
    assertTrue(nodes.size() > 0);
    TransportAddress publishAddress = randomFrom(nodes).getTransport().address().publishAddress();
    String clusterName = nodeInfos.getClusterName().value();

    Settings settings = Settings.builder()
            .put("cluster.name", clusterName)
            .put(ThreadContext.PREFIX + "." + CustomRealm.USER_HEADER, randomFrom(KNOWN_USERS))
            .put(ThreadContext.PREFIX + "." + CustomRealm.PW_HEADER, PASSWORD)
            .build();
    try (TransportClient client = new PreBuiltXPackTransportClient(settings)) {
        client.addTransportAddress(publishAddress);
        ClusterHealthResponse response = client.admin().cluster().prepareHealth().execute().actionGet();
        assertThat(response.isTimedOut(), is(false));
    }
}
 
开发者ID:elastic,项目名称:shield-custom-realm-example,代码行数:19,代码来源:CustomRealmIT.java

示例3: testPluginIsLoaded

import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse; //导入方法依赖的package包/类
public void testPluginIsLoaded() {
    NodesInfoResponse response = client().admin().cluster().prepareNodesInfo().setPlugins(true).get();
    for (NodeInfo node : response.getNodes()) {
        boolean founded = false;
        for (PluginInfo pluginInfo : node.getPlugins().getPluginInfos()) {
            if (pluginInfo.getName().equals(AnalysisOpenKoreanTextPlugin.class.getName())) {
                founded = true;
            }
        }
        Assert.assertTrue(founded);
    }
}
 
开发者ID:open-korean-text,项目名称:elasticsearch-analysis-openkoreantext,代码行数:13,代码来源:AnalysisOpenKoreanTextPluginTest.java

示例4: checkPluginInstalled

import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse; //导入方法依赖的package包/类
private boolean checkPluginInstalled(Client client) {
    NodesInfoResponse nodesInfoResponse = client.admin().cluster().prepareNodesInfo().setPlugins(true).get();
    for (NodeInfo nodeInfo : nodesInfoResponse.getNodes()) {
        for (PluginInfo pluginInfo : nodeInfo.getPlugins().getPluginInfos()) {
            if ("memgraph".equals(pluginInfo.getName())) {
                return true;
            }
        }
    }
    if (config.isErrorOnMissingMemgraphPlugin()) {
        throw new MemgraphException("Memgraph plugin cannot be found");
    }
    LOGGER.warn("Running without the server side Memgraph plugin will be deprecated in the future.");
    return false;
}
 
开发者ID:mware-solutions,项目名称:memory-graph,代码行数:16,代码来源:Elasticsearch5SearchIndex.java

示例5: testDifferentPorts

import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse; //导入方法依赖的package包/类
public void testDifferentPorts() throws Exception {
    if (!NetworkUtils.SUPPORTS_V6) {
        return;
    }
    logger.info("--> starting a node on ipv4 only");
    Settings ipv4Settings = Settings.builder().put("network.host", "127.0.0.1").build();
    String ipv4OnlyNode = internalCluster().startNode(ipv4Settings); // should bind 127.0.0.1:XYZ

    logger.info("--> starting a node on ipv4 and ipv6");
    Settings bothSettings = Settings.builder().put("network.host", "_local_").build();
    internalCluster().startNode(bothSettings); // should bind [::1]:XYZ and 127.0.0.1:XYZ+1

    logger.info("--> waiting for the cluster to declare itself stable");
    ensureStableCluster(2); // fails if port of publish address does not match corresponding bound address

    logger.info("--> checking if boundAddress matching publishAddress has same port");
    NodesInfoResponse nodesInfoResponse = client().admin().cluster().prepareNodesInfo().get();
    for (NodeInfo nodeInfo : nodesInfoResponse.getNodes()) {
        BoundTransportAddress boundTransportAddress = nodeInfo.getTransport().getAddress();
        if (nodeInfo.getNode().getName().equals(ipv4OnlyNode)) {
            assertThat(boundTransportAddress.boundAddresses().length, equalTo(1));
            assertThat(boundTransportAddress.boundAddresses()[0].getPort(), equalTo(boundTransportAddress.publishAddress().getPort()));
        } else {
            assertThat(boundTransportAddress.boundAddresses().length, greaterThan(1));
            for (TransportAddress boundAddress : boundTransportAddress.boundAddresses()) {
                assertThat(boundAddress, instanceOf(TransportAddress.class));
                TransportAddress inetBoundAddress = (TransportAddress) boundAddress;
                if (inetBoundAddress.address().getAddress() instanceof Inet4Address) {
                    // IPv4 address is preferred publish address for _local_
                    assertThat(inetBoundAddress.getPort(), equalTo(boundTransportAddress.publishAddress().getPort()));
                }
            }
        }
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:36,代码来源:Netty4TransportPublishAddressIT.java

示例6: testNodeInfoIsFiltered

import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse; //导入方法依赖的package包/类
public void testNodeInfoIsFiltered() {
    NodesInfoResponse nodeInfos = client().admin().cluster().prepareNodesInfo().clear().setSettings(true).get();
    for(NodeInfo info : nodeInfos.getNodes()) {
        Settings settings = info.getSettings();
        assertNotNull(settings);
        assertNull(settings.get(SettingsFilteringPlugin.SOME_NODE_SETTING.getKey()));
        assertTrue(settings.getAsBoolean(SettingsFilteringPlugin.SOME_OTHER_NODE_SETTING.getKey(), false));
        assertEquals(settings.get("node.name"), info.getNode().getName());
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:11,代码来源:SettingsFilteringIT.java

示例7: testPluginIsLoaded

import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse; //导入方法依赖的package包/类
public void testPluginIsLoaded() throws Exception {
    NodesInfoResponse response = client().admin().cluster().prepareNodesInfo().setPlugins(true).get();
    for (NodeInfo nodeInfo : response.getNodes()) {
        boolean pluginFound = false;
        for (PluginInfo pluginInfo : nodeInfo.getPlugins().getPluginInfos()) {
            if (pluginInfo.getName().equals(RosetteTextAnalysisPlugin.class.getName())) {
                pluginFound = true;
                break;
            }
        }
        assertTrue(pluginFound);
    }
}
 
开发者ID:rosette-api,项目名称:rosette-elasticsearch-plugin,代码行数:14,代码来源:RosetteTextAnalysisPluginIT.java

示例8: checkPluginInstalled

import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse; //导入方法依赖的package包/类
private boolean checkPluginInstalled(Client client) {
    NodesInfoResponse nodesInfoResponse = client.admin().cluster().prepareNodesInfo().setPlugins(true).get();
    for (NodeInfo nodeInfo : nodesInfoResponse.getNodes()) {
        for (PluginInfo pluginInfo : nodeInfo.getPlugins().getPluginInfos()) {
            if ("vertexium".equals(pluginInfo.getName())) {
                return true;
            }
        }
    }
    if (config.isErrorOnMissingVertexiumPlugin()) {
        throw new VertexiumException("Vertexium plugin cannot be found");
    }
    LOGGER.warn("Running without the server side Vertexium plugin will be deprecated in the future.");
    return false;
}
 
开发者ID:visallo,项目名称:vertexium,代码行数:16,代码来源:Elasticsearch5SearchIndex.java

示例9: checkConfigUpdateResponse

import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse; //导入方法依赖的package包/类
private static boolean checkConfigUpdateResponse(ConfigUpdateResponse response, NodesInfoResponse nir, int expectedConfigCount) {
    
    int expectedNodeCount = 0;
    
    for(NodeInfo ni: nir.getNodes()) {
        Settings nodeSettings = ni.getSettings();
      
        //do not count tribe clients
        if(nodeSettings.get("tribe.name", null) == null) {
            expectedNodeCount++;
        }           
    }

    boolean success = response.getNodes().size() == expectedNodeCount;
    if(!success) {
        System.out.println("FAIL: Expected "+expectedNodeCount+" nodes to return response, but got only "+response.getNodes().size());
    }
    
    for(String nodeId: response.getNodesMap().keySet()) {
        ConfigUpdateNodeResponse node = response.getNodesMap().get(nodeId);
        boolean successNode = (node.getUpdatedConfigTypes() != null && node.getUpdatedConfigTypes().length == expectedConfigCount);
        
        if(!successNode) {
            System.out.println("FAIL: Expected "+expectedConfigCount+" config types for node "+nodeId+" but got only "+Arrays.toString(node.getUpdatedConfigTypes()) + " due to: "+node.getMessage()==null?"unknown reason":node.getMessage());
        }
        
        success = success && successNode;
    }
    
    return success;
}
 
开发者ID:floragunncom,项目名称:search-guard,代码行数:32,代码来源:SearchGuardAdmin.java

示例10: testTransportClientWrongAuthentication

import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse; //导入方法依赖的package包/类
public void testTransportClientWrongAuthentication() throws Exception {
    NodesInfoResponse nodeInfos = client().admin().cluster().prepareNodesInfo().get();
    List<NodeInfo> nodes = nodeInfos.getNodes();
    assertTrue(nodes.size() > 0);
    TransportAddress publishAddress = randomFrom(nodes).getTransport().address().publishAddress();
    String clusterName = nodeInfos.getClusterName().value();

    Settings settings;
    if (randomBoolean()) {
        settings = Settings.builder()
                .put("cluster.name", clusterName)
                .put(ThreadContext.PREFIX + "." + CustomRealm.USER_HEADER, randomFrom(KNOWN_USERS) + randomAlphaOfLength(1))
                .put(ThreadContext.PREFIX + "." + CustomRealm.PW_HEADER, PASSWORD)
                .build();
    } else {
        settings = Settings.builder()
                .put("cluster.name", clusterName)
                .put(ThreadContext.PREFIX + "." + CustomRealm.USER_HEADER, randomFrom(KNOWN_USERS))
                .put(ThreadContext.PREFIX + "." + CustomRealm.PW_HEADER, randomAlphaOfLengthBetween(16, 32))
                .build();
    }

    try (TransportClient client = new PreBuiltXPackTransportClient(settings)) {
        client.addTransportAddress(publishAddress);
        client.admin().cluster().prepareHealth().execute().actionGet();
        fail("authentication failure should have resulted in a NoNodesAvailableException");
    } catch (NoNodeAvailableException e) {
        // expected
    }
}
 
开发者ID:elastic,项目名称:shield-custom-realm-example,代码行数:31,代码来源:CustomRealmIT.java

示例11: testTransportClientMultiRound

import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse; //导入方法依赖的package包/类
@Test
public void testTransportClientMultiRound() throws Exception {

    //Mock mode, no kerberos involved

    embeddedKrbServer.getSimpleKdcServer().stop();

    final Settings esServerSettings = Settings.builder().put(PREFIX + SettingConstants.ACCEPTOR_KEYTAB_PATH, "mock")
            .put(PREFIX + SettingConstants.ACCEPTOR_PRINCIPAL, "mock").put(PREFIX + "mock_mode", true)
            .putArray(PREFIX + SettingConstants.ROLES+".cc_kerberos_realm_role", "spock/[email protected]","mock_principal")
            .build();

    this.startES(esServerSettings);

    final NodesInfoResponse nodeInfos = client().admin().cluster().prepareNodesInfo().get();
    final NodeInfo[] nodes = nodeInfos.getNodes();
    assertTrue(nodes.length > 2);

    final Settings settings = Settings.builder().put("cluster.name", clustername)
            .putArray("plugin.types", ShieldPlugin.class.getName()).build();

    try (TransportClient client = TransportClient.builder().settings(settings).build()) {
        client.addTransportAddress(nodes[0].getTransport().address().publishAddress());
        try (KerberizedClient kc = new MockingKerberizedClient(client)) {

            ClusterHealthResponse response = kc.admin().cluster().prepareHealth().execute().actionGet();
            assertThat(response.isTimedOut(), is(false));

            response = kc.admin().cluster().prepareHealth().execute().actionGet();
            assertThat(response.isTimedOut(), is(false));

            response = kc.admin().cluster().prepareHealth().execute().actionGet();
            assertThat(response.isTimedOut(), is(false));
            assertThat(response.status(), is(RestStatus.OK));
            assertThat(response.getStatus(), is(ClusterHealthStatus.GREEN));
        }
    }
}
 
开发者ID:codecentric,项目名称:elasticsearch-shield-kerberos-realm,代码行数:39,代码来源:KerberosRealmEmbeddedTests.java

示例12: startES

import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse; //导入方法依赖的package包/类
public final void startES(final Settings settings) throws Exception {
    FileUtils.copyFileToDirectory(getAbsoluteFilePathFromClassPath("roles.yml").toFile(), new File("testtmp/config/shield"));

    final Set<Integer> ports = new HashSet<>();
    do {
        ports.add(NetworkUtil.getServerPort());
    } while (ports.size() < 7);

    final Iterator<Integer> portIt = ports.iterator();

    elasticsearchHttpPort1 = portIt.next();
    elasticsearchHttpPort2 = portIt.next();
    elasticsearchHttpPort3 = portIt.next();

    //elasticsearchNodePort1 = portIt.next();
    //elasticsearchNodePort2 = portIt.next();
    //elasticsearchNodePort3 = portIt.next();

    esNode1 = new PluginEnabledNode(getDefaultSettingsBuilder(1, 0, elasticsearchHttpPort1, false, true).put(
            settings == null ? Settings.Builder.EMPTY_SETTINGS : settings).build(), Lists.newArrayList(ShieldPlugin.class, LicensePlugin.class, KerberosRealmPlugin.class)).start();
    client = esNode1.client();
    
    esNode2 = new PluginEnabledNode(getDefaultSettingsBuilder(2, 0, elasticsearchHttpPort2, true, true).put(
            settings == null ? Settings.Builder.EMPTY_SETTINGS : settings).build(), Lists.newArrayList(ShieldPlugin.class, LicensePlugin.class, KerberosRealmPlugin.class)).start();
    
    esNode3 = new PluginEnabledNode(getDefaultSettingsBuilder(3, 0, elasticsearchHttpPort3, true, false).put(
            settings == null ? Settings.Builder.EMPTY_SETTINGS : settings).build(), Lists.newArrayList(ShieldPlugin.class, LicensePlugin.class, KerberosRealmPlugin.class)).start();
    
    waitForGreenClusterState();
    final NodesInfoResponse nodeInfos = client().admin().cluster().prepareNodesInfo().get();
    final NodeInfo[] nodes = nodeInfos.getNodes();
    Assert.assertEquals(nodes + "", 3, nodes.length);
}
 
开发者ID:codecentric,项目名称:elasticsearch-shield-kerberos-realm,代码行数:34,代码来源:AbstractUnitTest.java

示例13: setTestBehavior

import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse; //导入方法依赖的package包/类
@BeforeClass
public static void setTestBehavior() {
    try {
        NodesInfoResponse response = client.admin().cluster().prepareNodesInfo().get();
        for (NodeInfo nodeInfo : response.getNodes()) {
            Version version = nodeInfo.getVersion();
            if (version.id >= 6000000) {
                supportsMultipleTypes = false;
            }
        }
    } catch (NoNodeAvailableException e) {
        assumeNoException(e);
    }
}
 
开发者ID:dadoonet,项目名称:elasticsearch-beyonder,代码行数:15,代码来源:BeyonderTransportIT.java

示例14: getNodesStats

import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse; //导入方法依赖的package包/类
protected NodesStatsResponse getNodesStats() {
    final NodesInfoResponse nodesInfoResponse = client.admin().cluster().nodesInfo(new NodesInfoRequest()).actionGet();
    final String[] nodes = new String[nodesInfoResponse.getNodes().length];

    int i = 0;

    for (NodeInfo nodeInfo : nodesInfoResponse.getNodes()) {
        nodes[i++] = nodeInfo.getNode().getName();
    }

    return client.admin().cluster().nodesStats(new NodesStatsRequest(nodes)).actionGet();
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:13,代码来源:ElasticSearchService.java

示例15: testPluginIsLoaded

import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse; //导入方法依赖的package包/类
public void testPluginIsLoaded() throws Exception {
    NodesInfoResponse response = client().admin().cluster().prepareNodesInfo().setPlugins(true).get();
    for (NodeInfo nodeInfo : response.getNodes()) {
        boolean pluginFound = false;
        for (PluginInfo pluginInfo : nodeInfo.getPlugins().getPluginInfos()) {
            if (pluginInfo.getName().equals(AnalysisVietnamesePlugin.class.getName())) {
                pluginFound = true;
                break;
            }
        }
        assertThat(pluginFound, is(true));
    }
}
 
开发者ID:duydo,项目名称:elasticsearch-analysis-vietnamese,代码行数:14,代码来源:VietnameseAnalysisIntegrationTest.java


注:本文中的org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse.getNodes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。