if (nodeInfo.getHttp() != null && nodeInfo.getHttp().address() != null) { final TransportAddress his = nodeInfo.getHttp().address() .publishAddress(); clusterInfo.httpPort = his.getPort(); clusterInfo.nodeHost = is.getAddress(); if (nodeInfo.getHttp() != null && nodeInfo.getHttp().address() != null) { final TransportAddress his = nodeInfo.getHttp().address() .publishAddress(); clusterInfo.httpPort = his.getPort(); clusterInfo.nodeHost = is.getAddress(); if (nodeInfo.getHttp() != null && nodeInfo.getHttp().address() != null) { final TransportAddress his = nodeInfo.getHttp().address() .publishAddress(); clusterInfo.httpPort = his.getPort();
@Override public String getRestUrl(String clusterName) { NodeInfo[] nodes = getNodeInfo(clusterName); if (nodes != null && nodes.length > 0) { String publishAddress = nodes[0].getHttp().address().publishAddress().toString().substring(0); return publishAddress.substring(0, publishAddress.lastIndexOf(']')).replaceFirst("inet\\[.*\\/", "http://"); } return null; }
@Override public String getRestUrl(String clusterName) { NodeInfo[] nodes = getNodeInfo(clusterName); if (nodes != null && nodes.length > 0) { String publishAddress = nodes[0].getHttp().address().publishAddress().toString().substring(0); return publishAddress.substring(0, publishAddress.lastIndexOf(']')).replaceFirst("inet\\[.*\\/", "http://"); } return null; }
protected static RestClient createRestClient(final List<NodeInfo> nodes, RestClientBuilder.HttpClientConfigCallback httpClientConfigCallback, String protocol) { List<HttpHost> hosts = new ArrayList<>(); for (NodeInfo node : nodes) { if (node.getHttp() != null) { TransportAddress publishAddress = node.getHttp().address().publishAddress(); InetSocketAddress address = publishAddress.address(); hosts.add(new HttpHost(NetworkAddress.format(address.getAddress()), address.getPort(), protocol)); } } RestClientBuilder builder = RestClient.builder(hosts.toArray(new HttpHost[hosts.size()])); if (httpClientConfigCallback != null) { builder.setHttpClientConfigCallback(httpClientConfigCallback); } return builder.build(); }
@Override public void handleResponse(NodesInfoResponse response) { Collection<TransportAddress> httpAddresses = new HashSet<>(); for (NodeInfo info : response.getNodes()) { if (connectedNodes.contains(info.getNode()) && info.getHttp() != null) { httpAddresses.add(info.getHttp().getAddress().publishAddress()); } } if (httpAddresses.size() < maxNumRemoteConnections) { // just in case non of the connected nodes have http enabled we get other http enabled nodes instead. for (NodeInfo info : response.getNodes()) { if (nodePredicate.test(info.getNode()) && info.getHttp() != null) { httpAddresses.add(info.getHttp().getAddress().publishAddress()); } if (httpAddresses.size() == maxNumRemoteConnections) { break; // once we have enough return... } } } RemoteConnectionInfo remoteConnectionInfo = new RemoteConnectionInfo(clusterAlias, seedNodes.stream().map(n -> n.getAddress()).collect(Collectors.toList()), new ArrayList<>(httpAddresses), maxNumRemoteConnections, connectedNodes.size(), RemoteClusterService.REMOTE_INITIAL_CONNECTION_TIMEOUT_SETTING.get(settings)); listener.onResponse(remoteConnectionInfo); }
/** * Returns current address to connect to with HTTP client. * @return hostname/port for HTTP connection */ public TransportAddress httpAddress() { Preconditions.checkState(isStarted, "node is not started"); NodesInfoResponse response = client().admin().cluster().prepareNodesInfo() .execute().actionGet(); if (response.getNodes().size() != 1) { throw new IllegalStateException("Expected single node but got " + response.getNodes().size()); } NodeInfo node = response.getNodes().get(0); return node.getHttp().address().boundAddresses()[0]; }
table.addCell(node.getHostAddress()); table.addCell(node.getAddress().address().getPort()); final HttpInfo httpInfo = info == null ? null : info.getHttp(); if (httpInfo != null) { TransportAddress transportAddress = httpInfo.getAddress().publishAddress();
for (int i = 0; i < nodeInfos.getNodes().size(); i++) { NodeInfo nodeInfo = nodeInfos.getNodes().get(i); httpAddresses[i] = nodeInfo.getHttp().address().publishAddress().address(); if (DiscoveryNode.isDataNode(nodeInfo.getSettings())) { dataNodes++;
/** * Returns current address to connect to with HTTP client. * * @return hostname/port for HTTP connection */ public TransportAddress httpAddress() { Preconditions.checkState(isStarted, "node is not started"); NodesInfoResponse response = client().admin().cluster().prepareNodesInfo() .execute().actionGet(); if (response.getNodes().size() != 1) { throw new IllegalStateException("Expected single node but got " + response.getNodes().size()); } NodeInfo node = response.getNodes().get(0); return node.getHttp().address().boundAddresses()[0]; }
/** * Returns current address to connect to with HTTP client. * @return hostname/port for HTTP connection */ public TransportAddress httpAddress() { Preconditions.checkState(isStarted, "node is not started"); NodesInfoResponse response = client().admin().cluster().prepareNodesInfo() .execute().actionGet(); if (response.getNodes().size() != 1) { throw new IllegalStateException("Expected single node but got " + response.getNodes().size()); } NodeInfo node = response.getNodes().get(0); return node.getHttp().address().boundAddresses()[0]; }
protected void waitForCluster(final ClusterHealthStatus status, final TimeValue timeout, final Client client) throws IOException { try { log.debug("waiting for cluster state {}", status.name()); final ClusterHealthResponse healthResponse = client.admin().cluster().prepareHealth().setWaitForStatus(status) .setTimeout(timeout).setWaitForNodes("3").execute().actionGet(); if (healthResponse.isTimedOut()) { throw new IOException("cluster state is " + healthResponse.getStatus().name() + " with " + healthResponse.getNumberOfNodes() + " nodes"); } else { log.debug("... cluster state ok " + healthResponse.getStatus().name() + " with " + healthResponse.getNumberOfNodes() + " nodes"); } final NodesInfoResponse res = esNode1.client().admin().cluster().nodesInfo(new NodesInfoRequest()).actionGet(); final List<NodeInfo> nodes = res.getNodes(); for (NodeInfo nodeInfo: nodes) { if (nodeInfo.getHttp() != null && nodeInfo.getHttp().address() != null) { final TransportAddress is = nodeInfo.getHttp().address().publishAddress(); httpPort = is.getPort(); httpHost = is.getAddress(); } final TransportAddress is = nodeInfo.getTransport().getAddress().publishAddress(); nodePort = is.getPort(); nodeHost = is.getAddress(); } } catch (final ElasticsearchTimeoutException e) { throw new IOException("timeout, cluster does not respond to health request, cowardly refusing to continue with operations"); } }
table.addCell(node.getHostAddress()); table.addCell(node.getAddress().address().getPort()); final HttpInfo httpInfo = info == null ? null : info.getHttp(); if (httpInfo != null) { TransportAddress transportAddress = httpInfo.getAddress().publishAddress();
table.addCell("-"); final HttpInfo httpInfo = info == null ? null : info.getHttp(); if (httpInfo != null) { TransportAddress transportAddress = httpInfo.getAddress().publishAddress();
table.addCell(node.getHostAddress()); table.addCell(node.getAddress().address().getPort()); final HttpInfo httpInfo = info == null ? null : info.getHttp(); if (httpInfo != null) { TransportAddress transportAddress = httpInfo.getAddress().publishAddress();