Mercurial > hg > Members > nobuyasu > jungle-network
diff src/jungle/app/bbs/NetworkJungleBulletinBoard.java @ 93:75cf01a430a6
Added LocalTreeEditor
author | one |
---|---|
date | Fri, 15 Nov 2013 12:23:59 +0900 |
parents | e95faa202b4f |
children |
line wrap: on
line diff
--- a/src/jungle/app/bbs/NetworkJungleBulletinBoard.java Mon Nov 11 19:35:22 2013 +0900 +++ b/src/jungle/app/bbs/NetworkJungleBulletinBoard.java Fri Nov 15 12:23:59 2013 +0900 @@ -1,14 +1,11 @@ package jungle.app.bbs; -import java.io.IOException; import java.nio.ByteBuffer; import java.util.Date; import java.util.concurrent.atomic.AtomicInteger; import alice.jungle.core.NetworkDefaultJungle; -import alice.jungle.datasegment.store.container.DefaultTreeOperationLogContainer; import alice.jungle.persistence.AliceJournal; -import alice.jungle.transaction.NetworkDefaultJungleTreeEditor; 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; @@ -16,16 +13,13 @@ import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.core.Node; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.DefaultNodePath; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.DefaultTreeEditor; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.TreeOperation; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.trasnformer.EditableNode; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.trasnformer.NodeEditor; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.transaction.DefaultTreeNode; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.traverser.DefaultTraverser; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.DefaultEither; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.IterableConverter; -import jungle.app.bbs.codesegment.HashLogUpdateCodeSegment; public class NetworkJungleBulletinBoard implements BulletinBoard { @@ -79,12 +73,7 @@ throw new IllegalStateException(); } final long timestamp = new Date().getTime(); - /* Put DataSegment */ - try { - putTreeOperationLog((NetworkDefaultJungleTreeEditor)editor,timestamp); - } catch (IOException e1) { - e1.printStackTrace(); - } + tree = jungle.getTreeByName(_name); editor = tree.getTreeEditor(); @@ -111,12 +100,6 @@ } editor = either.b(); editor.success(); - /* Put DataSegment */ - try { - putTreeOperationLog((NetworkDefaultJungleTreeEditor)editor, timestamp); - } catch (IOException e1) { - e1.printStackTrace(); - } } @@ -157,12 +140,7 @@ } editor = either.b(); either = editor.success(); - try { - NetworkDefaultJungleTreeEditor<DefaultTreeNode> netEditor = (NetworkDefaultJungleTreeEditor<DefaultTreeNode>) editor; - putTreeOperationLog(netEditor, timestamp); - } catch (IOException e1) { - e1.printStackTrace(); - } + }while(either.isA()); /* Put DataSegment */ } @@ -193,11 +171,6 @@ } editor = either.b(); either = editor.success(); - try { - putTreeOperationLog((NetworkDefaultJungleTreeEditor)editor, timestamp); - } catch (IOException e1) { - e1.printStackTrace(); - } if(!either.isA()) { return; } @@ -225,31 +198,6 @@ return new IterableConverter<BoardMessage,Node>(chs,converter); } - private void putTreeOperationLog(NetworkDefaultJungleTreeEditor<DefaultTreeNode> editor, long timestamp) throws IOException { - String uuid = editor.getID(); - String treeName = editor.getTreeName(); - String updaterName = editor.getID(); - String revision = editor.getRevision(); - Iterable<TreeOperation> log = editor.getTreeOperationLog(); - putDataSegment(uuid, treeName, updaterName, log, revision, timestamp); - } - - private void putDataSegment(String _uuid, String _treeName, String _updaterName, Iterable<TreeOperation> _log, String nextRevision,long timestamp) throws IOException { - DefaultTreeOperationLogContainer container = new DefaultTreeOperationLogContainer(); - container.setTreeName(_treeName); - container.setUUID(_uuid); - container.setUpdaterName(_updaterName); - container.setRevision(nextRevision); - container.unconvert(_log); - container.setTimeStamp(timestamp); - HashLogUpdateCodeSegment cs = new HashLogUpdateCodeSegment(); - cs.ods.put("log", container); - cs.ods.put("logString", container.getHashLogString()); - /* If this node is not Root node, push log to parent node's DS */ - if(!_updaterName.equals("node0")) { - cs.ods.put("parent", "childLog", container); - } - } private static class BoardMessageImpl implements BoardMessage