Search in sources :

Example 1 with AwsEc2Service

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;
}
Also used : AwsEc2Service(org.elasticsearch.cloud.aws.AwsEc2Service) DiscoveryNode(org.elasticsearch.cluster.node.DiscoveryNode)

Example 2 with AwsEc2Service

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));
}
Also used : AwsEc2Service(org.elasticsearch.cloud.aws.AwsEc2Service) DiscoveryNode(org.elasticsearch.cluster.node.DiscoveryNode) ArrayList(java.util.ArrayList)

Example 3 with AwsEc2Service

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));
}
Also used : AwsEc2Service(org.elasticsearch.cloud.aws.AwsEc2Service) DiscoveryNode(org.elasticsearch.cluster.node.DiscoveryNode) Settings(org.elasticsearch.common.settings.Settings)

Aggregations

AwsEc2Service (org.elasticsearch.cloud.aws.AwsEc2Service)3 DiscoveryNode (org.elasticsearch.cluster.node.DiscoveryNode)3 ArrayList (java.util.ArrayList)1 Settings (org.elasticsearch.common.settings.Settings)1