RunningCassandraInEclipse(转载)
转载自:http://wiki.apache.org/cassandra/RunningCassandraInEclipse
Eclipse is open source. Download Eclipse from http://www.eclipse.org/downloads/. There is no need for the Enterprise Edition (EE) version of Eclipse. Hence "Eclipse IDE for Java Developers" is good enough.
Cassandra is using Git for version control. In this tutorial we will checkout Cassandra from it.
The previous version of this guide used the Subclipse (http://subclipse.tigris.org/) Eclipse Subversion plugin. However, over time, the instructions became out-of-date and confusing - if you are currently using Subclipse or Subversive successfully with Cassandra be aware as of December 2011 Cassandra was switched to Git.
For the moment, we will a command-line Subversion client.
Checkout and setup Cassandra
Preconditions: JDK6, Ant (http://ant.apache.org/), Eclipse, Git.
These instructions were originally tested on Ubuntu 11.04, Eclipse Indigo SR1, on the trunk code shortly after the release of Cassandra 1.0.
From the console, checkout the code using Git. Here we assume you are checking out the latest trunk, but browse http://git-wip-us.apache.org/repos/asf/cassandra.git for all available versions...
git clone http://git-wip-us.apache.org/repos/asf/cassandra.git cassandra-trunk cd cassandra-trunk ant build ant generate-eclipse-files
The ant build step may take some time as various libraries are downloaded. This step will do a whole lot of good things, eg. generate the CLI grammar with ANTLR, generate Thrift RPC code...
It is important that you generate the Eclipse files with Ant before trying to set up the Eclipse project. In the previous version of this tutorial, we executed the Ant tasks after importing the code into Eclipse, which tends to confuse Eclipse mightily, leaving you stuck with about 2000 compiler errors that you can't get rid of.
Setup Eclipse
- Start Eclipse.
Click the File->New->Java Project menu
- Enter "cassandra-trunk" as the project name (assuming you checked the code out into the folder cassandra-trunk as shown above. If your project name doesn't match the top-level folder name you may get problems).
- Untick "Use default location" and browse to the top-level folder you just checked out (cassandra-trunk).
- Click "Next"
Verify that the Default Output Folder is cassandra-trunk/build/classes/main. Eclipse normally defaults to bin which we DO NOT want for Cassandra.
- Click "Finish"
(The Eclipse console will show a few lines of output as the build process runs).
That's it. There should be no errors shown in the Problems view or the Package Explorer. In fact, problem markers (Errors and warnings in the Problems pane and in the Package Explorer) will not be working at all, because the custom builder replaces the default Java Builder. This should probably be fixed...
...in the meantime, you can add back the default Java Builder alongside the custom Ant Builder. Close Eclipse, edit .project to add the following next to the existingbuildCommand tag, and save the file
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
Then restart Eclipse, and refresh the project (F5). You should then see plenty of warnings (about 2400 at the time of writing) in the Problems view.
Common Errors
artifact:pom error
If you get the error artifact:pom doesn't support the "groupId" attribute when running ant build, the make sure your copy of Ant is up to date, and try downloading the latest Maven Ant Tasks from http://maven.apache.org/ant-tasks/download.html and add the jarfile to your Ant installation's lib directory.
Access Restriction
Some Eclipse users have complained about the following error message:
Access restriction: The method getDuration() from the type GcInfo is not accessible due to restriction on required library /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Classes/classes.jar.
This is because some parts of the Cassandra project are using stuff from the com.sun.* package and Eclipse's "default behaviour" (bug?) is to report that as an error, Intellij IDEA does not. By simply reploading the "JRE System Library" this will hopefully disappear. To do that, 1) go to your build path settings for your cassandra project in Eclipse, and under the libraries tab, select "JRE System Library" and click the "Remove" button 2) re-add the JRE System Library using "Add Library" (Thanks Todd Blose for this excellent solution!)

Still "Access restrictions" problems? Another solution to fix this is to change the ”severity level" from error to e.g warning for this. To do this right click on your cassandra project -> "Properties" -> "Java Compiler" -> "Error/Warnings" and locate "Forbidden reference (access rule)" under "Deprecated and restricted API")

Now the errors should be gone and you are ready to create a run/debug configuration for cassandra.
StackOverflowError
If you get a StackOverflowError while building Cassandra, you may need to upgrade to a more recent version of Ant (at least 1.8.1) - see https://issues.apache.org/jira/browse/CASSANDRA-2640. To upgrade Ant, you may need to upgrade to a recent version of Eclipse, as older versions (e.g. Helios SR2) don't appear to offer an upgrade via "Check for Updates" or "Install New Software".
(See https://bugs.eclipse.org/bugs/show_bug.cgi?id=302296 for recent history of the efforts to get Eclipse up to this version of Ant!)
Variable references non-existent resource
If you get the following (probably when refreshing the project after first setting it up):
Errors occurred during the build.
Errors running builder 'Integrated External Tool Builder' on project 'Cassandra-trunk'.
Variable references non-existent resource : ${workspace_loc:/cassandra-trunk/build.xml}
Variable references non-existent resource : ${workspace_loc:/cassandra-trunk/build.xml}
This probably means that the project name you chose in Eclipse doesn't match the top-level directory (must match exactly, including capitalisation). Go to Project->Properties->Builders, select Cassandra-Ant-Builder, Edit, and fix the Build File and Base Directory to match the name in Eclipse (the easiest way is just to browse to the right file/folder).
Can't find javadoc.exe
On Windows, at least, if you try to run an Ant target that invokes javadoc (such as the artifacts target), then you may get an error like:
Javadoc failed: java.io.IOException: Cannot run program "javadoc.exe": CreateProcess error=2, The system cannot find the file specified
Like it says, Eclipse can't find Javadoc.exe because it's not on the path.
The simplest fix seems to be to go to External Tools Configurations, and edit your configuration for the Cassandra build.xml: go to the JRE tab and make sure that you have selected a JDK not a JRE.
See http://blog.darevay.com/2008/12/running-javadoc-ant-task-from-eclipse/ for some discussion of this issue and some alternative fixes.
Other compile errors
If Eclipse still complains about compile errors it may be because 'src' (and not 'src/java') is added as source folder. To fix this I recommend to remove 'src' from build path and add 'src/java' to the build path.
Unit Tests
Question - can JUnit tests be run through Eclipse, or should they only be run using the Ant build target?
Note that some of the unit tests use Java assert as well as JUnit assertEquals() etc, so they need to be run with assertions enabled in the JVM (using -ea). If you just run them directly in Eclipse/JUnit without assertions enabled, you may get false test passes.
Run Cassandra
Click "Run" -> "Run Configurations...". Select org.apache.cassandra.thrift.CassandraDaemon as you Main class, make sure that your cassandra project is selected in the "Project" field. Under the Arguments tab you can specify VM arguments. Below is my complete VM arguments list for Cassandra 0.6:
-Dstorage-config=/Users/schildmeijer/Documents/workspace/cassandra/conf/
-Dcassandra-foreground
-ea -Xmx1G
Below are another set of VM arguments for running Cassandra 0.7+ in Windows. Notice that for config file property has changed to cassandra.config from storage-config in 0.6 and that all the files need to have "file:" perpended, for example:
-Dcassandra.config=file:C:\Users\Joaquin\workspace\cassandra-3\conf\cassandra.yaml
-Dcassandra-foreground
-ea -Xmx1G
-Dlog4j.configuration=file:C:\Users\Joaquin\workspace\cassandra-3\conf\log4j-server.properties
or
-Dcassandra.config=file:/home/david/programming/java/cassandra/conf/cassandra.yaml
-Dcassandra-foreground
-ea -Xmx1G
-Dlog4j.configuration=file:/home/david/programming/java/cassandra/conf/log4j-server.properties
Make sure to change the storage-config property so it defines the path to your storage-conf.xml file.
Add the following VM arguments if you want to use nodetool
-Djava.rmi.server.hostname=$JMX_HOST
-Dcom.sun.management.jmxremote.port=$JMX_PORT
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false
replace $JMX_HOST and $JMX_PORT with your own configurations.
That should be it. After running the newly created run configuration you should see something like this in the console view.
11/10/22 21:52:31 INFO service.AbstractCassandraDaemon: JVM vendor/version: Java HotSpot(TM) 64-Bit Server VM/1.6.0_27
11/10/22 21:52:31 INFO service.AbstractCassandraDaemon: Heap size: 96468992/1431699456
11/10/22 21:52:31 INFO service.AbstractCassandraDaemon: Classpath: C:\Users\David\eclipse_workspace\cassandra-trunk\build\classes\main; [...]
11/10/22 21:52:31 INFO utils.CLibrary: Unable to link C library. Native methods will be disabled.
11/10/22 21:52:31 INFO config.DatabaseDescriptor: Loading settings from file:C:/Users/David/eclipse_workspace/cassandra-trunk/conf/cassandra.yaml
11/10/22 21:52:31 INFO config.DatabaseDescriptor: DiskAccessMode 'auto' determined to be mmap, indexAccessMode is mmap
11/10/22 21:52:31 INFO config.DatabaseDescriptor: Global memtable threshold is enabled at 455MB
11/10/22 21:52:31 INFO config.DatabaseDescriptor: Couldn't detect any schema definitions in local storage.
11/10/22 21:52:31 INFO config.DatabaseDescriptor: Found table data in data directories. Consider using the CLI to define your schema.
11/10/22 21:52:31 INFO commitlog.CommitLogSegment: Creating new commitlog segment /var/lib/cassandra/commitlog\CommitLog-1319316751680.log
11/10/22 21:52:31 INFO commitlog.CommitLog: No commitlog files found; skipping replay
11/10/22 21:52:31 INFO service.StorageService: Cassandra version: 1.0.0-SNAPSHOT
11/10/22 21:52:31 INFO service.StorageService: Thrift API version: 19.18.0
11/10/22 21:52:31 INFO service.StorageService: Loading persisted ring state
11/10/22 21:52:31 INFO service.StorageService: Starting up server gossip
11/10/22 21:52:31 INFO db.ColumnFamilyStore: Enqueuing flush of Memtable-LocationInfo@779185335(192/240 serialized/live bytes, 4 ops)
11/10/22 21:52:31 INFO db.Memtable: Writing Memtable-LocationInfo@779185335(192/240 serialized/live bytes, 4 ops)
11/10/22 21:52:31 INFO db.Memtable: Completed flushing \var\lib\cassandra\data\system\LocationInfo-h-1-Data.db (300 bytes)
11/10/22 21:52:31 INFO net.MessagingService: Starting Messaging Service on localhost/127.0.0.1:7000
11/10/22 21:52:31 INFO service.StorageService: This node will not auto bootstrap because it is configured to be a seed node.
11/10/22 21:52:31 WARN service.StorageService: Generated random token 83227525456023497602384283663789453783. Random tokens will result in an unbalanced ring; see http://wiki.apache.org/cassandra/Operations
11/10/22 21:52:31 INFO db.ColumnFamilyStore: Enqueuing flush of Memtable-LocationInfo@753505921(53/66 serialized/live bytes, 2 ops)
11/10/22 21:52:31 INFO db.Memtable: Writing Memtable-LocationInfo@753505921(53/66 serialized/live bytes, 2 ops)
11/10/22 21:52:32 INFO db.Memtable: Completed flushing \var\lib\cassandra\data\system\LocationInfo-h-2-Data.db (163 bytes)
11/10/22 21:52:32 INFO service.StorageService: Node localhost/127.0.0.1 state jump to normal
11/10/22 21:52:32 INFO service.StorageService: Bootstrap/Replace/Move completed! Now serving reads.
11/10/22 21:52:32 INFO utils.Mx4jTool: Will not load MX4J, mx4j-tools.jar is not in the classpath
11/10/22 21:52:32 INFO thrift.CassandraDaemon: Binding thrift service to localhost/127.0.0.1:9160
11/10/22 21:52:32 INFO thrift.CassandraDaemon: Using TFastFramedTransport with a max frame size of 15728640 bytes.
11/10/22 21:52:32 INFO thrift.CassandraDaemon: Using synchronous/threadpool thrift server on localhost/127.0.0.1 : 9160
11/10/22 21:52:32 INFO thrift.CassandraDaemon: Listening for thrift clients...
Note: You may find that you receive an error like: java.io.IOError: java.io.IOException: unable to mkdirs /var/lib/cassandra/data
when running org.apache.cassandra.thrift.CassandraDaemon. This is because the cassandra.yaml file contains this path. Change these paths to a path which you have access to.
Try running the cassandra-cli as per CassandraCli, and you should be able to connect to localhost/9160.
Problems? contact me (rschildmeijer) in #cassandra on irc (freenode).
RunningCassandraInEclipse(转载)的更多相关文章
- Crystal Clear Applied: The Seven Properties of Running an Agile Project (转载)
作者Alistair Cockburn, Crystal Clear的7个成功要素,写得挺好. 敏捷方法的关注点,大家可以参考,太激动所以转载了. 原文:http://www.informit.com ...
- RTP与RTCP协议介绍(转载)
RTSP发起/终结流媒体.RTP传输流媒体数据 .RTCP对RTP进行控制,同步.RTP中没有连接的概念,本身并不能为按序传输数据包提供可靠的保证,也不提供流量控制和拥塞控制,这些都由RTCP来负责完 ...
- 《Walking the callstack(转载)》
本文转载自:https://www.codeproject.com/articles/11132/walking-the-callstack Download demo project with so ...
- [转载]MVVM模式原理分析及实践
没有找到很好的MVVM模式介绍文章,简单找了一篇,分享一下.MVVM实现了UI\UE设计师(Expression Blend 4设计界面)和软件工程师的合理分工,在SilverLight.WPF.Wi ...
- [转载]:STM32为什么必须先配置时钟再配置GPIO
转载来源 :http://blog.csdn.net/fushiqianxun/article/details/7926442 [原创]:我来添两句,就是很多同学(包括我)之前搞低端单片机,到了stm ...
- [转载]从MyEclipse到IntelliJ IDEA-让你摆脱鼠标,全键盘操作
从MyEclipse转战到IntelliJ IDEA的经历 注转载址:http://blog.csdn.net/luoweifu/article/details/13985835 我一个朋友写了一篇“ ...
- TCP同步与异步,长连接与短连接【转载】
原文地址:TCP同步与异步,长连接与短连接作者:1984346023 [转载说明:http://zjj1211.blog.51cto.com/1812544/373896 这是今天看到的一篇讲到T ...
- 在CentOS 7/6.5/6.4 中安装Java JDK 8(转载)
转载在CentOS 7/6.5/6.4 中安装Java JDK 8 首先,在你的服务器上运行一下更新. yum update 然后,在您的系统上搜索,任何版本的已安装的JDK组件. rpm -qa | ...
- 用C#实现MD5的加密(转载)
方法一 首先,先简单介绍一下MD5 MD5的全称是message-digest algorithm 5(信息-摘要算法,在90年代初由mit laboratory for computer scien ...
随机推荐
- 因式分解 · Factor Combinations
[抄题]: 给出 n = 8 返回 [[2,2,2],[2,4]] // 8 = 2 x 2 x 2 = 2 x 4 [暴力解法]: 时间分析: 空间分析: [思维问题]: [一句话思路]: 类似于全 ...
- yii 关于如何改变默认访问的控制器(site)
以前Yii1学了个皮毛就没去管了,现在想重新捡起来Yii2.0.2却出来了,于是搭建好环境来学习. 安装好Yii2后第一个想到的问题就是修改默认的控制器了. 按照网上所说,终于在/vendor/yii ...
- Laravel中Trait的用法实例详解
本文实例讲述了Laravel中Trait的用法.分享给大家供大家参考,具体如下: 看看PHP官方手册对Trait的定义: 自 PHP 5.4.0 起,PHP 实现了代码复用的一个方法,称为 trait ...
- Windows环境和Linux环境下Redis主从复制配置
Windows环境下和Linux环境下配置Redis主从复制基本上一样,都是更改配置文件.Windows环境下修改的配置文件是:redis.windows.conf.redis.windows-ser ...
- 交互原型画得丑?29个优秀UI/UX线框草图
现在越来越多UI设计师都需要画一些交互的线框图,然而作为视觉专家,当然要把它画得靓靓的嘛,是不是?所以很多用户会使用<5款高效的原型设计工具>来绘制,或者直接手绘更有逼格. 今天达人手工整 ...
- HRBUST1311 火影忍者之~忍者村 2017-03-06 16:06 106人阅读 评论(0) 收藏
火影忍者之-忍者村 忍者村是忍者聚居的村子,相等于国家的军事力量.绝大部分村民都是忍者,有一些忍者会在村内开设书店.餐厅等,不过大部分忍者都是为村子执行任务的忍者,以赚取酬劳,并于战时为国家出战. ...
- Charles网络工具
Charles 是在 Mac 下常用的网络封包截取工具,在做移动开发时,我们为了调试与服务器端的网络通讯协议,常常需要截取网络封包来分析. Charles 通过将自己设置成系统的网络访问代理服务器,使 ...
- OpenGL中常用的函数
OPengl的官方文档如下:https://www.opengl.org/sdk/docs/man4/ void glGetIntegerv( GLenum pname, GLint * ...
- Android-GsonUtil-工具类
GsonUtil-工具类 是把Google提供的Gons进行了方法封装,提供了关于一些常用的Gons使用的公共方法: package common.library.utils; import andr ...
- Github的注册经历
姓名 韦军 学号 1413042023 班级 网络141 兴趣爱好 读书 上网 在注册Github时,先去网上下载了一个Github的app,打开一看全是英文,还是看懂了一些,点击开始注册,在注册时还 ...