mirror of https://github.com/apache/lucene.git
SOLR-6801 addressing test failures, SOLR-6607 supporting all initArgs for requesthandlers
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1649821 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
cdb651976e
commit
82b4fedcea
|
@ -75,6 +75,7 @@ public class ConfigOverlay implements MapSerializable{
|
|||
for (int i = 0; i < hierarchy.size(); i++) {
|
||||
String s = hierarchy.get(i);
|
||||
if(i < hierarchy.size()-1){
|
||||
if (!(obj.get(s) instanceof Map)) return null;
|
||||
obj = (Map) obj.get(s);
|
||||
if(obj == null) return null;
|
||||
} else {
|
||||
|
|
|
@ -23,6 +23,8 @@ import static org.apache.solr.common.cloud.ZkStateReader.BASE_URL_PROP;
|
|||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
@ -71,8 +73,10 @@ public class JarRepository {
|
|||
ClusterState cs = this.coreContainer.getZkController().getZkStateReader().getClusterState();
|
||||
DocCollection coll = cs.getCollectionOrNull(CollectionsHandler.SYSTEM_COLL);
|
||||
if (coll == null) throw new SolrException(SERVICE_UNAVAILABLE, ".system collection not available");
|
||||
Slice slice = coll.getActiveSlices().iterator().next();
|
||||
if (slice == null) throw new SolrException(SERVICE_UNAVAILABLE, ".no active slices for .system collection");
|
||||
ArrayList<Slice> slices = new ArrayList<>(coll.getActiveSlices());
|
||||
if (slices.isEmpty()) throw new SolrException(SERVICE_UNAVAILABLE, ".no active slices for .system collection");
|
||||
Collections.shuffle(slices); //do load balancing
|
||||
Slice slice = slices.get(0) ;
|
||||
Replica replica = slice.getReplicas().iterator().next();
|
||||
if (replica == null) throw new SolrException(SERVICE_UNAVAILABLE, ".no active replica available for .system collection");
|
||||
String url = replica.getStr(BASE_URL_PROP) + "/.system/blob/" + key + "?wt=filestream";
|
||||
|
|
|
@ -63,12 +63,15 @@ public class PluginInfo implements MapSerializable{
|
|||
|
||||
public PluginInfo(String type, Map<String,Object> map) {
|
||||
LinkedHashMap m = new LinkedHashMap<>(map);
|
||||
NamedList nl = new NamedList();
|
||||
for (String s : asList(DEFAULTS, APPENDS, INVARIANTS)) if (m.get(s) != null) nl.add(s, map.remove(s));
|
||||
initArgs = new NamedList();
|
||||
for (Map.Entry<String, Object> entry : map.entrySet()) {
|
||||
Object value = entry.getValue();
|
||||
if (value instanceof Map) value = new NamedList((Map) value);
|
||||
initArgs.add(entry.getKey(), value);
|
||||
}
|
||||
this.type = type;
|
||||
this.name = (String) m.get(NAME);
|
||||
this.className = (String) m.get(CLASS_NAME);
|
||||
this.initArgs = nl;
|
||||
attributes = unmodifiableMap(m);
|
||||
this.children = Collections.<PluginInfo>emptyList();
|
||||
isFromSolrConfig = true;
|
||||
|
|
|
@ -188,7 +188,7 @@ public class BlobHandler extends RequestHandlerBase implements PluginInfoInitia
|
|||
req.forward(null,
|
||||
new MapSolrParams((Map) makeMap(
|
||||
"q", MessageFormat.format(q,blobName,version),
|
||||
"fl", "id,size,version,timestamp,blobName",
|
||||
"fl", "id,size,version,timestamp,blobName,md5",
|
||||
"sort", "version desc"))
|
||||
,rsp);
|
||||
}
|
||||
|
|
|
@ -54,6 +54,12 @@ public class DumpRequestHandler extends RequestHandlerBase
|
|||
}
|
||||
}
|
||||
|
||||
if(Boolean.TRUE.equals( req.getParams().getBool("getdefaults"))){
|
||||
NamedList def = (NamedList) initArgs.get(PluginInfo.DEFAULTS);
|
||||
rsp.add("getdefaults", def);
|
||||
}
|
||||
|
||||
|
||||
if(Boolean.TRUE.equals( req.getParams().getBool("initArgs"))) rsp.add("initArgs", initArgs);
|
||||
|
||||
// Write the streams...
|
||||
|
|
|
@ -172,7 +172,7 @@ public class TestSolrConfigHandler extends RestTestBase {
|
|||
10);
|
||||
|
||||
payload = "{\n" +
|
||||
"'update-requesthandler' : { 'name' : '/x', 'class': 'org.apache.solr.handler.DumpRequestHandler' , 'startup' : 'lazy' , 'a':'b'}\n" +
|
||||
"'update-requesthandler' : { 'name' : '/x', 'class': 'org.apache.solr.handler.DumpRequestHandler' , 'startup' : 'lazy' , 'a':'b' , 'defaults': {'def_a':'def A val'}}\n" +
|
||||
"}";
|
||||
runConfigCommand(writeHarness,"/config?wt=json", payload);
|
||||
|
||||
|
@ -184,6 +184,14 @@ public class TestSolrConfigHandler extends RestTestBase {
|
|||
"b",
|
||||
10);
|
||||
|
||||
testForResponseElement(writeHarness,
|
||||
testServerBaseUrl,
|
||||
"/x?wt=json&getdefaults=true&json.nl=map",
|
||||
cloudSolrServer,
|
||||
Arrays.asList("getdefaults", "def_a"),
|
||||
"def A val",
|
||||
10);
|
||||
|
||||
payload = "{\n" +
|
||||
"'delete-requesthandler' : '/x'" +
|
||||
"}";
|
||||
|
|
Loading…
Reference in New Issue