本文整理汇总了Java中org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse.getNodesMap方法的典型用法代码示例。如果您正苦于以下问题:Java NodesInfoResponse.getNodesMap方法的具体用法?Java NodesInfoResponse.getNodesMap怎么用?Java NodesInfoResponse.getNodesMap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse
的用法示例。
在下文中一共展示了NodesInfoResponse.getNodesMap方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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");
}
示例2: getSearchClusterInfo
import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse; //导入方法依赖的package包/类
/**
* Returns information about a cluster.
* @return a map of key value pairs containing cluster information
*/
public static Map<String, NodeInfo> getSearchClusterInfo() {
NodesInfoResponse res = getClient().admin().cluster().nodesInfo(new NodesInfoRequest().all()).actionGet();
return res.getNodesMap();
}