mirror of https://github.com/apache/lucene.git
SOLR-12387: fixing a test failure
This commit is contained in:
parent
add77d2725
commit
f9d807af75
|
@ -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));
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
@ -67,6 +68,23 @@ public class ClusterProperties {
|
|||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue