use of org.elasticsearch.cloud.aws.AwsEc2Service in project elasticsearch by elastic.
the class Ec2DiscoveryTests method buildDynamicNodes.
protected List<DiscoveryNode> buildDynamicNodes(Settings nodeSettings, int nodes, List<List<Tag>> tagsList) {
AwsEc2Service awsEc2Service = new AwsEc2ServiceMock(nodeSettings, nodes, tagsList);
AwsEc2UnicastHostsProvider provider = new AwsEc2UnicastHostsProvider(nodeSettings, transportService, awsEc2Service);
List<DiscoveryNode> discoveryNodes = provider.buildDynamicNodes();
logger.debug("--> nodes found: {}", discoveryNodes);
return discoveryNodes;
}
use of org.elasticsearch.cloud.aws.AwsEc2Service in project elasticsearch by elastic.
the class Ec2DiscoveryTests method testGetNodeListEmptyCache.
public void testGetNodeListEmptyCache() throws Exception {
AwsEc2Service awsEc2Service = new AwsEc2ServiceMock(Settings.EMPTY, 1, null);
DummyEc2HostProvider provider = new DummyEc2HostProvider(Settings.EMPTY, transportService, awsEc2Service) {
@Override
protected List<DiscoveryNode> fetchDynamicNodes() {
fetchCount++;
return new ArrayList<>();
}
};
for (int i = 0; i < 3; i++) {
provider.buildDynamicNodes();
}
assertThat(provider.fetchCount, is(3));
}
use of org.elasticsearch.cloud.aws.AwsEc2Service in project elasticsearch by elastic.
the class Ec2DiscoveryTests method testGetNodeListCached.
public void testGetNodeListCached() throws Exception {
Settings.Builder builder = Settings.builder().put(DISCOVERY_EC2.NODE_CACHE_TIME_SETTING.getKey(), "500ms");
AwsEc2Service awsEc2Service = new AwsEc2ServiceMock(Settings.EMPTY, 1, null);
DummyEc2HostProvider provider = new DummyEc2HostProvider(builder.build(), transportService, awsEc2Service) {
@Override
protected List<DiscoveryNode> fetchDynamicNodes() {
fetchCount++;
return Ec2DiscoveryTests.this.buildDynamicNodes(Settings.EMPTY, 1);
}
};
for (int i = 0; i < 3; i++) {
provider.buildDynamicNodes();
}
assertThat(provider.fetchCount, is(1));
// wait for cache to expire
Thread.sleep(1_000L);
for (int i = 0; i < 3; i++) {
provider.buildDynamicNodes();
}
assertThat(provider.fetchCount, is(2));
}
Aggregations