SOLR-11520: Implement autoscaling suggestions for cores count violations

This commit is contained in:
Noble Paul 2017-10-31 19:41:17 +10:30
parent 0f9012009b
commit 487f67620d
5 changed files with 52 additions and 17 deletions

View File

@ -53,13 +53,16 @@ New Features
* SOLR-11524: A new autoscaling/suggestions API end-point which gives autoscaling suggestions (noble)
* SOLR-11519: Implement suggestions for replica count violations (noble)
* SOLR-11519: Implement autoscaling suggestions for replica count violations (noble)
* SOLR-11518: Implement Suggestions for freedisk violations (noble)
* SOLR-11518: Implement autoscaling Suggestions for freedisk violations (noble)
* SOLR-10132: A new optional facet.matches parameter to return facet buckets only
for terms that match a regular expression. (Gus Heck, Christine Poerschke)
* SOLR-11520: Implement autoscaling suggestions for cores count violations (noble)
Bug Fixes
----------------------

View File

@ -259,16 +259,15 @@ public class Clause implements MapWriter, Comparable<Clause> {
replica.delta(counts.getValue()),
counts.getKey());
Suggestion.getTagType(tag.name).addViolatingReplicas(ctx.reset(counts.getKey(), counts.getValue(), violation));
// Suggestion.getByTag(tag.name).violationFun.accept(ctx.reset(counts.getKey(), counts.getValue(), violation));
}
}
}
}
} else {
for (Row r : allRows) {
if (!tag.isPass(r)) {
if (!globalTag.isPass(r)) {
Suggestion.ConditionType.CORES.addViolatingReplicas(ctx.reset(null, null,
new Violation(this, null, null, r.node, r.getVal(tag.name), tag.delta(r.getVal(tag.name)), null)));
new Violation(this, null, null, r.node, r.getVal(globalTag.name), globalTag.delta(r.getVal(globalTag.name)), null)));
}
}
}

View File

@ -146,7 +146,10 @@ public class PolicyHelper {
suggestionCtx.session = policy.createSession(cloudManager);
List<Violation> violations = suggestionCtx.session.getViolations();
for (Violation violation : violations) {
Suggestion.getTagType(violation.getClause().tag.name).getSuggestions(suggestionCtx.setViolation(violation));
Suggestion.getTagType(violation.getClause().isPerCollectiontag() ?
violation.getClause().tag.name:
violation.getClause().globalTag.name)
.getSuggestions(suggestionCtx.setViolation(violation));
suggestionCtx.violation = null;
}
return suggestionCtx.getSuggestions();

View File

@ -186,9 +186,7 @@ public class Suggestion {
if (ctx.violation.replicaCountDelta > 0) {//there are more replicas than necessary
for (int i = 0; i < Math.abs(ctx.violation.replicaCountDelta); i++) {
Suggester suggester = ctx.session.getSuggester(MOVEREPLICA)
.hint(Suggester.Hint.SRC_NODE, ctx.violation.node)
.hint(ctx.violation.shard.equals(ANY) ? Suggester.Hint.COLL : Suggester.Hint.COLL_SHARD,
ctx.violation.shard.equals(ANY) ? ctx.violation.coll : new Pair<>(ctx.violation.coll, ctx.violation.shard));
.hint(Suggester.Hint.SRC_NODE, ctx.violation.node);
ctx.addSuggestion(suggester);
}
}

View File

@ -1429,14 +1429,46 @@ public class TestPolicy extends SolrTestCaseJ4 {
assertEquals("r2", Utils.getObjectByPath(m, true, "operation/command/move-replica/replica"));
assertEquals("node1", Utils.getObjectByPath(m, true, "operation/command/move-replica/targetNode"));
// System.out.println(Utils.toJSONString(l.get(0)));
// Map m = l.get(0).toMap(new LinkedHashMap<>());
/*assertEquals(1l,Utils.getObjectByPath(m,true,"violation/violation/delta"));
assertEquals("POST",Utils.getObjectByPath(m,true,"operation/method"));
assertEquals("/c/mycoll1",Utils.getObjectByPath(m,true,"operation/path"));
assertNotNull(Utils.getObjectByPath(m,false,"operation/command/move-replica"));
assertEquals("10.0.0.6:7574_solr",Utils.getObjectByPath(m,true,"operation/command/move-replica/targetNode"));
assertEquals("core_node2",Utils.getObjectByPath(m,true,"operation/command/move-replica/replica"));*/
}
public void testCoresSuggestions() {
String dataproviderdata = "{" +
" 'liveNodes':[" +
" '10.0.0.6:7574_solr'," +
" '10.0.0.6:8983_solr']," +
" 'replicaInfo':{" +
" '10.0.0.6:7574_solr':{}," +
" '10.0.0.6:8983_solr':{'mycoll1':{" +
" 'shard1':[{'core_node1':{'type':'NRT'}}]," +
" 'shard2':[{'core_node2':{'type':'NRT'}}]," +
" 'shard3':[{'core_node3':{'type':'NRT'}}]," +
" 'shard4':[{'core_node4':{'type':'NRT'}}]}}}," +
" 'nodeValues':{" +
" '10.0.0.6:7574_solr':{" +
" 'node':'10.0.0.6:7574_solr'," +
" 'cores':0}," +
" '10.0.0.6:8983_solr':{" +
" 'node':'10.0.0.6:8983_solr'," +
" 'cores':4}}}";
String autoScalingjson = " { cluster-policy:[" +
" { cores :'<3', node :'#ANY'}]," +
" cluster-preferences :[{ minimize : cores }]}";
AutoScalingConfig cfg = new AutoScalingConfig((Map<String, Object>) Utils.fromJSONString(autoScalingjson));
List<Violation> violations = cfg.getPolicy().createSession(cloudManagerWithData(dataproviderdata)).getViolations();
assertFalse(violations.isEmpty());
assertEquals(2l, violations.get(0).replicaCountDelta.longValue());
List<Suggester.SuggestionInfo> l = PolicyHelper.getSuggestions(cfg,
cloudManagerWithData(dataproviderdata));
assertEquals(2, l.size());
for (Suggester.SuggestionInfo suggestionInfo : l) {
Map m = suggestionInfo.toMap(new LinkedHashMap<>());
assertEquals("10.0.0.6:7574_solr", Utils.getObjectByPath(m, true, "operation/command/move-replica/targetNode"));
assertEquals("POST", Utils.getObjectByPath(m, true, "operation/method"));
assertEquals("/c/mycoll1", Utils.getObjectByPath(m, true, "operation/path"));
}
}