changeset 281:8a746ab2dd02

Guarantee Difference Transaction append subTree
author tatsuki
date Tue, 20 Dec 2016 20:09:56 +0900
parents 9f38fcb07d36
children 5da8a19dbe76
files src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/manager/DifferenceTransactionManager.java src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/util/Error/TransactionError.java
diffstat 2 files changed, 4 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/manager/DifferenceTransactionManager.java	Tue Dec 20 18:17:18 2016 +0900
+++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/manager/DifferenceTransactionManager.java	Tue Dec 20 20:09:56 2016 +0900
@@ -19,6 +19,7 @@
 import java.util.Iterator;
 import java.util.concurrent.atomic.AtomicReference;
 
+import static jp.ac.u_ryukyu.ie.cr.jungle.util.Error.TransactionError.APPEND_FAILD;
 import static jp.ac.u_ryukyu.ie.cr.jungle.util.Error.TreeEditorError.APPENDED_NODE_NULL;
 import static jp.ac.u_ryukyu.ie.cr.jungle.util.Error.TreeEditorError.CAS_MISS;
 
@@ -86,6 +87,8 @@
     private Either<Error, TreeNode> appendSubTree(TreeNode subTreeRoot) {
         TreeNode appendedNode = tip.getAppendedNode();
         TreeNodeChildren children = appendedNode.getChildren();
+        if (children.size() != 0)
+            return DefaultEither.newA(APPEND_FAILD); //append Nodeが1つ以上子を持つ場合過去の木であるため、変更させない。そうすることで整合性を保証する
         return children.addNewChildAt(0, subTreeRoot);
     }
 
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/util/Error/TransactionError.java	Tue Dec 20 18:17:18 2016 +0900
+++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/util/Error/TransactionError.java	Tue Dec 20 20:09:56 2016 +0900
@@ -5,4 +5,5 @@
  */
 public class TransactionError {
     public static final Error INVALID_ARGUMENT = new DefaultError();
+    public static final Error APPEND_FAILD = new DefaultError();
 }