mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-20 03:45:02 +00:00
EC2 Discovery should optionally bind to nodes who are members of all groups, closes #345.
This commit is contained in:
parent
7709cd1bc2
commit
38cae95ebc
@ -53,6 +53,8 @@ public class AwsEc2UnicastHostsProvider extends AbstractComponent implements Uni
|
|||||||
|
|
||||||
private final String ports;
|
private final String ports;
|
||||||
|
|
||||||
|
private final boolean bindAnyGroup;
|
||||||
|
|
||||||
private final ImmutableSet<String> groups;
|
private final ImmutableSet<String> groups;
|
||||||
|
|
||||||
private final ImmutableSet<String> availabilityZones;
|
private final ImmutableSet<String> availabilityZones;
|
||||||
@ -66,6 +68,7 @@ public class AwsEc2UnicastHostsProvider extends AbstractComponent implements Uni
|
|||||||
this.hostType = HostType.valueOf(componentSettings.get("host_type", "private_ip").toUpperCase());
|
this.hostType = HostType.valueOf(componentSettings.get("host_type", "private_ip").toUpperCase());
|
||||||
this.ports = componentSettings.get("ports", "9300-9302");
|
this.ports = componentSettings.get("ports", "9300-9302");
|
||||||
|
|
||||||
|
this.bindAnyGroup = componentSettings.getAsBoolean("any_group", true);
|
||||||
Set<String> groups = Sets.newHashSet(componentSettings.getAsArray("groups"));
|
Set<String> groups = Sets.newHashSet(componentSettings.getAsArray("groups"));
|
||||||
if (componentSettings.get("groups") != null) {
|
if (componentSettings.get("groups") != null) {
|
||||||
groups.addAll(Strings.commaDelimitedListToSet(componentSettings.get("groups")));
|
groups.addAll(Strings.commaDelimitedListToSet(componentSettings.get("groups")));
|
||||||
@ -89,11 +92,19 @@ public class AwsEc2UnicastHostsProvider extends AbstractComponent implements Uni
|
|||||||
if (!groups.isEmpty()) {
|
if (!groups.isEmpty()) {
|
||||||
// lets see if we can filter based on groups
|
// lets see if we can filter based on groups
|
||||||
List<String> groupNames = reservation.getGroupNames();
|
List<String> groupNames = reservation.getGroupNames();
|
||||||
|
if (bindAnyGroup) {
|
||||||
if (Collections.disjoint(groups, groupNames)) {
|
if (Collections.disjoint(groups, groupNames)) {
|
||||||
logger.trace("filtering out reservation {} based on groups {}, not part of {}", reservation.getReservationId(), groupNames, groups);
|
logger.trace("filtering out reservation {} based on groups {}, not part of {}", reservation.getReservationId(), groupNames, groups);
|
||||||
// continue to the next reservation
|
// continue to the next reservation
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if (!groupNames.containsAll(groups)) {
|
||||||
|
logger.trace("filtering out reservation {} based on groups {}, does not include all of {}", reservation.getReservationId(), groupNames, groups);
|
||||||
|
// continue to the next reservation
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Instance instance : reservation.getInstances()) {
|
for (Instance instance : reservation.getInstances()) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user