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 ...
随机推荐
- 转载《Spring AOP中pointcut expression表达式解析 及匹配多个条件》
原文地址:https://www.cnblogs.com/rainy-shurun/p/5195439.html 原文 Pointcut 是指那些方法需要被执行"AOP",是由&q ...
- oracle删除表空间下所有的表
SELECT 'DROP TABLE ' || TABLE_NAME || ' CASCADE CONSTRAINTS' V_NAME FROM DBA_TABLES WHERE TABLESPACE ...
- Ansible常用模块命令
Ansible常用模块命令 一.安装ansible yum install epel-release yum install ansible 二.配置文件配置 vi /etc/ansible/ansi ...
- s16 计算机网络基础
交换机设备说明 1)交换机设备说明 交换机概念:解决多台主机在一个网络里面通讯的需求 主机身份标识信息:称为叫做mac地址 交换机通讯的网络范围:称为叫做一个局域网 交换机传输数据问题: 01.会有广 ...
- spring常用接口 InitializingBean的作用
工作中遇到spring接口中的InitializingBean接口.浅浅的解说一下. --------------------------------------------------------- ...
- C#基础入门 九
C#基础入门 九 集合 对于很多应用程序,需要创建和管理相关对象组,有两种方式可以将对象分组,一是创建对象数组,如 object[] obj=new object[3]{1,2.33,"st ...
- C-sharp精华面试题
注:红色表示答案 一.选择,填空题 1. 在ADO.NET中,对于Command对象的ExecuteNonQuery()方法和ExecuteReader()方法,下面叙述错误的是(C). a) ...
- java中的软引用,弱引用,虚引用
http://zh.wikipedia.org/wiki/%E5%BC%B1%E5%BC%95%E7%94%A8 有些语言包含多种强度的弱引用.例如Java,在java.lang.ref[1]包中定义 ...
- 代码修改之后MSbuild编译不出最新的dll解决方法
问题: 使用jenkins发布的时候,开发不断反馈自己修改的文件使用jenkins没有发布到测试环境.经过查证发现使用MSBUILD编译的时出现修改的文件编译出的日期不是最新日期,但是使用VS编译就不 ...
- hadoop 2.7.3伪分布式安装
hadoop 2.7.3伪分布式安装 hadoop集群的伪分布式部署由于只需要一台服务器,在测试,开发过程中还是很方便实用的,有必要将搭建伪分布式的过程记录下来,好记性不如烂笔头. hadoop 2. ...