官方文档太啰嗦,而且不跟我的习惯不和。
下面记录以下自己使用eclipse搭建kylin开发调试环境的过程。
1、eclipse环境:
包含maven的m2e插件,sysdeo tomcat插件,使用tomcat运行kylin,不使用官方的DebugTomcat,eclipse workspace关闭各种无用的validator,尤其是javascript的;
2、hadoop,hbase,hive搭建:
这个参考各个工程的文档;
3、git clone代码:
git clone https://github.com/apache/kylin.git
4、kylin导入eclipse:
使用maven方式导入,File>>import>>maven>>Existing Maven Projects,导入成功建立一堆project,实际代码没有那么复杂,很多工程没多少代码,弄清楚各个工程的用处后就觉得简单了;
5、server下的pom增加hibernate-validator依赖包
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>4.3.1.Final</version>
</dependency>
6、hbase,hadoop,hive依赖包:
kylin自身的hbase,hadoop,hive依赖包使用环境变量在运行时shell里通过查找环境变量将相关依赖jar中加入classpath,我们实际开发中可不像这样,这样需要将server/pom.xml的相关依赖该provider未compile;
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-common</artifactId>
<scope>provided</scope> <!--改为compile-->
<exclusions>
<exclusion>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</exclusion>
<exclusion>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
</exclusion>
</exclusions>
</dependency>
7、升级hbase,hadoop,hive为自己环境的版本:
kylin/pom.xml修改版本未自己的版本,kylin默认hbase是0.98,升级未1.X以上版本后,因为hbase client接口的变化,需要修改mock
<!-- Hadoop versions -->
<hadoop2.version>2.6.0</hadoop2.version>
<yarn.version>2.6.0</yarn.version>
<!-- Hive versions -->
<hive.version>0.14.0</hive.version>
<hive-hcatalog.version>0.14.0</hive-hcatalog.version>
<!-- HBase versions -->
<hbase-hadoop2.version>0.98.8-hadoop2</hbase-hadoop2.version>
<kafka.version>0.8.1</kafka.version>
我把hbase升级 1.0.1.1,hive 1.0.1
注意过滤jsp,jasper,jetty 等包
<exclusion>
<artifactId>jasper-runtime</artifactId>
<groupId>tomcat</groupId>
</exclusion>
<exclusion>
<artifactId>jasper-compiler</artifactId>
<groupId>tomcat</groupId>
</exclusion>
<exclusion>
<artifactId>jetty-util</artifactId>
<groupId>org.mortbay.jetty</groupId>
</exclusion>
<exclusion>
<artifactId>jetty</artifactId>
<groupId>org.mortbay.jetty</groupId>
</exclusion>
hbase升级后修改类:
kylin-server-base 下:MockHTable
默认增加未实现的方法,不需要再去实现,接口定义多了方法而已,这个类也只是测试环境类;
修改代码:
private List<KeyValue> filter(Filter filter, List<KeyValue> kvs) throws IOException {
filter.reset();
List<KeyValue> tmp = new ArrayList<KeyValue>(kvs.size());
tmp.addAll(kvs);
/*
* Note. Filter flow for a single row. Adapted from
* "HBase: The Definitive Guide" (p. 163) by Lars George, 2011.
* See Figure 4-2 on p. 163.
*/
boolean filteredOnRowKey = false;
List<KeyValue> nkvs = new ArrayList<KeyValue>(tmp.size());
//增加定义
List<Cell> cells = new ArrayList<Cell>(tmp.size());
for (KeyValue kv : tmp) {
if (filter.filterRowKey(kv.getBuffer(), kv.getRowOffset(), kv.getRowLength())) {
filteredOnRowKey = true;
break;
}
Filter.ReturnCode filterResult = filter.filterKeyValue(kv);
if (filterResult == Filter.ReturnCode.INCLUDE) {
nkvs.add(kv);
//增加
cells.add(kv);
} else if (filterResult == Filter.ReturnCode.NEXT_ROW) {
break;
} else if (filterResult == Filter.ReturnCode.NEXT_COL || filterResult == Filter.ReturnCode.SKIP) {
continue;
}
/*
* Ignoring next key hint which is a optimization to reduce file
* system IO
*/
}
if (filter.hasFilterRow() && !filteredOnRowKey) {
//filter.filterRow(nkvs);
//改为: 原方法1.x不支持
filter.filterRowCells(cells);
}
if (filter.filterRow() || filteredOnRowKey) {
nkvs.clear();
}
tmp = nkvs;
return tmp;
}
public void delete(Delete delete) throws IOException 方法修改:
//if (kv.isDeleteFamily()) { 改为
if (kv.isDelete(KeyValue.Type.DeleteFamily.getCode())) {
8、执行 mvn clean install -DskipTests;
mvn 下载,编译,安装kylin的依赖包
9、webapp合并:
cd webapp
npm install -g bower
bower –allow-root install
cp -r webapp/app/ server/src/main/webapp/
我们要使用调试的webapp在server(kylin-server)和server-base(kylin-server-base),server工程继承server-base,实现tomcat的,就一个类和webapp的spring配置文件等;
执行 cp -r server/src/main/webapp/WEB-INF webapp/app/WEB-INF 将server下的webapp的classes和lib等拷贝到外面的webapp工程;或者cp -r webapp/app/ server/src/main/webapp/ 将app下的js等页面,拷贝到server下,使用server作为tomcat调试工程;(一般使用后者去调试tomcat);
代码下直接运行src/main/webapp的话,其下面没有相应的lib包,classes,需要拷贝相应的lib到WEB-INF下。
mkdir server/src/main/webapp/WEB-INF/lib/
cp -r server/target/kylin-server-1.5.4-SNAPSHOT/WEB-INF/lib/ server/src/main/webapp/WEB-INF/lib/
10、准备运行环境配置sandbox
修改 examples/test_case_data/sandbox/kylin.properties文件, 修改
# 改为 true
kylin.job.run.as.remote.cmd= true #false
# Only necessary when kylin.job.run.as.remote.cmd=true 改为你的hadoop服务地址
kylin.job.remote.cli.hostname=localhost #sandbox
# Only necessary when kylin.job.run.as.remote.cmd=true
kylin.job.remote.cli.username=root
# Only necessary when kylin.job.run.as.remote.cmd=true
kylin.job.remote.cli.password=hadoop
其中hive,hbase,hadoop的相关配置文件改为你开发环境中的相关配置文件
11、运行kylin在eclipse中
设置tomcat的jvm以下参数
-Dspring.profiles.active=”testing”
-DKYLIN_CONF=/Users/admin/projects/kylin/examples/test_case_data/sandbox
-Dhdp.version=2.6.4
运行tomcat,启动成功,访问http://localhost:8080/kylin
用户/密码 :ADMIN/KYLIN