*Java API用CLIツール [#h2f0f6c5]
Scalarisをコマンドラインツールから利用する方法について説明します。

*必要なソフトウェア [#lc4e51a8]
CLIツールではJavaのAPIを利用しており、antでビルドする必要があります。
以下のパッケージが必要になります。

-Java Development Kit 1.6
-Apache Ant

*ビルド [#pad5d192]

Scalarisのディレクトリで以下のコマンドを実行します。

 # make java

*設定ファイル [#a156919c]

java-apiディレクトリに、必要なファイルが用意されています。
設定ファイルとして、編集が必要なのは以下の2つです。

-scalaris.properties
-scalaris-java.conf

scalaris-java.confはデフォルトでは存在せず、scalaris-java.conf.sampleが用意されています。~
また保存場所としてはjava-apiディレクトリではなく、/etc/scalaris/scalaris-java.conf か ~/.scalaris/scalaris-java.confとして保存しておく必要があります。
scalaris.propertiesについては保存場所がscalaris-java.confで定義されています。
ここではデフォルトの値に合わせて/etc/scalaris/scalaris.propertiesに保存します。
まずはコピーしておきましょう。

 # mkdir /etc/scalaris/
 # cp scalaris-java.conf.sample /etc/scalaris/scalaris-java.conf
 # cp scalaris.properties /etc/scalaris/scalaris.properties

*scalaris.propertiesの編集 [#ec3a5daa]

scalaris.propertiesは以下のようになっています。

 # the name of the scalaris node to establish the connection to
 scalaris.node=boot@localhost
 
 # the cookie the scalaris node uses for connections
 scalaris.cookie=chocolate chip cookie
 
 # the name of the (Java) client to use when establishing a connection with erlang
 scalaris.client.name=java_client
 
 # specifies whether to append an UUID to client names or not
 scalaris.client.appendUUID=true

scalaris.node=boot@localhostの箇所を、利用するscalarisノードに変更する必要があります。
scalaris.node=boot@localhostの箇所を、利用するscalarisノードに変更する必要があります。~
@前のbootは、ノードの名前です。
bootサーバならboot、レギュラーノードであればnode1やnode2となります。~
@の後ろはホストを指定するのに使用しますが、そのホストのhostnameと一致している必要があります。
このため、IPアドレスで指定しても使用できません。

*scalaris-java.confの編集 [#h679853a]

scalaris-java.conf.sampleは以下のようになっています。

 #  Copyright 2007-2008 Konrad-Zuse-Zentrum f端r Informationstechnik Berlin
 #
 #   Licensed under the Apache License, Version 2.0 (the "License");
 #   you may not use this file except in compliance with the License.
 #   You may obtain a copy of the License at
 #
 #       http://www.apache.org/licenses/LICENSE-2.0
 #
 #   Unless required by applicable law or agreed to in writing, software
 #   distributed under the License is distributed on an "AS IS" BASIS,
 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 #   See the License for the specific language governing permissions and
 #   limitations under the License.
 
 # sample configuration file for the scalaris java client start script
 # save file to /etc/scalaris/scalaris-java.conf or ~/.scalaris/scalaris-java.conf
 
 # 1. rpm_mode
 # 
 #  Specifies:
 #
 #      If in rpm mode system tools will be used to build the classpath and
 #      set up the java virtual machine.
 #
 #  Type of value:
 #
 #      boolean
 #
 #  Default value:
 #
 #      false
 #
 #  Effect if unset:
 #
 #      Start script builds the classpath based on the libraries provided in
 #      SCALARIS_JAVA_HOME.
 #
 rpm_mode=true 
 
 # 2. SCALARIS_JAVA_HOME
 #
 #  Specifies:
 #
 #      The directory of the scalaris.jar file to use.
 #      SCALARIS_JAVA_HOME/lib provides some needed libraries.
 #
 #  Type of value:
 #
 #      Path name
 #
 #  Default value:
 #
 #      unset
 #
 #  Effect if unset:
 #
 #      Start script will set the value to the directory it is located in.
 #
 SCALARIS_JAVA_HOME="/usr/share/java/scalaris"
 
 # 3. OPT_JAR_LIST
 #
 #  Specifies:
 #
 #      Additional libraries to add to the classpath.
 #
 #  Type of value:
 #
 #      list of names of jar files (without extension)
 #
 #  Default value:
 #
 #      empty
 #
 #  Effect if unset:
 #
 #      Start script will set the value to the directory it is located in.
 #
 OPT_JAR_LIST=
 
 # 4. LOCALCLASSPATH
 #
 #  Specifies:
 #
 #      Classpath to prepend to the path the start script sets up.
 #      (only used if not in rpm_mode)
 #
 #  Type of value:
 #
 #      java classpath
 #
 #  Default value:
 #
 #      empty
 #
 #  Notes:
 #      The following classpath will be set up by the start script if not in rpm_mode:
 #      $SCALARIS_JAVA_HOME/scalaris.jar:$SCALARIS_JAVA_HOME/lib/jakarta-commons-cli-1.1.jar:$SCALARIS_JAVA_HOME/lib/OtpErlang-1.4.jar
 LOCALCLASSPATH=
 
 # 4. SCALARIS_JAVA_CONFIG
 #
 #  Specifies:
 #
 #      Name of the config file to load (contains properties such as the node
 #      name to connect to).
 #
 #  Type of value:
 #
 #      file name (including path)
 #
 #  Default value:
 #
 #      "scalaris.properties"
 #      (set by the java classes)
 #
 #  Effect if unset:
 #
 #      The de.zib.scalaris.ConnectionFactory class will try to find the
 #      default file at the same location where the jar file is located.
 #      If no file exists, default values are used - see
 #      de.zib.scalaris.ConnectionFactory::ConnectionFactory() for more details.
 #
 SCALARIS_JAVA_CONFIG="/etc/scalaris/scalaris.properties"

殆どがコメントで、設定項目についての説明になっています。
デフォルトの値から変更する必要があるのはrpm_mode=trueと
SCALARIS_JAVA_HOME="/usr/share/java/scalaris"の部分になります。~
[[インストール方法のページ>Scalaris/インストール方法]]では、rpmではなくmakeでインストールしたため、trueからfalseに変更します。~

 rpm_mode=false

SCALARIS_JAVA_HOMEは、Scalarisのjava-apiディレクトリを指定する必要があります。~
例えば/home/nanodayo/scalaris以下にソースコードをチェックアウトして、
scalaris-read-onlyというディレクトリに保存されている場合は以下のように指定します。

 SCALARIS_JAVA_HOME="/home/nanodayo/scalaris/scalaris-read-only/java-api"

*CLIツールの使用 [#v42d1f07]

設定が終わったら、実際にCLIツールを使ってみましょう。
java-apiディレクトリにある、scalarisというスクリプトです。

-key/valueの書き込み

 # ./scalaris -w key value
 write(key, value)

このように実行すると、keyという鍵に対してvalueという値を設定できます。
成功するとwrite(key, value)のように表示されます。
なお、既にあるkeyに対して実行すると、値が上書きされます。

-key/valueの読み出し

 # ./scalaris -r key
 read(key) == value

このように実行すると、keyという鍵に対して設定されているvalueという値を取得できます。
成功するとread(key) == valueのように表示されます。

-ヘルプの表示

他のオプションなどについてはヘルプで確認できます。

 # ./scalaris -h


トップ   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS