mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-08 22:14:59 +00:00
Follow up to #50550. Cache empty nodes lists (`fetchDynamicNodes` will return an empty list in case of failure) now that the plugin properly retries requests to AWS EC2 APIs.
This commit is contained in:
parent
a45de8a96b
commit
8819fa4ebe
@ -221,22 +221,13 @@ class AwsEc2SeedHostsProvider implements SeedHostsProvider {
|
|||||||
|
|
||||||
private final class TransportAddressesCache extends SingleObjectCache<List<TransportAddress>> {
|
private final class TransportAddressesCache extends SingleObjectCache<List<TransportAddress>> {
|
||||||
|
|
||||||
private boolean empty = true;
|
|
||||||
|
|
||||||
protected TransportAddressesCache(TimeValue refreshInterval) {
|
protected TransportAddressesCache(TimeValue refreshInterval) {
|
||||||
super(refreshInterval, new ArrayList<>());
|
super(refreshInterval, new ArrayList<>());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected boolean needsRefresh() {
|
|
||||||
return (empty || super.needsRefresh());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<TransportAddress> refresh() {
|
protected List<TransportAddress> refresh() {
|
||||||
final List<TransportAddress> nodes = fetchDynamicNodes();
|
return fetchDynamicNodes();
|
||||||
empty = nodes.isEmpty();
|
|
||||||
return nodes;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -306,10 +306,10 @@ public class Ec2DiscoveryTests extends ESTestCase {
|
|||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
for (int i=0; i<3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
provider.getSeedAddresses(null);
|
provider.getSeedAddresses(null);
|
||||||
}
|
}
|
||||||
assertThat(provider.fetchCount, is(3));
|
assertThat(provider.fetchCount, is(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGetNodeListCached() throws Exception {
|
public void testGetNodeListCached() throws Exception {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user