Catch AmazonClientExceptions to prevent connection loss

If the AWS client throws an exception (e.g: because of a DNS failure) it will end up killing the rejoin thread and stop retrying which can lead to a node getting stuck unable to rejoin the cluster.

Closes #30.
This commit is contained in:
Gianni O'Neill 2013-08-05 12:45:05 +01:00 committed by David Pilato
parent 906326d056
commit 4da9b2cc9c

View File

@ -19,6 +19,7 @@
package org.elasticsearch.discovery.ec2;
import com.amazonaws.AmazonClientException;
import com.amazonaws.services.ec2.AmazonEC2;
import com.amazonaws.services.ec2.model.*;
import org.elasticsearch.Version;
@ -96,7 +97,14 @@ public class AwsEc2UnicastHostsProvider extends AbstractComponent implements Uni
public List<DiscoveryNode> buildDynamicNodes() {
List<DiscoveryNode> discoNodes = Lists.newArrayList();
DescribeInstancesResult descInstances = client.describeInstances(new DescribeInstancesRequest());
DescribeInstancesResult descInstances;
try {
descInstances = client.describeInstances(new DescribeInstancesRequest());
} catch (AmazonClientException e) {
logger.info("Exception while retrieving instance list from AWS API: {}", e.getMessage());
logger.debug("Full exception:", e);
return discoNodes;
}
logger.trace("building dynamic unicast discovery nodes...");
for (Reservation reservation : descInstances.getReservations()) {