mirror of
https://github.com/apache/lucene.git
synced 2025-02-28 13:29:26 +00:00
SOLR-13504: improve autoscaling syntax by adding a nodeset attribute (#691)
SOLR-13504: In autoscaling policies, use an explicit 'nodeset' attribute for filtering nodes instead of using them directly at the toplevel
This commit is contained in:
parent
0c15f638e9
commit
1ff7b2942c
@ -99,6 +99,9 @@ New Features
|
|||||||
|
|
||||||
* SOLR-13494: Add DeepRandomStream implementation (Joel Bernstein)
|
* SOLR-13494: Add DeepRandomStream implementation (Joel Bernstein)
|
||||||
|
|
||||||
|
* SOLR-13504: In autoscaling policies, use an explicit 'nodeset' attribute for filtering
|
||||||
|
nodes instead of using them directly at the toplevel (noble)
|
||||||
|
|
||||||
Bug Fixes
|
Bug Fixes
|
||||||
----------------------
|
----------------------
|
||||||
|
|
||||||
|
@ -56,12 +56,14 @@ import static org.apache.solr.common.util.Utils.toJSONString;
|
|||||||
* Represents a set of conditions in the policy
|
* Represents a set of conditions in the policy
|
||||||
*/
|
*/
|
||||||
public class Clause implements MapWriter, Comparable<Clause> {
|
public class Clause implements MapWriter, Comparable<Clause> {
|
||||||
private static final Set<String> IGNORE_TAGS = new HashSet<>(Arrays.asList(REPLICA, COLLECTION, SHARD, "strict", "type"));
|
public static final String NODESET = "nodeset";
|
||||||
|
private static final Set<String> IGNORE_TAGS = new HashSet<>(Arrays.asList(REPLICA, COLLECTION, SHARD, "strict", "type", "put", NODESET));
|
||||||
|
|
||||||
private final int hashCode;
|
private final int hashCode;
|
||||||
final boolean hasComputedValue;
|
final boolean hasComputedValue;
|
||||||
final Map<String, Object> original;
|
final Map<String, Object> original;
|
||||||
final Clause derivedFrom;
|
final Clause derivedFrom;
|
||||||
|
private boolean nodeSetPresent = false;
|
||||||
Condition collection, shard, replica, tag, globalTag;
|
Condition collection, shard, replica, tag, globalTag;
|
||||||
final Replica.Type type;
|
final Replica.Type type;
|
||||||
boolean strict;
|
boolean strict;
|
||||||
@ -70,6 +72,7 @@ public class Clause implements MapWriter, Comparable<Clause> {
|
|||||||
this.original = clause.original;
|
this.original = clause.original;
|
||||||
this.hashCode = original.hashCode();
|
this.hashCode = original.hashCode();
|
||||||
this.type = clause.type;
|
this.type = clause.type;
|
||||||
|
this.nodeSetPresent = clause.nodeSetPresent;
|
||||||
this.collection = clause.collection;
|
this.collection = clause.collection;
|
||||||
this.shard = clause.shard;
|
this.shard = clause.shard;
|
||||||
this.tag = evaluateValue(clause.tag, computedValueEvaluator);
|
this.tag = evaluateValue(clause.tag, computedValueEvaluator);
|
||||||
@ -81,7 +84,7 @@ public class Clause implements MapWriter, Comparable<Clause> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// internal use only
|
// internal use only
|
||||||
Clause(Map<String, Object> original, Condition tag, Condition globalTag, boolean isStrict) {
|
Clause(Map<String, Object> original, Condition tag, Condition globalTag, boolean isStrict, boolean nodeSetPresent) {
|
||||||
this.hashCode = original.hashCode();
|
this.hashCode = original.hashCode();
|
||||||
this.original = original;
|
this.original = original;
|
||||||
this.tag = tag;
|
this.tag = tag;
|
||||||
@ -91,6 +94,7 @@ public class Clause implements MapWriter, Comparable<Clause> {
|
|||||||
this.hasComputedValue = false;
|
this.hasComputedValue = false;
|
||||||
this.strict = isStrict;
|
this.strict = isStrict;
|
||||||
derivedFrom = null;
|
derivedFrom = null;
|
||||||
|
this.nodeSetPresent = nodeSetPresent;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Clause(Map<String, Object> m) {
|
private Clause(Map<String, Object> m) {
|
||||||
@ -117,7 +121,9 @@ public class Clause implements MapWriter, Comparable<Clause> {
|
|||||||
}
|
}
|
||||||
this.replica = parse(REPLICA, m);
|
this.replica = parse(REPLICA, m);
|
||||||
if (replica.op == WILDCARD) throw new IllegalArgumentException("replica val cannot be null" + toJSONString(m));
|
if (replica.op == WILDCARD) throw new IllegalArgumentException("replica val cannot be null" + toJSONString(m));
|
||||||
m.forEach(this::parseCondition);
|
|
||||||
|
this.nodeSetPresent = parseNodeset(m);
|
||||||
|
m.forEach((s, o) -> parseCondition(s, o, m));
|
||||||
}
|
}
|
||||||
if (tag == null)
|
if (tag == null)
|
||||||
throw new RuntimeException("Invalid op, must have one and only one tag other than collection, shard,replica " + toJSONString(m));
|
throw new RuntimeException("Invalid op, must have one and only one tag other than collection, shard,replica " + toJSONString(m));
|
||||||
@ -131,9 +137,33 @@ public class Clause implements MapWriter, Comparable<Clause> {
|
|||||||
hasComputedValue = hasComputedValue();
|
hasComputedValue = hasComputedValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean parseNodeset(Map<String, Object> m) {
|
||||||
|
if (!m.containsKey(NODESET)) return false;
|
||||||
|
Object o = m.get(NODESET);
|
||||||
|
if (o instanceof Map) {
|
||||||
|
Map map = (Map) o;
|
||||||
|
if (map.size() != 1) {
|
||||||
|
throwExp(m, "nodeset must only have one and only one key");
|
||||||
|
}
|
||||||
|
String key = (String) map.keySet().iterator().next();
|
||||||
|
parseCondition(key, o, m);
|
||||||
|
} else if (o instanceof List) {
|
||||||
|
List l = (List) o;
|
||||||
|
for (Object it : l) {
|
||||||
|
if (it instanceof String) continue;
|
||||||
|
else throwExp(m, "nodeset :[]must have only string values");
|
||||||
|
}
|
||||||
|
parseCondition("node", o, m);
|
||||||
|
} else {
|
||||||
|
throwExp(m, "invalid value for nodeset, must be an object or a list of String");
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public Condition getThirdTag() {
|
public Condition getThirdTag() {
|
||||||
return globalTag == null ? tag : globalTag;
|
return globalTag == null ? tag : globalTag;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doPostValidate(Condition... conditions) {
|
private void doPostValidate(Condition... conditions) {
|
||||||
for (Condition condition : conditions) {
|
for (Condition condition : conditions) {
|
||||||
if (condition == null) continue;
|
if (condition == null) continue;
|
||||||
@ -198,12 +228,12 @@ public class Clause implements MapWriter, Comparable<Clause> {
|
|||||||
return globalTag == null;
|
return globalTag == null;
|
||||||
}
|
}
|
||||||
|
|
||||||
void parseCondition(String s, Object o) {
|
void parseCondition(String s, Object o, Map m) {
|
||||||
if (IGNORE_TAGS.contains(s)) return;
|
if (IGNORE_TAGS.contains(s)) return;
|
||||||
if (tag != null) {
|
if (tag != null) {
|
||||||
throw new IllegalArgumentException("Only one tag other than collection, shard, replica is possible");
|
throwExp(m, "Only one tag other than collection, shard, replica is possible");
|
||||||
}
|
}
|
||||||
tag = parse(s, singletonMap(s, o));
|
tag = parse(s, o instanceof Map? (Map<String, Object>) o : singletonMap(s, o));
|
||||||
}
|
}
|
||||||
|
|
||||||
private int compareTypes(Replica.Type t1, Replica.Type t2) {
|
private int compareTypes(Replica.Type t1, Replica.Type t2) {
|
||||||
@ -249,7 +279,7 @@ public class Clause implements MapWriter, Comparable<Clause> {
|
|||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (this == o) return true;
|
if (this == o) return true;
|
||||||
if (!(o instanceof Clause)) return false;
|
if (!(o instanceof Clause)) return false;
|
||||||
Clause that = (Clause)o;
|
Clause that = (Clause) o;
|
||||||
return Objects.equals(this.original, that.original);
|
return Objects.equals(this.original, that.original);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -265,14 +295,14 @@ public class Clause implements MapWriter, Comparable<Clause> {
|
|||||||
new SealedClause(this, computedValueEvaluator);
|
new SealedClause(this, computedValueEvaluator);
|
||||||
}
|
}
|
||||||
|
|
||||||
Condition parse(String s, Map<String,Object> m) {
|
Condition parse(String s, Map<String, Object> m) {
|
||||||
|
|
||||||
Object expectedVal = null;
|
Object expectedVal = null;
|
||||||
ComputedType computedType = null;
|
ComputedType computedType = null;
|
||||||
Object val = m.get(s);
|
Object val = m.get(s);
|
||||||
Type varType = VariableBase.getTagType(s);
|
Type varType = VariableBase.getTagType(s);
|
||||||
if (varType.meta.isHidden()) {
|
if (varType.meta.isHidden()) {
|
||||||
throwExp(m,"''{0}'' is not allowed", varType.tagName);
|
throwExp(m, "''{0}'' is not allowed", varType.tagName);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
String conditionName = s.trim();
|
String conditionName = s.trim();
|
||||||
@ -297,12 +327,12 @@ public class Clause implements MapWriter, Comparable<Clause> {
|
|||||||
computedType = t;
|
computedType = t;
|
||||||
strVal = changedVal;
|
strVal = changedVal;
|
||||||
if (varType == null || !varType.supportedComputedTypes.contains(computedType)) {
|
if (varType == null || !varType.supportedComputedTypes.contains(computedType)) {
|
||||||
throwExp(m,"''{0}'' is not allowed for variable : ''{1}''",t,conditionName);
|
throwExp(m, "''{0}'' is not allowed for variable : ''{1}''", t, conditionName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (computedType == null && ((String) val).charAt(0) == '#' && !varType.wildCards.contains(val)) {
|
if (computedType == null && ((String) val).charAt(0) == '#' && !varType.wildCards.contains(val)) {
|
||||||
throwExp(m, "''{0}'' is not an allowed value for ''{1}'', supported value is : {2} ", val, conditionName, varType.wildCards );
|
throwExp(m, "''{0}'' is not an allowed value for ''{1}'', supported value is : {2} ", val, conditionName, varType.wildCards);
|
||||||
|
|
||||||
}
|
}
|
||||||
operand = varType == null ? operand : varType.getOperand(operand, strVal, computedType);
|
operand = varType == null ? operand : varType.getOperand(operand, strVal, computedType);
|
||||||
@ -318,16 +348,16 @@ public class Clause implements MapWriter, Comparable<Clause> {
|
|||||||
} catch (IllegalArgumentException iae) {
|
} catch (IllegalArgumentException iae) {
|
||||||
throw iae;
|
throw iae;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throwExp(m, "Invalid tag : {0} ",s );
|
throwExp(m, "Invalid tag : {0} ", s);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void throwExp(Map<String, Object> clause, String msg, Object... args) {
|
public static void throwExp(Map clause, String msg, Object... args) {
|
||||||
throw new IllegalArgumentException("syntax error in clause :"+ toJSONString(clause)+ " , msg: "+ formatString(msg, args));
|
throw new IllegalArgumentException("syntax error in clause :" + toJSONString(clause) + " , msg: " + formatString(msg, args));
|
||||||
}
|
}
|
||||||
|
|
||||||
private List readListVal(Map m, List val, Type varType, String conditionName) {
|
private static List readListVal(Map m, List val, Type varType, String conditionName) {
|
||||||
List list = val;
|
List list = val;
|
||||||
list = (List) list.stream()
|
list = (List) list.stream()
|
||||||
.map(it -> varType.validate(conditionName, it, true))
|
.map(it -> varType.validate(conditionName, it, true))
|
||||||
@ -360,7 +390,7 @@ public class Clause implements MapWriter, Comparable<Clause> {
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Operand getOperand(String strVal) {
|
private static Operand getOperand(String strVal) {
|
||||||
Operand operand;
|
Operand operand;
|
||||||
if (Policy.ANY.equals(strVal) || Policy.EACH.equals(strVal)) operand = WILDCARD;
|
if (Policy.ANY.equals(strVal) || Policy.EACH.equals(strVal)) operand = WILDCARD;
|
||||||
else if (strVal.startsWith(NOT_EQUAL.operand)) operand = NOT_EQUAL;
|
else if (strVal.startsWith(NOT_EQUAL.operand)) operand = NOT_EQUAL;
|
||||||
@ -456,6 +486,7 @@ public class Clause implements MapWriter, Comparable<Clause> {
|
|||||||
public static long addReplicaCountsForNode = 0;
|
public static long addReplicaCountsForNode = 0;
|
||||||
public static long addReplicaCountsForNodeCacheMiss = 0;
|
public static long addReplicaCountsForNodeCacheMiss = 0;
|
||||||
public static final String PERSHARD_REPLICAS = Clause.class.getSimpleName() + ".perShardReplicas";
|
public static final String PERSHARD_REPLICAS = Clause.class.getSimpleName() + ".perShardReplicas";
|
||||||
|
|
||||||
private void addReplicaCountsForNode(ComputedValueEvaluator computedValueEvaluator, ReplicaCount replicaCount, Row node) {
|
private void addReplicaCountsForNode(ComputedValueEvaluator computedValueEvaluator, ReplicaCount replicaCount, Row node) {
|
||||||
addReplicaCountsForNode++;
|
addReplicaCountsForNode++;
|
||||||
|
|
||||||
@ -537,6 +568,10 @@ public class Clause implements MapWriter, Comparable<Clause> {
|
|||||||
|
|
||||||
public List<Violation> test(Policy.Session session, double[] deviations) {
|
public List<Violation> test(Policy.Session session, double[] deviations) {
|
||||||
if (isPerCollectiontag()) {
|
if (isPerCollectiontag()) {
|
||||||
|
if(nodeSetPresent) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
return tag.varType == Type.NODE ||
|
return tag.varType == Type.NODE ||
|
||||||
(tag.varType.meta.isNodeSpecificVal() && replica.computedType == null) ?
|
(tag.varType.meta.isNodeSpecificVal() && replica.computedType == null) ?
|
||||||
testPerNode(session, deviations) :
|
testPerNode(session, deviations) :
|
||||||
|
@ -557,7 +557,7 @@ public class Policy implements MapWriter {
|
|||||||
if (!withCollMap.isEmpty()) {
|
if (!withCollMap.isEmpty()) {
|
||||||
Clause withCollClause = new Clause((Map<String,Object>)Utils.fromJSONString("{withCollection:'*' , node: '#ANY'}") ,
|
Clause withCollClause = new Clause((Map<String,Object>)Utils.fromJSONString("{withCollection:'*' , node: '#ANY'}") ,
|
||||||
new Condition(NODE.tagName, "#ANY", Operand.EQUAL, null, null),
|
new Condition(NODE.tagName, "#ANY", Operand.EQUAL, null, null),
|
||||||
new Condition(WITH_COLLECTION.tagName,"*" , Operand.EQUAL, null, null), true
|
new Condition(WITH_COLLECTION.tagName,"*" , Operand.EQUAL, null, null), true, false
|
||||||
);
|
);
|
||||||
expandedClauses.add(withCollClause);
|
expandedClauses.add(withCollClause);
|
||||||
}
|
}
|
||||||
|
@ -86,8 +86,12 @@ import static org.apache.solr.common.params.CollectionParams.CollectionAction.AD
|
|||||||
import static org.apache.solr.common.params.CollectionParams.CollectionAction.MOVEREPLICA;
|
import static org.apache.solr.common.params.CollectionParams.CollectionAction.MOVEREPLICA;
|
||||||
|
|
||||||
public class TestPolicy extends SolrTestCaseJ4 {
|
public class TestPolicy extends SolrTestCaseJ4 {
|
||||||
|
boolean useNodeset ;
|
||||||
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
|
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
|
||||||
|
|
||||||
|
public TestPolicy(){
|
||||||
|
useNodeset = true;
|
||||||
|
}
|
||||||
static Suggester createSuggester(SolrCloudManager cloudManager, Map jsonObj, Suggester seed) throws IOException, InterruptedException {
|
static Suggester createSuggester(SolrCloudManager cloudManager, Map jsonObj, Suggester seed) throws IOException, InterruptedException {
|
||||||
Policy.Session session = null;
|
Policy.Session session = null;
|
||||||
if (seed != null) session = seed.session;
|
if (seed != null) session = seed.session;
|
||||||
@ -696,6 +700,20 @@ public class TestPolicy extends SolrTestCaseJ4 {
|
|||||||
|
|
||||||
expectThrows(IllegalArgumentException.class,
|
expectThrows(IllegalArgumentException.class,
|
||||||
() -> Clause.create("{cores: '>14%' , node:'#ANY'}"));
|
() -> Clause.create("{cores: '>14%' , node:'#ANY'}"));
|
||||||
|
clause = Clause.create("{replica:1, nodeset : {sysprop.zone : east}}");
|
||||||
|
assertEquals(Variable.Type.STRING, clause.tag.varType);
|
||||||
|
clause =Clause.create("{replica:1, nodeset : [node1, node2, node3]}");
|
||||||
|
assertEquals(Variable.Type.NODE, clause.tag.varType);
|
||||||
|
assertEquals(Operand.IN, clause.tag.op);
|
||||||
|
|
||||||
|
expectThrows(IllegalArgumentException.class,
|
||||||
|
() -> Clause.create("{replica:1, node: n1, nodeset : {sysprop.zone : east}}"));
|
||||||
|
|
||||||
|
IllegalArgumentException exp = expectThrows(IllegalArgumentException.class,
|
||||||
|
() -> Clause.create("{replica:1, nodeset : {sysprop.zone : east , port: 8983 }}"));
|
||||||
|
assertTrue(exp.getMessage().contains("nodeset must only have one and only one key"));
|
||||||
|
clause = Clause.create("{'replica': '#ALL', 'nodeset': {'freedisk': '>700'}, 'strict': false}");
|
||||||
|
assertEquals(Operand.GREATER_THAN , clause.tag.op);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -976,6 +994,19 @@ public class TestPolicy extends SolrTestCaseJ4 {
|
|||||||
" { 'replica': '<2', 'shard': '#EACH', 'node': '#ANY'}," +
|
" { 'replica': '<2', 'shard': '#EACH', 'node': '#ANY'}," +
|
||||||
" ]" +
|
" ]" +
|
||||||
"}");
|
"}");
|
||||||
|
|
||||||
|
if(useNodeset) {
|
||||||
|
policies = (Map) Utils.fromJSONString("{" +
|
||||||
|
" 'cluster-preferences': [" +
|
||||||
|
" { 'maximize': 'freedisk', 'precision': 50}," +
|
||||||
|
" { 'minimize': 'cores', 'precision': 50}" +
|
||||||
|
" ]," +
|
||||||
|
" 'cluster-policy': [" +
|
||||||
|
" { 'replica': 0, nodeset:{'nodeRole': 'overseer'}}" +
|
||||||
|
" { 'replica': '<2', 'shard': '#EACH', 'node': '#ANY'}," +
|
||||||
|
" ]" +
|
||||||
|
"}");
|
||||||
|
}
|
||||||
AutoScalingConfig config = new AutoScalingConfig(policies);
|
AutoScalingConfig config = new AutoScalingConfig(policies);
|
||||||
Policy policy = config.getPolicy();
|
Policy policy = config.getPolicy();
|
||||||
Policy.Session session = policy.createSession(provider);
|
Policy.Session session = policy.createSession(provider);
|
||||||
@ -1011,6 +1042,19 @@ public class TestPolicy extends SolrTestCaseJ4 {
|
|||||||
" { 'replica': '<3', 'shard': '#EACH', 'node': '#ANY'}," +
|
" { 'replica': '<3', 'shard': '#EACH', 'node': '#ANY'}," +
|
||||||
" ]" +
|
" ]" +
|
||||||
"}");
|
"}");
|
||||||
|
if(useNodeset){
|
||||||
|
policies = (Map) Utils.fromJSONString("{" +
|
||||||
|
" 'cluster-preferences': [" +
|
||||||
|
" { 'maximize': 'freedisk', 'precision': 50}," +
|
||||||
|
" { 'minimize': 'cores', 'precision': 50}" +
|
||||||
|
" ]," +
|
||||||
|
" 'cluster-policy': [" +
|
||||||
|
" { 'replica': 0, nodeset: {'nodeRole': 'overseer'}}" +
|
||||||
|
" { 'replica': '<3', 'shard': '#EACH', 'node': '#ANY'}," +
|
||||||
|
" ]" +
|
||||||
|
"}");
|
||||||
|
|
||||||
|
}
|
||||||
config = new AutoScalingConfig(policies);
|
config = new AutoScalingConfig(policies);
|
||||||
policy = config.getPolicy();
|
policy = config.getPolicy();
|
||||||
session = policy.createSession(provider);
|
session = policy.createSession(provider);
|
||||||
@ -1055,6 +1099,20 @@ public class TestPolicy extends SolrTestCaseJ4 {
|
|||||||
" { 'replica': '<3', 'shard': 'shard2', 'node': '#ANY'}," +
|
" { 'replica': '<3', 'shard': 'shard2', 'node': '#ANY'}," +
|
||||||
" ]" +
|
" ]" +
|
||||||
"}");
|
"}");
|
||||||
|
if(useNodeset){
|
||||||
|
policies = (Map) Utils.fromJSONString("{" +
|
||||||
|
" 'cluster-preferences': [" +
|
||||||
|
" { 'maximize': 'freedisk', 'precision': 50}," +
|
||||||
|
" { 'minimize': 'cores', 'precision': 50}" +
|
||||||
|
" ]," +
|
||||||
|
" 'cluster-policy': [" +
|
||||||
|
" { 'replica': 0, nodeset:{'nodeRole': 'overseer'}}" +
|
||||||
|
" { 'replica': '<2', 'shard': 'shard1', 'node': '#ANY'}," +
|
||||||
|
" { 'replica': '<3', 'shard': 'shard2', 'node': '#ANY'}," +
|
||||||
|
" ]" +
|
||||||
|
"}");
|
||||||
|
|
||||||
|
}
|
||||||
config = new AutoScalingConfig(policies);
|
config = new AutoScalingConfig(policies);
|
||||||
policy = config.getPolicy();
|
policy = config.getPolicy();
|
||||||
session = policy.createSession(provider);
|
session = policy.createSession(provider);
|
||||||
@ -1167,6 +1225,21 @@ public class TestPolicy extends SolrTestCaseJ4 {
|
|||||||
" { 'replica': 0, 'shard': '#EACH', sysprop.fs : '!slowdisk' , type : PULL }" +
|
" { 'replica': 0, 'shard': '#EACH', sysprop.fs : '!slowdisk' , type : PULL }" +
|
||||||
" ]" +
|
" ]" +
|
||||||
"}");
|
"}");
|
||||||
|
if(useNodeset){
|
||||||
|
policies = (Map) Utils.fromJSONString("{" +
|
||||||
|
" 'cluster-preferences': [" +
|
||||||
|
" { 'maximize': 'freedisk', 'precision': 50}," +
|
||||||
|
" { 'minimize': 'cores', 'precision': 50}" +
|
||||||
|
" ]," +
|
||||||
|
" 'cluster-policy': [" +
|
||||||
|
" { 'replica': 0, nodeset : {'nodeRole': 'overseer'}}" +
|
||||||
|
" { 'replica': '<2', 'shard': '#EACH', 'node': '#ANY'}," +
|
||||||
|
" { 'replica': 0, 'shard': '#EACH', nodeset : { sysprop.fs : '!ssd'}, type : TLOG }" +
|
||||||
|
" { 'replica': 0, 'shard': '#EACH', nodeset : {sysprop.fs : '!slowdisk'} , type : PULL }" +
|
||||||
|
" ]" +
|
||||||
|
"}");
|
||||||
|
|
||||||
|
}
|
||||||
Map<String, Map> nodeValues = (Map<String, Map>) Utils.fromJSONString("{" +
|
Map<String, Map> nodeValues = (Map<String, Map>) Utils.fromJSONString("{" +
|
||||||
"node1:{cores:12, freedisk: 334, heapUsage:10480, rack: rack4, sysprop.fs: slowdisk}," +
|
"node1:{cores:12, freedisk: 334, heapUsage:10480, rack: rack4, sysprop.fs: slowdisk}," +
|
||||||
"node2:{cores:4, freedisk: 749, heapUsage:6873, rack: rack3, sysprop.fs: unknown }," +
|
"node2:{cores:4, freedisk: 749, heapUsage:6873, rack: rack3, sysprop.fs: unknown }," +
|
||||||
@ -1276,6 +1349,23 @@ public class TestPolicy extends SolrTestCaseJ4 {
|
|||||||
" { 'replica': 0, 'shard': '#EACH', sysprop.fs : '!slowdisk' , type : PULL }" +
|
" { 'replica': 0, 'shard': '#EACH', sysprop.fs : '!slowdisk' , type : PULL }" +
|
||||||
" ]" +
|
" ]" +
|
||||||
"}");
|
"}");
|
||||||
|
if(useNodeset){
|
||||||
|
policies = (Map) Utils.fromJSONString("{" +
|
||||||
|
" 'cluster-preferences': [" +
|
||||||
|
" { 'maximize': 'freedisk', 'precision': 50}," +
|
||||||
|
" { 'minimize': 'cores', 'precision': 1}" +
|
||||||
|
" ]," +
|
||||||
|
" 'cluster-policy': [" +
|
||||||
|
" { 'replica': 0, nodeset : {'nodeRole': 'overseer'}}" +
|
||||||
|
" { 'replica': '<2', 'shard': '#EACH', 'node': '#ANY', 'collection':'newColl'}," +
|
||||||
|
" { 'replica': '<2', 'shard': '#EACH', 'node': '#ANY', 'collection':'newColl2', type : PULL}," +
|
||||||
|
" { 'replica': '<3', 'shard': '#EACH', 'node': '#ANY', 'collection':'newColl2'}," +
|
||||||
|
" { 'replica': 0, 'shard': '#EACH', nodeset:{ sysprop.fs : '!ssd'}, type : TLOG }" +
|
||||||
|
" { 'replica': 0, 'shard': '#EACH', nodeset : {sysprop.fs : '!slowdisk'} , type : PULL }" +
|
||||||
|
" ]" +
|
||||||
|
"}");
|
||||||
|
|
||||||
|
}
|
||||||
Map<String, Map> nodeValues = (Map<String, Map>) Utils.fromJSONString("{" +
|
Map<String, Map> nodeValues = (Map<String, Map>) Utils.fromJSONString("{" +
|
||||||
"node1:{cores:12, freedisk: 334, heapUsage:10480, rack: rack4, sysprop.fs: slowdisk}," +
|
"node1:{cores:12, freedisk: 334, heapUsage:10480, rack: rack4, sysprop.fs: slowdisk}," +
|
||||||
"node2:{cores:4, freedisk: 749, heapUsage:6873, rack: rack3, sysprop.fs: unknown}," +
|
"node2:{cores:4, freedisk: 749, heapUsage:6873, rack: rack3, sysprop.fs: unknown}," +
|
||||||
@ -1400,6 +1490,26 @@ public class TestPolicy extends SolrTestCaseJ4 {
|
|||||||
" ]" +
|
" ]" +
|
||||||
" }" +
|
" }" +
|
||||||
"}");
|
"}");
|
||||||
|
if(useNodeset){
|
||||||
|
map = (Map) Utils.fromJSONString("{" +
|
||||||
|
" 'cluster-preferences': [" +
|
||||||
|
" { 'maximize': 'freedisk', 'precision': 50}," +
|
||||||
|
" { 'minimize': 'cores', 'precision': 50}" +
|
||||||
|
" ]," +
|
||||||
|
" 'cluster-policy': [" +
|
||||||
|
" { 'replica': 0, nodeset: {'nodeRole': 'overseer'}}," +
|
||||||
|
" { 'replica': '<2', 'shard': '#EACH', 'node': '#ANY'}" +
|
||||||
|
" ]," +
|
||||||
|
" 'policies': {" +
|
||||||
|
" 'policy1': [" +
|
||||||
|
" { 'replica': '1', nodeset:{ 'sysprop.fs': 'ssd'}, 'shard': '#EACH'}," +
|
||||||
|
" { 'replica': '<2', 'shard': '#ANY', 'node': '#ANY'}," +
|
||||||
|
" { 'replica': '<2', 'shard': '#EACH',nodeset:{ 'sysprop.rack': 'rack1'}}" +
|
||||||
|
" ]" +
|
||||||
|
" }" +
|
||||||
|
"}");
|
||||||
|
|
||||||
|
}
|
||||||
Policy policy = new Policy(map);
|
Policy policy = new Policy(map);
|
||||||
List<Clause> clauses = Policy.mergePolicies("mycoll", policy.getPolicies().get("policy1"), policy.getClusterPolicy());
|
List<Clause> clauses = Policy.mergePolicies("mycoll", policy.getPolicies().get("policy1"), policy.getClusterPolicy());
|
||||||
Collections.sort(clauses);
|
Collections.sort(clauses);
|
||||||
@ -1407,8 +1517,8 @@ public class TestPolicy extends SolrTestCaseJ4 {
|
|||||||
assertEquals("1", String.valueOf(clauses.get(0).original.get("replica")));
|
assertEquals("1", String.valueOf(clauses.get(0).original.get("replica")));
|
||||||
assertEquals("0", String.valueOf(clauses.get(1).original.get("replica")));
|
assertEquals("0", String.valueOf(clauses.get(1).original.get("replica")));
|
||||||
assertEquals("#ANY", clauses.get(3).original.get("shard"));
|
assertEquals("#ANY", clauses.get(3).original.get("shard"));
|
||||||
assertEquals("rack1", clauses.get(2).original.get("sysprop.rack"));
|
assertEquals("rack1", clauses.get(2).tag.val);
|
||||||
assertEquals("overseer", clauses.get(1).original.get("nodeRole"));
|
assertEquals("overseer",clauses.get(1).tag.val);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testConditionsSort() {
|
public void testConditionsSort() {
|
||||||
@ -1419,6 +1529,16 @@ public class TestPolicy extends SolrTestCaseJ4 {
|
|||||||
" { 'replica':'<2', 'node':'#ANY', 'shard':'#EACH'}," +
|
" { 'replica':'<2', 'node':'#ANY', 'shard':'#EACH'}," +
|
||||||
" { 'replica':1, 'sysprop.rack':'rack1'}]" +
|
" { 'replica':1, 'sysprop.rack':'rack1'}]" +
|
||||||
" }";
|
" }";
|
||||||
|
if(useNodeset){
|
||||||
|
rules = "{" +
|
||||||
|
" 'cluster-policy':[" +
|
||||||
|
" { 'nodeRole':'overseer', replica: 0, 'strict':false}," +
|
||||||
|
" { 'replica':'<1', 'node':'node3', 'shard':'#EACH'}," +
|
||||||
|
" { 'replica':'<2', 'node':'#ANY', 'shard':'#EACH'}," +
|
||||||
|
" { 'replica':1, nodeset: {'sysprop.rack':'rack1'}}]" +
|
||||||
|
" }";
|
||||||
|
|
||||||
|
}
|
||||||
Policy p = new Policy((Map<String, Object>) Utils.fromJSONString(rules));
|
Policy p = new Policy((Map<String, Object>) Utils.fromJSONString(rules));
|
||||||
List<Clause> clauses = new ArrayList<>(p.getClusterPolicy());
|
List<Clause> clauses = new ArrayList<>(p.getClusterPolicy());
|
||||||
Collections.sort(clauses);
|
Collections.sort(clauses);
|
||||||
@ -1436,6 +1556,17 @@ public class TestPolicy extends SolrTestCaseJ4 {
|
|||||||
"{minimize:cores , precision:2}," +
|
"{minimize:cores , precision:2}," +
|
||||||
"{maximize:freedisk, precision:50}, " +
|
"{maximize:freedisk, precision:50}, " +
|
||||||
"{minimize:heapUsage, precision:1000}]}";
|
"{minimize:heapUsage, precision:1000}]}";
|
||||||
|
if(useNodeset){
|
||||||
|
rules = "{" +
|
||||||
|
"cluster-policy:[" +
|
||||||
|
"{nodeset:{nodeRole:'overseer'},replica : 0 , strict:false}," +
|
||||||
|
"{replica:'<1',node:node3}," +
|
||||||
|
"{replica:'<2',node:'#ANY', shard:'#EACH'}]," +
|
||||||
|
" cluster-preferences:[" +
|
||||||
|
"{minimize:cores , precision:2}," +
|
||||||
|
"{maximize:freedisk, precision:50}, " +
|
||||||
|
"{minimize:heapUsage, precision:1000}]}";
|
||||||
|
}
|
||||||
|
|
||||||
Map<String, Map> nodeValues = (Map<String, Map>) Utils.fromJSONString("{" +
|
Map<String, Map> nodeValues = (Map<String, Map>) Utils.fromJSONString("{" +
|
||||||
"node1:{cores:12, freedisk: 334, heapUsage:10480}," +
|
"node1:{cores:12, freedisk: 334, heapUsage:10480}," +
|
||||||
@ -1624,6 +1755,18 @@ public class TestPolicy extends SolrTestCaseJ4 {
|
|||||||
" 'cluster-preferences':[" +
|
" 'cluster-preferences':[" +
|
||||||
" {'minimize':'cores', 'precision':3}," +
|
" {'minimize':'cores', 'precision':3}," +
|
||||||
" {'maximize':'freedisk','precision':100}]}";
|
" {'maximize':'freedisk','precision':100}]}";
|
||||||
|
if(useNodeset){
|
||||||
|
autoscaleJson = "{" +
|
||||||
|
" 'cluster-policy':[" +
|
||||||
|
" {'cores':'<10','node':'#ANY'}," +
|
||||||
|
" {'replica':'<3','shard':'#EACH','node':'#ANY'}," +
|
||||||
|
" { 'replica': 2, nodeset: {'sysprop.fs': 'ssd'}, 'shard': '#EACH'}," +//greedy condition
|
||||||
|
" {nodeset:{'nodeRole':'overseer'},'replica':'0'}]," +
|
||||||
|
" 'cluster-preferences':[" +
|
||||||
|
" {'minimize':'cores', 'precision':3}," +
|
||||||
|
" {'maximize':'freedisk','precision':100}]}";
|
||||||
|
|
||||||
|
}
|
||||||
Map<String, Map> nodeValues = (Map<String, Map>) Utils.fromJSONString("{" +
|
Map<String, Map> nodeValues = (Map<String, Map>) Utils.fromJSONString("{" +
|
||||||
"node1:{cores:12, freedisk: 334, heapUsage:10480, rack: rack4}," +
|
"node1:{cores:12, freedisk: 334, heapUsage:10480, rack: rack4}," +
|
||||||
"node2:{cores:4, freedisk: 749, heapUsage:6873, rack: rack3}," +
|
"node2:{cores:4, freedisk: 749, heapUsage:6873, rack: rack3}," +
|
||||||
@ -1667,6 +1810,17 @@ public class TestPolicy extends SolrTestCaseJ4 {
|
|||||||
" {'minimize':'cores', 'precision':3}," +
|
" {'minimize':'cores', 'precision':3}," +
|
||||||
" {'maximize':'freedisk','precision':100}]}";
|
" {'maximize':'freedisk','precision':100}]}";
|
||||||
|
|
||||||
|
if(useNodeset){
|
||||||
|
autoscaleJson = "{" +
|
||||||
|
" 'cluster-policy':[" +
|
||||||
|
" {'cores':'<10','node':'#ANY'}," +
|
||||||
|
" {'replica':'<3','shard':'#EACH','node':'#ANY'}," +
|
||||||
|
" {nodeset: {'nodeRole':'overseer'},'replica':'0'}]," +
|
||||||
|
" 'cluster-preferences':[" +
|
||||||
|
" {'minimize':'cores', 'precision':3}," +
|
||||||
|
" {'maximize':'freedisk','precision':100}]}";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
Map replicaInfoMap = (Map) Utils.fromJSONString("{ '127.0.0.1:60099_solr':{}," +
|
Map replicaInfoMap = (Map) Utils.fromJSONString("{ '127.0.0.1:60099_solr':{}," +
|
||||||
" '127.0.0.1:60089_solr':{'compute_plan_action_test':{'shard1':[" +
|
" '127.0.0.1:60089_solr':{'compute_plan_action_test':{'shard1':[" +
|
||||||
@ -1741,6 +1895,31 @@ public class TestPolicy extends SolrTestCaseJ4 {
|
|||||||
"}" +
|
"}" +
|
||||||
"}";
|
"}";
|
||||||
|
|
||||||
|
if(useNodeset){
|
||||||
|
rules = "{" +
|
||||||
|
"'cluster-preferences':[" +
|
||||||
|
"{'minimize':'cores','precision':2}," +
|
||||||
|
"{'maximize':'freedisk','precision':50}," +
|
||||||
|
"{'minimize':'heapUsage','precision':1000}" +
|
||||||
|
"]," +
|
||||||
|
"'cluster-policy':[" +
|
||||||
|
"{replica:0, nodeset:{'nodeRole':'overseer'},'strict':false}," +
|
||||||
|
"{'replica':'<1','node':'node3'}," +
|
||||||
|
"{'replica':'<2','node':'#ANY','shard':'#EACH'}" +
|
||||||
|
"]," +
|
||||||
|
"'policies':{" +
|
||||||
|
"'p1':[" +
|
||||||
|
"{replica:0, nodeset:{'nodeRole':'overseer'},'strict':false}," +
|
||||||
|
"{'replica':'<1','node':'node3'}," +
|
||||||
|
"{'replica':'<2','node':'#ANY','shard':'#EACH'}," +
|
||||||
|
"{'replica':'<3','shard':'#EACH', nodeset : { 'sysprop.rack':'#EACH'}}" +
|
||||||
|
"]" +
|
||||||
|
"}" +
|
||||||
|
"}";
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
Map<String, Map> nodeValues = (Map<String, Map>) Utils.fromJSONString("{" +
|
Map<String, Map> nodeValues = (Map<String, Map>) Utils.fromJSONString("{" +
|
||||||
"node1:{cores:12, freedisk: 334, heapUsage:10480, rack: rack4}," +
|
"node1:{cores:12, freedisk: 334, heapUsage:10480, rack: rack4}," +
|
||||||
"node2:{cores:4, freedisk: 749, heapUsage:6873, rack: rack3}," +
|
"node2:{cores:4, freedisk: 749, heapUsage:6873, rack: rack3}," +
|
||||||
@ -1928,6 +2107,26 @@ public class TestPolicy extends SolrTestCaseJ4 {
|
|||||||
" ]" +
|
" ]" +
|
||||||
" }" +
|
" }" +
|
||||||
"}";
|
"}";
|
||||||
|
if(useNodeset){
|
||||||
|
autoScaleJson = "{" +
|
||||||
|
" cluster-preferences: [" +
|
||||||
|
" { maximize : freedisk , precision: 50}," +
|
||||||
|
" { minimize : cores, precision: 2}" +
|
||||||
|
" ]," +
|
||||||
|
" cluster-policy: [" +
|
||||||
|
" { replica : '0' , nodeset: {nodeRole: overseer}}," +
|
||||||
|
" { replica: '<2', shard: '#ANY', node: '#ANY'" +
|
||||||
|
" }" +
|
||||||
|
" ]," +
|
||||||
|
" policies: {" +
|
||||||
|
" policy1: [" +
|
||||||
|
" { replica: '<2', shard: '#EACH', node: '#ANY'}," +
|
||||||
|
" { replica: '<2', shard: '#EACH', nodeset:{ sysprop.rack: rack1}}" +
|
||||||
|
" ]" +
|
||||||
|
" }" +
|
||||||
|
"}";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Map<String, Map> nodeValues = (Map<String, Map>) Utils.fromJSONString("{" +
|
Map<String, Map> nodeValues = (Map<String, Map>) Utils.fromJSONString("{" +
|
||||||
@ -2003,6 +2202,15 @@ public class TestPolicy extends SolrTestCaseJ4 {
|
|||||||
" cluster-policy:[{cores:'<10',node:'#ANY'}," +
|
" cluster-policy:[{cores:'<10',node:'#ANY'}," +
|
||||||
" {replica:'<2', shard:'#EACH',node:'#ANY'}," +
|
" {replica:'<2', shard:'#EACH',node:'#ANY'}," +
|
||||||
" { nodeRole:overseer,replica:0}]}";
|
" { nodeRole:overseer,replica:0}]}";
|
||||||
|
if(useNodeset){
|
||||||
|
autoScalingjson = "cluster-preferences:[" +
|
||||||
|
" {minimize : cores}," +
|
||||||
|
" {'maximize':freedisk , precision:100}], " +
|
||||||
|
" cluster-policy:[{cores:'<10',node:'#ANY'}," +
|
||||||
|
" {replica:'<2', shard:'#EACH',node:'#ANY'}," +
|
||||||
|
" {nodeset:{ nodeRole:overseer},replica:0}]}";
|
||||||
|
|
||||||
|
}
|
||||||
Policy policy = new Policy((Map<String, Object>) Utils.fromJSONString(autoScalingjson));
|
Policy policy = new Policy((Map<String, Object>) Utils.fromJSONString(autoScalingjson));
|
||||||
Policy.Session session = policy.createSession(cloudManagerWithData((Map) loadFromResource("testComputePlanAfterNodeAdded.json")));
|
Policy.Session session = policy.createSession(cloudManagerWithData((Map) loadFromResource("testComputePlanAfterNodeAdded.json")));
|
||||||
Suggester suggester = session.getSuggester(CollectionParams.CollectionAction.MOVEREPLICA)
|
Suggester suggester = session.getSuggester(CollectionParams.CollectionAction.MOVEREPLICA)
|
||||||
@ -2018,6 +2226,14 @@ public class TestPolicy extends SolrTestCaseJ4 {
|
|||||||
" { replica :'<2', node:'#ANY'}," +
|
" { replica :'<2', node:'#ANY'}," +
|
||||||
" { nodeRole : overseer, replica :0}]," +
|
" { nodeRole : overseer, replica :0}]," +
|
||||||
" cluster-preferences :[{ minimize : cores }]}";
|
" cluster-preferences :[{ minimize : cores }]}";
|
||||||
|
if(useNodeset){
|
||||||
|
autoScalingjson = " { cluster-policy:[" +
|
||||||
|
" { cores :'<10', node :'#ANY'}," +
|
||||||
|
" { replica :'<2', node:'#ANY'}," +
|
||||||
|
" { nodeset:{nodeRole : overseer}, replica :0}]," +
|
||||||
|
" cluster-preferences :[{ minimize : cores }]}";
|
||||||
|
|
||||||
|
}
|
||||||
List<Suggester.SuggestionInfo> l = PolicyHelper.getSuggestions(new AutoScalingConfig((Map<String, Object>) Utils.fromJSONString(autoScalingjson)),
|
List<Suggester.SuggestionInfo> l = PolicyHelper.getSuggestions(new AutoScalingConfig((Map<String, Object>) Utils.fromJSONString(autoScalingjson)),
|
||||||
cloudManagerWithData((Map) loadFromResource("testReplicaCountSuggestions.json")));
|
cloudManagerWithData((Map) loadFromResource("testReplicaCountSuggestions.json")));
|
||||||
assertFalse(l.isEmpty());
|
assertFalse(l.isEmpty());
|
||||||
@ -2123,6 +2339,12 @@ public class TestPolicy extends SolrTestCaseJ4 {
|
|||||||
public void testFreeDiskDeviation() {
|
public void testFreeDiskDeviation() {
|
||||||
Map map = (Map) loadFromResource("testFreeDiskDeviation.json");
|
Map map = (Map) loadFromResource("testFreeDiskDeviation.json");
|
||||||
AutoScalingConfig cfg = new AutoScalingConfig((Map<String, Object>) map.get("config"));
|
AutoScalingConfig cfg = new AutoScalingConfig((Map<String, Object>) map.get("config"));
|
||||||
|
if(useNodeset){
|
||||||
|
cfg = new AutoScalingConfig((Map<String, Object>) Utils.fromJSONString("{" +
|
||||||
|
" 'cluster-policy': [{'replica':'<2', 'shard':'#EACH', 'node':'#ANY'}," +
|
||||||
|
" {'replica': '#ALL', 'nodeset': {'freedisk': '>700'}, 'strict': false}]" +
|
||||||
|
" }"));
|
||||||
|
}
|
||||||
SolrCloudManager scm = cloudManagerWithData(map);
|
SolrCloudManager scm = cloudManagerWithData(map);
|
||||||
Suggester suggester = cfg.getPolicy()
|
Suggester suggester = cfg.getPolicy()
|
||||||
.createSession(scm)
|
.createSession(scm)
|
||||||
@ -2159,6 +2381,12 @@ public class TestPolicy extends SolrTestCaseJ4 {
|
|||||||
" { replica :'0', freedisk:'<1000'}," +
|
" { replica :'0', freedisk:'<1000'}," +
|
||||||
" { nodeRole : overseer, replica :0}]," +
|
" { nodeRole : overseer, replica :0}]," +
|
||||||
" cluster-preferences :[{ minimize : cores, precision : 2 }]}";
|
" cluster-preferences :[{ minimize : cores, precision : 2 }]}";
|
||||||
|
if(useNodeset){
|
||||||
|
autoScalingjson = " { cluster-policy:[" +
|
||||||
|
" { replica :'0', nodeset:{ freedisk:'<1000'}}," +
|
||||||
|
" { replica :0, nodeset : {nodeRole : overseer}}]," +
|
||||||
|
" cluster-preferences :[{ minimize : cores, precision : 2 }]}";
|
||||||
|
}
|
||||||
AutoScalingConfig cfg = new AutoScalingConfig((Map<String, Object>) Utils.fromJSONString(autoScalingjson));
|
AutoScalingConfig cfg = new AutoScalingConfig((Map<String, Object>) Utils.fromJSONString(autoScalingjson));
|
||||||
List<Violation> violations = cfg.getPolicy().createSession(cloudManagerWithData((Map) loadFromResource("testFreeDiskSuggestions.json"))).getViolations();
|
List<Violation> violations = cfg.getPolicy().createSession(cloudManagerWithData((Map) loadFromResource("testFreeDiskSuggestions.json"))).getViolations();
|
||||||
assertEquals(1, violations.size());
|
assertEquals(1, violations.size());
|
||||||
@ -2185,6 +2413,12 @@ public class TestPolicy extends SolrTestCaseJ4 {
|
|||||||
" { replica :'#ALL', freedisk:'>1000'}," +
|
" { replica :'#ALL', freedisk:'>1000'}," +
|
||||||
" { nodeRole : overseer, replica :0}]," +
|
" { nodeRole : overseer, replica :0}]," +
|
||||||
" cluster-preferences :[{ minimize : cores, precision : 2 }]}";
|
" cluster-preferences :[{ minimize : cores, precision : 2 }]}";
|
||||||
|
if(useNodeset){
|
||||||
|
autoScalingjson = " { cluster-policy:[" +
|
||||||
|
" { replica :'#ALL', nodeset:{ freedisk:'>1000'}}," +
|
||||||
|
" { replica :0 , nodeset : {nodeRole : overseer}}]," +
|
||||||
|
" cluster-preferences :[{ minimize : cores, precision : 2 }]}";
|
||||||
|
}
|
||||||
cfg = new AutoScalingConfig((Map<String, Object>) Utils.fromJSONString(autoScalingjson));
|
cfg = new AutoScalingConfig((Map<String, Object>) Utils.fromJSONString(autoScalingjson));
|
||||||
violations = cfg.getPolicy().createSession(cloudManagerWithData((Map) loadFromResource("testFreeDiskSuggestions.json"))).getViolations();
|
violations = cfg.getPolicy().createSession(cloudManagerWithData((Map) loadFromResource("testFreeDiskSuggestions.json"))).getViolations();
|
||||||
assertEquals(1, violations.size());
|
assertEquals(1, violations.size());
|
||||||
@ -2237,6 +2471,17 @@ public class TestPolicy extends SolrTestCaseJ4 {
|
|||||||
" { 'replica': '1', shard:'#EACH', sysprop.fs : 'ssd'}" +
|
" { 'replica': '1', shard:'#EACH', sysprop.fs : 'ssd'}" +
|
||||||
" ]" +
|
" ]" +
|
||||||
"}";
|
"}";
|
||||||
|
if(useNodeset){
|
||||||
|
autoScalingjson = "{" +
|
||||||
|
" 'cluster-preferences': [" +
|
||||||
|
" { 'maximize': 'freedisk', 'precision': 50}," +
|
||||||
|
" { 'minimize': 'cores', 'precision': 3}" +
|
||||||
|
" ]," +
|
||||||
|
" 'cluster-policy': [" +
|
||||||
|
" { 'replica': '1', shard:'#EACH', nodeset:{ sysprop.fs : 'ssd'}}" +
|
||||||
|
" ]" +
|
||||||
|
"}";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
AutoScalingConfig cfg = new AutoScalingConfig((Map<String, Object>) Utils.fromJSONString(autoScalingjson));
|
AutoScalingConfig cfg = new AutoScalingConfig((Map<String, Object>) Utils.fromJSONString(autoScalingjson));
|
||||||
@ -2260,6 +2505,18 @@ public class TestPolicy extends SolrTestCaseJ4 {
|
|||||||
" ]" +
|
" ]" +
|
||||||
"}";
|
"}";
|
||||||
|
|
||||||
|
if(useNodeset){
|
||||||
|
autoScalingjson = "{" +
|
||||||
|
" 'cluster-preferences': [" +
|
||||||
|
" { 'maximize': 'freedisk', 'precision': 50}," +
|
||||||
|
" { 'minimize': 'cores', 'precision': 3}" +
|
||||||
|
" ]," +
|
||||||
|
" 'cluster-policy': [" +
|
||||||
|
" { 'replica': 0, shard:'#EACH', nodeset :{ port : '8983'}}" +
|
||||||
|
" ]" +
|
||||||
|
"}";
|
||||||
|
|
||||||
|
}
|
||||||
AutoScalingConfig cfg = new AutoScalingConfig((Map<String, Object>) Utils.fromJSONString(autoScalingjson));
|
AutoScalingConfig cfg = new AutoScalingConfig((Map<String, Object>) Utils.fromJSONString(autoScalingjson));
|
||||||
List<Violation> violations = cfg.getPolicy().createSession(cloudManagerWithData((Map) loadFromResource("testPortSuggestions.json"))).getViolations();
|
List<Violation> violations = cfg.getPolicy().createSession(cloudManagerWithData((Map) loadFromResource("testPortSuggestions.json"))).getViolations();
|
||||||
assertEquals(2, violations.size());
|
assertEquals(2, violations.size());
|
||||||
|
@ -53,6 +53,11 @@ import static org.apache.solr.common.util.Utils.MAPOBJBUILDER;
|
|||||||
import static org.apache.solr.common.util.Utils.getObjectByPath;
|
import static org.apache.solr.common.util.Utils.getObjectByPath;
|
||||||
|
|
||||||
public class TestPolicy2 extends SolrTestCaseJ4 {
|
public class TestPolicy2 extends SolrTestCaseJ4 {
|
||||||
|
boolean useNodeset ;
|
||||||
|
public TestPolicy2(){
|
||||||
|
useNodeset = true;
|
||||||
|
}
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
|
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
|
||||||
|
|
||||||
public void testEqualOnNonNode() {
|
public void testEqualOnNonNode() {
|
||||||
@ -60,6 +65,12 @@ public class TestPolicy2 extends SolrTestCaseJ4 {
|
|||||||
String autoScalingjson = "{cluster-policy:[" +
|
String autoScalingjson = "{cluster-policy:[" +
|
||||||
" { replica : '<3' , shard : '#EACH', sysprop.zone: [east,west] } ]," +
|
" { replica : '<3' , shard : '#EACH', sysprop.zone: [east,west] } ]," +
|
||||||
" 'cluster-preferences':[{ minimize : cores},{maximize : freedisk, precision : 50}]}";
|
" 'cluster-preferences':[{ minimize : cores},{maximize : freedisk, precision : 50}]}";
|
||||||
|
if(useNodeset){
|
||||||
|
autoScalingjson = "{cluster-policy:[" +
|
||||||
|
" { replica : '<3' , shard : '#EACH', nodeset:{ sysprop.zone: [east,west] }} ]," +
|
||||||
|
" 'cluster-preferences':[{ minimize : cores},{maximize : freedisk, precision : 50}]}";
|
||||||
|
|
||||||
|
}
|
||||||
Policy policy = new Policy((Map<String, Object>) Utils.fromJSONString(autoScalingjson));
|
Policy policy = new Policy((Map<String, Object>) Utils.fromJSONString(autoScalingjson));
|
||||||
Policy.Session session = policy.createSession(createCloudManager(l.get(0), l.get(1)));
|
Policy.Session session = policy.createSession(createCloudManager(l.get(0), l.get(1)));
|
||||||
List<Violation> violations = session.getViolations();
|
List<Violation> violations = session.getViolations();
|
||||||
@ -74,6 +85,11 @@ public class TestPolicy2 extends SolrTestCaseJ4 {
|
|||||||
autoScalingjson = "{cluster-policy:[" +
|
autoScalingjson = "{cluster-policy:[" +
|
||||||
" { replica : '<3' , shard : '#EACH', sysprop.zone: '#EACH' } ]," +
|
" { replica : '<3' , shard : '#EACH', sysprop.zone: '#EACH' } ]," +
|
||||||
" 'cluster-preferences':[{ minimize : cores},{maximize : freedisk, precision : 50}]}";
|
" 'cluster-preferences':[{ minimize : cores},{maximize : freedisk, precision : 50}]}";
|
||||||
|
if(useNodeset){
|
||||||
|
autoScalingjson = "{cluster-policy:[" +
|
||||||
|
" { replica : '<3' , shard : '#EACH', nodeset:{sysprop.zone: '#EACH'} } ]," +
|
||||||
|
" 'cluster-preferences':[{ minimize : cores},{maximize : freedisk, precision : 50}]}";
|
||||||
|
}
|
||||||
policy = new Policy((Map<String, Object>) Utils.fromJSONString(autoScalingjson));
|
policy = new Policy((Map<String, Object>) Utils.fromJSONString(autoScalingjson));
|
||||||
session = policy.createSession(createCloudManager(l.get(0), l.get(1)));
|
session = policy.createSession(createCloudManager(l.get(0), l.get(1)));
|
||||||
violations = session.getViolations();
|
violations = session.getViolations();
|
||||||
@ -335,6 +351,22 @@ public class TestPolicy2 extends SolrTestCaseJ4 {
|
|||||||
Map<String, Object> m = (Map<String, Object>) loadFromResource("testSysPropSuggestions.json");
|
Map<String, Object> m = (Map<String, Object>) loadFromResource("testSysPropSuggestions.json");
|
||||||
|
|
||||||
Map<String, Object> conf = (Map<String, Object>) getObjectByPath(m, false, "diagnostics/config");
|
Map<String, Object> conf = (Map<String, Object>) getObjectByPath(m, false, "diagnostics/config");
|
||||||
|
if(useNodeset){
|
||||||
|
conf = (Map<String, Object>) Utils.fromJSONString("{" +
|
||||||
|
" 'cluster-preferences':[{" +
|
||||||
|
" 'minimize':'cores'," +
|
||||||
|
" 'precision':1}," +
|
||||||
|
" {" +
|
||||||
|
" 'maximize':'freedisk'," +
|
||||||
|
" 'precision':100}," +
|
||||||
|
" {" +
|
||||||
|
" 'minimize':'sysLoadAvg'," +
|
||||||
|
" 'precision':10}]," +
|
||||||
|
" 'cluster-policy':[{" +
|
||||||
|
" 'replica':'<3'," +
|
||||||
|
" 'shard':'#EACH'," +
|
||||||
|
" nodeset: {'sysprop.zone':['east','west']}}]}");
|
||||||
|
}
|
||||||
Policy policy = new Policy(conf);
|
Policy policy = new Policy(conf);
|
||||||
SolrCloudManager cloudManagerFromDiagnostics = createCloudManagerFromDiagnostics(m);
|
SolrCloudManager cloudManagerFromDiagnostics = createCloudManagerFromDiagnostics(m);
|
||||||
Policy.Session session = policy.createSession(cloudManagerFromDiagnostics);
|
Policy.Session session = policy.createSession(cloudManagerFromDiagnostics);
|
||||||
@ -361,6 +393,17 @@ public class TestPolicy2 extends SolrTestCaseJ4 {
|
|||||||
" {'minimize':'sysLoadAvg','precision':10}]," +
|
" {'minimize':'sysLoadAvg','precision':10}]," +
|
||||||
" 'cluster-policy':[" +
|
" 'cluster-policy':[" +
|
||||||
"{'replica':'<5','shard':'#EACH','sysprop.zone':['east','west']}]}";
|
"{'replica':'<5','shard':'#EACH','sysprop.zone':['east','west']}]}";
|
||||||
|
if(useNodeset){
|
||||||
|
conf = " {" +
|
||||||
|
" 'cluster-preferences':[{" +
|
||||||
|
" 'minimize':'cores'," +
|
||||||
|
" 'precision':1}," +
|
||||||
|
" {'maximize':'freedisk','precision':100}," +
|
||||||
|
" {'minimize':'sysLoadAvg','precision':10}]," +
|
||||||
|
" 'cluster-policy':[" +
|
||||||
|
"{'replica':'<5','shard':'#EACH', nodeset:{'sysprop.zone':['east','west']}}]}";
|
||||||
|
|
||||||
|
}
|
||||||
Map<String, Object> m = (Map<String, Object>) loadFromResource("testSuggestionsRebalanceOnly.json");
|
Map<String, Object> m = (Map<String, Object>) loadFromResource("testSuggestionsRebalanceOnly.json");
|
||||||
SolrCloudManager cloudManagerFromDiagnostics = createCloudManagerFromDiagnostics(m);
|
SolrCloudManager cloudManagerFromDiagnostics = createCloudManagerFromDiagnostics(m);
|
||||||
AutoScalingConfig autoScalingConfig = new AutoScalingConfig((Map<String, Object>) Utils.fromJSONString(conf));
|
AutoScalingConfig autoScalingConfig = new AutoScalingConfig((Map<String, Object>) Utils.fromJSONString(conf));
|
||||||
|
@ -0,0 +1,26 @@
|
|||||||
|
/*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
* this work for additional information regarding copyright ownership.
|
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
* (the "License"); you may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.apache.solr.client.solrj.cloud.autoscaling;
|
||||||
|
|
||||||
|
public class TestPolicy2Old extends TestPolicy2 {
|
||||||
|
public TestPolicy2Old(){
|
||||||
|
super();
|
||||||
|
useNodeset = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
/*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
* this work for additional information regarding copyright ownership.
|
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
* (the "License"); you may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.apache.solr.client.solrj.cloud.autoscaling;
|
||||||
|
|
||||||
|
public class TestPolicyOld extends TestPolicy {
|
||||||
|
public TestPolicyOld(){
|
||||||
|
super();
|
||||||
|
useNodeset = false;
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user