Search in sources :

Example 1 with HostAndPort

use of com.pamirs.attach.plugin.es.shadowserver.utils.HostAndPort in project LinkAgent by shulieTech.

the class AbstractTransportClientDefinition method addPtTransportAddress.

protected void addPtTransportAddress(TransportClient transportClient, ShadowEsServerConfig shadowEsServerConfig) {
    for (String performanceTestNode : shadowEsServerConfig.getPerformanceTestNodes()) {
        try {
            HostAndPort hostAndPort = new HostAndPort(performanceTestNode);
            transportClient.addTransportAddress(hostAndPort.toTransportAddress());
        } catch (UnknownHostException e) {
            throw new PressureMeasureError("影子sever nodes配置错误!", e);
        }
    }
}
Also used : HostAndPort(com.pamirs.attach.plugin.es.shadowserver.utils.HostAndPort) UnknownHostException(java.net.UnknownHostException) PressureMeasureError(com.pamirs.pradar.exception.PressureMeasureError)

Example 2 with HostAndPort

use of com.pamirs.attach.plugin.es.shadowserver.utils.HostAndPort in project LinkAgent by shulieTech.

the class AbstractRestClientDefinition method solve.

@Override
public RestClient solve(RestClient target, ShadowEsServerConfig shadowEsServerConfig) {
    HttpHost[] httpHosts = new HttpHost[shadowEsServerConfig.getPerformanceTestNodes().size()];
    for (int i = 0; i < shadowEsServerConfig.getPerformanceTestNodes().size(); i++) {
        httpHosts[i] = new HostAndPort(shadowEsServerConfig.getPerformanceTestNodes().get(i)).toHttpHost();
    }
    RestClientBuilder builder = RestClient.builder(httpHosts);
    assembleBuilder(target, builder);
    return builder.build();
}
Also used : HostAndPort(com.pamirs.attach.plugin.es.shadowserver.utils.HostAndPort) HttpHost(org.apache.http.HttpHost) RestClientBuilder(org.elasticsearch.client.RestClientBuilder)

Aggregations

HostAndPort (com.pamirs.attach.plugin.es.shadowserver.utils.HostAndPort)2 PressureMeasureError (com.pamirs.pradar.exception.PressureMeasureError)1 UnknownHostException (java.net.UnknownHostException)1 HttpHost (org.apache.http.HttpHost)1 RestClientBuilder (org.elasticsearch.client.RestClientBuilder)1