mbean value of long type returned as string

classic Classic list List threaded Threaded
5 messages Options
wai wai
Reply | Threaded
Open this post in threaded view
|

mbean value of long type returned as string

I have gotten jolokia deployed in jetty 7 as a war, and is successful in issuing via curl to fetch memory data, but the values are returned within quotes:

{"timestamp":1298408028,
  "status":200,
  "request": {
    "mbean":"java.lang:type=Memory",
    "attribute":"HeapMemoryUsage",
    "type":"read"
  },
  "value":{
    "max":"66650112",
    "committed":"18046976",
    "init":"0",
    "used":"11829200"
  }
}

Since I am sending the json response to a collectd plugin (curl_json), it requires the values as long/int and not string.  Is there a way to have these values returned as the types specified in the mbean?

Thanks,
Wai.
roland roland
Reply | Threaded
Open this post in threaded view
|

Re: mbean value of long type returned as string

Hi Wai,

sorry, this seems to be indeed a bug. Strangely, no one really
reported this so far (probably because you have implicite conversion in
the Perl client lib). I'm going to fix this for 0.84, I will post an update
here as soon as I pushed a fix to Github.

I don't know an easy workaround yet.

Sorry for that ...
... roland
wai wai
Reply | Threaded
Open this post in threaded view
|

Re: mbean value of long type returned as string

Hi Roland,

Thanks for tracking this down.  I will get your change set from Github once it is published.

Wai.
roland roland
Reply | Threaded
Open this post in threaded view
|

Re: mbean value of long type returned as string

I justed pushed a new branch 'json-typed' to Github. It contains the necessary
changes to get numbers back as numbers (same for booleans).

I also remember now, that back in 2009 I decided to return everything as String
for simplicity reasons. But obviously, although JSON is mostly typeless one
should fully support the handful of JSON types, of course.

The changes will be merged into the 0.84 release, I still need to check
all client libraries, whether they properly can handle the change and
what are the implications.

Please give it a try and let me know, whether it works for you.
... roland
roland roland
Reply | Threaded
Open this post in threaded view
|

Re: mbean value of long type returned as string

FYI, I merged my changes into master and just released a 0.90-SNAPSHOT. You can download the agent war from http://labs.consol.de/maven/snapshots-repository/org/jolokia/jolokia-war/0.90-SNAPSHOT/jolokia-war-0.90-20110304.203923-1.war
... roland