Skip to content

Commit

Permalink
SOLR-10035 Admin UI cannot find dataimport handlers.
Browse files Browse the repository at this point in the history
  • Loading branch information
sigram committed Feb 1, 2017
1 parent 48a6a0a commit 72f75b2
Show file tree
Hide file tree
Showing 7 changed files with 99 additions and 12 deletions.
7 changes: 7 additions & 0 deletions solr/CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ Apache UIMA 2.3.1
Apache ZooKeeper 3.4.6
Jetty 9.3.14.v20161028

Upgrade Notes
----------------------
* SOLR-10035: Category names of some SolrInfoMBeans have been changed in release 6.4.0. This issue
changes the /admin/mbeans handler to return these beans both under the new and the old back-compatible
names. Old names are deprecated and will be eventually removed in Solr 7.0. They can be also removed via
system property "-Dsolr.mbeans.useOnlyNewNaming=true". (ab, Shawn Heisey, Jan Høydahl)

Bug Fixes
----------------------
* SOLR-9969: "Plugin/Stats" section of the UI doesn't display empty metric types (Tomás Fernández Löbbe)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import java.net.URL;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Set;
Expand All @@ -46,6 +47,21 @@
@SuppressWarnings("unchecked")
public class SolrInfoMBeanHandler extends RequestHandlerBase {

// back-compat names, only needed in 6.x - see SOLR-10035
static final Map<String, String> newToOldCategories = new HashMap<String, String>() {{
put(Category.QUERY.toString(), "QUERYHANDLER");
put(Category.UPDATE.toString(), "UPDATEHANDLER");
put(Category.HIGHLIGHTER.toString(), "HIGHLIGHTING");
}};
static final Map<String, String> oldToNewCategories = new HashMap<String, String>() {{
put("QUERYHANDLER", Category.QUERY.toString());
put("UPDATEHANDLER", Category.UPDATE.toString());
put("HIGHLIGHTING", Category.HIGHLIGHTER.toString());
}};

static final boolean useOnlyNewNaming = Boolean.valueOf(System.getProperty("solr.mbeans.useOnlyNewNaming", "false"));


/**
* Take an array of any type and generate a Set containing the toString.
* Set is guarantee to never be null (but may be empty)
Expand Down Expand Up @@ -120,28 +136,51 @@ protected NamedList<NamedList<NamedList<Object>>> getMBeanInfo(SolrQueryRequest
for (SolrInfoMBean.Category cat : SolrInfoMBean.Category.values()) {
cats.add(cat.name(), new SimpleOrderedMap<NamedList<Object>>());
}
if (!useOnlyNewNaming) {
for (String oldName : newToOldCategories.values()) {
cats.add(oldName, new SimpleOrderedMap<NamedList<Object>>());
}
}
} else {
for (String catName : requestedCats) {
cats.add(catName,new SimpleOrderedMap<NamedList<Object>>());
if (!useOnlyNewNaming) {
if (newToOldCategories.containsKey(catName)) {
cats.add(newToOldCategories.get(catName), new SimpleOrderedMap<NamedList<Object>>());
}
if (oldToNewCategories.containsKey(catName)) {
cats.add(oldToNewCategories.get(catName), new SimpleOrderedMap<NamedList<Object>>());
}
}
}
}

Set<String> requestedKeys = arrayToSet(req.getParams().getParams("key"));

Map<String, SolrInfoMBean> reg = req.getCore().getInfoRegistry();
for (Map.Entry<String, SolrInfoMBean> entry : reg.entrySet()) {
addMBean(req, cats, requestedKeys, entry.getKey(),entry.getValue());
String cat = entry.getValue().getCategory().name();
addMBean(req, cat, cats, requestedKeys, entry.getKey(),entry.getValue());
// add it also under back-compat name
if (!useOnlyNewNaming && newToOldCategories.containsKey(cat)) {
addMBean(req, newToOldCategories.get(cat), cats, requestedKeys, entry.getKey(),entry.getValue());
}
}

for (SolrInfoMBean infoMBean : req.getCore().getCoreDescriptor().getCoreContainer().getResourceLoader().getInfoMBeans()) {
addMBean(req,cats,requestedKeys,infoMBean.getName(),infoMBean);
String cat = infoMBean.getCategory().name();
addMBean(req,cat, cats,requestedKeys,infoMBean.getName(),infoMBean);
// add it also under back-compat name
if (!useOnlyNewNaming && newToOldCategories.containsKey(cat)) {
addMBean(req, newToOldCategories.get(cat), cats, requestedKeys, infoMBean.getName(), infoMBean);
}
}
return cats;
}

private void addMBean(SolrQueryRequest req, NamedList<NamedList<NamedList<Object>>> cats, Set<String> requestedKeys, String key, SolrInfoMBean m) {
private void addMBean(SolrQueryRequest req, String categoryName, NamedList<NamedList<NamedList<Object>>> cats, Set<String> requestedKeys, String key, SolrInfoMBean m) {
if ( ! ( requestedKeys.isEmpty() || requestedKeys.contains(key) ) ) return;
NamedList<NamedList<Object>> catInfo = cats.get(m.getCategory().name());
NamedList<NamedList<Object>> catInfo = cats.get(categoryName);
if ( null == catInfo ) return;
NamedList<Object> mBeanInfo = new SimpleOrderedMap<>();
mBeanInfo.add("class", m.getName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.apache.solr.common.util.ContentStreamBase;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.request.LocalSolrQueryRequest;
import org.apache.solr.request.SolrQueryRequest;
import org.junit.BeforeClass;
import org.junit.Test;

Expand Down Expand Up @@ -84,4 +85,38 @@ public void testXMLDiffWithExternalEntity() throws Exception {

assertTrue("external entity ignored properly", true);
}

@Test
public void testBackCompatNames() throws Exception {
SolrQueryRequest req = req(
CommonParams.QT,"/admin/mbeans",
CommonParams.WT,"xml"
);
h.validateQuery(req,
"boolean(//lst[@name='QUERY'])",
"boolean(//lst[@name='QUERYHANDLER'])",
"boolean(//lst[@name='UPDATE'])",
"boolean(//lst[@name='UPDATEHANDLER'])",
"boolean(//lst[@name='HIGHLIGHTING'])",
"boolean(//lst[@name='HIGHLIGHTER'])"
);
req = req(
CommonParams.QT,"/admin/mbeans",
CommonParams.WT,"xml",
"cat", "QUERYHANDLER"
);
h.validateQuery(req,
"boolean(//lst[@name='QUERY'])",
"boolean(//lst[@name='QUERYHANDLER'])"
);
req = req(
CommonParams.QT,"/admin/mbeans",
CommonParams.WT,"xml",
"cat", "UPDATE"
);
h.validateQuery(req,
"boolean(//lst[@name='UPDATE'])",
"boolean(//lst[@name='UPDATEHANDLER'])"
);
}
}
9 changes: 6 additions & 3 deletions solr/webapp/web/css/angular/plugins.css
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,12 @@ limitations under the License.
#content #plugins #navigation .cache a { background-image: url( ../../img/ico/disk-black.png ); }
#content #plugins #navigation .core a { background-image: url( ../../img/ico/wooden-box.png ); }
#content #plugins #navigation .other a { background-image: url( ../../img/ico/zone.png ); }
#content #plugins #navigation .highlighting a { background-image: url( ../../img/ico/highlighter-text.png ); }
#content #plugins #navigation .updatehandler a{ background-image: url( ../../img/ico/arrow-circle.png ); }
#content #plugins #navigation .queryhandler a { background-image: url( ../../img/ico/magnifier.png ); }
#content #plugins #navigation .highlighting a { text-decoration: line-through; background-image: url( ../../img/ico/highlighter-text.png ); }
#content #plugins #navigation .highlighter a { background-image: url( ../../img/ico/highlighter-text.png ); }
#content #plugins #navigation .updatehandler a{ text-decoration: line-through; background-image: url( ../../img/ico/arrow-circle.png ); }
#content #plugins #navigation .update a{ background-image: url( ../../img/ico/arrow-circle.png ); }
#content #plugins #navigation .queryhandler a { text-decoration: line-through; background-image: url( ../../img/ico/magnifier.png ); }
#content #plugins #navigation .query a { background-image: url( ../../img/ico/magnifier.png ); }
#content #plugins #navigation .queryparser a { background-image: url( ../../img/ico/asterisk.png ); }

#content #plugins #navigation .PLUGINCHANGES { margin-top: 20px; }
Expand Down
9 changes: 6 additions & 3 deletions solr/webapp/web/css/styles/plugins.css
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,12 @@ limitations under the License.
#content #plugins #navigation .cache a { background-image: url( ../../img/ico/disk-black.png ); }
#content #plugins #navigation .core a { background-image: url( ../../img/ico/wooden-box.png ); }
#content #plugins #navigation .other a { background-image: url( ../../img/ico/zone.png ); }
#content #plugins #navigation .highlighting a { background-image: url( ../../img/ico/highlighter-text.png ); }
#content #plugins #navigation .updatehandler a{ background-image: url( ../../img/ico/arrow-circle.png ); }
#content #plugins #navigation .queryhandler a { background-image: url( ../../img/ico/magnifier.png ); }
#content #plugins #navigation .highlighting a { text-decoration: line-through; background-image: url( ../../img/ico/highlighter-text.png ); }
#content #plugins #navigation .highlighter a { background-image: url( ../../img/ico/highlighter-text.png ); }
#content #plugins #navigation .updatehandler a{ text-decoration: line-through; background-image: url( ../../img/ico/arrow-circle.png ); }
#content #plugins #navigation .update a{ background-image: url( ../../img/ico/arrow-circle.png ); }
#content #plugins #navigation .queryhandler a { text-decoration: line-through; background-image: url( ../../img/ico/magnifier.png ); }
#content #plugins #navigation .query a { background-image: url( ../../img/ico/magnifier.png ); }
#content #plugins #navigation .queryparser a { background-image: url( ../../img/ico/asterisk.png ); }

#content #plugins #navigation .PLUGINCHANGES { margin-top: 20px; }
Expand Down
2 changes: 1 addition & 1 deletion solr/webapp/web/js/angular/controllers/dataimport.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ solrAdminApp.controller('DataImportController',
$scope.resetMenu("dataimport", Constants.IS_COLLECTION_PAGE);

$scope.refresh = function () {
Mbeans.info({core: $routeParams.core, cat: 'QUERYHANDLER'}, function (data) {
Mbeans.info({core: $routeParams.core, cat: 'QUERY'}, function (data) {
var mbeans = data['solr-mbeans'][1];
$scope.handlers = [];
for (var key in mbeans) {
Expand Down
2 changes: 1 addition & 1 deletion solr/webapp/web/js/scripts/dataimport.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ sammy.bind
$.ajax
(
{
url : core_basepath + '/admin/mbeans?cat=QUERYHANDLER&wt=json',
url : core_basepath + '/admin/mbeans?cat=QUERY&wt=json',
dataType : 'json',
beforeSend : function( xhr, settings )
{
Expand Down

0 comments on commit 72f75b2

Please sign in to comment.