Apache Lucene open-source search software
SOLR-3852: Fixed ZookeeperInfoServlet so that the SolrCloud Admin UI pages will work even if ZK contains nodes with data which are not utf8 text
Chris M. Hostetter31a88ab101e6
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex 8d66fd2dcf8..1c6bc0a323c 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -173,6 +173,9 @@ Bug Fixes* SOLR-5190: SolrEntityProcessor substitutes variables only once in child entities(Harsh Chawla, shalin)+* SOLR-3852: Fixed ZookeeperInfoServlet so that the SolrCloud Admin UI pages will+ work even if ZK contains nodes with data which are not utf8 text. (hossman)+Optimizations----------------------diff --git a/solr/core/src/java/org/apache/solr/servlet/ZookeeperInfoServlet.java b/solr/core/src/java/org/apache/solr/servlet/ZookeeperInfoServlet.javaindex 03d593f1c9c..32ad684f09f 100644--- a/solr/core/src/java/org/apache/solr/servlet/ZookeeperInfoServlet.java+++ b/solr/core/src/java/org/apache/solr/servlet/ZookeeperInfoServlet.java@@ -290,21 +290,6 @@ public final class ZookeeperInfoServlet extends HttpServlet {printZnode(json, path);}- /*- if (stat.getNumChildren() != 0)- {- writeKeyValue(json, "children_count", stat.getNumChildren(), false );- out.println(", \"children_count\" : \"" + stat.getNumChildren() + "\"");- }- */-- //if (stat.getDataLength() != 0)- if (data != null) {- String str = new BytesRef(data).utf8ToString();- //?? writeKeyValue(json, "content", str, false );- // Does nothing now, but on the assumption this will be used later we'll leave it in. If it comes out- // the catches below need to be restructured.- }} catch (IllegalArgumentException e) {// path doesn't exist (must have been removed)writeKeyValue(json, "warning", "(path gone)", false);@@ -381,6 +366,16 @@ public final class ZookeeperInfoServlet extends HttpServlet {// Trickily, the call to zkClient.getData fills in the stat variablebyte[] data = zkClient.getData(path, null, stat, true);+ String dataStr = null;+ String dataStrErr = null;+ if (null != data) {+ try {+ dataStr = (new BytesRef(data)).utf8ToString();+ } catch (Exception e) {+ dataStrErr = "data is not parsable as a utf8 String: " + e.toString();+ }+ }+json.writeString("znode");json.writeNameSeparator();json.startObject();@@ -397,15 +392,18 @@ public final class ZookeeperInfoServlet extends HttpServlet {writeKeyValue(json, "ctime", time(stat.getCtime()), false);writeKeyValue(json, "cversion", stat.getCversion(), false);writeKeyValue(json, "czxid", stat.getCzxid(), false);- writeKeyValue(json, "dataLength", stat.getDataLength(), false);writeKeyValue(json, "ephemeralOwner", stat.getEphemeralOwner(), false);writeKeyValue(json, "mtime", time(stat.getMtime()), false);writeKeyValue(json, "mzxid", stat.getMzxid(), false);writeKeyValue(json, "pzxid", stat.getPzxid(), false);+ writeKeyValue(json, "dataLength", stat.getDataLength(), false);+ if (null != dataStrErr) {+ writeKeyValue(json, "dataNote", dataStrErr, false);+ }json.endObject();- if (data != null) {- writeKeyValue(json, "data", new BytesRef(data).utf8ToString(), false);+ if (null != dataStr) {+ writeKeyValue(json, "data", dataStr, false);}json.endObject();} catch (KeeperException e) {diff --git a/solr/webapp/web/js/scripts/cloud.js b/solr/webapp/web/js/scripts/cloud.jsindex 9a1f51f7f40..d78cb459939 100644--- a/solr/webapp/web/js/scripts/cloud.js+++ b/solr/webapp/web/js/scripts/cloud.js@@ -612,7 +612,7 @@ var init_tree = function( tree_element )var data_element = $( '#data', this );var highlight = false;- var data = '<em>File "' + response.znode.path + '" has no Content</em>';+ var data = '<em>Node "' + response.znode.path + '" has no utf8 Content</em>';if( response.znode.data ){