changeset 45:cd3b8cf7a3a1

Added file for gnuplot
author Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
date Thu, 30 Jan 2014 20:22:22 +0900
parents 618adf0a9b2b
children c63aaa629330
files paper/.DS_Store paper/chapter3.tex paper/figures/distributed_read_bench.pdf paper/figures/distributed_write_bench.pdf paper/figures/remote_codesegment.pdf paper/figures/remote_codesegment.xbb paper/gnuplot/distributed_read_cassandra_one.dat paper/gnuplot/distributed_read_cassandra_quorum.dat paper/gnuplot/distributed_read_jungle.dat paper/gnuplot/distributed_write_cassandra_one.dat paper/gnuplot/distributed_write_cassandra_quorum.dat paper/gnuplot/distributed_write_jungle.dat paper/gnuplot/makegraph_distributed_read.sh paper/gnuplot/makegraph_distributed_write.sh paper/graffle/remote_codesegment.graffle paper/master_paper.pdf
diffstat 16 files changed, 119 insertions(+), 40 deletions(-) [+]
line wrap: on
line diff
Binary file paper/.DS_Store has changed
--- a/paper/chapter3.tex	Thu Jan 30 16:15:32 2014 +0900
+++ b/paper/chapter3.tex	Thu Jan 30 20:22:22 2014 +0900
@@ -104,8 +104,7 @@
 public class TestCodeSegment extends CodeSegment {
   public Receiver arg1 = ids.create(CommandType.TAKE);
   
-  public TestCodeSegment() {
-  }
+  public TestCodeSegment() { }
 
   public void run() {
     int count = ds.asInteger();
@@ -126,6 +125,7 @@
 \end{lstlisting}
 これは, 数字を1から10まで出力を行い終了するプログラムである.
 コードの説明を行う.
+17行目から19行目の処理が最初に行われる.
 まずTestCodeSegmentというCodeSegmentのインスタンスcsを生成する.
 csはarg1というReceiverクラスのフィールドを保持しており, Receiverクラスは
 DataSegmentを受けとるためのクラスである.
@@ -135,15 +135,16 @@
 この場合は自分自身を表す"local"になる.
 
 データの登録は\verb|ods.update|により行える.
-上記のコード20行目ではupdateにより"count"をキーとして数値の0を登録している.
+上記のコード19行目ではupdateにより"count"をキーとして数値の0を登録している.
 updateがされるとcsの計算が始まり別スレッドにより8行目からの処理が行われる.
 
 updateによりキー"count"に登録された数値0はReceiverであるdsを使って取ることができる.
-8行目から14行目では\verb|ds.asInteger()|により, "count"に登録したデータの中身を受け取りインクリメントし出力する.
+7行目から13行目では\verb|ds.asInteger()|により, "count"に登録したデータの中身を受け取りインクリメントし出力する.
 そして最後には\verb|ods.update|を行っている.
 新たなTestCodeSegmentも生成しており, これはインクリメントされた"count"がupdateされることで実行される.
 この一連の処理を"count"の数値が10以上になるまで行う.
 
+DataSegmentへデータの追加とCodeSegmentの実行について表した図\ref{fig:testcodesegment}になる.
 \begin{figure}[htpb]
   \begin{center}
     \includegraphics[scale=0.70]{figures/testcodesegment.pdf}
@@ -163,60 +164,94 @@
 その時に実際に作られるトポロジーを図\ref{fig:remote_cs}に示す.
 \begin{figure}[htpb]
   \begin{center}
-    \includegraphics[scale=0.70]{figures/testcodesegment.pdf}
+    \includegraphics[scale=0.70]{figures/remote_codesegment.pdf}
     \caption{トポロジーの形成}
     \label{fig:remote_cs}
   \end{center}
 \end{figure}
-このトポロジー上で, 標準入力より入力されたメッセージを他サーバノードに送信
-するプログラムを考える.
 
-server node0, server node1, server node2 がそれぞれ接続しあっている.
-矢印に付いている
-
-\begin{lstlisting}[frame=lrbt,label=src:,caption=メッセージを受け取り他のサーバに流すCodeSegment,numbers=left]
-public class SendMessageCodeSegment extends CodeSegment {
+ネットワークを介したDataSegmentへのアクセスはそのサーバノードを示す
+文字列のキーを追加することで行える.
+他サーバノードを示す文字列のキーとは図\ref{fig:remote_cs}に矢印の隣に書かれている文字列
+"parent", "child1", "child2" のことを指す.
+例えば, server node0 が server node1のDataSegmentに入っている"count"というデータを
+を使用したい場合は, 次のようにsetKeyを行えばよい(\ref{src:remote_cs1}).
+\begin{lstlisting}[frame=lrbt,label=src:remote_cs1,caption=CodeSegmentで他サーバノードのDataSegmentを使用する,numbers=left]
+CodeSegment cs = new RemoteCodeSegment();
+cs.arg1.setKey("child1", "count");
+\end{lstlisting}
+また, 他サーバノードのDataSegmentにデータを送りたい場合は, putを行うときにサーバノードへのキーを
+追加すればよい.
+例として, server node1やserver node2がserver node0のDataSegmentに"message"というキーでデータを追加したい場合
+次のようになる(\ref{src:remote_cs2}).
+\begin{lstlisting}[frame=lrbt,label=src:remote_cs2,caption=他サーバーノードのDatasSegmentにデータを追加する,numbers=left]
+ods.put("parent", "message", "Hello parent");
+\end{lstlisting}
 
-  Receiver sendNodeList = ids.create(CommandType.PEEK);
-  public SendMessageCodeSegment() {
-    sendNodeList.setKey("_CLIST");
-  }
-  @Override
-  public void run() {
-    @SuppressWarnings("unchecked")
-    List<String> list = sendNodeList.asClass(List.class);
-    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
-    String message = null;
-    try {
-      System.out.println("Please enter your message");
-      while((message = reader.readLine()) != null ) {
-        for(String node : list) {
-          ods.put(node, "message", message);
-          System.out.println("send message to "+node);
-      }
-    } catch (IOException e) {
-     e.printStackTrace();
-  }
+\subsection{独自クラスのインスタンスの送受信}
+最後に, 独自クラスのインスタンスのDataSegmentでの扱い方について述べる.
+AliceではMessagePackを用いてシリアライズを行い他サーバノードへと送信している.
+MessagePackはクラス単位でシリアライズを行うことができる.
+そのため, Aliceではプリミティブな型に限らずクラスのインスタンスをDataSegmentとして
+扱うことができる.
+
+MessagePackによりシリアライズとなるクラスはいくつか制限がある.
+それはそのクラスに@Messageアノテーションを付けることと, そのクラスが保持するフィールドが
+MessagePackによりシリアライズ可能であることである.
+例えば次のようなクラスである.
+\begin{lstlisting}[frame=lrbt,label=src:msgpack1,caption=MessagePackによりシリアライズ可能なクラス1,numbers=left]
+import org.msgpack.annotation.Message
+
+@Message
+public class Student {
+  String name;
+  int age;
 }
 \end{lstlisting}
+上記のStudenクラスはプリミティブ型しか保持していない.
+そのためシリアライズが可能である
+また, 次のようなクラスもシリアライズ可能な型となる.
+\begin{lstlisting}[frame=lrbt,label=src:msgpack2,caption=MessagePackによりシリアライズ可能なクラス2,numbers=left]
+import org.msgpack.annotation.Message
 
-\begin{lstlisting}[frame=lrbt,label=src:,caption=,numbers=left]
-
+@Message
+public class Class {
+  List<Student> studentList;
+}
 \end{lstlisting}
+この場合, フィールドはプリミティブな型でないStudentクラスのフィールドを保持している.
+しかし, Studentクラスはシリアライズ可能な形で作成しているため, クラスのフィールドとして
+保持しても問題はない.
 
-\begin{lstlisting}[frame=lrbt,label=src:,caption=,numbers=left]
+これらの制約にそった形で作成しDataSegmentにネットワークを介してクラスのインスタンス
+をupdateすることができる.
+DataSegmentから受け取ったデータはそのままではシリアライズされたものため, 一度手元で
+元のクラスにコンバートすることで扱う.
+例として, AliceにおけるStudenクラス(Listing\ref{src:msgpack1})のコンバートを次に示す.
+\begin{lstlisting}[frame=lrbt,label=src:msgpack3,caption=DataSegment,numbers=left]
+// public Receiver arg1 = ids.create(CommandType.PEEK);
+Student s = arg1.asClass(Student.class);
+\end{lstlisting}
+MessagePackでシリアライズ可能な形としているためDataSegmentはネットワークを介して
+送受信が可能である.
 
-\end{lstlisting}
+
+\section{Aliceを用いたJungleの分散実装}
+ここまでAliceを用いたプログラミングの方法について述べた.
 
 
 
-\section{ログのシリアライズ}
+\subsection{ログのシリアライズ}
 ここでログのシリアライズについて述べる.
 
+
 シリアライズとは, データをネットワーク上に流しても良い形式に変換することである.
 
 
-
+\subsection{}
+% TreeOperationLog に木の名前の情報がない
+% そのため木の名前を追加して持たせた
+% 木がなければそのばでつくるようにした
 
 \section{掲示板プログラムにおけるマージの実装}
 Jungle に分散実装を行った後の問題としてデータ衝突がある.
Binary file paper/figures/distributed_read_bench.pdf has changed
Binary file paper/figures/distributed_write_bench.pdf has changed
Binary file paper/figures/remote_codesegment.pdf has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/paper/figures/remote_codesegment.xbb	Thu Jan 30 20:22:22 2014 +0900
@@ -0,0 +1,8 @@
+%%Title: ./figures/remote_codesegment.pdf
+%%Creator: extractbb 20130405
+%%BoundingBox: 0 0 295 166
+%%HiResBoundingBox: 0.000000 0.000000 295.000000 166.000000
+%%PDFVersion: 1.3
+%%Pages: 1
+%%CreationDate: Thu Jan 30 16:46:19 2014
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/paper/gnuplot/distributed_read_cassandra_one.dat	Thu Jan 30 20:22:22 2014 +0900
@@ -0,0 +1,3 @@
+10 12
+20 12
+30 20
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/paper/gnuplot/distributed_read_cassandra_quorum.dat	Thu Jan 30 20:22:22 2014 +0900
@@ -0,0 +1,3 @@
+10 23
+20 29
+30 27
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/paper/gnuplot/distributed_read_jungle.dat	Thu Jan 30 20:22:22 2014 +0900
@@ -0,0 +1,3 @@
+10 9
+20 8
+30 10
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/paper/gnuplot/distributed_write_cassandra_one.dat	Thu Jan 30 20:22:22 2014 +0900
@@ -0,0 +1,3 @@
+10 25
+20 24
+30 38
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/paper/gnuplot/distributed_write_cassandra_quorum.dat	Thu Jan 30 20:22:22 2014 +0900
@@ -0,0 +1,3 @@
+10 50
+20 82
+30 113
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/paper/gnuplot/distributed_write_jungle.dat	Thu Jan 30 20:22:22 2014 +0900
@@ -0,0 +1,3 @@
+10 16
+20 18
+30 20
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/paper/gnuplot/makegraph_distributed_read.sh	Thu Jan 30 20:22:22 2014 +0900
@@ -0,0 +1,9 @@
+#!/bin/sh
+gnuplot << EOF
+set terminal postscript eps
+set output 'distributed_read_bench.eps'
+set title 'distributed read benchmark (Requests : clients * 50,000)'
+set xlabel 'number of nodes and clients'
+set ylabel 'time(sec)'
+plot 'distributed_read_jungle.dat' title 'Jungle' lt rgb "blue" with linespoints, 'distributed_read_cassandra_quorum.dat' title "Cassandra Consistency Level Quorum" lt rgb "red" with linespoints, 'distributed_read_cassandra_one.dat' title "Cassandra Consistency Level ONE" lt rgb "dark-red" with linespoints
+EOF
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/paper/gnuplot/makegraph_distributed_write.sh	Thu Jan 30 20:22:22 2014 +0900
@@ -0,0 +1,9 @@
+#!/bin/sh
+gnuplot << EOF
+set terminal postscript eps
+set output 'distributed_write_bench.eps'
+set title 'write benchmark (Requests : clients * 50,000)'
+set xlabel 'number of nodes'
+set ylabel 'time(sec)'
+plot 'distributed_write_jungle.dat' title 'Jungle' lt rgb "blue" with linespoints, 'distributed_write_cassandra_quorum.dat' title "Cassandra Consistency Level Quorum" lt rgb "red" with linespoints,'distributed_write_cassandra_one.dat' title "Cassandra Consistency Level ONE" lt rgb "dark-red" with linespoints
+EOF
--- a/paper/graffle/remote_codesegment.graffle	Thu Jan 30 16:15:32 2014 +0900
+++ b/paper/graffle/remote_codesegment.graffle	Thu Jan 30 20:22:22 2014 +0900
@@ -133,7 +133,7 @@
 		</dict>
 		<dict>
 			<key>Bounds</key>
-			<string>{{208.00003051757812, 224}, {75, 22}}</string>
+			<string>{{209.00003051757812, 224}, {75, 22}}</string>
 			<key>Class</key>
 			<string>ShapedGraphic</string>
 			<key>ID</key>
@@ -517,7 +517,7 @@
 	<key>MasterSheets</key>
 	<array/>
 	<key>ModificationDate</key>
-	<string>2014-01-30 05:53:05 +0000</string>
+	<string>2014-01-30 07:54:48 +0000</string>
 	<key>Modifier</key>
 	<string>Oshiro Nobuyasu</string>
 	<key>NotesVisible</key>
Binary file paper/master_paper.pdf has changed