Differences between revisions 19 and 20
Revision 19 as of 2014-06-18 02:32:39
Size: 2956
Editor: DaveBrosius
Comment: change xss to 200
Revision 20 as of 2014-10-31 03:15:54
Size: 2856
Editor: DaveBrosius
Comment: minor updates due to changes
Deletions are marked like this. Additions are marked like this.
Line 14: Line 14:
 1. Set the target directory for classes to build/classes  1. Set the target directory for classes to build/classes/main
Line 24: Line 24:
   2. Use org.apache.cassandra.thrift.CassandraDaemon as the main class    2. Use org.apache.cassandra.service.CassandraDaemon as the main class
Line 26: Line 26:
   2. Add the directory ./conf to your debugging user class path (that will be the location of your log4j.properties file)    2. Add the directory ./conf to your debugging user class path (that will be the location of your logback.xml file)
Line 33: Line 33:
          -Xms752M
          -Xmx752M
          -Xms750M
          -Xmx4000M
Line 49: Line 49:
          -Dlog4j.configuration=log4j-server.properties
          -Dlog4j.defaultInitOverride=true

How to debug Cassandra in Eclipse

Create Project in Eclipse

  1. Create a new Java Project in Eclipse
  2. Add the following directories as source folders
    1. src/gen-java
    2. interface/thrift/gen-java
    3. src/resources
    4. src/java
  3. Set the target directory for classes to build/classes/main
  4. Add the following jars to the eclipse project
    1. All jars in lib
    2. build/lib/jars/hadoop-core-*.jar, build/lib/jars/jna-*.jar, build/lib/jars/commons-logging-*.jar, build/lib/jars/pig-*.jar, build/lib/apache-rat-*.jar
  5. Create a Debug Configuration
    1. Use org.apache.cassandra.service.CassandraDaemon as the main class

    2. Add the directory ./conf to your debugging user class path (that will be the location of your logback.xml file)
    3. Put the following parameters in the VM args section

          -ea -javaagent:${project_loc}/lib/jamm-0.2.6.jar 
          -XX:+UseThreadPriorities 
          -XX:ThreadPriorityPolicy=42 
          -Xms750M 
          -Xmx4000M 
          -Xmn188M 
          -XX:+HeapDumpOnOutOfMemoryError 
          -Xss200k 
          -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 

In versions less then 2.1 the following information is important for directory ownership

On 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.

Note in 2.1 and greater, then data directory by default is found in the cassandra directory
  1. The entries in the cassandra.yaml file that are effected are:
    1. data_file_directories
    2. commitlog_directory
    3. saved_caches_directory
  2. The entries in the cassandra-env.sh file that are effected are:
    1. JVM_OPTS="$JVM_OPTS -Xloggc
  3. The entries in the logback.xml file that are effected are:
    1. <fileNamePattern/>

Note: You should always build from the command line

stats

HowToDebug (last edited 2014-10-31 03:15:54 by DaveBrosius)