public static DiscoveryNodeFilters buildFromKeyValue(OpType opType, Map<String, String> filters) { Map<String, String[]> bFilters = new HashMap<>(); for (Map.Entry<String, String> entry : filters.entrySet()) { String[] values = Strings.tokenizeToStringArray(entry.getValue(), ","); if (values.length > 0) { bFilters.put(entry.getKey(), values); } } if (bFilters.isEmpty()) { return null; } return new DiscoveryNodeFilters(opType, bFilters); }
private void setClusterRequireFilters(Map<String, String> filters) { clusterRequireFilters = DiscoveryNodeFilters.buildFromKeyValue(AND, filters); } private void setClusterIncludeFilters(Map<String, String> filters) {
private Decision shouldClusterFilter(RoutingNode node, RoutingAllocation allocation) { if (clusterRequireFilters != null) { if (clusterRequireFilters.match(node.node()) == false) { return allocation.decision(Decision.NO, NAME, "node does not match cluster setting [%s] filters [%s]", CLUSTER_ROUTING_REQUIRE_GROUP_PREFIX, clusterRequireFilters); } } if (clusterIncludeFilters != null) { if (clusterIncludeFilters.match(node.node()) == false) { return allocation.decision(Decision.NO, NAME, "node does not cluster setting [%s] filters [%s]", CLUSTER_ROUTING_INCLUDE_GROUP_PREFIX, clusterIncludeFilters); } } if (clusterExcludeFilters != null) { if (clusterExcludeFilters.match(node.node())) { return allocation.decision(Decision.NO, NAME, "node matches cluster setting [%s] filters [%s]", CLUSTER_ROUTING_EXCLUDE_GROUP_PREFIX, clusterExcludeFilters); } } return null; }
private void setClusterExcludeFilters(Map<String, String> filters) { clusterExcludeFilters = DiscoveryNodeFilters.buildFromKeyValue(OR, filters); } }
private Decision shouldIndexFilter(IndexMetaData indexMd, RoutingNode node, RoutingAllocation allocation) { if (indexMd.requireFilters() != null) { if (indexMd.requireFilters().match(node.node()) == false) { return allocation.decision(Decision.NO, NAME, "node does not match index setting [%s] filters [%s]", IndexMetaData.INDEX_ROUTING_REQUIRE_GROUP_PREFIX, indexMd.requireFilters()); } } if (indexMd.includeFilters() != null) { if (indexMd.includeFilters().match(node.node()) == false) { return allocation.decision(Decision.NO, NAME, "node does not match index setting [%s] filters [%s]", IndexMetaData.INDEX_ROUTING_INCLUDE_GROUP_PREFIX, indexMd.includeFilters()); } } if (indexMd.excludeFilters() != null) { if (indexMd.excludeFilters().match(node.node())) { return allocation.decision(Decision.NO, NAME, "node matches index setting [%s] filters [%s]", IndexMetaData.INDEX_ROUTING_EXCLUDE_GROUP_SETTING.getKey(), indexMd.excludeFilters()); } } return null; }
public static DiscoveryNodeFilters buildFromKeyValue(OpType opType, Map<String, String> filters) { Map<String, String[]> bFilters = new HashMap<>(); for (Map.Entry<String, String> entry : filters.entrySet()) { String[] values = Strings.tokenizeToStringArray(entry.getValue(), ","); if (values.length > 0) { bFilters.put(entry.getKey(), values); } } if (bFilters.isEmpty()) { return null; } return new DiscoveryNodeFilters(opType, bFilters); }
private void setClusterIncludeFilters(Map<String, String> filters) { clusterIncludeFilters = DiscoveryNodeFilters.buildFromKeyValue(OR, filters); } private void setClusterExcludeFilters(Map<String, String> filters) {
@Override public Decision canAllocate(ShardRouting shardRouting, RoutingNode node, RoutingAllocation allocation) { if (shardRouting.unassigned()) { // only for unassigned - we filter allocation right after the index creation ie. for shard shrinking etc. to ensure // that once it has been allocated post API the replicas can be allocated elsewhere without user interaction // this is a setting that can only be set within the system! IndexMetaData indexMd = allocation.metaData().getIndexSafe(shardRouting.index()); DiscoveryNodeFilters initialRecoveryFilters = indexMd.getInitialRecoveryFilters(); if (initialRecoveryFilters != null && INITIAL_RECOVERY_TYPES.contains(shardRouting.recoverySource().getType()) && initialRecoveryFilters.match(node.node()) == false) { String explanation = (shardRouting.recoverySource().getType() == RecoverySource.Type.LOCAL_SHARDS) ? "initial allocation of the shrunken index is only allowed on nodes [%s] that hold a copy of every shard in the index" : "initial allocation of the index is only allowed on nodes [%s]"; return allocation.decision(Decision.NO, NAME, explanation, initialRecoveryFilters); } } return shouldFilter(shardRouting, node, allocation); }
public static DiscoveryNodeFilters buildFromKeyValue(OpType opType, Map<String, String> filters) { Map<String, String[]> bFilters = new HashMap<>(); for (Map.Entry<String, String> entry : filters.entrySet()) { String[] values = Strings.tokenizeToStringArray(entry.getValue(), ","); if (values.length > 0) { bFilters.put(entry.getKey(), values); } } if (bFilters.isEmpty()) { return null; } return new DiscoveryNodeFilters(opType, bFilters); }
requireFilters = null; } else { requireFilters = DiscoveryNodeFilters.buildFromKeyValue(AND, requireMap); includeFilters = null; } else { includeFilters = DiscoveryNodeFilters.buildFromKeyValue(OR, includeMap); excludeFilters = null; } else { excludeFilters = DiscoveryNodeFilters.buildFromKeyValue(OR, excludeMap); initialRecoveryFilters = null; } else { initialRecoveryFilters = DiscoveryNodeFilters.buildFromKeyValue(OR, initialRecoveryMap);
private Decision shouldClusterFilter(RoutingNode node, RoutingAllocation allocation) { if (clusterRequireFilters != null) { if (!clusterRequireFilters.match(node.node())) { return allocation.decision(Decision.NO, NAME, "node does not match global required filters [%s]", clusterRequireFilters); } } if (clusterIncludeFilters != null) { if (!clusterIncludeFilters.match(node.node())) { return allocation.decision(Decision.NO, NAME, "node does not match global include filters [%s]", clusterIncludeFilters); } } if (clusterExcludeFilters != null) { if (clusterExcludeFilters.match(node.node())) { return allocation.decision(Decision.NO, NAME, "node matches global exclude filters [%s]", clusterExcludeFilters); } } return null; }
public static DiscoveryNodeFilters buildFromKeyValue(OpType opType, Map<String, String> filters) { Map<String, String[]> bFilters = new HashMap<>(); for (Map.Entry<String, String> entry : filters.entrySet()) { String[] values = Strings.tokenizeToStringArray(entry.getValue(), ","); if (values.length > 0) { bFilters.put(entry.getKey(), values); } } if (bFilters.isEmpty()) { return null; } return new DiscoveryNodeFilters(opType, bFilters); }
private void setClusterExcludeFilters(Map<String, String> filters) { clusterExcludeFilters = DiscoveryNodeFilters.buildFromKeyValue(OR, filters); } }
private Decision shouldClusterFilter(RoutingNode node, RoutingAllocation allocation) { if (clusterRequireFilters != null) { if (clusterRequireFilters.match(node.node()) == false) { return allocation.decision(Decision.NO, NAME, "node does not match cluster setting [%s] filters [%s]", CLUSTER_ROUTING_REQUIRE_GROUP_PREFIX, clusterRequireFilters); } } if (clusterIncludeFilters != null) { if (clusterIncludeFilters.match(node.node()) == false) { return allocation.decision(Decision.NO, NAME, "node does not cluster setting [%s] filters [%s]", CLUSTER_ROUTING_INCLUDE_GROUP_PREFIX, clusterIncludeFilters); } } if (clusterExcludeFilters != null) { if (clusterExcludeFilters.match(node.node())) { return allocation.decision(Decision.NO, NAME, "node matches cluster setting [%s] filters [%s]", CLUSTER_ROUTING_EXCLUDE_GROUP_PREFIX, clusterExcludeFilters); } } return null; }
public static DiscoveryNodeFilters buildFromKeyValue(OpType opType, Map<String, String> filters) { Map<String, String[]> bFilters = new HashMap<>(); for (Map.Entry<String, String> entry : filters.entrySet()) { String[] values = Strings.splitStringByCommaToArray(entry.getValue()); if (values.length > 0) { bFilters.put(entry.getKey(), values); } } if (bFilters.isEmpty()) { return null; } return new DiscoveryNodeFilters(opType, bFilters); }