Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Cassandra Wiki" for 
change notification.

The "RunningCassandraInIDEA" page has been changed by RogerSchildmeijer.
The comment on this change is: Major refactoring.
http://wiki.apache.org/cassandra/RunningCassandraInIDEA?action=diff&rev1=10&rev2=11

--------------------------------------------------

  
  = Setup Cassandra =
  
- Check out Cassandra from Subversion and create your new project.
+ Preconditions: JDK6 and Ant (http://ant.apache.org/) 
  
+ IDEA will generally set the project up properly for you (you'll need to run 
some ant targets and add a couple of folders as "content roots"). 
-    1. Install jdk6 and Ant
-    2. Svn checkout https://svn.apache.org/repos/asf/incubator/cassandra/trunk 
cassandra-trunk
-    3. Ant (optional: ant test)
  
-    Step (3) is critical to execution as certain cli-classes are generated by 
ANTLR on running the build script
+ Open IDEA and Select "Check out from Version Control" under "Quick Start" and 
select 'Git' or 'Subversion' (this tutorial will use Git).
+ (The URL to the Apache Cassandra svn is 
https://svn.apache.org/repos/asf/incubator/cassandra/trunk)
+  
  
- IDEA will generally set the project up properly for you (you'll need to add 
the lib folder to your project dependencies). 
+ {{attachment:CheckOutFromVersionControl-1.png}}
+ The 'Git Repository URL' is git://git.apache.org/cassandra.git
+ Parent directory is where IDEA will place the Cassandra checkout/clone.
+ Press Clone to engage the checkout/clone (be patient, will take some time). 
+ Answer 'Yes' to "Would you like to create an IntelliJ IDEA project for the 
sources you have checked out to /Users/schildmeijer/workspace/cassandra?"
  
- Open IDEA and Select "Create Project from existing sources" and select the 
cassandra-trunk folder created from the prior step i.e. svn checkout
+ {{attachment:CloneRepository-2.png}}
  
- {{attachment:CreateNewProject-1.png}}
+ Choose "Create Java project from existing sources".
  
- {{attachment:CreateNewProject-2.png}}
+ {{attachment:CreateProjectFromExistingSources-3.png}}
  
- {{attachment:CreateNewProject-3.png}}
+ Pick an appropriate name for the new project (e.g cassandra)
+ 'Project files location' is where on the file system IDEA will create your 
Java project.
  
- {{attachment:project.png}}
+ {{attachment:NewProject-4.png}}
  
- You will need to add the "conf" to your sources, so that log4j properties can 
be found. 
+ Add the following Java source files to your module.
+   * interface/thrift/gen-java
+   * src/java
+   * test/unit
  
+ {{attachment:NewProjectChooseModules-5.png}}
- Right Click on Main Project "Cassandra-trunk" and select "Module Settings" 
and select "Dependencies" tab.
- Click "Add" and Choose "Module Dependency" and add "Interface" project to the 
dependency list
- Click "Add" again and choose "Single Entry Module Library" and add the conf 
folder containing log4j.properties file to the project path (ignore this step 
if the conf folder has been added to the project as a pre-cursory step)
  
- {{attachment:ModuleSettings.png}}
+ Uncheck the zookeeper jar file and press 'Next' followed by 'Finish' after 
you the review of the suggested module structure. I recommend to only have one 
module (Cassandra).
+ 
+ {{attachment:NewProjectReviewLibrariesFound-6.png}}
+ {{attachment:NewProjectReviewModuleStructure-7.png}}
+ 
+ Your project will be now imported into the IDEA project workspace. Wait until 
the project indexing is done. (This might take some time depending on your 
computer)
+ 
+ Your IDEA project workspace should now look something like this:
+ 
+ {{attachment:InitialProjectWorkspace-8.png}}
+  
+ Whats left now is to generate the Command Line Interface (CLI) grammar by 
ANTLR, add the "conf" folder to your sources, so that log4j properties can be 
found, generate the avro code and finally add these folders as "content roots". 
+ 
+ First we will generate some code (CLI grammar, avro bindings, thrift 
bindings). This is where ant enters the building.
+ 
+ Press the 'Ant Build' tab (far to the right), then 'Add' (the plus sign) and 
locate the build.xml in your cassandra project folder.
+ Run the ant 'build' target by double clicking on it (this should hopefully 
generate all the code necessary to run cassandra in IDEA).
+ (Press no if IDEA asks you to add some project specific files to git/svn 
version control).
+ 
+ {{attachment:Ant-9.png}}
+ 
+ Next step is to add the "conf" folder.
+ Choose 'View as: Packages" and right click on your cassandra project and pick 
'Module Settings'. Go to dependencies and press 'Add' then 'Single-Entry Module 
Library...' Now locate the conf folder and press 'Ok'. 
+ 
+ {{attachment:Single-EntryModuleDependency-10.png}}
+ 
+ Now it's time to add avro and thrift generated java files as 'content roots'.
+ Once again, right click on the cassandra project in the 'View as: Packages" 
perspective and choose 'Module Settings'
+ This time you press 'Add Content Root' and locate "interface/avro/gen-java", 
do the same for "interface/thrift/gen-java"
+ 
+ {{attachment:ContentRootAvro-11.png}}
+ {{attachment:ContentRootThrift-12.png}}
+ 
+ One final thing needs to be done in this view; choose the cassandra/src 
content root, right click on "gen-java" and click 'Sources'.
+ 
+ {{attachment:ContentRootSrc-13.png}}
  
  = Create a Cassandra application's RUN configuration =
  
- Create a new application called cassandra
+ Create a new application called cassandra (e.g Run -> Edit Configurations -> 
Add new configuration (insert) -> Application)
  
   * Main class
  
  {{{
-  org.apache.cassandra.service.CassandraDaemon
+  org.apache.cassandra.thrift.CassandraDaemon
  }}}
  
   * VM Parameters
@@ -47, +88 @@

   -Dcassandra -Dstorage-config=@@@ -ea -Xdebug 
-Xrunjdwp:transport=dt_socket,server=y,address=8888,suspend=n -Xms128M  -Xmx1G  
-XX:SurvivorRatio=8  -XX:TargetSurvivorRatio=90  -XX:+AggressiveOpts  
-XX:+UseParNewGC  -XX:+UseConcMarkSweepGC  -XX:CMSInitiatingOccupancyFraction=1 
 -XX:+CMSParallelRemarkEnabled -XX:+HeapDumpOnOutOfMemoryError 
-Dcom.sun.management.jmxremote.port=8080 
-Dcom.sun.management.jmxremote.ssl=false  
-Dcom.sun.management.jmxremote.authenticate=false
  }}}
  
- Replace @@@ above with the path to your conf folder, eg mine is 
"/home/dehora/projects/asf/cassandra/trunk/conf". The flags above are taken 
from the cassandra shell script.  
+ Replace @@@ above with the path to your conf folder, eg mine is 
"/Users/schildmeijer/workspace/cassandra/conf". The flags above are taken from 
the cassandra shell script.  
  
   * Working Directory
  
- eg mine is "/home/dehora/projects/asf/cassandra" 
+ eg mine is "/Users/schildmeijer/workspace/cassandra" 
  
-  * Environment variables
  
- eg,
+ {{attachment:EditConfigurations-14.png}}
  
+ Review and Modify storage-conf.xml and log4j.properties accordingly, as in 
certain cases directory creation of /var/cassandra fails due to ACLs of 
execution context
- {{{
- CASSANDRA_HOME: /home/dehora/projects/asf/cassandra/trunk
- CASSANDRA_CONF: /home/dehora/projects/asf/cassandra/trunk/conf
- }}}
  
- IDEA didn't expand these for me in the VM Parameters line, hence the 
hardcoded path above - you probably don't need them.
- 
- Mine looks like this
- 
- {{attachment:app.png}}
- 
- Review and Modify Storage-Conf.xml and log4j.properties accordingly, as in 
certain cases directory creation of /var/cassandra fails due to ACLs of 
execution context
- 
- Storage-Conf.xml
+ storage-conf.xml
  {{{
      Directories: Specify where Cassandra should store different data on disk
           Keep the data disks and the CommitLog disks separate for best 
performance
@@ -98, +127 @@

  When you start the app it should look similar to cmd line start, eg mine 
looks like this:
  
  {{{
- Connected to the target VM, address: '127.0.0.1:51235', transport: 'socket'
- DEBUG - Loading settings from 
/home/dehora/projects/asf/cassandra/trunk/conf/storage-conf.xml
- DEBUG - adding edges as 0
- DEBUG - adding extended_attributes as 1
- DEBUG - adding base_attributes as 2
- DEBUG - adding Super1 as 3
- DEBUG - adding Standard2 as 4
- DEBUG - adding Standard1 as 5
- DEBUG - adding StandardByTime1 as 6
- DEBUG - adding LocationInfo as 7
- DEBUG - adding HintsColumnFamily as 8
- DEBUG - INDEX LOAD TIME for 
/var/cassandra/data/users-base_attributes-2-Data.db: 50 ms.
- DEBUG - INDEX LOAD TIME for /var/cassandra/data/Table1-Standard1-2-Data.db: 0 
ms.
- DEBUG - INDEX LOAD TIME for /var/cassandra/data/Table1-Standard1-4-Data.db: 0 
ms.
- INFO - Replaying /var/cassandra/commitlog/CommitLog-1246387410151.log
- DEBUG - Starting to listen on 127.0.0.1:7001
+ Listening for transport dt_socket at address: 8888
+ DEBUG 18:49:27,959 Loading settings from 
/Users/schildmeijer/Documents/workspace/cassandra/conf/storage-conf.xml
+ DEBUG 18:49:28,141 Syncing log with a period of 10000
+  INFO 18:49:28,146 Auto DiskAccessMode determined to be mmap
+ DEBUG 18:49:28,268 setting autoBootstrap to false
+ DEBUG 18:49:28,446 Starting CFS Schema
+ DEBUG 18:49:28,464 Starting CFS Migrations
+ DEBUG 18:49:28,495 opening keyspace system
+ DEBUG 18:49:28,496 Starting CFS LocationInfo
+ DEBUG 18:49:28,497 key cache capacity for LocationInfo is 1
+ DEBUG 18:49:28,499 Starting CFS HintsColumnFamily
+ DEBUG 18:49:28,499 key cache capacity for HintsColumnFamily is 1
+ DEBUG 18:49:28,500 opening keyspace definitions
+ DEBUG 18:49:28,533 Estimating compactions for LocationInfo
+ DEBUG 18:49:28,543 Estimating compactions for HintsColumnFamily
+ DEBUG 18:49:28,543 Estimating compactions for Migrations
+ DEBUG 18:49:28,549 Estimating compactions for Schema
+ DEBUG 18:49:28,572 Checking to see if compaction of LocationInfo would be 
useful
+ DEBUG 18:49:28,573 Checking to see if compaction of HintsColumnFamily would 
be useful
+ DEBUG 18:49:28,573 Checking to see if compaction of Migrations would be useful
+ DEBUG 18:49:28,574 Checking to see if compaction of Schema would be useful
+  INFO 18:49:28,578 Saved Token not found. Using 
1816769162446994796948805497871322369
+  INFO 18:49:28,579 Saved ClusterName not found. Using Test Cluster
+  INFO 18:49:28,610 Creating new commitlog segment 
/var/lib/cassandra/commitlog/CommitLog-1270745368610.log
+  INFO 18:49:28,650 Starting up server gossip
+ DEBUG 18:49:28,737 attempting to connect to /127.0.0.1
+  INFO 18:49:28,800 Binding thrift service to localhost/127.0.0.1:9160
  }}}
- 
- 
- Mine looks like this
- 
- {{attachment:debug.png}}
  
  Try running the cassandra-cli as per CassandraCli, and you should be able to 
connect to localhost/9160.
  

Reply via email to