本文整理匯總了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();
}