From 23b8b81e1598e5995724f34b88e07afa6c265055 Mon Sep 17 00:00:00 2001 From: kimchy Date: Tue, 10 Aug 2010 22:16:13 +0300 Subject: [PATCH] EC2 Discovery ignoring instances with more than one security group, closes #311. --- .../discovery/ec2/AwsEc2UnicastHostsProvider.java | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/plugins/cloud/aws/src/main/java/org/elasticsearch/discovery/ec2/AwsEc2UnicastHostsProvider.java b/plugins/cloud/aws/src/main/java/org/elasticsearch/discovery/ec2/AwsEc2UnicastHostsProvider.java index fc77e6c624e..85bdaff2fdb 100644 --- a/plugins/cloud/aws/src/main/java/org/elasticsearch/discovery/ec2/AwsEc2UnicastHostsProvider.java +++ b/plugins/cloud/aws/src/main/java/org/elasticsearch/discovery/ec2/AwsEc2UnicastHostsProvider.java @@ -33,6 +33,7 @@ import org.elasticsearch.common.transport.InetSocketTransportAddress; import org.elasticsearch.common.transport.PortsRange; import org.elasticsearch.discovery.zen.ping.unicast.UnicastHostsProvider; +import java.util.Collections; import java.util.List; import java.util.Set; @@ -87,16 +88,10 @@ public class AwsEc2UnicastHostsProvider extends AbstractComponent implements Uni for (Reservation reservation : descInstances.getReservations()) { if (!groups.isEmpty()) { // lets see if we can filter based on groups - boolean filter = false; - for (String group : reservation.getGroupNames()) { - if (!groups.contains(group)) { - logger.trace("filtering out reservation {} based on group {}, not part of {}", reservation.getReservationId(), group, groups); - filter = true; - break; - } - } - if (filter) { - // if we are filtering, continue to the next reservation + List groupNames = reservation.getGroupNames(); + if (Collections.disjoint(groups, groupNames)) { + logger.trace("filtering out reservation {} based on groups {}, not part of {}", reservation.getReservationId(), groupNames, groups); + // continue to the next reservation continue; } }