use of org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse 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());
}
}
}
use of org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse in project vertexium by visallo.
the class Elasticsearch5SearchIndex method checkPluginInstalled.
private boolean checkPluginInstalled(Client client) {
if (config.isForceDisableVertexiumPlugin()) {
LOGGER.info("Forcing the vertexium plugin off. Running without the server side Vertexium plugin will disable some features.");
return false;
}
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 disable some features.");
return false;
}
use of org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse in project MSEC by Tencent.
the class ESHelper method waitForClusterReady.
public void waitForClusterReady(final TransportClient client, ArrayList<String> ips, final ClusterHealthStatus status) throws IOException {
Logger logger = Logger.getLogger(ESHelper.class);
int timeout = 60;
int node_num = 0;
long begin = System.currentTimeMillis() / 1000L;
long end = begin;
Set<String> done_ips = new HashSet<>();
try {
logger.info("waiting for cluster state: " + status.name());
ClusterHealthResponse healthResponse = null;
while (true) {
try {
healthResponse = client.admin().cluster().prepareHealth().setWaitForStatus(status).setTimeout(TimeValue.timeValueSeconds(5)).execute().actionGet();
} catch (NoNodeAvailableException | MasterNotDiscoveredException ex) {
end = System.currentTimeMillis() / 1000L;
if (end - begin >= timeout)
throw new IOException("Server start timeout");
logger.info("server still starting/discovering, retry...");
try {
TimeUnit.SECONDS.sleep(2);
} catch (InterruptedException e) {
}
continue;
}
if (healthResponse != null && healthResponse.isTimedOut()) {
end = System.currentTimeMillis() / 1000L;
if (// timeout
end - begin >= timeout)
throw new IOException("cluster not ready, current state is " + healthResponse.getStatus().name());
continue;
} else {
logger.info("cluster state ok");
int new_node_num = healthResponse.getNumberOfNodes();
if (new_node_num > node_num) {
node_num = new_node_num;
NodesInfoResponse nodeInfos = client.admin().cluster().prepareNodesInfo().all().get();
for (NodeInfo node : nodeInfos.getNodes()) {
if (!done_ips.contains(node.getHostname()) && ips.contains(node.getHostname())) {
updateStatus(node.getHostname(), "Done.");
done_ips.add(node.getHostname());
}
}
if (done_ips.size() == ips.size())
break;
end = System.currentTimeMillis() / 1000L;
if (// timeout
end - begin >= timeout)
break;
}
}
}
} catch (final ElasticsearchTimeoutException e) {
throw new IOException("ES API timeout");
}
}
Aggregations