Permalink
Browse files

Added object allocation instrumentation for Column

  - Modified CassandraDaemon to create allocation sampler before
    it starts the server;
  - Added allocations.jar to lib/
  • Loading branch information...
aryanet authored and Arya Goudarzi committed Aug 14, 2013
1 parent 7d4380d commit 3c7a9dd7562907692267e23ebf031384d0f1cc34
Showing with 23 additions and 0 deletions.
  1. BIN lib/allocation.jar
  2. +23 −0 src/java/org/apache/cassandra/service/CassandraDaemon.java
BIN +370 KB lib/allocation.jar
Binary file not shown.
@@ -19,6 +19,7 @@

import java.io.File;
import java.io.IOException;
import java.lang.instrument.UnmodifiableClassException;
import java.net.InetAddress;
import java.net.MalformedURLException;
import java.net.URL;
@@ -45,6 +46,9 @@
import org.apache.cassandra.utils.CLibrary;
import org.apache.cassandra.utils.Mx4jTool;

import com.google.monitoring.runtime.instrumentation.ConstructorCallback;
import com.google.monitoring.runtime.instrumentation.ConstructorInstrumenter;

/**
* The <code>CassandraDaemon</code> is an abstraction for a Cassandra daemon
* service, which defines not only a way to activate and deactivate it, but also
@@ -453,9 +457,28 @@ public static void stop(String[] args)

public static void main(String[] args)
{
instrumentAllocations();
instance.activate();
}

/*
* @see: https://code.google.com/p/java-allocation-instrumenter/wiki/GettingStarted
*/
private static void instrumentAllocations() {
try {
ConstructorInstrumenter.instrumentClass(
Column.class, new ConstructorCallback<Column>() {
@Override public void sample(Column c) {
if ((Math.random() * 10000) > 9998) {
logger.info("Allocated a column", new Exception("Sample stacktrace"));
}
}
});
} catch (UnmodifiableClassException e) {
System.out.println("Class cannot be modified");
}
}

public interface Server
{
/**

0 comments on commit 3c7a9dd

Please sign in to comment.