From 82b4fedcea02ff736d03ba178143c3470a45bf11 Mon Sep 17 00:00:00 2001 From: Noble Paul Date: Tue, 6 Jan 2015 15:11:12 +0000 Subject: [PATCH] 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 --- .../src/java/org/apache/solr/core/ConfigOverlay.java | 1 + .../src/java/org/apache/solr/core/JarRepository.java | 8 ++++++-- .../core/src/java/org/apache/solr/core/PluginInfo.java | 9 ++++++--- .../src/java/org/apache/solr/handler/BlobHandler.java | 2 +- .../org/apache/solr/handler/DumpRequestHandler.java | 6 ++++++ .../org/apache/solr/core/TestSolrConfigHandler.java | 10 +++++++++- 6 files changed, 29 insertions(+), 7 deletions(-) diff --git a/solr/core/src/java/org/apache/solr/core/ConfigOverlay.java b/solr/core/src/java/org/apache/solr/core/ConfigOverlay.java index c1632ddba05..3a119c22930 100644 --- a/solr/core/src/java/org/apache/solr/core/ConfigOverlay.java +++ b/solr/core/src/java/org/apache/solr/core/ConfigOverlay.java @@ -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 { diff --git a/solr/core/src/java/org/apache/solr/core/JarRepository.java b/solr/core/src/java/org/apache/solr/core/JarRepository.java index 33db0eb45a7..dfaffc1e6c4 100644 --- a/solr/core/src/java/org/apache/solr/core/JarRepository.java +++ b/solr/core/src/java/org/apache/solr/core/JarRepository.java @@ -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 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"; diff --git a/solr/core/src/java/org/apache/solr/core/PluginInfo.java b/solr/core/src/java/org/apache/solr/core/PluginInfo.java index 67fe6ed0b91..0cd0c1ab17a 100644 --- a/solr/core/src/java/org/apache/solr/core/PluginInfo.java +++ b/solr/core/src/java/org/apache/solr/core/PluginInfo.java @@ -63,12 +63,15 @@ public class PluginInfo implements MapSerializable{ public PluginInfo(String type, Map 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 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.emptyList(); isFromSolrConfig = true; diff --git a/solr/core/src/java/org/apache/solr/handler/BlobHandler.java b/solr/core/src/java/org/apache/solr/handler/BlobHandler.java index abe22f5be5c..05e0deec1be 100644 --- a/solr/core/src/java/org/apache/solr/handler/BlobHandler.java +++ b/solr/core/src/java/org/apache/solr/handler/BlobHandler.java @@ -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); } diff --git a/solr/core/src/java/org/apache/solr/handler/DumpRequestHandler.java b/solr/core/src/java/org/apache/solr/handler/DumpRequestHandler.java index 43669e29a32..c78d4f6f82c 100644 --- a/solr/core/src/java/org/apache/solr/handler/DumpRequestHandler.java +++ b/solr/core/src/java/org/apache/solr/handler/DumpRequestHandler.java @@ -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... diff --git a/solr/core/src/test/org/apache/solr/core/TestSolrConfigHandler.java b/solr/core/src/test/org/apache/solr/core/TestSolrConfigHandler.java index d7fe61aa145..3624dfdeefc 100644 --- a/solr/core/src/test/org/apache/solr/core/TestSolrConfigHandler.java +++ b/solr/core/src/test/org/apache/solr/core/TestSolrConfigHandler.java @@ -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'" + "}";