TeamDewberry / jmxdatamart

A Data Mart for JMX Statistics
BSD 2-Clause "Simplified" License
3 stars 8 forks source link

Support ClassLoadingMXBean #33

Open DavidWhitlock opened 11 years ago

DavidWhitlock commented 11 years ago

So, I'm going to start a series of issues on the standard JDK MBeans that we want to make sure can be extracted and loaded. I'm also putting together the skeleton of fitnesse tests so that we can have automated tests for these MBeans.

The first one is "java.lang:type=ClassLoading" (http://docs.oracle.com/javase/6/docs/api/java/lang/management/ClassLoadingMXBean.html)) which has a boolean attribute, an int attribute, and two long attributes.

I would expect that the following XML can be used to extract the Class Loading MBean

<Settings>
  <pollingRate>2</pollingRate>
  <folderLocation>extractClassLoadingMXBeans</folderLocation>
  <url>service:jmx:rmi:///jndi/rmi://:8888/jmxrmi</url>
  <BeanList>
    <Bean>
      <name>java.lang:type=ClassLoading</name>
      <alias>ClassLoading</alias>
      <AttributeList>
        <Attribute>
          <dataType>BOOLEAN</dataType>
          <name>Verbose</name>
        </Attribute>
        <Attribute>
          <dataType>INT</dataType>
          <name>LoadedClassCount</name>
        </Attribute>
        <Attribute>
          <dataType>LONG</dataType>
          <name>UnloadedClassCount</name>
        </Attribute>
        <Attribute>
          <dataType>LONG</dataType>
          <name>TotalLoadedClassCount</name>
        </Attribute>
      </AttributeList>
      <enable>true</enable>
    </Bean>
  </BeanList>
</Settings>

At the moment, this XML blows up in the Extractor with the following exception.

Caused by: java.lang.IllegalArgumentException: No enum const class org.jmxdatamart.common.DataType.BOOLEAN
    at java.lang.Enum.valueOf(Enum.java:196)
    at com.thoughtworks.xstream.converters.enums.EnumConverter.unmarshal(EnumConverter.java:47)
    at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)

Which I believe is expected given other open issues.

ankel commented 11 years ago

Can you try remove all and re-run the above settings?

ankel commented 11 years ago

Scratch that. The error was because ms sql doesn't support boolean type, thus neither is extractor. How do you propose we should do to support Boolean?

DavidWhitlock commented 11 years ago

I don't know how to best represent boolean values in MS SQL Server. Google has a couple of ideas, though:

ankel commented 11 years ago

I think it should be best to ask your Datamart / MS SQL team since we don't want to introduce some new / different way into Tripwire's ecosystem, unless Tripwire is using some super-secret way, then we'll fall back to other ways.

As far as the actual change, let's say if we decided to use bit (as both link suggest) then it would be as simple as adding an extra case for bit type in loader, and a conversion true -> 1, false -> 0 in extractor.

DavidWhitlock commented 11 years ago

I'll ask the Data Mart guys what they do with boolean columns, but I'm pretty sure they'd use bit also.