use of org.elasticsearch.action.admin.cluster.node.info.NodesInfoRequest in project elasticsearch-skywalker by jprante.
the class AbstractNodeTest method createIndices.
@BeforeMethod
public void createIndices() throws Exception {
startNode("1");
NodesInfoRequest nodesInfoRequest = new NodesInfoRequest().transport(true);
NodesInfoResponse response = client("1").admin().cluster().nodesInfo(nodesInfoRequest).actionGet();
InetSocketTransportAddress address = (InetSocketTransportAddress) response.iterator().next().getTransport().getAddress().publishAddress();
addresses.put("1", address);
client("1").admin().indices().create(new CreateIndexRequest(INDEX)).actionGet();
}
use of org.elasticsearch.action.admin.cluster.node.info.NodesInfoRequest in project elasticsearch by elastic.
the class RestNodesAction method doCatRequest.
@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);
}
});
}
});
}
});
}
use of org.elasticsearch.action.admin.cluster.node.info.NodesInfoRequest in project elasticsearch by elastic.
the class RestPluginsAction method doCatRequest.
@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);
}
});
}
});
}
use of org.elasticsearch.action.admin.cluster.node.info.NodesInfoRequest in project gerrit by GerritCodeReview.
the class ElasticTestUtils method getHttpPort.
private static String getHttpPort(Node node) throws InterruptedException, ExecutionException {
String nodes = node.client().admin().cluster().nodesInfo(new NodesInfoRequest("*")).get().toString();
Gson gson = new GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).create();
Info info = gson.fromJson(nodes, Info.class);
if (info.nodes == null || info.nodes.size() != 1) {
throw new RuntimeException("Cannot extract local Elasticsearch http port");
}
Iterator<NodeInfo> values = info.nodes.values().iterator();
String httpAddress = values.next().httpAddress;
if (Strings.isNullOrEmpty(httpAddress)) {
throw new RuntimeException("Cannot extract local Elasticsearch http port");
}
if (httpAddress.indexOf(':') < 0) {
throw new RuntimeException("Seems that port is not included in Elasticsearch http_address");
}
return httpAddress.substring(httpAddress.indexOf(':') + 1, httpAddress.length());
}
use of org.elasticsearch.action.admin.cluster.node.info.NodesInfoRequest in project elasticsearch-jdbc by jprante.
the class NodeTestUtils method findNodeAddresses.
protected void findNodeAddresses() {
NodesInfoRequest nodesInfoRequest = new NodesInfoRequest().transport(true);
NodesInfoResponse response = client("1").admin().cluster().nodesInfo(nodesInfoRequest).actionGet();
Iterator<NodeInfo> it = response.iterator();
hosts = new LinkedList<>();
hosts = new LinkedList<>();
while (it.hasNext()) {
NodeInfo nodeInfo = it.next();
TransportInfo transportInfo = nodeInfo.getTransport();
TransportAddress address = transportInfo.getAddress().publishAddress();
if (address instanceof InetSocketTransportAddress) {
InetSocketTransportAddress inetSocketTransportAddress = (InetSocketTransportAddress) address;
hosts.add(inetSocketTransportAddress.address().getHostName() + ":" + inetSocketTransportAddress.address().getPort());
}
}
}
Aggregations