changeset 48:6553b7a3717c

Modified chapter3
author Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
date Fri, 31 Jan 2014 09:31:57 +0900
parents b303f22d8b0d
children 7b595f4b341e
files paper/chapter2.tex paper/chapter3.tex
diffstat 2 files changed, 76 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/paper/chapter2.tex	Fri Jan 31 05:46:50 2014 +0900
+++ b/paper/chapter2.tex	Fri Jan 31 09:31:57 2014 +0900
@@ -141,7 +141,19 @@
 Jungle 内部ではTreeOperationは順次ログに積まれていき, 最終的に
 commitされることで編集が完了する.
 この時, ログに積まれた複数のTreeOperationはTreeOperationLogとして扱われる.
-以下にTreeOperationLogの具体的な例を示す(\ref{src:treelog}).
+TreeOperationLogの仕様を\ref{src:treeoperationlog}に示す.
+\begin{lstlisting}[frame=lrbt,label=src:treeoperationlog,caption=TreeOperationLogの仕様,numbers=left]
+public interface TreeOperationLog extends Iterable<TreeOperation>
+{
+  public TreeOperationLog add(NodePath _p,NodeOperation _op);
+  public TreeOperationLog append(TreeOperationLog _log);
+  public int length();
+}
+\end{lstlisting}
+\verb|Iterable<TreeOperation>|を継承しているためIteratorによりTreeOperationを取り出せるようになっている.
+addやappendメソッドを使ってTreeOperationを積み上げていくことができる
+
+次にデータ編集により発生するTreeOperationLogの具体的な例を示す(\ref{src:treelog}).
 \begin{lstlisting}[frame=lrbt,label=src:treelog,caption=トポロジーマネージャーの利用,numbers=left]
 [APPEND_CHILD:<-1>:pos:0]
 [PUT_ATTRIBUTE:<-1,0>:key:author,value:oshiro]
--- a/paper/chapter3.tex	Fri Jan 31 05:46:50 2014 +0900
+++ b/paper/chapter3.tex	Fri Jan 31 09:31:57 2014 +0900
@@ -238,14 +238,40 @@
 
 \section{ログのシリアライズ}
 Jungleの具体的な分散実装について述べる.
-Jungleの分散実装はデータ編集のログを他のサーバに送ることで行うことを第3章で説明した.
 実装にあたり, 解決しなければならない問題はまず, ログをDataSegmentで扱える形にすることである.
 そのためには, @Messageアノテーションを付けたログのクラスの作成を行わなければならない.
 
 
-\subsection{TreeOperationLogの}
-TreeOperationLogの仕様は次の通りである.
-\begin{lstlisting}[frame=lrbt,label=src:treeoperationlog,aption=TreeOperationLogの仕様,numbers=left]
+\subsection{TreeOperationLogのシリアライズ}
+TreeOperationLogをシリアライズ可能な形にするにあたって気をつけなければならないのが, フィールドを
+シリアライズ可能にする部分である.
+TreeOperationLogはTreeOperationをいくつも保持し, TreeOperationはNodePathとNodeOperationを保持するものであった.
+そのため, これら全てシリアライズ可能な形にしなければならない.
+
+基本的にこれらの実装は, フィールドを全てプリミティブなものだけにすればよい.
+MessagePackはListを扱うこともできるため, TreeOperationLogで継承されていたIterableの挙動もListを使うことで
+実装を行うことができた.
+
+
+このInterfaceをimplementsしつつシリアライズを行えるクラスとしてNetworkTreeOperationLogを実装した.
+NetworkTreeOperationLogでは次のフィールドを保持する(\ref{src:nettreeoplog}).
+\begin{lstlisting}[frame=lrbt,label=src:nettreeoplog,caption=NetworkTreeOperationLogの実装,numbers=left]
+@Message
+public class NetworkTreeOperationLog implements TreeOperationLog
+{
+  public LinkedList<NetworkTreeOperation> list;
+  public int size;
+  String uuid;
+  String treeName;
+  long timestamp;
+  : // 実装が続いていく
+\end{lstlisting}
+
+
+
+
+TreeOperationLogの仕様はInterfaceにより定義される.
+\begin{lstlisting}[frame=lrbt,label=src:treeoperationlog,caption=TreeOperationLogの仕様,numbers=left]
 public interface TreeOperationLog extends Iterable<TreeOperation>
 {
   public TreeOperationLog add(NodePath _p,NodeOperation _op);
@@ -253,7 +279,39 @@
   public int length();
 }
 \end{lstlisting}
-IterableとしてTreeOperationを保持しているクラスがTreeOperationLogである.
+\verb|Iterable<TreeOperationLog>|を継承しているクラスがTreeOperationLogとなる.
+次にTreeOperationの仕様と, NodeOperation, NodePath の仕様について以下に示す
+\begin{lstlisting}[frame=lrbt,label=src:treeop,caption=TreeOperationの仕様,numbers=left]
+public interface TreeOperation
+{
+  public NodePath getNodePath();
+  public NodeOperation getNodeOperation();
+}
+\end{lstlisting}
+
+\begin{lstlisting}[frame=lrbt,label=src:nodeop,caption=NodeOperationの仕様,numbers=left]
+public interface NodeOperation
+{
+  public Command getCommand();
+  public <T extends EditableNode<T>> Either<Error,T> invoke(T _target);
+  
+  public int getPosition();
+  public String getKey();
+  public ByteBuffer getValue();
+}
+\end{lstlisting}
+
+\begin{lstlisting}[frame=lrbt,label=src:nodepath,caption=Nodepathの仕様,numbers=left]
+public interface NodePath extends Iterable<Integer>
+{
+  public NodePath add(int _pos);
+  public Pair<Integer,NodePath> pop();
+  public int size();
+}
+\end{lstlisting}
+
+
+