HADOOP集群,以及其它相关的集群如HBase是用Cloudera搭建的,那么就要配置相应的Cloudera的开发环境,接下来会以开发HBase的Coprocessor为例:其部署集群使用的Cloudera为5.2.4
以下是基本的步骤:
1.在maven的pom.xml文件中加入cloudera的maven仓库:(红色部分)
<repositories>
<!-- cloudera 的仓库 -->
<repository>
<id>cloudera</id>
<url>https://repository.cloudera.com/artifactory/cloudera-repos/</url>
</repository>
<repository>
<id>spring-milestone</id>
<url>http://repo.springsource.org/libs-milestone</url>
</repository>
<repository>
<id>oschina Releases</id>
<name>oschina Releases</name>
<url>http://maven.oschina.net/content/groups/public</url>
</repository>
</repositories>
2.到http://www.cloudera.com/documentation/enterprise/latest/topics/cdh_vd_cdh5_maven_repo.html中查找自已cloudera的版本这里选择5.2.4
3.到页面选择相关的maven坐标:
4.把坐标添加到maven依赖中:
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-server</artifactId>
<version>0.98.6-cdh5.2.4</version>
</dependency>
这样就完成了Cloudera的hbase开发环境的配置,其它模块方式同样。
如下就可以进行相关模块的开发了:
import java.io.IOException; import java.util.List; import org.apache.hadoop.hbase.Cell; import org.apache.hadoop.hbase.CellUtil; import org.apache.hadoop.hbase.client.Get; import org.apache.hadoop.hbase.coprocessor.BaseRegionObserver; import org.apache.hadoop.hbase.coprocessor.ObserverContext; import org.apache.hadoop.hbase.util.Bytes; public class PutObserver extends BaseRegionObserver { @Override public void preGetOp(final ObserverContext e, final Get get, final List results) throws IOException { .......................... .......................... } } }