You are viewing a plain text version of this content. The canonical link for it is here.
Posted to hdfs-dev@hadoop.apache.org by "Eric Sirianni (JIRA)" <ji...@apache.org> on 2013/12/18 16:38:06 UTC

[jira] [Created] (HDFS-5680) Double-JSON-encoding of JMX attributes yields malformed JSON

Eric Sirianni created HDFS-5680:
-----------------------------------

             Summary: Double-JSON-encoding of JMX attributes yields malformed JSON
                 Key: HDFS-5680
                 URL: https://issues.apache.org/jira/browse/HDFS-5680
             Project: Hadoop HDFS
          Issue Type: Bug
          Components: datanode, namenode
            Reporter: Eric Sirianni
            Priority: Minor


The practice of  "double JSON encoding" JMX attributes:
# in the {{MXBean}} itself using Jetty's {{JSON.toString(...)}}
# in the {{JMXJsonServlet}} using Jackson

results in malformed JSON documents (technically not "malformed", but doesn't properly allow for traversal into nested JSON structures).

For example:
{noformat}
$ curl http://localhost:50070/jmx?get=Hadoop:service=NameNode,name=NameNodeInfo::NodeUsage
{
  "beans" : [ {
    "name" : "Hadoop:service=NameNode,name=NameNodeInfo",
    "modelerType" : "org.apache.hadoop.hdfs.server.namenode.FSNamesystem",
    "NodeUsage" : "{\"nodeUsage\":{\"min\":\"0.00%\",\"median\":\"0.01%\",\"max\":\"0.01%\",\"stdDev\":\"0.00%\"}}"
  } ]
{noformat}

The {{NodeUsage}} attribute should instead be:
{noformat}
    "NodeUsage" : {"nodeUsage":{"min":"0.00%","median":"0.01%","max":"0.01%","stdDev":"0.00%"}}
{noformat}

The Web UI seems to be aware of this and has applied a workaround:
{code:title=dfshealth.js}
  // Workarounds for the fact that JMXJsonServlet returns non-standard JSON strings
{code}

Putting JMX aside, one fix would be to let {{JMXJsonServlet}} do all the encoding and simply have the {{MXBean}} return a {{Map}}.  That would, however, likely not encode properly for native JMX access.  I'm not familiar enough with how JMX is used elsewhere in Hadoop to suggest an alternative.  



--
This message was sent by Atlassian JIRA
(v6.1.4#6159)