mirror of https://github.com/apache/lucene.git
SOLR-11520: Implement autoscaling suggestions for cores count violations
This commit is contained in:
parent
0f9012009b
commit
487f67620d
|
@ -53,13 +53,16 @@ New Features
|
||||||
|
|
||||||
* SOLR-11524: A new autoscaling/suggestions API end-point which gives autoscaling suggestions (noble)
|
* 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
|
* SOLR-10132: A new optional facet.matches parameter to return facet buckets only
|
||||||
for terms that match a regular expression. (Gus Heck, Christine Poerschke)
|
for terms that match a regular expression. (Gus Heck, Christine Poerschke)
|
||||||
|
|
||||||
|
* SOLR-11520: Implement autoscaling suggestions for cores count violations (noble)
|
||||||
|
|
||||||
|
|
||||||
Bug Fixes
|
Bug Fixes
|
||||||
----------------------
|
----------------------
|
||||||
|
|
||||||
|
|
|
@ -259,16 +259,15 @@ public class Clause implements MapWriter, Comparable<Clause> {
|
||||||
replica.delta(counts.getValue()),
|
replica.delta(counts.getValue()),
|
||||||
counts.getKey());
|
counts.getKey());
|
||||||
Suggestion.getTagType(tag.name).addViolatingReplicas(ctx.reset(counts.getKey(), counts.getValue(), violation));
|
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 {
|
} else {
|
||||||
for (Row r : allRows) {
|
for (Row r : allRows) {
|
||||||
if (!tag.isPass(r)) {
|
if (!globalTag.isPass(r)) {
|
||||||
Suggestion.ConditionType.CORES.addViolatingReplicas(ctx.reset(null, null,
|
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)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -146,7 +146,10 @@ public class PolicyHelper {
|
||||||
suggestionCtx.session = policy.createSession(cloudManager);
|
suggestionCtx.session = policy.createSession(cloudManager);
|
||||||
List<Violation> violations = suggestionCtx.session.getViolations();
|
List<Violation> violations = suggestionCtx.session.getViolations();
|
||||||
for (Violation violation : violations) {
|
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;
|
suggestionCtx.violation = null;
|
||||||
}
|
}
|
||||||
return suggestionCtx.getSuggestions();
|
return suggestionCtx.getSuggestions();
|
||||||
|
|
|
@ -186,9 +186,7 @@ public class Suggestion {
|
||||||
if (ctx.violation.replicaCountDelta > 0) {//there are more replicas than necessary
|
if (ctx.violation.replicaCountDelta > 0) {//there are more replicas than necessary
|
||||||
for (int i = 0; i < Math.abs(ctx.violation.replicaCountDelta); i++) {
|
for (int i = 0; i < Math.abs(ctx.violation.replicaCountDelta); i++) {
|
||||||
Suggester suggester = ctx.session.getSuggester(MOVEREPLICA)
|
Suggester suggester = ctx.session.getSuggester(MOVEREPLICA)
|
||||||
.hint(Suggester.Hint.SRC_NODE, ctx.violation.node)
|
.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));
|
|
||||||
ctx.addSuggestion(suggester);
|
ctx.addSuggestion(suggester);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1429,14 +1429,46 @@ public class TestPolicy extends SolrTestCaseJ4 {
|
||||||
assertEquals("r2", Utils.getObjectByPath(m, true, "operation/command/move-replica/replica"));
|
assertEquals("r2", Utils.getObjectByPath(m, true, "operation/command/move-replica/replica"));
|
||||||
assertEquals("node1", Utils.getObjectByPath(m, true, "operation/command/move-replica/targetNode"));
|
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"));
|
public void testCoresSuggestions() {
|
||||||
assertNotNull(Utils.getObjectByPath(m,false,"operation/command/move-replica"));
|
String dataproviderdata = "{" +
|
||||||
assertEquals("10.0.0.6:7574_solr",Utils.getObjectByPath(m,true,"operation/command/move-replica/targetNode"));
|
" 'liveNodes':[" +
|
||||||
assertEquals("core_node2",Utils.getObjectByPath(m,true,"operation/command/move-replica/replica"));*/
|
" '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"));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue