# HG changeset patch # User Nobuyasu Oshiro # Date 1391128317 -32400 # Node ID 6553b7a3717c7681f485de29887e924d9c79a3f5 # Parent b303f22d8b0dd75a6e0ce0d4f936b98a9b7ac573 Modified chapter3 diff -r b303f22d8b0d -r 6553b7a3717c paper/chapter2.tex --- 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 +{ + public TreeOperationLog add(NodePath _p,NodeOperation _op); + public TreeOperationLog append(TreeOperationLog _log); + public int length(); +} +\end{lstlisting} +\verb|Iterable|を継承しているため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] diff -r b303f22d8b0d -r 6553b7a3717c paper/chapter3.tex --- 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 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 { public TreeOperationLog add(NodePath _p,NodeOperation _op); @@ -253,7 +279,39 @@ public int length(); } \end{lstlisting} -IterableとしてTreeOperationを保持しているクラスがTreeOperationLogである. +\verb|Iterable|を継承しているクラスが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 > Either 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 +{ + public NodePath add(int _pos); + public Pair pop(); + public int size(); +} +\end{lstlisting} + + +