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

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1519763 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Chris M. Hostetter 2013-09-03 17:29:49 +00:00
parent 386bbd0675
commit 31a88ab101
3 changed files with 20 additions and 19 deletions

View File

@ -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
----------------------

View File

@ -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 variable
byte[] 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) {

View File

@ -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 )
{