2011年10月24日月曜日

rexsterを使ってみよう!


rexsterを使うことで、OrientDBやNeo4jのデータをRESTで取得することができます。
今回はOrientDBのデータを取得してみることにしました。

導入方法は、下記参照。
http://code.google.com/p/orient/wiki/Rexster

モジュールのダウンロードと解凍
$ wget https://github.com/downloads/tinkerpop/rexster/rexster-0.6.zip
$ unzip rexster-0.6.zip

OrientDBのバージョンが1.0rc5でない場合は、これもダウンロードして解凍しておく
$ wget http://orient.googlecode.com/files/orientdb-graphed-1.0rc5.zip
$ $ unzip orientdb-graphed-1.0rc5.zip -d orientdb_rc5

OrientDBからRexsterへ下記2つのjarをコピ-する。

  • orientdb-client-1.0rc5.jar
  • orientdb-enterprise-1.0rc5.jar

これをやるのというのは、上記のOrientDBのWikiサイトにしか書かれていないので、
Rexsterのほうを見てるとおそらくハマります。(ハマりました…)
cp orientdb_rc5/lib/orientdb-client-1.0rc5.jar  ~/rexster-0.6/target/rexster-0.6-standalone/lib/
cp orientdb_rc5/lib/orientdb-enterprise-1.0rc5.jar  ~/rexster-0.6/target/rexster-0.6-standalone/lib/
なんでこんな事をするのかは下記をご覧ください。
http://groups.google.com/group/orient-database/browse_thread/thread/f0d4ed39366396b7/02afb7c9017d9ade?#02afb7c9017d9ade


定義ファイルの編集
$ vi /home/tiffany/rexster-0.6/target/rexster-0.6-standalone/bin/rexster.xml 
1) 接続するOrientDB部の編集
   localでは上手く行かず…。
<graph>
  <graph-enabled>true</graph-enabled>
  <graph-name>orientdbsample</graph-name>
  <graph-type>orientgraph</graph-type>
  <graph-file>remote:10.3.216.204/demo</graph-file>
  <properties>
    <username>admin</username>
    <password>admin</password>
  </properties>
</graph>
2) localhost以外でつなげるなら、適宜変更。
<base-uri>http://IP</base-uri>
起動スクリプトの修正
rc5とrc6ではスクリプトが違うみたいですね。

読み込ませるrexster.xmlを-configureで指定する必要があります。
$DIR/target/rexster-*-standalone/bin/rexster.sh $@ -webroot $DIR/target/rexster-*-standalone/bin/public -configuration /home/tiffany/rexster-0.6/target/rexster-0.6-standalone/bin/rexster.xml 
起動
$ ./rexster.sh -s
その他のコマンドは下記のとおりです。
usage: rexster
 -h,--help                  print this message
 -s,--start <parameters>    start rexster (learn more with start -h)
 -u,--status <parameters>   status of rexster (learn more with status -h)
 -v,--version               print the version of rexster server
 -x,--stop <parameters>     stop rexster (learn more with stop -h)

Rexster起動中は下記ページにあるAPIが実行可能です。
https://github.com/tinkerpop/rexster/wiki/Basic-REST-API

0 件のコメント:

コメントを投稿

注: コメントを投稿できるのは、このブログのメンバーだけです。