Index level allocation filtering: Add _host option, closes #1991.

Add _host option to index level allocation filtering, which will match on either the hostname or ip address.
This commit is contained in:
Shay Banon 2012-05-31 11:39:09 +02:00
parent eb95bb50a8
commit cf04cff273

View File

@ -73,6 +73,20 @@ public class DiscoveryNodeFilters {
}
}
return false;
} else if ("_host".equals(attr)) {
if (!(node.address() instanceof InetSocketTransportAddress)) {
return false;
}
InetSocketTransportAddress inetAddress = (InetSocketTransportAddress) node.address();
for (String value : values) {
if (Regex.simpleMatch(value, inetAddress.address().getHostName())) {
return true;
}
if (Regex.simpleMatch(value, inetAddress.address().getAddress().getHostAddress())) {
return true;
}
}
return false;
} else if ("_id".equals(attr)) {
for (String value : values) {
if (node.id().equals(value)) {