Java Code Examples for org.elasticsearch.cluster.node.DiscoveryNode#address()

The following examples show how to use org.elasticsearch.cluster.node.DiscoveryNode#address() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RestNodeAttrsAction.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
private Table buildTable(RestRequest req, ClusterStateResponse state, NodesInfoResponse nodesInfo, NodesStatsResponse nodesStats) {
    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.id());
        ImmutableMap<String, String> attrs = node.getAttributes();
        for(String att : attrs.keySet()) {
            table.startRow();
            table.addCell(node.name());
            table.addCell(fullId ? node.id() : Strings.substring(node.getId(), 0, 4));
            table.addCell(info == null ? null : info.getProcess().getId());
            table.addCell(node.getHostName());
            table.addCell(node.getHostAddress());
            if (node.address() instanceof InetSocketTransportAddress) {
                table.addCell(((InetSocketTransportAddress) node.address()).address().getPort());
            } else {
                table.addCell("-");
            }
            table.addCell(att);
            table.addCell(attrs.containsKey(att) ? attrs.get(att) : null);
            table.endRow();
        }
    }

    return table;
}
 
Example 2
Source File: TransportClient.java    From elasticshell with Apache License 2.0 5 votes vote down vote up
public List<String> connectedNodes() {
    ImmutableList<DiscoveryNode> discoveryNodes = client().connectedNodes();
    List<String> nodes = new ArrayList<String>();
    for (DiscoveryNode discoveryNode : discoveryNodes) {
        TransportAddress address = discoveryNode.address();
        if (address != null) {
            nodes.add(address.toString());
        }
    }
    return nodes;
}
 
Example 3
Source File: RestThreadPoolAction.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
private Table buildTable(RestRequest req, ClusterStateResponse state, NodesInfoResponse nodesInfo, NodesStatsResponse nodesStats) {
    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.id());
        NodeStats stats = nodesStats.getNodesMap().get(node.id());
        table.startRow();

        table.addCell(fullId ? node.id() : Strings.substring(node.getId(), 0, 4));
        table.addCell(info == null ? null : info.getProcess().getId());
        table.addCell(node.getHostName());
        table.addCell(node.getHostAddress());
        if (node.address() instanceof InetSocketTransportAddress) {
            table.addCell(((InetSocketTransportAddress) node.address()).address().getPort());
        } else {
            table.addCell("-");
        }

        final Map<String, ThreadPoolStats.Stats> poolThreadStats;
        final Map<String, ThreadPool.Info> poolThreadInfo;

        if (stats == null) {
            poolThreadStats = Collections.emptyMap();
            poolThreadInfo = Collections.emptyMap();
        } else {
            poolThreadStats = new HashMap<>(14);
            poolThreadInfo = new HashMap<>(14);

            ThreadPoolStats threadPoolStats = stats.getThreadPool();
            for (ThreadPoolStats.Stats threadPoolStat : threadPoolStats) {
                poolThreadStats.put(threadPoolStat.getName(), threadPoolStat);
            }
            if (info != null) {
                for (ThreadPool.Info threadPoolInfo : info.getThreadPool()) {
                    poolThreadInfo.put(threadPoolInfo.getName(), threadPoolInfo);
                }
            }
        }
        for (String pool : SUPPORTED_NAMES) {
            ThreadPoolStats.Stats poolStats = poolThreadStats.get(pool);
            ThreadPool.Info poolInfo = poolThreadInfo.get(pool);

            Long maxQueueSize = null;
            String keepAlive = null;
            Integer minThreads = null;
            Integer maxThreads = null;

            if (poolInfo != null) {
                if (poolInfo.getQueueSize() != null) {
                    maxQueueSize = poolInfo.getQueueSize().singles();
                }
                if (poolInfo.getKeepAlive() != null) {
                    keepAlive = poolInfo.getKeepAlive().toString();
                }
                if (poolInfo.getMin() >= 0) {
                    minThreads = poolInfo.getMin();
                }
                if (poolInfo.getMax() >= 0) {
                    maxThreads = poolInfo.getMax();
                }
            }

            table.addCell(poolInfo == null  ? null : poolInfo.getThreadPoolType().getType());
            table.addCell(poolStats == null ? null : poolStats.getActive());
            table.addCell(poolStats == null ? null : poolStats.getThreads());
            table.addCell(poolStats == null ? null : poolStats.getQueue());
            table.addCell(maxQueueSize);
            table.addCell(poolStats == null ? null : poolStats.getRejected());
            table.addCell(poolStats == null ? null : poolStats.getLargest());
            table.addCell(poolStats == null ? null : poolStats.getCompleted());
            table.addCell(minThreads);
            table.addCell(maxThreads);
            table.addCell(keepAlive);
        }

        table.endRow();
    }

    return table;
}
 
Example 4
Source File: SendRequestTransportException.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
public SendRequestTransportException(DiscoveryNode node, String action, Throwable cause) {
    super(node == null ? null : node.name(), node == null ? null : node.address(), action, cause);
}
 
Example 5
Source File: ConnectTransportException.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
public ConnectTransportException(DiscoveryNode node, String msg, String action, Throwable cause) {
    super(node == null ? null : node.name(), node == null ? null : node.address(), action, msg, cause);
    this.node = node;
}
 
Example 6
Source File: ReceiveTimeoutTransportException.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
public ReceiveTimeoutTransportException(DiscoveryNode node, String action, String msg) {
    super(node.name(), node.address(), action, msg, null);
}