changeset 34:bf696a6334b2

add LogUpdateCodeSegment
author one
date Tue, 02 Jul 2013 11:52:32 +0900
parents afccf06c4063
children 054dc02c117d
files src/alice/jungle/codesegment/LogUpdateCodeSegment.java src/alice/jungle/core/NetworkDefaultJungle.java src/alice/jungle/datasegment/store/operations/DefaultTreeOperationLogContainer.java src/alice/jungle/transaction/NetworkTransactionManager.java
diffstat 4 files changed, 62 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/alice/jungle/codesegment/LogUpdateCodeSegment.java	Tue Jul 02 11:52:32 2013 +0900
@@ -0,0 +1,15 @@
+package alice.jungle.codesegment;
+
+import alice.codesegment.CodeSegment;
+import alice.datasegment.CommandType;
+import alice.datasegment.Receiver;
+
+public class LogUpdateCodeSegment extends CodeSegment {
+	
+	public void run() {
+		
+		
+	}
+	
+
+}
--- a/src/alice/jungle/core/NetworkDefaultJungle.java	Mon Jul 01 21:07:43 2013 +0900
+++ b/src/alice/jungle/core/NetworkDefaultJungle.java	Tue Jul 02 11:52:32 2013 +0900
@@ -27,8 +27,7 @@
 	
 	public NetworkDefaultJungle(Journal _journal,String _uuid,TreeEditor _editor)
 	{
-//		journal = new AliceJournal();
-		journal = new NullJournal();		
+		journal = new AliceJournal();
 		trees = new ConcurrentHashMap<String,JungleTree>();
 		uuid = _uuid;
 		editor = _editor;
--- a/src/alice/jungle/datasegment/store/operations/DefaultTreeOperationLogContainer.java	Mon Jul 01 21:07:43 2013 +0900
+++ b/src/alice/jungle/datasegment/store/operations/DefaultTreeOperationLogContainer.java	Tue Jul 02 11:52:32 2013 +0900
@@ -25,6 +25,8 @@
 public class DefaultTreeOperationLogContainer {
 
 	Value logValue;
+	String treeName;
+	String uuid;
 	
 	public static void main(String[] args) throws IOException {
 		String key = "hoge";
@@ -41,6 +43,8 @@
 		
 		DefaultTreeOperationLogContainer logContainer = new DefaultTreeOperationLogContainer();
 		logContainer.unconvert(log);
+		logContainer.setUUID("uuid");
+		logContainer.setTreeName("treeName");
 
 		MessagePack msgpack = new MessagePack();
 		Value logContainerValue = msgpack.unconvert(logContainer);
@@ -48,6 +52,8 @@
 																	DefaultTreeOperationLogContainer.class);
 		
 		TreeOperationLog convertedLog = convertedLogContainer.convert();
+		System.out.println("uuid = "+ convertedLogContainer.getUUID());
+		System.out.println("treeName = "+ convertedLogContainer.getTreeName());
 		for (TreeOperation treeOp : convertedLog) {
 			NodePath path = treeOp.getNodePath();
 			NodeOperation nodeOp = treeOp.getNodeOperation();
@@ -80,12 +86,28 @@
 			}
 			
 		}
-		
-		
 	}
 	
 	public DefaultTreeOperationLogContainer() {
-		
+		logValue = null;
+		treeName = "";
+		uuid = "";
+	}
+	
+	public void setTreeName(String _treeName) {
+		treeName = _treeName;
+	}
+	
+	public void setUUID(String _uuid) {
+		uuid = _uuid;
+	}
+	
+	public String getUUID() {
+		return uuid;
+	}
+	
+	public String getTreeName() {
+		return treeName;
 	}
 	
 	public void unconvert(Iterable<TreeOperation> _log) throws IOException {
--- a/src/alice/jungle/transaction/NetworkTransactionManager.java	Mon Jul 01 21:07:43 2013 +0900
+++ b/src/alice/jungle/transaction/NetworkTransactionManager.java	Tue Jul 02 11:52:32 2013 +0900
@@ -1,7 +1,10 @@
 package alice.jungle.transaction;
 
+import java.io.IOException;
 import java.util.Iterator;
 
+import alice.jungle.datasegment.store.operations.DefaultTreeOperationLogContainer;
+
 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.core.Node;
 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.ChangeList;
 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.ChangeListWriter;
@@ -63,12 +66,25 @@
 			return DefaultEither.newA((Error)new DefaultError());
 		}
 		Result r = writer.write(list);
-		if(r == Result.SUCCESS){
-			reservation.confirm();
-			TransactionManager<T> txManager = new NetworkTransactionManager<T>(treeName, writer, newContext, repository, uuid);
-			return DefaultEither.newB(txManager);
+		if(r != Result.SUCCESS) {
+			return DefaultEither.newA((Error)new DefaultError());
+		}
+		try {
+			updateDataSegment(uuid, treeName, list);
+		} catch (IOException e) {
+			e.printStackTrace();
 		}
-		return DefaultEither.newA((Error)new DefaultError());
+		reservation.confirm();
+		TransactionManager<T> txManager = new NetworkTransactionManager<T>(treeName, writer, newContext, repository, uuid);
+		return DefaultEither.newB(txManager);
+	}
+	
+	private void updateDataSegment(String _uuid, String _treeName, Iterable<TreeOperation> _log) throws IOException {
+		DefaultTreeOperationLogContainer container = new DefaultTreeOperationLogContainer();
+		container.setTreeName(_treeName);
+		container.setUUID(_uuid);
+		container.unconvert(_log);
+		
 	}
 
 	@Override