You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by cp...@apache.org on 2017/06/07 14:02:36 UTC
lucene-solr:master: SOLR-10800: Factor out
HttpShardHandler.transformReplicasToShardUrls from
HttpShardHandler.prepDistributed. (Domenico Fabio Marino, Christine Poerschke)
Repository: lucene-solr
Updated Branches:
refs/heads/master fe176b601 -> b25dda0b2
SOLR-10800: Factor out HttpShardHandler.transformReplicasToShardUrls from HttpShardHandler.prepDistributed.
(Domenico Fabio Marino, Christine Poerschke)
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/b25dda0b
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/b25dda0b
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/b25dda0b
Branch: refs/heads/master
Commit: b25dda0b209cddaf6165042dc0e860068e9aacc5
Parents: fe176b6
Author: Christine Poerschke <cp...@apache.org>
Authored: Wed Jun 7 13:26:18 2017 +0100
Committer: Christine Poerschke <cp...@apache.org>
Committed: Wed Jun 7 13:27:53 2017 +0100
----------------------------------------------------------------------
solr/CHANGES.txt | 3 ++
.../handler/component/HttpShardHandler.java | 31 ++++++++++++--------
2 files changed, 22 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/b25dda0b/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index d7eb46f..7e45c3b 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -253,6 +253,9 @@ Other Changes
* SOLR-10419: All collection APIs should use the new Policy framework for replica placement. (Noble Paul, shalin)
+* SOLR-10800: Factor out HttpShardHandler.transformReplicasToShardUrls from HttpShardHandler.prepDistributed.
+ (Domenico Fabio Marino, Christine Poerschke)
+
================== 6.7.0 ==================
Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release.
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/b25dda0b/solr/core/src/java/org/apache/solr/handler/component/HttpShardHandler.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/component/HttpShardHandler.java b/solr/core/src/java/org/apache/solr/handler/component/HttpShardHandler.java
index 2954cff..1c98f58 100644
--- a/solr/core/src/java/org/apache/solr/handler/component/HttpShardHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/component/HttpShardHandler.java
@@ -379,10 +379,11 @@ public class HttpShardHandler extends ShardHandler {
for (int i=0; i<rb.shards.length; i++) {
- final List<String> shardUrls;
if (rb.shards[i] != null) {
- shardUrls = StrUtils.splitSmart(rb.shards[i], "|", true);
+ final List<String> shardUrls = StrUtils.splitSmart(rb.shards[i], "|", true);
replicaListTransformer.transform(shardUrls);
+ // And now recreate the | delimited list of equivalent servers
+ rb.shards[i] = createSliceShardsStr(shardUrls);
} else {
if (clusterState == null) {
clusterState = zkController.getClusterState();
@@ -424,15 +425,11 @@ public class HttpShardHandler extends ShardHandler {
final List<Replica> eligibleSliceReplicas = collectEligibleReplicas(slice, clusterState, onlyNrtReplicas, isShardLeader);
- replicaListTransformer.transform(eligibleSliceReplicas);
+ final List<String> shardUrls = transformReplicasToShardUrls(replicaListTransformer, eligibleSliceReplicas);
- shardUrls = new ArrayList<>(eligibleSliceReplicas.size());
- for (Replica replica : eligibleSliceReplicas) {
- String url = ZkCoreNodeProps.getCoreUrl(replica);
- shardUrls.add(url);
- }
-
- if (shardUrls.isEmpty()) {
+ // And now recreate the | delimited list of equivalent servers
+ final String sliceShardsStr = createSliceShardsStr(shardUrls);
+ if (sliceShardsStr.isEmpty()) {
boolean tolerant = rb.req.getParams().getBool(ShardParams.SHARDS_TOLERANT, false);
if (!tolerant) {
// stop the check when there are no replicas available for a shard
@@ -440,9 +437,8 @@ public class HttpShardHandler extends ShardHandler {
"no servers hosting shard: " + rb.slices[i]);
}
}
+ rb.shards[i] = sliceShardsStr;
}
- // And now recreate the | delimited list of equivalent servers
- rb.shards[i] = createSliceShardsStr(shardUrls);
}
}
String shards_rows = params.get(ShardParams.SHARDS_ROWS);
@@ -475,6 +471,17 @@ public class HttpShardHandler extends ShardHandler {
return eligibleSliceReplicas;
}
+ private static List<String> transformReplicasToShardUrls(final ReplicaListTransformer replicaListTransformer, final List<Replica> eligibleSliceReplicas) {
+ replicaListTransformer.transform(eligibleSliceReplicas);
+
+ final List<String> shardUrls = new ArrayList<>(eligibleSliceReplicas.size());
+ for (Replica replica : eligibleSliceReplicas) {
+ String url = ZkCoreNodeProps.getCoreUrl(replica);
+ shardUrls.add(url);
+ }
+ return shardUrls;
+ }
+
private static String createSliceShardsStr(final List<String> shardUrls) {
final StringBuilder sliceShardsStr = new StringBuilder();
boolean first = true;