Search in sources :

Example 1 with HttpHostInfoAccessor

use of com.navercorp.pinpoint.plugin.elasticsearch.accessor.HttpHostInfoAccessor in project pinpoint by naver.

the class HighLevelConnectInterceptor method getHostList.

private List<String> getHostList(Object arg) {
    if (!(arg instanceof RestClient)) {
        return Collections.emptyList();
    }
    final List<String> hostList = new ArrayList<>();
    HttpHost[] httpHosts = null;
    if (arg instanceof HttpHostInfoAccessor) {
        httpHosts = ((HttpHostInfoAccessor) arg)._$PINPOINT$_getHttpHostInfo();
    }
    // v6.4 ~
    if (httpHosts == null) {
        for (Node node : ((RestClient) arg).getNodes()) {
            final String hostAddress = HostAndPort.toHostAndPortString(node.getHost().getHostName(), node.getHost().getPort());
            hostList.add(hostAddress);
        }
    } else {
        // v6.0 ~ 6.3
        for (HttpHost httpHost : httpHosts) {
            final String hostAddress = HostAndPort.toHostAndPortString(httpHost.getHostName(), httpHost.getPort());
            hostList.add(hostAddress);
        }
    }
    return hostList;
}
Also used : HttpHostInfoAccessor(com.navercorp.pinpoint.plugin.elasticsearch.accessor.HttpHostInfoAccessor) HttpHost(org.apache.http.HttpHost) Node(org.elasticsearch.client.Node) RestClient(org.elasticsearch.client.RestClient) ArrayList(java.util.ArrayList)

Aggregations

HttpHostInfoAccessor (com.navercorp.pinpoint.plugin.elasticsearch.accessor.HttpHostInfoAccessor)1 ArrayList (java.util.ArrayList)1 HttpHost (org.apache.http.HttpHost)1 Node (org.elasticsearch.client.Node)1 RestClient (org.elasticsearch.client.RestClient)1