You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by no...@apache.org on 2017/05/24 09:09:05 UTC
[1/2] lucene-solr:feature/autoscaling: use the hint to add collection
to session
Repository: lucene-solr
Updated Branches:
refs/heads/feature/autoscaling b010ebd51 -> fe217668c
use the hint to add collection to session
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/66a6cffd
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/66a6cffd
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/66a6cffd
Branch: refs/heads/feature/autoscaling
Commit: 66a6cffd6653729439a39d4b8c1bd4d518d49430
Parents: cfe5cff
Author: Noble Paul <no...@apache.org>
Authored: Wed May 24 18:35:54 2017 +0930
Committer: Noble Paul <no...@apache.org>
Committed: Wed May 24 18:35:54 2017 +0930
----------------------------------------------------------------------
.../apache/solr/cloud/autoscaling/Policy.java | 28 +++++++++++++++-----
.../solr/cloud/autoscaling/PolicyHelper.java | 8 +-----
2 files changed, 22 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/66a6cffd/solr/solrj/src/java/org/apache/solr/cloud/autoscaling/Policy.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/cloud/autoscaling/Policy.java b/solr/solrj/src/java/org/apache/solr/cloud/autoscaling/Policy.java
index 8a1292d..614bfa2 100644
--- a/solr/solrj/src/java/org/apache/solr/cloud/autoscaling/Policy.java
+++ b/solr/solrj/src/java/org/apache/solr/cloud/autoscaling/Policy.java
@@ -165,13 +165,7 @@ public class Policy implements MapWriter {
.collect(Collectors.toList());
for (String c : collections) {
- String p = dataProvider.getPolicy(c);
- if (p != null) {
- List<Clause> perCollPolicy = policies.get(p);
- if (perCollPolicy == null)
- throw new RuntimeException(StrUtils.formatString("Policy for collection {0} is {1} . It does not exist", c, p));
- }
- expandedClauses.addAll(mergePolicies(c, policies.getOrDefault(p, emptyList()), clusterPolicy));
+ addClausesForCollection(dataProvider, c);
}
Collections.sort(expandedClauses);
@@ -183,6 +177,16 @@ public class Policy implements MapWriter {
applyRules();
}
+ private void addClausesForCollection(ClusterDataProvider dataProvider, String c) {
+ String p = dataProvider.getPolicy(c);
+ if (p != null) {
+ List<Clause> perCollPolicy = policies.get(p);
+ if (perCollPolicy == null)
+ throw new RuntimeException(StrUtils.formatString("Policy for collection {0} is {1} . It does not exist", c, p));
+ }
+ expandedClauses.addAll(mergePolicies(c, policies.getOrDefault(p, emptyList()), clusterPolicy));
+ }
+
Session copy() {
return new Session(nodes, dataProvider, getMatrixCopy(), expandedClauses, paramsOfInterest);
}
@@ -343,6 +347,16 @@ public class Policy implements MapWriter {
public SolrRequest getOperation() {
if (!isInitialized) {
+ String coll = (String) hints.get(Hint.COLL);
+ if(coll != null){
+ // if this is not a known collection from the existing clusterstate,
+ // then add it
+ if(session.matrix.stream().noneMatch(row -> row.replicaInfo.containsKey(coll))){
+ session.matrix.get(0).replicaInfo.put(coll, new HashMap<>());
+ session.addClausesForCollection(session.dataProvider, coll);
+ Collections.sort(session.expandedClauses);
+ }
+ }
session.applyRules();
originalViolations.addAll(session.getViolations());
this.operation = init();
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/66a6cffd/solr/solrj/src/java/org/apache/solr/cloud/autoscaling/PolicyHelper.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/cloud/autoscaling/PolicyHelper.java b/solr/solrj/src/java/org/apache/solr/cloud/autoscaling/PolicyHelper.java
index 2012be8..6b199c2 100644
--- a/solr/solrj/src/java/org/apache/solr/cloud/autoscaling/PolicyHelper.java
+++ b/solr/solrj/src/java/org/apache/solr/cloud/autoscaling/PolicyHelper.java
@@ -54,13 +54,7 @@ public class PolicyHelper {
@Override
public Map<String, Map<String, List<Policy.ReplicaInfo>>> getReplicaInfo(String node, Collection<String> keys) {
- Map<String, Map<String, List<Policy.ReplicaInfo>>> replicaInfo = delegate.getReplicaInfo(node, keys);
- for (String s : optionalPolicyMapping.keySet()) {
- if (!replicaInfo.containsKey(s)) {
- replicaInfo.put(s, new HashMap<>());
- }
- }
- return replicaInfo;
+ return delegate.getReplicaInfo(node, keys);
}
@Override
[2/2] lucene-solr:feature/autoscaling: Merge remote-tracking branch
'origin/feature/autoscaling' into feature/autoscaling
Posted by no...@apache.org.
Merge remote-tracking branch 'origin/feature/autoscaling' into feature/autoscaling
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/fe217668
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/fe217668
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/fe217668
Branch: refs/heads/feature/autoscaling
Commit: fe217668cb43ad6e78b135551576e3568efdfaae
Parents: 66a6cff b010ebd
Author: Noble Paul <no...@apache.org>
Authored: Wed May 24 18:38:58 2017 +0930
Committer: Noble Paul <no...@apache.org>
Committed: Wed May 24 18:38:58 2017 +0930
----------------------------------------------------------------------
solr/CHANGES.txt | 2 ++
.../org/apache/solr/cloud/autoscaling/NodeAddedTrigger.java | 1 -
.../org/apache/solr/cloud/autoscaling/NodeLostTrigger.java | 1 -
.../org/apache/solr/cloud/autoscaling/ScheduledTriggers.java | 4 ++++
.../apache/solr/cloud/autoscaling/TriggerIntegrationTest.java | 6 +++---
5 files changed, 9 insertions(+), 5 deletions(-)
----------------------------------------------------------------------