Mercurial > hg > Database > jungle-network
changeset 28:e968224ad0ce
add jungle.test.core.practice
author | one |
---|---|
date | Mon, 01 Jul 2013 19:14:24 +0900 |
parents | 0493340583ab |
children | 16ea4835f36e |
files | .classpath src/jungle/test/codesegment/persistence/AliceJournal.java src/jungle/test/core/NetworkDefaultJungle.java src/jungle/test/core/practice/LogReadCodeSegment.java src/jungle/test/core/practice/LogSendTest.java src/jungle/test/core/practice/PrintChildrenAttribute.java src/jungle/test/datasegment/store/operations/DefaultTreeOperationLogContainer.java src/jungle/test/transaction/NetworkDefaultJungleTreeEditor.java |
diffstat | 8 files changed, 150 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/.classpath Mon Jul 01 04:27:11 2013 +0900 +++ b/.classpath Mon Jul 01 19:14:24 2013 +0900 @@ -3,10 +3,10 @@ <classpathentry kind="src" path="src"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> <classpathentry kind="lib" path="/Users/nobuyasu/workspace/Alice/Alice.jar"/> - <classpathentry kind="lib" path="/Users/nobuyasu/workspace/jungle-core/target/jungle-core-0.0.1-SNAPSHOT.jar"/> <classpathentry kind="lib" path="lib/commons-collections-3.2.1.jar"/> <classpathentry kind="lib" path="lib/functionaljava.jar"/> <classpathentry kind="lib" path="lib/guava-12.0-sources.jar"/> <classpathentry kind="lib" path="lib/guava-12.0.jar"/> + <classpathentry kind="lib" path="/jungle-core/target/jungle-core-0.0.1-SNAPSHOT.jar"/> <classpathentry kind="output" path="bin"/> </classpath>
--- a/src/jungle/test/codesegment/persistence/AliceJournal.java Mon Jul 01 04:27:11 2013 +0900 +++ b/src/jungle/test/codesegment/persistence/AliceJournal.java Mon Jul 01 19:14:24 2013 +0900 @@ -42,11 +42,7 @@ } -*/ - - - - +*/ for(TreeOperation op : _operations){ NodePath p = op.getNodePath(); NodeOperation nodeOp = op.getNodeOperation();
--- a/src/jungle/test/core/NetworkDefaultJungle.java Mon Jul 01 04:27:11 2013 +0900 +++ b/src/jungle/test/core/NetworkDefaultJungle.java Mon Jul 01 19:14:24 2013 +0900 @@ -26,7 +26,8 @@ public NetworkDefaultJungle(Journal _journal,String _uuid,TreeEditor _editor) { - journal = new AliceJournal(); +// journal = new AliceJournal(); + journal = new NullJournal(); trees = new ConcurrentHashMap<String,JungleTree>(); uuid = _uuid; editor = _editor; @@ -48,7 +49,6 @@ return nil.iterator(); } }; - DefaultTreeNode root = new DefaultTreeNode(); ChangeSet set = new DefaultChangeSet(root.getAsNode(),null,list,uuid,0); DefaultTreeContext<DefaultTreeNode> tc = new DefaultTreeContext<DefaultTreeNode>(root,set); @@ -58,6 +58,4 @@ } return newTree; } - - }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/jungle/test/core/practice/LogReadCodeSegment.java Mon Jul 01 19:14:24 2013 +0900 @@ -0,0 +1,51 @@ +package jungle.test.core.practice; + +import java.io.IOException; + +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.Jungle; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTree; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTreeEditor; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.logger.DefaultTreeOperationLog; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error; +import jungle.test.codesegment.operation.JungleManager; +import jungle.test.datasegment.store.operations.DefaultTreeOperationLogContainer; +import jungle.test.transaction.NetworkDefaultJungleTreeEditor; +import alice.codesegment.CodeSegment; +import alice.datasegment.CommandType; +import alice.datasegment.Receiver; + +public class LogReadCodeSegment extends CodeSegment { + + Receiver arg1 = ids.create(CommandType.TAKE); + + public LogReadCodeSegment() { + arg1.setKey("log"); + } + + public void run() { + System.out.println("--LogReadCodeSegment--"); + + DefaultTreeOperationLogContainer container = arg1.asClass(DefaultTreeOperationLogContainer.class); + DefaultTreeOperationLog log = null; + try { + log = container.convert(); + } catch (IOException e) { + e.printStackTrace(); + } + + JungleManager jm = new JungleManager(); + Jungle jungle = jm.getJungle(); + JungleTree tree = jungle.getTreeByName("tree"); + NetworkDefaultJungleTreeEditor nEditor = (NetworkDefaultJungleTreeEditor) tree.getTreeEditor(); + JungleTreeEditor editor = nEditor.setNewLogAndGetEditor(log); + Either<Error,JungleTreeEditor> either = editor.success(); + if(either.isA()) { + throw new IllegalStateException(); + } + new PrintChildrenAttribute("key1"); + ods.update("key1", "key1"); + + } + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/jungle/test/core/practice/LogSendTest.java Mon Jul 01 19:14:24 2013 +0900 @@ -0,0 +1,47 @@ +package jungle.test.core.practice; + +import java.io.IOException; +import java.nio.ByteBuffer; + +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTree; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTreeEditor; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.DefaultNodePath; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.logger.TreeOperationLog; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error; +import jungle.test.codesegment.operation.JungleManager; +import jungle.test.datasegment.store.operations.DefaultTreeOperationLogContainer; +import jungle.test.transaction.NetworkDefaultJungleTreeEditor; + +public class LogSendTest { + + public static void main(String[] args) { + System.out.println("Start LogSendTest"); + JungleManager jm = new JungleManager(); + JungleTree tree = jm.createNewTree("tree"); + JungleTreeEditor editor = tree.getTreeEditor(); + + DefaultNodePath root = new DefaultNodePath(); + Either<Error, JungleTreeEditor> either = editor.addNewChildAt(root, 0); + if(either.isA()) { + throw new IllegalStateException(); + } + editor = either.b(); + either = editor.putAttribute(root.add(0), "key1", ByteBuffer.wrap("first message".getBytes())); + if(either.isA()) { + throw new IllegalStateException(); + } + NetworkDefaultJungleTreeEditor nEditor = (NetworkDefaultJungleTreeEditor) either.b(); + TreeOperationLog log = nEditor.getTreeOperationLog(); + + DefaultTreeOperationLogContainer container = new DefaultTreeOperationLogContainer(); + try { + container.unconvert(log); + } catch (IOException e) { + e.printStackTrace(); + } + LogReadCodeSegment cs = new LogReadCodeSegment(); + cs.ods.update("log", container); + } + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/jungle/test/core/practice/PrintChildrenAttribute.java Mon Jul 01 19:14:24 2013 +0900 @@ -0,0 +1,46 @@ +package jungle.test.core.practice; + +import java.nio.ByteBuffer; + +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.Jungle; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTree; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.core.Children; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.core.Node; +import jungle.test.codesegment.operation.JungleManager; +import alice.codesegment.CodeSegment; +import alice.datasegment.CommandType; +import alice.datasegment.Receiver; + +public class PrintChildrenAttribute extends CodeSegment { + + Receiver key = ids.create(CommandType.TAKE); + + public PrintChildrenAttribute(String _key) { + key.setKey(_key); + } + + public void run() { + System.out.println("--PrintChildrenAttribute--"); + String k = key.asString(); + System.out.println("key : "+ k); + JungleManager jm = new JungleManager(); + Jungle jungle = jm.getJungle(); + JungleTree tree = jungle.getTreeByName("tree"); + Node node = tree.getRootNode(); + Children<Node> chs = node.getChildren(); + System.out.println("children size : "+chs.size()); + for(Node n : chs) { + ByteBuffer b = n.getAttributes().get(k); + System.out.println(new String(b.array())); + } + + System.exit(0); + + + + + + } + + +}
--- a/src/jungle/test/datasegment/store/operations/DefaultTreeOperationLogContainer.java Mon Jul 01 04:27:11 2013 +0900 +++ b/src/jungle/test/datasegment/store/operations/DefaultTreeOperationLogContainer.java Mon Jul 01 19:14:24 2013 +0900 @@ -88,7 +88,7 @@ } - public void unconvert(DefaultTreeOperationLog _log) throws IOException { + public void unconvert(TreeOperationLog _log) throws IOException { MessagePack msgpack = new MessagePack(); List<Value> list = new LinkedList<Value>(); for(TreeOperation op : _log) {
--- a/src/jungle/test/transaction/NetworkDefaultJungleTreeEditor.java Mon Jul 01 04:27:11 2013 +0900 +++ b/src/jungle/test/transaction/NetworkDefaultJungleTreeEditor.java Mon Jul 01 19:14:24 2013 +0900 @@ -143,7 +143,7 @@ return newEditor; } - public TreeOperationLog getLog() { + public TreeOperationLog getTreeOperationLog() { return log; }