本文整理汇总了Java中org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse类的典型用法代码示例。如果您正苦于以下问题:Java NodesInfoResponse类的具体用法?Java NodesInfoResponse怎么用?Java NodesInfoResponse使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NodesInfoResponse类属于org.elasticsearch.action.admin.cluster.node.info包,在下文中一共展示了NodesInfoResponse类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
});
}
});
}
示例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;
}
示例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);
}
});
}
});
}
示例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;
}
示例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));
}
示例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);
}
});
}
});
}
示例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();
}
示例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));
}
示例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));
}
}
示例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;
}
}
}
示例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");
}
示例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;
}
示例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()));
}
}
}
}
}
示例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);
}
});
}
});
}
});
}