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 2018/06/06 09:19:08 UTC
lucene-solr:branch_7x: SOLR-12387: fixing a test failure
Repository: lucene-solr
Updated Branches:
refs/heads/branch_7x bc9cd8086 -> d0e9284a7
SOLR-12387: fixing a test failure
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/d0e9284a
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/d0e9284a
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/d0e9284a
Branch: refs/heads/branch_7x
Commit: d0e9284a7ff3a7ee1597aa1bf5ddc8e2bae71627
Parents: bc9cd80
Author: Noble Paul <no...@apache.org>
Authored: Tue Jun 5 23:14:11 2018 +1000
Committer: Noble Paul <no...@apache.org>
Committed: Wed Jun 6 19:18:48 2018 +1000
----------------------------------------------------------------------
.../solr/handler/admin/CollectionsHandler.java | 5 +++--
.../solr/common/cloud/ClusterProperties.java | 18 ++++++++++++++++++
.../apache/solr/common/cloud/ZkStateReader.java | 6 ++++++
3 files changed, 27 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d0e9284a/solr/core/src/java/org/apache/solr/handler/admin/CollectionsHandler.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/CollectionsHandler.java b/solr/core/src/java/org/apache/solr/handler/admin/CollectionsHandler.java
index 01d2fe8..269bb50 100644
--- a/solr/core/src/java/org/apache/solr/handler/admin/CollectionsHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/admin/CollectionsHandler.java
@@ -206,9 +206,10 @@ public class CollectionsHandler extends RequestHandlerBase implements Permission
return this.coreContainer;
}
- protected void copyFromClusterProp(Map<String, Object> props, String prop) {
+ protected void copyFromClusterProp(Map<String, Object> props, String prop) throws IOException {
if (props.get(prop) != null) return;//if it's already specified , return
- Object defVal = coreContainer.getZkController().getZkStateReader().getClusterProperty(ImmutableList.of(COLLECTION_DEF, prop), null);
+ Object defVal = new ClusterProperties(coreContainer.getZkController().getZkStateReader().getZkClient())
+ .getClusterProperty(ImmutableList.of(COLLECTION_DEF, prop), null);
if (defVal != null) props.put(prop, String.valueOf(defVal));
}
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d0e9284a/solr/solrj/src/java/org/apache/solr/common/cloud/ClusterProperties.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/common/cloud/ClusterProperties.java b/solr/solrj/src/java/org/apache/solr/common/cloud/ClusterProperties.java
index 87896da..446923b 100644
--- a/solr/solrj/src/java/org/apache/solr/common/cloud/ClusterProperties.java
+++ b/solr/solrj/src/java/org/apache/solr/common/cloud/ClusterProperties.java
@@ -21,6 +21,7 @@ import java.io.IOException;
import java.lang.invoke.MethodHandles;
import java.util.Collections;
import java.util.LinkedHashMap;
+import java.util.List;
import java.util.Map;
import org.apache.solr.common.SolrException;
@@ -68,6 +69,23 @@ public class ClusterProperties {
}
/**
+ * Read the value of a cluster property, returning a default if it is not set
+ *
+ * @param key the property name or the full path to the property as a list of parts.
+ * @param defaultValue the default value
+ * @param <T> the type of the property
+ * @return the property value
+ * @throws IOException if there is an error reading the value from the cluster
+ */
+ @SuppressWarnings("unchecked")
+ public <T> T getClusterProperty(List<String> key, T defaultValue) throws IOException {
+ T value = (T) Utils.getObjectByPath(getClusterProperties(), false, key);
+ if (value == null)
+ return defaultValue;
+ return value;
+ }
+
+ /**
* Return the cluster properties
* @throws IOException if there is an error reading properties from the cluster
*/
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d0e9284a/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java b/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java
index 6b65c34..a86c5e2 100644
--- a/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java
+++ b/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java
@@ -961,6 +961,12 @@ public class ZkStateReader implements Closeable {
return value;
}
+ /**Same as the above but allows a full json path as a list of parts
+ *
+ * @param keyPath path to the property example ["collectionDefauls", "numShards"]
+ * @param defaultValue a default value to use if no such property exists
+ * @return the cluster property, or a default if the property is not set
+ */
public <T> T getClusterProperty(List<String> keyPath, T defaultValue) {
T value = (T) Utils.getObjectByPath( clusterProperties, false, keyPath);
if (value == null)