Skip to content

Make EC2 Discovery Cache Empty Seed Hosts List #50607

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
import static org.elasticsearch.discovery.ec2.AwsEc2Service.HostType.TAG_PREFIX;

class AwsEc2SeedHostsProvider implements SeedHostsProvider {

private static final Logger logger = LogManager.getLogger(AwsEc2SeedHostsProvider.class);

private final TransportService transportService;
Expand Down Expand Up @@ -221,22 +221,13 @@ private DescribeInstancesRequest buildDescribeInstancesRequest() {

private final class TransportAddressesCache extends SingleObjectCache<List<TransportAddress>> {

private boolean empty = true;

protected TransportAddressesCache(TimeValue refreshInterval) {
super(refreshInterval, new ArrayList<>());
}

@Override
protected boolean needsRefresh() {
return (empty || super.needsRefresh());
}

@Override
protected List<TransportAddress> refresh() {
final List<TransportAddress> nodes = fetchDynamicNodes();
empty = nodes.isEmpty();
return nodes;
return fetchDynamicNodes();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -306,10 +306,10 @@ protected List<TransportAddress> fetchDynamicNodes() {
return new ArrayList<>();
}
};
for (int i=0; i<3; i++) {
for (int i = 0; i < 3; i++) {
provider.getSeedAddresses(null);
}
assertThat(provider.fetchCount, is(3));
assertThat(provider.fetchCount, is(1));
}

public void testGetNodeListCached() throws Exception {
Expand Down