use of org.graylog.shaded.elasticsearch7.org.elasticsearch.client.Node 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;
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.client.Node in project graylog2-server by Graylog2.
the class FilteredElasticsearchNodesSnifferTest method returnsAllNodesIfFilterMatchesAll.
@Test
void returnsAllNodesIfFilterMatchesAll() throws Exception {
final List<Node> nodes = mockNodes();
final NodesSniffer nodesSniffer = new FilteredElasticsearchNodesSniffer(mockSniffer(nodes), "always", "true");
assertThat(nodesSniffer.sniff()).isEqualTo(nodes);
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.client.Node in project graylog2-server by Graylog2.
the class FilteredElasticsearchNodesSnifferTest method mockSniffer.
private NodesSniffer mockSniffer(List<Node> nodes) throws IOException {
final NodesSniffer mockSniffer = mock(NodesSniffer.class);
when(mockSniffer.sniff()).thenReturn(nodes);
return mockSniffer;
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.client.Node in project graylog2-server by Graylog2.
the class FilteredElasticsearchNodesSnifferTest method doesNotFilterNodesIfNoFilterIsSet.
@Test
void doesNotFilterNodesIfNoFilterIsSet() throws Exception {
final List<Node> nodes = mockNodes();
final NodesSniffer nodesSniffer = new FilteredElasticsearchNodesSniffer(mockSniffer(nodes), null, null);
assertThat(nodesSniffer.sniff()).isEqualTo(nodes);
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.client.Node in project graylog2-server by Graylog2.
the class FilteredElasticsearchNodesSniffer method create.
static FilteredElasticsearchNodesSniffer create(RestClient restClient, long sniffRequestTimeoutMillis, ElasticsearchNodesSniffer.Scheme scheme, String filter) {
final String attribute;
final String value;
if (!Strings.isNullOrEmpty(filter)) {
final String[] conditions = filter.split(":");
if (conditions.length < 2) {
throw new IllegalArgumentException("Invalid filter specified for ES node discovery: " + filter);
}
attribute = conditions[0].trim();
value = conditions[1].trim();
} else {
attribute = null;
value = null;
}
final NodesSniffer nodesSniffer = new ElasticsearchNodesSniffer(restClient, sniffRequestTimeoutMillis, scheme);
return new FilteredElasticsearchNodesSniffer(nodesSniffer, attribute, value);
}
Aggregations