How to debug Cassandra in Eclipse
Create Project in Eclipse
- Create a new Java Project in Eclipse
- Add the following directories as source folders
- src/gen-java
- interface/thrift/gen-java
- src/resources
- src/java
- src/avro
- Set the target directory for classes to build/classes
- Add the following jars to the eclipse project
- All jars in lib
- build/lib/jars/hadoop-core-*.jar, build/lib/jars/jna-*.jar, build/lib/jars/commons-logging-*.jar, build/lib/jars/pig-*.jar
- Create a Debug Configuration
Use org.apache.cassandra.thrift.CassandraDaemon as the main class
- Add the directory ./conf to your debugging user class path (that will be the location of your log4j.properties file)
- Put the following parameters in the VM args section
-ea -javaagent:${project_loc}/lib/jamm-0.2.5.jar
-XX:+UseThreadPriorities
-XX:ThreadPriorityPolicy=42
-Xms752M
-Xmx752M
-Xmn188M
-XX:+HeapDumpOnOutOfMemoryError
-Xss128k
-XX:+UseParNewGC
-XX:+UseConcMarkSweepGC
-XX:+CMSParallelRemarkEnabled
-XX:SurvivorRatio=8
-XX:MaxTenuringThreshold=1
-XX:CMSInitiatingOccupancyFraction=75
-XX:+UseCMSInitiatingOccupancyOnly
-Djava.net.preferIPv4Stack=true
-Dcom.sun.management.jmxremote.port=7199
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false
-Dlog4j.configuration=log4j-server.properties
-Dlog4j.defaultInitOverride=trueOn Linux systems, by default, Cassandra writes various pieces of data to directories that are not owned by the normal user. This will cause failures when debugging in eclipse. To address this you can chown the directories, or if you don't have rights, you should adjust various settings in the cassandra.yaml, cassandra-env.sh and log4j-server.properties files inside the conf directory to account for this. For debugging purposes you probably want to place these in some directory(s) under your home directory.
- The entries in the cassandra.yaml file that are effected are:
- data_file_directories
- commitlog_directory
- saved_caches_directory
- The entries in the cassandra-env.sh file that are effected are:
- JVM_OPTS="$JVM_OPTS -Xloggc
- The entries in the log4j-server.properties file that are effected are:
- log4j.appender.R.File
Note: You should always build from the command line