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


Java NodesInfoResponse类代码示例

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

NodesInfoResponse类属于org.elasticsearch.action.admin.cluster.node.info包,在下文中一共展示了NodesInfoResponse类的40个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: doCatRequest

import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse; //导入依赖的package包/类
@Override
public RestChannelConsumer doCatRequest(final RestRequest request, final NodeClient client) {
    final ClusterStateRequest clusterStateRequest = new ClusterStateRequest();
    clusterStateRequest.clear().nodes(true);
    clusterStateRequest.local(request.paramAsBoolean("local", clusterStateRequest.local()));
    clusterStateRequest.masterNodeTimeout(request.paramAsTime("master_timeout", clusterStateRequest.masterNodeTimeout()));

    return channel -> client.admin().cluster().state(clusterStateRequest, new RestActionListener<ClusterStateResponse>(channel) {
        @Override
        public void processResponse(final ClusterStateResponse clusterStateResponse) {
            NodesInfoRequest nodesInfoRequest = new NodesInfoRequest();
            nodesInfoRequest.clear().jvm(false).os(false).process(true);
            client.admin().cluster().nodesInfo(nodesInfoRequest, new RestResponseListener<NodesInfoResponse>(channel) {
                @Override
                public RestResponse buildResponse(NodesInfoResponse nodesInfoResponse) throws Exception {
                    return RestTable.buildResponse(buildTable(request, clusterStateResponse, nodesInfoResponse), channel);
                }
            });
        }
    });
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:22,代码来源:RestNodeAttrsAction.java


示例2: buildTable

import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse; //导入依赖的package包/类
private Table buildTable(RestRequest req, ClusterStateResponse state, NodesInfoResponse nodesInfo) {
    boolean fullId = req.paramAsBoolean("full_id", false);

    DiscoveryNodes nodes = state.getState().nodes();
    Table table = getTableWithHeader(req);

    for (DiscoveryNode node : nodes) {
        NodeInfo info = nodesInfo.getNodesMap().get(node.getId());
        for (Map.Entry<String, String> attrEntry : node.getAttributes().entrySet()) {
            table.startRow();
            table.addCell(node.getName());
            table.addCell(fullId ? node.getId() : Strings.substring(node.getId(), 0, 4));
            table.addCell(info == null ? null : info.getProcess().getId());
            table.addCell(node.getHostName());
            table.addCell(node.getHostAddress());
            table.addCell(node.getAddress().address().getPort());
            table.addCell(attrEntry.getKey());
            table.addCell(attrEntry.getValue());
            table.endRow();
        }
    }
    return table;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:24,代码来源:RestNodeAttrsAction.java


示例3: doCatRequest

import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse; //导入依赖的package包/类
@Override
public RestChannelConsumer doCatRequest(final RestRequest request, final NodeClient client) {
    final ClusterStateRequest clusterStateRequest = new ClusterStateRequest();
    clusterStateRequest.clear().nodes(true);
    clusterStateRequest.local(request.paramAsBoolean("local", clusterStateRequest.local()));
    clusterStateRequest.masterNodeTimeout(request.paramAsTime("master_timeout", clusterStateRequest.masterNodeTimeout()));

    return channel -> client.admin().cluster().state(clusterStateRequest, new RestActionListener<ClusterStateResponse>(channel) {
        @Override
        public void processResponse(final ClusterStateResponse clusterStateResponse) throws Exception {
            NodesInfoRequest nodesInfoRequest = new NodesInfoRequest();
            nodesInfoRequest.clear().plugins(true);
            client.admin().cluster().nodesInfo(nodesInfoRequest, new RestResponseListener<NodesInfoResponse>(channel) {
                @Override
                public RestResponse buildResponse(final NodesInfoResponse nodesInfoResponse) throws Exception {
                    return RestTable.buildResponse(buildTable(request, clusterStateResponse, nodesInfoResponse), channel);
                }
            });
        }
    });
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:22,代码来源:RestPluginsAction.java


示例4: buildTable

import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse; //导入依赖的package包/类
private Table buildTable(RestRequest req, ClusterStateResponse state, NodesInfoResponse nodesInfo) {
    DiscoveryNodes nodes = state.getState().nodes();
    Table table = getTableWithHeader(req);

    for (DiscoveryNode node : nodes) {
        NodeInfo info = nodesInfo.getNodesMap().get(node.getId());

        for (PluginInfo pluginInfo : info.getPlugins().getPluginInfos()) {
            table.startRow();
            table.addCell(node.getId());
            table.addCell(node.getName());
            table.addCell(pluginInfo.getName());
            table.addCell(pluginInfo.getVersion());
            table.addCell(pluginInfo.getDescription());
            table.endRow();
        }
    }

    return table;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:21,代码来源:RestPluginsAction.java


示例5: 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


示例6: doRequest

import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse; //导入依赖的package包/类
@Override
public void doRequest(final RestRequest request, final RestChannel channel, final Client client) {
    final ClusterStateRequest clusterStateRequest = new ClusterStateRequest();
    clusterStateRequest.clear().nodes(true);
    clusterStateRequest.local(request.paramAsBoolean("local", clusterStateRequest.local()));
    clusterStateRequest.masterNodeTimeout(request.paramAsTime("master_timeout", clusterStateRequest.masterNodeTimeout()));

    client.admin().cluster().state(clusterStateRequest, new RestActionListener<ClusterStateResponse>(channel) {
        @Override
        public void processResponse(final ClusterStateResponse clusterStateResponse) throws Exception {
            NodesInfoRequest nodesInfoRequest = new NodesInfoRequest();
            nodesInfoRequest.clear().plugins(true);
            client.admin().cluster().nodesInfo(nodesInfoRequest, new RestResponseListener<NodesInfoResponse>(channel) {
                @Override
                public RestResponse buildResponse(final NodesInfoResponse nodesInfoResponse) throws Exception {
                    return RestTable.buildResponse(buildTable(request, clusterStateResponse, nodesInfoResponse), channel);
                }
            });
        }
    });
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:22,代码来源:RestPluginsAction.java


示例7: initClient

import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse; //导入依赖的package包/类
private void initClient() throws IOException {

    final String hosts;
    if(remote && nodes != null && nodes.length > 0 && nodes[0] != null){
      NodesInfoResponse response =  nodes[0].client().admin().cluster().prepareNodesInfo().execute().actionGet();
      TransportInfo info = response.getNodes()[0].getTransport();
      InetSocketTransportAddress inet = (InetSocketTransportAddress) info.address().publishAddress();
      hosts = inet.address().getAddress().getHostAddress() + ":" + inet.address().getPort();
    } else {
      int port = sslEnabled ? sslPort : ELASTICSEARCH_PORT;
      hosts = "127.0.0.1:" + port;
    }

    this.pool = new ElasticConnectionPool(hosts, sslEnabled, null, null, 10000, false);
    pool.connect();
    connection = pool.getRandomConnection();
    webTarget = connection.getTarget();
  }
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:19,代码来源:ElasticsearchCluster.java


示例8: testPluginLoaded

import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse; //导入依赖的package包/类
@Test
public void testPluginLoaded() {
  NodesInfoResponse nodesInfoResponse = client().admin().cluster().prepareNodesInfo().clear().setPlugins(true).get();
  assertTrue(nodesInfoResponse.getNodes().length != 0);
  assertThat(nodesInfoResponse.getNodes()[0].getPlugins().getPluginInfos(), notNullValue());
  assertThat(nodesInfoResponse.getNodes()[0].getPlugins().getPluginInfos().size(), not(0));

  boolean pluginFound = false;

  for (PluginInfo pluginInfo : nodesInfoResponse.getNodes()[0].getPlugins().getPluginInfos()) {
    if (pluginInfo.getName().equals("SirenJoinPlugin")) {
      pluginFound = true;
      break;
    }
  }

  assertThat(pluginFound, is(true));
}
 
开发者ID:sirensolutions,项目名称:siren-join,代码行数:19,代码来源:SirenJoinPluginTest.java


示例9: 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


示例10: testClusterRunning

import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse; //导入依赖的package包/类
private static boolean testClusterRunning(boolean withSecurity) throws IOException {
        try {
            NodesInfoResponse response = client.admin().cluster().prepareNodesInfo().get();
            Version version = response.getNodes().get(0).getVersion();
            logger.info("Starting integration tests against an external cluster running elasticsearch [{}] with {}",
                    version, withSecurity ? "security" : "no security" );
            return withSecurity;
//        } catch (NoNodeAvailableException e) {
//            // If we have an exception here, let's ignore the test
//            logger.warn("Integration tests are skipped: [{}]", e.getMessage());
//            assumeThat("Integration tests are skipped", e.getMessage(), not(containsString("Connection refused")));
//            return withSecurity;
        } catch (NoNodeAvailableException e) {
            if (e.getMessage() == "401") {
                logger.debug("The cluster is secured. So we need to build a client with security", e);
                return true;
            } else {
                logger.error("Full error is", e);
                throw e;
            }
        }
    }
 
开发者ID:dadoonet,项目名称:elasticsearch-beyonder,代码行数:23,代码来源:BeyonderTransportIT.java


示例11: ElasticsearchInsert

import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse; //导入依赖的package包/类
public ElasticsearchInsert(KafkaStream stream, String esHost, int threadNum, int bulkSize, String esCluster) {
  this.stream = stream;
  this.threadNum = threadNum;
  this.bulkSize = bulkSize;
  elasticSearchCluster = esCluster;
  elasticSearchHost = esHost;
  Settings settings = ImmutableSettings.settingsBuilder().put("cluster.name", elasticSearchCluster).build();
  client = new TransportClient(settings).addTransportAddress(new InetSocketTransportAddress(elasticSearchHost, elasticSearchPort));
  NodesInfoResponse response = client.admin().cluster().nodesInfo(new NodesInfoRequest().timeout("60")).actionGet();
  nodesMap = response.getNodesMap();
  for(String k: nodesMap.keySet()){
    if(!elasticSearchHost.equals(nodesMap.get(k).getHostname())) {
     client.addTransportAddress(new InetSocketTransportAddress(nodesMap.get(k).getHostname(), elasticSearchPort));
    }
  }
  LOG.info("init es");
}
 
开发者ID:wking1986,项目名称:kafka2elasticsearch,代码行数:18,代码来源:ElasticsearchInsert.java


示例12: 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


示例13: 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


示例14: 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


示例15: doCatRequest

import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse; //导入依赖的package包/类
@Override
public RestChannelConsumer doCatRequest(final RestRequest request, final NodeClient client) {
    final ClusterStateRequest clusterStateRequest = new ClusterStateRequest();
    clusterStateRequest.clear().nodes(true);
    clusterStateRequest.local(request.paramAsBoolean("local", clusterStateRequest.local()));
    clusterStateRequest.masterNodeTimeout(request.paramAsTime("master_timeout", clusterStateRequest.masterNodeTimeout()));
    final boolean fullId = request.paramAsBoolean("full_id", false);
    return channel -> client.admin().cluster().state(clusterStateRequest, new RestActionListener<ClusterStateResponse>(channel) {
        @Override
        public void processResponse(final ClusterStateResponse clusterStateResponse) {
            NodesInfoRequest nodesInfoRequest = new NodesInfoRequest();
            nodesInfoRequest.clear().jvm(true).os(true).process(true).http(true);
            client.admin().cluster().nodesInfo(nodesInfoRequest, new RestActionListener<NodesInfoResponse>(channel) {
                @Override
                public void processResponse(final NodesInfoResponse nodesInfoResponse) {
                    NodesStatsRequest nodesStatsRequest = new NodesStatsRequest();
                    nodesStatsRequest.clear().jvm(true).os(true).fs(true).indices(true).process(true).script(true);
                    client.admin().cluster().nodesStats(nodesStatsRequest, new RestResponseListener<NodesStatsResponse>(channel) {
                        @Override
                        public RestResponse buildResponse(NodesStatsResponse nodesStatsResponse) throws Exception {
                            return RestTable.buildResponse(buildTable(fullId, request, clusterStateResponse, nodesInfoResponse,
                                nodesStatsResponse), channel);
                        }
                    });
                }
            });
        }
    });
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:30,代码来源:RestNodesAction.java


示例16: doCatRequest

import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse; //导入依赖的package包/类
@Override
public RestChannelConsumer doCatRequest(final RestRequest request, final NodeClient client) {
    final ClusterStateRequest clusterStateRequest = new ClusterStateRequest();
    clusterStateRequest.clear().nodes(true);
    clusterStateRequest.local(request.paramAsBoolean("local", clusterStateRequest.local()));
    clusterStateRequest.masterNodeTimeout(request.paramAsTime("master_timeout", clusterStateRequest.masterNodeTimeout()));

    return channel -> client.admin().cluster().state(clusterStateRequest, new RestActionListener<ClusterStateResponse>(channel) {
        @Override
        public void processResponse(final ClusterStateResponse clusterStateResponse) {
            NodesInfoRequest nodesInfoRequest = new NodesInfoRequest();
            nodesInfoRequest.clear().process(true).threadPool(true);
            client.admin().cluster().nodesInfo(nodesInfoRequest, new RestActionListener<NodesInfoResponse>(channel) {
                @Override
                public void processResponse(final NodesInfoResponse nodesInfoResponse) {
                    NodesStatsRequest nodesStatsRequest = new NodesStatsRequest();
                    nodesStatsRequest.clear().threadPool(true);
                    client.admin().cluster().nodesStats(nodesStatsRequest, new RestResponseListener<NodesStatsResponse>(channel) {
                        @Override
                        public RestResponse buildResponse(NodesStatsResponse nodesStatsResponse) throws Exception {
                            return RestTable.buildResponse(buildTable(request, clusterStateResponse, nodesInfoResponse, nodesStatsResponse), channel);
                        }
                    });
                }
            });
        }
    });
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:29,代码来源:RestThreadPoolAction.java


示例17: testNodesInfos

import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse; //导入依赖的package包/类
public void testNodesInfos() throws Exception {
    List<String> nodesIds = internalCluster().startNodes(2);
    final String node_1 = nodesIds.get(0);
    final String node_2 = nodesIds.get(1);

    ClusterHealthResponse clusterHealth = client().admin().cluster().prepareHealth().setWaitForGreenStatus().setWaitForNodes("2").get();
    logger.info("--> done cluster_health, status {}", clusterHealth.getStatus());

    String server1NodeId = internalCluster().getInstance(ClusterService.class, node_1).state().nodes().getLocalNodeId();
    String server2NodeId = internalCluster().getInstance(ClusterService.class, node_2).state().nodes().getLocalNodeId();
    logger.info("--> started nodes: {} and {}", server1NodeId, server2NodeId);

    NodesInfoResponse response = client().admin().cluster().prepareNodesInfo().execute().actionGet();
    assertThat(response.getNodes().size(), is(2));
    assertThat(response.getNodesMap().get(server1NodeId), notNullValue());
    assertThat(response.getNodesMap().get(server2NodeId), notNullValue());

    response = client().admin().cluster().nodesInfo(nodesInfoRequest()).actionGet();
    assertThat(response.getNodes().size(), is(2));
    assertThat(response.getNodesMap().get(server1NodeId), notNullValue());
    assertThat(response.getNodesMap().get(server2NodeId), notNullValue());

    response = client().admin().cluster().nodesInfo(nodesInfoRequest(server1NodeId)).actionGet();
    assertThat(response.getNodes().size(), is(1));
    assertThat(response.getNodesMap().get(server1NodeId), notNullValue());

    response = client().admin().cluster().nodesInfo(nodesInfoRequest(server1NodeId)).actionGet();
    assertThat(response.getNodes().size(), is(1));
    assertThat(response.getNodesMap().get(server1NodeId), notNullValue());

    response = client().admin().cluster().nodesInfo(nodesInfoRequest(server2NodeId)).actionGet();
    assertThat(response.getNodes().size(), is(1));
    assertThat(response.getNodesMap().get(server2NodeId), notNullValue());

    response = client().admin().cluster().nodesInfo(nodesInfoRequest(server2NodeId)).actionGet();
    assertThat(response.getNodes().size(), is(1));
    assertThat(response.getNodesMap().get(server2NodeId), notNullValue());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:39,代码来源:SimpleNodesInfoIT.java


示例18: testNodesInfosTotalIndexingBuffer

import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse; //导入依赖的package包/类
public void testNodesInfosTotalIndexingBuffer() throws Exception {
    List<String> nodesIds = internalCluster().startNodes(2);
    final String node_1 = nodesIds.get(0);
    final String node_2 = nodesIds.get(1);

    ClusterHealthResponse clusterHealth = client().admin().cluster().prepareHealth().setWaitForGreenStatus().setWaitForNodes("2").get();
    logger.info("--> done cluster_health, status {}", clusterHealth.getStatus());

    String server1NodeId = internalCluster().getInstance(ClusterService.class, node_1).state().nodes().getLocalNodeId();
    String server2NodeId = internalCluster().getInstance(ClusterService.class, node_2).state().nodes().getLocalNodeId();
    logger.info("--> started nodes: {} and {}", server1NodeId, server2NodeId);

    NodesInfoResponse response = client().admin().cluster().prepareNodesInfo().execute().actionGet();
    assertThat(response.getNodes().size(), is(2));
    assertThat(response.getNodesMap().get(server1NodeId), notNullValue());
    assertNotNull(response.getNodesMap().get(server1NodeId).getTotalIndexingBuffer());
    assertThat(response.getNodesMap().get(server1NodeId).getTotalIndexingBuffer().getBytes(), greaterThan(0L));

    assertThat(response.getNodesMap().get(server2NodeId), notNullValue());
    assertNotNull(response.getNodesMap().get(server2NodeId).getTotalIndexingBuffer());
    assertThat(response.getNodesMap().get(server2NodeId).getTotalIndexingBuffer().getBytes(), greaterThan(0L));

    // again, using only the indices flag
    response = client().admin().cluster().prepareNodesInfo().clear().setIndices(true).execute().actionGet();
    assertThat(response.getNodes().size(), is(2));
    assertThat(response.getNodesMap().get(server1NodeId), notNullValue());
    assertNotNull(response.getNodesMap().get(server1NodeId).getTotalIndexingBuffer());
    assertThat(response.getNodesMap().get(server1NodeId).getTotalIndexingBuffer().getBytes(), greaterThan(0L));

    assertThat(response.getNodesMap().get(server2NodeId), notNullValue());
    assertNotNull(response.getNodesMap().get(server2NodeId).getTotalIndexingBuffer());
    assertThat(response.getNodesMap().get(server2NodeId).getTotalIndexingBuffer().getBytes(), greaterThan(0L));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:34,代码来源:SimpleNodesInfoIT.java


示例19: testAllocatedProcessors

import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse; //导入依赖的package包/类
public void testAllocatedProcessors() throws Exception {
    List<String> nodesIds = internalCluster().startNodes(
                    Settings.builder().put(EsExecutors.PROCESSORS_SETTING.getKey(), 3).build(),
                    Settings.builder().put(EsExecutors.PROCESSORS_SETTING.getKey(), 6).build()
            );

    final String node_1 = nodesIds.get(0);
    final String node_2 = nodesIds.get(1);

    ClusterHealthResponse clusterHealth = client().admin().cluster().prepareHealth().setWaitForGreenStatus().setWaitForNodes("2").get();
    logger.info("--> done cluster_health, status {}", clusterHealth.getStatus());

    String server1NodeId = internalCluster().getInstance(ClusterService.class, node_1).state().nodes().getLocalNodeId();
    String server2NodeId = internalCluster().getInstance(ClusterService.class, node_2).state().nodes().getLocalNodeId();
    logger.info("--> started nodes: {} and {}", server1NodeId, server2NodeId);

    NodesInfoResponse response = client().admin().cluster().prepareNodesInfo().execute().actionGet();

    assertThat(response.getNodes().size(), is(2));
    assertThat(response.getNodesMap().get(server1NodeId), notNullValue());
    assertThat(response.getNodesMap().get(server2NodeId), notNullValue());

    assertThat(response.getNodesMap().get(server1NodeId).getOs().getAvailableProcessors(),
            equalTo(Runtime.getRuntime().availableProcessors()));
    assertThat(response.getNodesMap().get(server2NodeId).getOs().getAvailableProcessors(),
            equalTo(Runtime.getRuntime().availableProcessors()));

    assertThat(response.getNodesMap().get(server1NodeId).getOs().getAllocatedProcessors(), equalTo(3));
    assertThat(response.getNodesMap().get(server2NodeId).getOs().getAllocatedProcessors(), equalTo(6));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:31,代码来源:SimpleNodesInfoIT.java


示例20: 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


示例21: 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


示例22: doRequest

import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse; //导入依赖的package包/类
@Override
public void doRequest(final RestRequest request, final RestChannel channel, final Client client) {
    final ClusterStateRequest clusterStateRequest = new ClusterStateRequest();
    clusterStateRequest.clear().nodes(true);
    clusterStateRequest.local(request.paramAsBoolean("local", clusterStateRequest.local()));
    clusterStateRequest.masterNodeTimeout(request.paramAsTime("master_timeout", clusterStateRequest.masterNodeTimeout()));

    client.admin().cluster().state(clusterStateRequest, new RestActionListener<ClusterStateResponse>(channel) {
        @Override
        public void processResponse(final ClusterStateResponse clusterStateResponse) {
            NodesInfoRequest nodesInfoRequest = new NodesInfoRequest();
            nodesInfoRequest.clear().jvm(false).os(false).process(true);
            client.admin().cluster().nodesInfo(nodesInfoRequest, new RestActionListener<NodesInfoResponse>(channel) {
                @Override
                public void processResponse(final NodesInfoResponse nodesInfoResponse) {
                    NodesStatsRequest nodesStatsRequest = new NodesStatsRequest();
                    nodesStatsRequest.clear().jvm(false).os(false).fs(false).indices(false).process(false);
                    client.admin().cluster().nodesStats(nodesStatsRequest, new RestResponseListener<NodesStatsResponse>(channel) {
                        @Override
                        public RestResponse buildResponse(NodesStatsResponse nodesStatsResponse) throws Exception {
                            return RestTable.buildResponse(buildTable(request, clusterStateResponse, nodesInfoResponse, nodesStatsResponse), channel);
                        }
                    });
                }
            });
        }
    });
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:29,代码来源:RestNodeAttrsAction.java


示例23: buildTable

import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse; //导入依赖的package包/类
private Table buildTable(RestRequest req, ClusterStateResponse state, NodesInfoResponse nodesInfo, NodesStatsResponse nodesStats) {
    boolean fullId = req.paramAsBoolean("full_id", false);

    DiscoveryNodes nodes = state.getState().nodes();
    Table table = getTableWithHeader(req);

    for (DiscoveryNode node : nodes) {
        NodeInfo info = nodesInfo.getNodesMap().get(node.id());
        ImmutableMap<String, String> attrs = node.getAttributes();
        for(String att : attrs.keySet()) {
            table.startRow();
            table.addCell(node.name());
            table.addCell(fullId ? node.id() : Strings.substring(node.getId(), 0, 4));
            table.addCell(info == null ? null : info.getProcess().getId());
            table.addCell(node.getHostName());
            table.addCell(node.getHostAddress());
            if (node.address() instanceof InetSocketTransportAddress) {
                table.addCell(((InetSocketTransportAddress) node.address()).address().getPort());
            } else {
                table.addCell("-");
            }
            table.addCell(att);
            table.addCell(attrs.containsKey(att) ? attrs.get(att) : null);
            table.endRow();
        }
    }

    return table;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:30,代码来源:RestNodeAttrsAction.java


示例24: doRequest

import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse; //导入依赖的package包/类
@Override
public void doRequest(final RestRequest request, final RestChannel channel, final Client client) {
    final ClusterStateRequest clusterStateRequest = new ClusterStateRequest();
    clusterStateRequest.clear().nodes(true);
    clusterStateRequest.local(request.paramAsBoolean("local", clusterStateRequest.local()));
    clusterStateRequest.masterNodeTimeout(request.paramAsTime("master_timeout", clusterStateRequest.masterNodeTimeout()));

    client.admin().cluster().state(clusterStateRequest, new RestActionListener<ClusterStateResponse>(channel) {
        @Override
        public void processResponse(final ClusterStateResponse clusterStateResponse) {
            NodesInfoRequest nodesInfoRequest = new NodesInfoRequest();
            nodesInfoRequest.clear().jvm(true).os(true).process(true);
            client.admin().cluster().nodesInfo(nodesInfoRequest, new RestActionListener<NodesInfoResponse>(channel) {
                @Override
                public void processResponse(final NodesInfoResponse nodesInfoResponse) {
                    NodesStatsRequest nodesStatsRequest = new NodesStatsRequest();
                    nodesStatsRequest.clear().jvm(true).os(true).fs(true).indices(true).process(true).script(true);
                    client.admin().cluster().nodesStats(nodesStatsRequest, new RestResponseListener<NodesStatsResponse>(channel) {
                        @Override
                        public RestResponse buildResponse(NodesStatsResponse nodesStatsResponse) throws Exception {
                            return RestTable.buildResponse(buildTable(request, clusterStateResponse, nodesInfoResponse, nodesStatsResponse), channel);
                        }
                    });
                }
            });
        }
    });
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:29,代码来源:RestNodesAction.java


示例25: buildTable

import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse; //导入依赖的package包/类
private Table buildTable(RestRequest req, ClusterStateResponse state, NodesInfoResponse nodesInfo) {
    DiscoveryNodes nodes = state.getState().nodes();
    Table table = getTableWithHeader(req);

    for (DiscoveryNode node : nodes) {
        NodeInfo info = nodesInfo.getNodesMap().get(node.id());

        for (PluginInfo pluginInfo : info.getPlugins().getPluginInfos()) {
            table.startRow();
            table.addCell(node.id());
            table.addCell(node.name());
            table.addCell(pluginInfo.getName());
            table.addCell(pluginInfo.getVersion());
            String type;
            if (pluginInfo.isSite()) {
                if (pluginInfo.isJvm()) {
                    type = "j/s";
                } else {
                    type = "s";
                }
            } else {
                if (pluginInfo.isJvm()) {
                    type = "j";
                } else {
                    type = "";
                }
            }
            table.addCell(type);
            table.addCell(pluginInfo.getUrl());
            table.addCell(pluginInfo.getDescription());
            table.endRow();
        }
    }

    return table;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:37,代码来源:RestPluginsAction.java


示例26: doRequest

import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse; //导入依赖的package包/类
@Override
public void doRequest(final RestRequest request, final RestChannel channel, final Client client) {
    final ClusterStateRequest clusterStateRequest = new ClusterStateRequest();
    clusterStateRequest.clear().nodes(true);
    clusterStateRequest.local(request.paramAsBoolean("local", clusterStateRequest.local()));
    clusterStateRequest.masterNodeTimeout(request.paramAsTime("master_timeout", clusterStateRequest.masterNodeTimeout()));

    client.admin().cluster().state(clusterStateRequest, new RestActionListener<ClusterStateResponse>(channel) {
        @Override
        public void processResponse(final ClusterStateResponse clusterStateResponse) {
            NodesInfoRequest nodesInfoRequest = new NodesInfoRequest();
            nodesInfoRequest.clear().process(true).threadPool(true);
            client.admin().cluster().nodesInfo(nodesInfoRequest, new RestActionListener<NodesInfoResponse>(channel) {
                @Override
                public void processResponse(final NodesInfoResponse nodesInfoResponse) {
                    NodesStatsRequest nodesStatsRequest = new NodesStatsRequest();
                    nodesStatsRequest.clear().threadPool(true);
                    client.admin().cluster().nodesStats(nodesStatsRequest, new RestResponseListener<NodesStatsResponse>(channel) {
                        @Override
                        public RestResponse buildResponse(NodesStatsResponse nodesStatsResponse) throws Exception {
                            return RestTable.buildResponse(buildTable(request, clusterStateResponse, nodesInfoResponse, nodesStatsResponse), channel);
                        }
                    });
                }
            });
        }
    });
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:29,代码来源:RestThreadPoolAction.java


示例27: green

import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse; //导入依赖的package包/类
/**
 * Waits for cluster to attain green state.
 */
public void green() {

  if(!USE_EXTERNAL_ES5){
    TimeValue timeout = TimeValue.timeValueSeconds(30);

    final org.elasticsearch.client.Client c = nodes[0].client();
    ClusterHealthResponse actionGet = c.admin().cluster()
            .health(Requests.clusterHealthRequest()
                .timeout(timeout)
                .waitForGreenStatus()
                .waitForEvents(Priority.LANGUID)
                .waitForRelocatingShards(0)).actionGet();

    if (actionGet.isTimedOut()) {
      logger.info("--> timed out waiting for cluster green state.\n{}\n{}",
              c.admin().cluster().prepareState().get().getState().prettyPrint(),
              c.admin().cluster().preparePendingClusterTasks().get().prettyPrint());
      fail("timed out waiting for cluster green state");
    }

    Assert.assertTrue(actionGet.getStatus().compareTo(ClusterHealthStatus.GREEN) == 0);

    NodesInfoResponse actionInfoGet = c.admin().cluster().nodesInfo(Requests.nodesInfoRequest().all()).actionGet();
    for (NodeInfo node : actionInfoGet) {
      Version nodeVersion = node.getVersion();
      if (version == null) {
        version = nodeVersion;
      } else {
        if (!nodeVersion.equals(version)) {
          logger.debug("Nodes in elasticsearch cluster have inconsistent versions.");
        }
      }
      if (nodeVersion.before(version)) {
        version = nodeVersion;
      }
    }
  }

}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:43,代码来源:ElasticsearchCluster.java


示例28: resolveAddresses

import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse; //导入依赖的package包/类
private void resolveAddresses() {
    ClusterAdminClient cluster = client.admin().cluster();
    cluster.prepareHealth().setWaitForYellowStatus().get();
    NodesInfoResponse nodeInfos = cluster.prepareNodesInfo(NODE_NAME)
        .setHttp(true).setTransport(true).get();
    NodeInfo nodeInfo = nodeInfos.getAt(0);
    httpAddress = addressToString(nodeInfo.getHttp().getAddress());
    transportAddress = addressToString(nodeInfo.getTransport().getAddress());
}
 
开发者ID:gquintana,项目名称:beepbeep,代码行数:10,代码来源:EmbeddedElasticsearch.java


示例29: findNodeAddress

import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse; //导入依赖的package包/类
protected void findNodeAddress() {
    NodesInfoRequest nodesInfoRequest = new NodesInfoRequest().transport(true);
    NodesInfoResponse response = client("1").admin().cluster().nodesInfo(nodesInfoRequest).actionGet();
    Object obj = response.iterator().next().getTransport().getAddress()
            .publishAddress();
    if (obj instanceof InetSocketTransportAddress) {
        InetSocketTransportAddress address = (InetSocketTransportAddress) obj;
        host = address.address().getHostName();
        port = address.address().getPort();
    }
}
 
开发者ID:jprante,项目名称:elasticsearch-client-http,代码行数:12,代码来源:NodeTestUtils.java


示例30: 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


示例31: 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


示例32: 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


示例33: testPluginIsLoaded

import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse; //导入依赖的package包/类
@Test
public void testPluginIsLoaded() {
    NodesInfoResponse infos = client().admin().cluster().prepareNodesInfo().setPlugins(true).execute().actionGet();
    boolean found = false;
    for (PluginInfo pluginInfo : infos.getNodes()[0].getPlugins().getInfos()) {
        if ("phone-plugin".equals(pluginInfo.getName())) {
            found = true;
        }
    }
    assertTrue(found);
}
 
开发者ID:MyPureCloud,项目名称:elasticsearch-phone,代码行数:12,代码来源:PhoneTokenizerIntegrationTest.java


示例34: 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


示例35: 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


示例36: 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


示例37: startEmbeddedES

import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse; //导入依赖的package包/类
/**
 * Start an Elasticsearch instance
 */
private static void startEmbeddedES() {
  if(esPort == null) {
    try {
      esPort = getAvailablePort();
    } catch (IOException e) {
      fail("Cannot get available port : " + e.getMessage());
    }
  }

  // Init ES
  LOGGER.info("Embedded ES instance - Starting on port " + esPort);
  Settings.Builder elasticsearchSettings = Settings.settingsBuilder()
          .put(Node.HTTP_ENABLED, true)
          .put("network.host", "127.0.0.1")
          .put("http.port", esPort)
          .put("name", "esEmbeddedForTests" + esPort)
          .put("path.home", "target/es")
          .put("path.data", "target/es")
          .put("plugins.load_classpath_plugins", true);

  Environment environment = new Environment(elasticsearchSettings.build());
  Collection plugins = new ArrayList<>();
  Collections.<Class<? extends Plugin>>addAll(plugins, MapperAttachmentsPlugin.class, DeleteByQueryPlugin.class);
  node = new EmbeddedNode(environment, Version.CURRENT, plugins);
  node.start();
  //node = nodeBuilder().local(true).settings(elasticsearchSettings.build()).node();
  node.client().admin().cluster().prepareHealth().setWaitForYellowStatus().execute().actionGet();
  assertNotNull(node);
  assertFalse(node.isClosed());
  LOGGER.info("Embedded ES instance - Started");
  // Set URL of server in property
  NodesInfoRequest nodesInfoRequest = new NodesInfoRequest().transport(true);
  NodesInfoResponse response = node.client().admin().cluster().nodesInfo(nodesInfoRequest).actionGet();
  NodeInfo nodeInfo = response.iterator().next();
  InetSocketTransportAddress address = (InetSocketTransportAddress) nodeInfo.getHttp().getAddress().publishAddress();
  String url = "http://" + address.address().getHostName() + ":" + address.address().getPort();
  PropertyManager.setProperty("exo.es.index.server.url", url);
  PropertyManager.setProperty("exo.es.search.server.url", url);
}
 
开发者ID:exo-archives,项目名称:exo-es-search,代码行数:43,代码来源:BaseIntegrationTest.java


示例38: 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


示例39: setUp

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

       Settings settings = Settings.builder().build();
       client = TransportClient.builder().settings(settings).build().addTransportAddress(getTransportAddress());

	NodesInfoResponse nodeInfos = client.admin().cluster().prepareNodesInfo().get();
	String clusterName = nodeInfos.getClusterName().value();
	System.out.println(String.format("Found cluster... cluster name: %s", clusterName));

	// Load test data.
       if(client.admin().indices().prepareExists(TestsConstants.TEST_INDEX).execute().actionGet().isExists()){
           client.admin().indices().prepareDelete(TestsConstants.TEST_INDEX).get();
       }
	loadBulk("src/test/resources/accounts.json");
	loadBulk("src/test/resources/online.json");
       loadBulk("src/test/resources/phrases.json");
       loadBulk("src/test/resources/dogs.json");
       loadBulk("src/test/resources/peoples.json");
       loadBulk("src/test/resources/character_complex.json");

       prepareOdbcIndex();
       loadBulk("src/test/resources/odbc-date-formats.json");

       searchDao = new SearchDao(client);

       //refresh to make sure all the docs will return on queries
       client.admin().indices().prepareRefresh(TestsConstants.TEST_INDEX).execute().actionGet();

	System.out.println("Finished the setup process...");
}
 
开发者ID:selvakumarEsra,项目名称:es4sql,代码行数:32,代码来源:MainTestSuite.java


示例40: findHttpAddress

import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse; //导入依赖的package包/类
public static InetSocketTransportAddress findHttpAddress(Client client) {
    NodesInfoRequestBuilder nodesInfoRequestBuilder = new NodesInfoRequestBuilder(client, NodesInfoAction.INSTANCE);
    nodesInfoRequestBuilder.setHttp(true).setTransport(false);
    NodesInfoResponse response = nodesInfoRequestBuilder.execute().actionGet();
    Object obj = response.iterator().next().getHttp().getAddress().publishAddress();
    if (obj instanceof InetSocketTransportAddress) {
        return (InetSocketTransportAddress) obj;
    }
    return null;
}
 
开发者ID:jprante,项目名称:elasticsearch-xml,代码行数:11,代码来源:XmlPluginTest.java



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