blob: 97b89ba43f3c10068cf2370d2b896887bce12775 [file] [log] [blame]
<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Building and IDE Integration &mdash; Apache Cassandra Documentation v4.0-rc2</title>
<link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../_static/extra.css" type="text/css" />
<!--[if lt IE 9]>
<script src="../_static/js/html5shiv.min.js"></script>
<![endif]-->
<script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
<script src="../_static/jquery.js"></script>
<script src="../_static/underscore.js"></script>
<script src="../_static/doctools.js"></script>
<script type="text/javascript" src="../_static/js/theme.js"></script>
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
<link rel="next" title="Testing" href="testing.html" />
<link rel="prev" title="Getting Started" href="gettingstarted.html" />
</head>
<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" >
<a href="../index.html" class="icon icon-home"> Apache Cassandra
</a>
<div class="version">
4.0-rc2
</div>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../getting_started/index.html">Getting Started</a></li>
<li class="toctree-l1"><a class="reference internal" href="../new/index.html">New Features in Apache Cassandra 4.0</a></li>
<li class="toctree-l1"><a class="reference internal" href="../architecture/index.html">Architecture</a></li>
<li class="toctree-l1"><a class="reference internal" href="../cql/index.html">The Cassandra Query Language (CQL)</a></li>
<li class="toctree-l1"><a class="reference internal" href="../data_modeling/index.html">Data Modeling</a></li>
<li class="toctree-l1"><a class="reference internal" href="../configuration/index.html">Configuring Cassandra</a></li>
<li class="toctree-l1"><a class="reference internal" href="../operating/index.html">Operating Cassandra</a></li>
<li class="toctree-l1"><a class="reference internal" href="../tools/index.html">Cassandra Tools</a></li>
<li class="toctree-l1"><a class="reference internal" href="../troubleshooting/index.html">Troubleshooting</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="index.html">Contributing to Cassandra</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="gettingstarted.html">Getting Started</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="#">Building and IDE Integration</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#building-from-source">Building From Source</a></li>
<li class="toctree-l3"><a class="reference internal" href="#setting-up-cassandra-in-intellij-idea">Setting up Cassandra in IntelliJ IDEA</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#setup-cassandra-as-a-project-c-2-1-and-newer">Setup Cassandra as a Project (C* 2.1 and newer)</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="#opening-cassandra-in-apache-netbeans">Opening Cassandra in Apache NetBeans</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#open-cassandra-as-a-project-c-4-0-and-newer">Open Cassandra as a Project (C* 4.0 and newer)</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="#setting-up-cassandra-in-eclipse">Setting up Cassandra in Eclipse</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#project-settings">Project Settings</a></li>
<li class="toctree-l4"><a class="reference internal" href="#unit-tests">Unit Tests</a></li>
<li class="toctree-l4"><a class="reference internal" href="#debugging-cassandra-using-eclipse">Debugging Cassandra Using Eclipse</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="testing.html">Testing</a></li>
<li class="toctree-l2"><a class="reference internal" href="patches.html">Contributing Code Changes</a></li>
<li class="toctree-l2"><a class="reference internal" href="code_style.html">Code Style</a></li>
<li class="toctree-l2"><a class="reference internal" href="license_compliance.html">License Compliance</a></li>
<li class="toctree-l2"><a class="reference internal" href="how_to_review.html">Review Checklist</a></li>
<li class="toctree-l2"><a class="reference internal" href="how_to_commit.html">How-to Commit</a></li>
<li class="toctree-l2"><a class="reference internal" href="documentation.html">Working on Documentation</a></li>
<li class="toctree-l2"><a class="reference internal" href="ci.html">Jenkins CI Environment</a></li>
<li class="toctree-l2"><a class="reference internal" href="dependencies.html">Dependency Management</a></li>
<li class="toctree-l2"><a class="reference internal" href="release_process.html">Release Process</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../faq/index.html">Frequently Asked Questions</a></li>
<li class="toctree-l1"><a class="reference internal" href="../plugins/index.html">Third-Party Plugins</a></li>
<li class="toctree-l1"><a class="reference internal" href="../bugs.html">Reporting Bugs</a></li>
<li class="toctree-l1"><a class="reference internal" href="../contactus.html">Contact us</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="../index.html">Apache Cassandra</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="../index.html" class="icon icon-home"></a> &raquo;</li>
<li><a href="index.html">Contributing to Cassandra</a> &raquo;</li>
<li>Building and IDE Integration</li>
<li class="wy-breadcrumbs-aside">
<a href="../_sources/development/ide.rst.txt" rel="nofollow"> View page source</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<div class="section" id="building-and-ide-integration">
<h1>Building and IDE Integration<a class="headerlink" href="#building-and-ide-integration" title="Permalink to this headline"></a></h1>
<div class="section" id="building-from-source">
<h2>Building From Source<a class="headerlink" href="#building-from-source" title="Permalink to this headline"></a></h2>
<p>Getting started with Cassandra and IntelliJ IDEA or Eclipse is simple, once you manage to build Cassandra from source using <a class="reference external" href="http://www.oracle.com/technetwork/java/javase/downloads/index.html">Java 8</a>, <a class="reference external" href="https://git-scm.com/">Git</a> and <a class="reference external" href="http://ant.apache.org/">Ant</a>.</p>
<p>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:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">git</span> <span class="n">clone</span> <span class="n">https</span><span class="p">:</span><span class="o">//</span><span class="n">gitbox</span><span class="o">.</span><span class="n">apache</span><span class="o">.</span><span class="n">org</span><span class="o">/</span><span class="n">repos</span><span class="o">/</span><span class="n">asf</span><span class="o">/</span><span class="n">cassandra</span><span class="o">.</span><span class="n">git</span> <span class="n">cassandra</span><span class="o">-</span><span class="n">trunk</span>
</pre></div>
</div>
<p>Other branches will point to different versions of Cassandra. Switching to a different branch requires checking out the branch by its name:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">git</span> <span class="n">checkout</span> <span class="n">cassandra</span><span class="o">-</span><span class="mf">3.0</span>
</pre></div>
</div>
<p>You can get a list of available branches with <code class="docutils literal notranslate"><span class="pre">git</span> <span class="pre">branch</span></code>.</p>
<p>Finally build Cassandra using ant:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ant</span>
</pre></div>
</div>
<p>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.</p>
<div class="admonition hint">
<p class="admonition-title">Hint</p>
<p>You can setup multiple working trees for different Cassandra versions from the same repository using <a class="reference external" href="https://git-scm.com/docs/git-worktree">git-worktree</a>.</p>
</div>
<div class="line-block">
<div class="line"><br /></div>
</div>
</div>
<div class="section" id="setting-up-cassandra-in-intellij-idea">
<h2>Setting up Cassandra in IntelliJ IDEA<a class="headerlink" href="#setting-up-cassandra-in-intellij-idea" title="Permalink to this headline"></a></h2>
<p><a class="reference external" href="https://www.jetbrains.com/idea/">IntelliJ IDEA</a> 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.</p>
<div class="section" id="setup-cassandra-as-a-project-c-2-1-and-newer">
<h3>Setup Cassandra as a Project (C* 2.1 and newer)<a class="headerlink" href="#setup-cassandra-as-a-project-c-2-1-and-newer" title="Permalink to this headline"></a></h3>
<p>Since 2.1.5, there is a new ant target: <code class="docutils literal notranslate"><span class="pre">generate-idea-files</span></code>. Please see our <a class="reference external" href="https://wiki.apache.org/cassandra/RunningCassandraInIDEA">wiki</a> for instructions for older Cassandra versions.</p>
<p>Please clone and build Cassandra as described above and execute the following steps:</p>
<ol class="arabic simple">
<li><p>Once Cassandra is built, generate the IDEA files using ant:</p></li>
</ol>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ant</span> <span class="n">generate</span><span class="o">-</span><span class="n">idea</span><span class="o">-</span><span class="n">files</span>
</pre></div>
</div>
<ol class="arabic simple" start="2">
<li><p>Start IDEA</p></li>
<li><p>Open the IDEA project from the checked out Cassandra directory using the menu item Open in IDEA’s File menu</p></li>
</ol>
<p>The project generated by the ant task <code class="docutils literal notranslate"><span class="pre">generate-idea-files</span></code> contains nearly everything you need to debug Cassandra and execute unit tests.</p>
<blockquote>
<div><ul class="simple">
<li><p>Run/debug defaults for JUnit</p></li>
<li><p>Run/debug configuration for Cassandra daemon</p></li>
<li><p>License header for Java source files</p></li>
<li><p>Cassandra code style</p></li>
<li><p>Inspections</p></li>
</ul>
</div></blockquote>
<div class="line-block">
<div class="line"><br /></div>
</div>
</div>
</div>
<div class="section" id="opening-cassandra-in-apache-netbeans">
<h2>Opening Cassandra in Apache NetBeans<a class="headerlink" href="#opening-cassandra-in-apache-netbeans" title="Permalink to this headline"></a></h2>
<p><a class="reference external" href="https://netbeans.apache.org/">Apache NetBeans</a> is the elder of the open sourced java IDEs, and can be used for Cassandra development. There is no project setup or generation required to open Cassandra in NetBeans.</p>
<div class="section" id="open-cassandra-as-a-project-c-4-0-and-newer">
<h3>Open Cassandra as a Project (C* 4.0 and newer)<a class="headerlink" href="#open-cassandra-as-a-project-c-4-0-and-newer" title="Permalink to this headline"></a></h3>
<p>Please clone and build Cassandra as described above and execute the following steps:</p>
<ol class="arabic simple">
<li><p>Start Apache NetBeans</p></li>
<li><p>Open the NetBeans project from the <cite>ide/</cite> folder of the checked out Cassandra directory using the menu item “Open Project…” in NetBeans’ File menu</p></li>
</ol>
<p>The project opened supports building, running, debugging, and profiling Cassandra from within the IDE. These actions delegate to the ant <cite>build.xml</cite> script.</p>
<blockquote>
<div><ul class="simple">
<li><p>Build/Run/Debug Project is available via the Run/Debug menus, or the project context menu.</p></li>
<li><p>Profile Project is available via the Profile menu. In the opened Profiler tab, click the green “Profile” button.</p></li>
<li><p>Cassandra’s code style is honored in <cite>ide/nbproject/project.properties</cite></p></li>
</ul>
</div></blockquote>
<p>The <cite>JAVA8_HOME</cite> system variable must be set in the environment that NetBeans starts in for the Run/Debug/Profile ant targets to execute.</p>
<div class="line-block">
<div class="line"><br /></div>
</div>
</div>
</div>
<div class="section" id="setting-up-cassandra-in-eclipse">
<h2>Setting up Cassandra in Eclipse<a class="headerlink" href="#setting-up-cassandra-in-eclipse" title="Permalink to this headline"></a></h2>
<p>Eclipse is a popular open source IDE that can be used for Cassandra development. Various Eclipse environments are available from the <a class="reference external" href="https://www.eclipse.org/downloads/eclipse-packages/">download page</a>. The following guide was created with “Eclipse IDE for Java Developers”.</p>
<p>These instructions were tested on Ubuntu 16.04 with Eclipse Neon (4.6) using Cassandra 2.1, 2.2 and 3.x.</p>
<div class="section" id="project-settings">
<h3>Project Settings<a class="headerlink" href="#project-settings" title="Permalink to this headline"></a></h3>
<p><strong>It is important that you generate the Eclipse files with Ant before trying to set up the Eclipse project.</strong></p>
<blockquote>
<div><ul class="simple">
<li><p>Clone and build Cassandra as described above.</p></li>
<li><p>Run <code class="docutils literal notranslate"><span class="pre">ant</span> <span class="pre">generate-eclipse-files</span></code> to create the Eclipse settings.</p></li>
<li><p>Start Eclipse.</p></li>
<li><p>Select <code class="docutils literal notranslate"><span class="pre">File-&gt;Import-&gt;Existing</span> <span class="pre">Projects</span> <span class="pre">into</span> <span class="pre">Workspace-&gt;Select</span> <span class="pre">git</span> <span class="pre">directory</span></code>.</p></li>
<li><p>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).</p></li>
<li><p>Confirm “Finish” to have your project imported.</p></li>
</ul>
</div></blockquote>
<p>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.</p>
</div>
<div class="section" id="unit-tests">
<h3>Unit Tests<a class="headerlink" href="#unit-tests" title="Permalink to this headline"></a></h3>
<p>Unit tests can be run from Eclipse by simply right-clicking the class file or method and selecting <code class="docutils literal notranslate"><span class="pre">Run</span> <span class="pre">As-&gt;JUnit</span> <span class="pre">Test</span></code>. Tests can be debugged this way as well by defining breakpoints (double-click line number) and selecting <code class="docutils literal notranslate"><span class="pre">Debug</span> <span class="pre">As-&gt;JUnit</span> <span class="pre">Test</span></code>.</p>
<p>Alternatively all unit tests can be run from the command line as described in <a class="reference internal" href="testing.html"><span class="doc">Testing</span></a></p>
</div>
<div class="section" id="debugging-cassandra-using-eclipse">
<h3>Debugging Cassandra Using Eclipse<a class="headerlink" href="#debugging-cassandra-using-eclipse" title="Permalink to this headline"></a></h3>
<p>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 <code class="docutils literal notranslate"><span class="pre">./bin/cassandra</span></code> script and connect to the JVM through <a class="reference external" href="https://docs.oracle.com/javase/8/docs/technotes/guides/troubleshoot/introclientissues005.html">remotely</a> from Eclipse or start Cassandra from Eclipse right away.</p>
<div class="section" id="starting-cassandra-from-command-line">
<h4>Starting Cassandra From Command Line<a class="headerlink" href="#starting-cassandra-from-command-line" title="Permalink to this headline"></a></h4>
<blockquote>
<div><ul class="simple">
<li><p>Set environment variable to define remote debugging options for the JVM:
<code class="docutils literal notranslate"><span class="pre">export</span> <span class="pre">JVM_EXTRA_OPTS=&quot;-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=1414&quot;</span></code></p></li>
<li><p>Start Cassandra by executing the <code class="docutils literal notranslate"><span class="pre">./bin/cassandra</span></code></p></li>
</ul>
</div></blockquote>
<p>Afterwards you should be able to connect to the running Cassandra process through the following steps:</p>
<p>From the menu, select <code class="docutils literal notranslate"><span class="pre">Run-&gt;Debug</span> <span class="pre">Configurations..</span></code></p>
<img alt="../_images/eclipse_debug0.png" src="../_images/eclipse_debug0.png" />
<p>Create new remote application</p>
<img alt="../_images/eclipse_debug1.png" src="../_images/eclipse_debug1.png" />
<p>Configure connection settings by specifying a name and port 1414</p>
<img alt="../_images/eclipse_debug2.png" src="../_images/eclipse_debug2.png" />
<p>Afterwards confirm “Debug” to connect to the JVM and start debugging Cassandra!</p>
</div>
<div class="section" id="starting-cassandra-from-eclipse">
<h4>Starting Cassandra From Eclipse<a class="headerlink" href="#starting-cassandra-from-eclipse" title="Permalink to this headline"></a></h4>
<p>Cassandra can also be started directly from Eclipse if you don’t want to use the command line.</p>
<p>From the menu, select <code class="docutils literal notranslate"><span class="pre">Run-&gt;Run</span> <span class="pre">Configurations..</span></code></p>
<img alt="../_images/eclipse_debug3.png" src="../_images/eclipse_debug3.png" />
<p>Create new application</p>
<img alt="../_images/eclipse_debug4.png" src="../_images/eclipse_debug4.png" />
<p>Specify name, project and main class <code class="docutils literal notranslate"><span class="pre">org.apache.cassandra.service.CassandraDaemon</span></code></p>
<img alt="../_images/eclipse_debug5.png" src="../_images/eclipse_debug5.png" />
<p>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.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">-</span><span class="n">Xms1024M</span> <span class="o">-</span><span class="n">Xmx1024M</span> <span class="o">-</span><span class="n">Xmn220M</span> <span class="o">-</span><span class="n">Xss256k</span> <span class="o">-</span><span class="n">ea</span> <span class="o">-</span><span class="n">XX</span><span class="p">:</span><span class="o">+</span><span class="n">UseThreadPriorities</span> <span class="o">-</span><span class="n">XX</span><span class="p">:</span><span class="n">ThreadPriorityPolicy</span><span class="o">=</span><span class="mi">42</span> <span class="o">-</span><span class="n">XX</span><span class="p">:</span><span class="o">+</span><span class="n">UseParNewGC</span> <span class="o">-</span><span class="n">XX</span><span class="p">:</span><span class="o">+</span><span class="n">UseConcMarkSweepGC</span> <span class="o">-</span><span class="n">XX</span><span class="p">:</span><span class="o">+</span><span class="n">CMSParallelRemarkEnabled</span> <span class="o">-</span><span class="n">XX</span><span class="p">:</span><span class="o">+</span><span class="n">UseCondCardMark</span> <span class="o">-</span><span class="n">javaagent</span><span class="p">:</span><span class="o">./</span><span class="n">lib</span><span class="o">/</span><span class="n">jamm</span><span class="o">-</span><span class="mf">0.3</span><span class="o">.</span><span class="mf">0.</span><span class="n">jar</span> <span class="o">-</span><span class="n">Djava</span><span class="o">.</span><span class="n">net</span><span class="o">.</span><span class="n">preferIPv4Stack</span><span class="o">=</span><span class="n">true</span>
</pre></div>
</div>
<img alt="../_images/eclipse_debug6.png" src="../_images/eclipse_debug6.png" />
<p>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!</p>
</div>
</div>
</div>
</div>
</div>
</div>
<footer>
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
<a href="testing.html" class="btn btn-neutral float-right" title="Testing" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
<a href="gettingstarted.html" class="btn btn-neutral float-left" title="Getting Started" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
</div>
<hr/>
<div role="contentinfo">
<p>
&#169; Copyright 2020, The Apache Cassandra team.
</p>
</div>
Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
<a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
</body>
</html>