2011年05月31日

MavenでHBaseのクライアント機能を使おうとした記録

HBaseは一応Mavenのレポジトリを用意してくれている。

<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase</artifactId>
<version>0.90.3</version>
</dependency>

けど、上記の記述で依存性を解決させると、JRubyとかJettyとかservlet-apiとか、嫌がらせのように大量のjarが落とされてしまう。

HBaseのサーバ側を動かす場合はそれらも必要なんだろうけど、クライアントでデータをputとかgetしろとか命令する分には、そんなにいらないはず。

軽く試した感じだと、以下の5つだけで最低限の動作はしてくれた。

・hbase
・zookeeper
・hadoop
・commons-logging
・log4j

というわけで、いらなそうなものを何も考えずにexclusionしまくった結果、dependencyが下記のような魔物になった。Maven2です。まぁ、なんかの冗談だと思ってください。

テーブルの作成、削除、値のput、getくらいしか試してないので、そのうち「これ、足りないぞ」と怒られることはありそう。まぁ、怒られた時に追加しよう。

<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase</artifactId>
<version>0.90.3</version>
<exclusions>
<exclusion>
<groupId>com.google.guava</groupId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<groupId>commons-cli</groupId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<groupId>commons-codec</groupId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<groupId>commons-httpclient</groupId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<groupId>commons-lang</groupId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<groupId>commons-el</groupId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<groupId>commons-net</groupId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<groupId>xmlenc</groupId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.thrift</groupId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<groupId>org.jruby</groupId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<groupId>org.mortbay.jetty</groupId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<groupId>tomcat</groupId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<groupId>com.google.protobuf</groupId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.jersey</groupId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<groupId>javax.ws.rs</groupId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<groupId>javax.xml.bind</groupId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<groupId>stax</groupId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<groupId>org.mockito</groupId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.commons</groupId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-text</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.hadoop</groupId>
<artifactId>avro</artifactId>
</exclusion>
</exclusions>
</dependency>

commonsが同じgroupIdだったら、だいぶ行数も圧縮されただろうに。

尚、log4jが外せないのは、Zookeeperが直接呼んでやがるためです。logback使うつもりだったんだけどなぁ。