Database Reference
In-Depth Information
Runtime Analysis Tools
We don't need to go into too much more detail about JMX in general here, but to understand
Cassandra and manage it, it's good to know what features are exposed with JMX. It's also useful
to know what tools Java makes available out of the box to detect and spot the source of a memory
leak, analyze a hung process, and so on. Because Cassandra is a Java application, and because it
is relatively young, there are no third-party tools specific to Cassandra at this point.
NOTE
If you are debugging and you're not sure what commands have been executed against Cassandra with
the CLI, look in your home directory for a hidden file called .cassandra.history. This acts like your Bash
shell history, listing the commands in a plain-text file in the order Cassandra executed them. Nice!
Heap Analysis with JMX and JHAT
As you're debugging your Cassandra application, it's often useful to understand what's happening
in your heap. If you're working of of the trunk or are otherwise unsure of your Cassandra build,
there are some native Java tools available to you.
Cassandra can use a lot of memory, and garbage collection and major compactions can have a
big impact on performance. One helpful program here is called Java Heap Analysis Tool (JHAT).
JHAT uses the HPROF binary format to create web pages that allow you to browse all the objects
in the heap and see all the references to and from heap objects. You can combine this tool, which
ships with the JDK, with some data made available through JMX.
To gain a better understanding of our heap, we'll use the
com.sun.management.HotSpotDiagnostic bean. It has an operation called dumpHeap . Be-
cause that's the name of the operation in the MBean, that's the label on the button in the JMX
agent. This bean allows you to specify a filename where you want to dump the heap to; then you
click the button and it writes the heap information into the file you specified. But the dumpHeap
operation writes the heap's current state to a file that's encoded in the HPROF binary format for
heap and CPU profiling. So we can't read it in a text file and will need to use JHAT to view the
data.
To get a heap dump, run JConsole and navigate to the
com.sun.management.HotSpotDiagnostic bean, expand the Operations tree, and click the
dumpHeap operation. Enter a relative or absolute path naming the file you want to write the heap
dump to, as shown in Figure 9-7 .
Search WWH ::




Custom Search