Mercurial > hg > Papers > 2014 > nobuyasu-master
diff paper/chapter3.tex @ 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 |
line wrap: on
line diff
--- 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} + + +