The source code for Cassandra is shared through the central Apache Git repository and organized by different branches. You can access the code for the current development branch through git as follows:
git clone http://git-wip-us.apache.org/repos/asf/cassandra.git cassandra-trunk
Other branches will point to different versions of Cassandra. Switching to a different branch requires checking out the branch by its name:
git checkout cassandra-3.0
You can get a list of available branches with
Finally build Cassandra using ant:
This may take a significant amount of time depending on whether artifacts have to be downloaded and the number of classes that need to be compiled.
You can setup multiple working trees for different Cassandra versions from the same repository using git-worktree.
IntelliJ IDEA by JetBrains is one of the most popular IDEs for Cassandra and Java development in general. The Community Edition is provided as a free download with all features needed to get started developing Cassandra.
Since 2.1.5, there is a new ant target:
generate-idea-files. Please see our wiki for instructions for older Cassandra versions.
Please clone and build Cassandra as described above and execute the following steps:
The project generated by the ant task
generate-idea-files contains nearly everything you need to debug Cassandra and execute unit tests.
- Run/debug defaults for JUnit
- Run/debug configuration for Cassandra daemon
- License header for Java source files
- Cassandra code style
Eclipse is a popular open source IDE that can be used for Cassandra development. Various Eclipse environments are available from the download page. The following guide was created with “Eclipse IDE for Java Developers”.
These instructions were tested on Ubuntu 16.04 with Eclipse Neon (4.6) using Cassandra 2.1, 2.2 and 3.x.
It is important that you generate the Eclipse files with Ant before trying to set up the Eclipse project.
- Clone and build Cassandra as described above.
ant generate-eclipse-filesto create the Eclipse settings.
- Start Eclipse.
File->Import->Existing Projects into Workspace->Select git directory.
- Make sure “cassandra-trunk” is recognized and selected as a project (assuming you checked the code out into the folder cassandra-trunk as described above).
- Confirm “Finish” to have your project imported.
You should now be able to find the project as part of the “Package Explorer” or “Project Explorer” without having Eclipse complain about any errors after building the project automatically.
Unit tests can be run from Eclipse by simply right-clicking the class file or method and selecting
Run As->JUnit Test. Tests can be debugged this way as well by defining breakpoints (double-click line number) and selecting
Debug As->JUnit Test.
Alternatively all unit tests can be run from the command line as described in Testing
There are two ways how to start and debug a local Cassandra instance with Eclipse. You can either start Cassandra just as you normally would by using the
./bin/cassandra script and connect to the JVM through remotely from Eclipse or start Cassandra from Eclipse right away.
- Set environment variable to define remote debugging options for the JVM:
- Start Cassandra by executing the
Afterwards you should be able to connect to the running Cassandra process through the following steps:
From the menu, select
Create new remote application
Configure connection settings by specifying a name and port 1414
Afterwards confirm “Debug” to connect to the JVM and start debugging Cassandra!
Cassandra can also be started directly from Eclipse if you don’t want to use the command line.
From the menu, select
Create new application
Specify name, project and main class
Configure additional JVM specific parameters that will start Cassandra with some of the settings created by the regular startup script. Change heap related values as needed.
-Xms1024M -Xmx1024M -Xmn220M -Xss256k -ea -XX:+UseThreadPriorities -XX:ThreadPriorityPolicy=42 -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -XX:+UseCondCardMark -javaagent:./lib/jamm-0.3.0.jar -Djava.net.preferIPv4Stack=true
Now just confirm “Debug” and you should see the output of Cassandra starting up in the Eclipse console and should be able to set breakpoints and start debugging!