Mercurial > hg > Database > jungle-network
changeset 47:686057add8a4
confirmed LogUpdateCodeSegment
author | one |
---|---|
date | Fri, 12 Jul 2013 11:45:12 +0900 |
parents | fd3643699f83 |
children | ab8c655ef457 |
files | src/alice/jungle/codesegment/LogUpdateCodeSegment.java src/alice/jungle/core/NetworkDefaultJungle.java src/jungle/test/bbs/NetworkJungleBulletinBoard.java src/jungle/test/bbs/codesegment/StartBBSCodeSegment.java src/jungle/test/core/practice/LogReadCodeSegment.java src/jungle/test/core/practice/LogSendTest.java src/jungle/test/core/practice/PrintChildrenAttribute.java src/test/alice/jungle/codesegment/DoubleJungleManager.java |
diffstat | 8 files changed, 21 insertions(+), 23 deletions(-) [+] |
line wrap: on
line diff
--- a/src/alice/jungle/codesegment/LogUpdateCodeSegment.java Fri Jul 12 11:27:00 2013 +0900 +++ b/src/alice/jungle/codesegment/LogUpdateCodeSegment.java Fri Jul 12 11:45:12 2013 +0900 @@ -17,21 +17,20 @@ public class LogUpdateCodeSegment extends CodeSegment { public Receiver arg1 = ids.create(CommandType.PEEK); - private final String rh; - private final String key; + public Receiver host = ids.create(CommandType.PEEK); - public LogUpdateCodeSegment(String _rh, String _key) { - rh = _rh; - key = _key; + public LogUpdateCodeSegment() { + host.setKey("host",0); } public void run() { System.out.println("--LogUpdateCodeSegment--"); int index = arg1.index; + String h = host.asString(); DefaultTreeOperationLogContainer container = arg1.asClass(DefaultTreeOperationLogContainer.class); - if(updaterIsMe(container)) { - LogUpdateCodeSegment updateCS = new LogUpdateCodeSegment(rh, key); - updateCS.arg1.setKey(rh, key, index+1); + if(updaterIsMe(h, container)) { + LogUpdateCodeSegment updateCS = new LogUpdateCodeSegment(); + updateCS.arg1.setKey("log", index+1); return; } DefaultTreeOperationLog log = null; @@ -51,13 +50,12 @@ if(either.isA()) { throw new IllegalStateException(); } - LogUpdateCodeSegment updateCS = new LogUpdateCodeSegment(rh, key); - updateCS.arg1.setKey(rh, key, index+1); + LogUpdateCodeSegment updateCS = new LogUpdateCodeSegment(); + updateCS.arg1.setKey("log", index+1); } - private boolean updaterIsMe(DefaultTreeOperationLogContainer container) { - - return false; + private boolean updaterIsMe(String host, DefaultTreeOperationLogContainer container) { + return host.equals(container.getServerName()); }
--- a/src/alice/jungle/core/NetworkDefaultJungle.java Fri Jul 12 11:27:00 2013 +0900 +++ b/src/alice/jungle/core/NetworkDefaultJungle.java Fri Jul 12 11:45:12 2013 +0900 @@ -9,7 +9,6 @@ import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTree; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.ChangeList; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.Journal; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.NullJournal; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.ChangeSet; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.TreeEditor; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.TreeOperation;
--- a/src/jungle/test/bbs/NetworkJungleBulletinBoard.java Fri Jul 12 11:27:00 2013 +0900 +++ b/src/jungle/test/bbs/NetworkJungleBulletinBoard.java Fri Jul 12 11:45:12 2013 +0900 @@ -235,7 +235,7 @@ container.setRevision(nextRevision); container.unconvert(_log); NullCodeSegmentForUpdate cs = new NullCodeSegmentForUpdate(); - cs.ods.put("local", "log", container); + cs.ods.put("log", container); }
--- a/src/jungle/test/bbs/codesegment/StartBBSCodeSegment.java Fri Jul 12 11:27:00 2013 +0900 +++ b/src/jungle/test/bbs/codesegment/StartBBSCodeSegment.java Fri Jul 12 11:45:12 2013 +0900 @@ -21,6 +21,7 @@ import alice.codesegment.CodeSegment; import alice.datasegment.CommandType; import alice.datasegment.Receiver; +import alice.jungle.codesegment.LogUpdateCodeSegment; public class StartBBSCodeSegment extends CodeSegment { @@ -40,7 +41,9 @@ String type = matcher.group(1); int num = new Integer(matcher.group(2)); - + LogUpdateCodeSegment cs = new LogUpdateCodeSegment(); + cs.arg1.setKey("log", 0); + BulletinBoard cassaBBS = new NetworkJungleBulletinBoard(name); String createBoardMessagePath = "/createBoardMessage"; String createBoardPath = "/createBoard";
--- a/src/jungle/test/core/practice/LogReadCodeSegment.java Fri Jul 12 11:27:00 2013 +0900 +++ b/src/jungle/test/core/practice/LogReadCodeSegment.java Fri Jul 12 11:45:12 2013 +0900 @@ -38,7 +38,7 @@ } catch (IOException e) { e.printStackTrace(); } - Jungle jungle = new JungleManager().getJungle(); + Jungle jungle = JungleManager.getJungle(); JungleTree tree = jungle.getTreeByName("tree"); JungleTreeEditor editor = tree.getTreeEditor(); Either<Error, JungleTreeEditor> either = edit(editor, log);
--- a/src/jungle/test/core/practice/LogSendTest.java Fri Jul 12 11:27:00 2013 +0900 +++ b/src/jungle/test/core/practice/LogSendTest.java Fri Jul 12 11:45:12 2013 +0900 @@ -18,8 +18,7 @@ public static void main(String[] args) { System.out.println("Start LogSendTest"); - JungleManager jm = new JungleManager(); - JungleTree tree = jm.createNewTree("tree"); + JungleTree tree = JungleManager.createNewTree("tree"); JungleTreeEditor editor = tree.getTreeEditor(); DefaultNodePath root = new DefaultNodePath();
--- a/src/jungle/test/core/practice/PrintChildrenAttribute.java Fri Jul 12 11:27:00 2013 +0900 +++ b/src/jungle/test/core/practice/PrintChildrenAttribute.java Fri Jul 12 11:45:12 2013 +0900 @@ -23,8 +23,7 @@ System.out.println("--PrintChildrenAttribute--"); String k = key.asString(); System.out.println("key : "+ k); - JungleManager jm = new JungleManager(); - Jungle jungle = jm.getJungle(); + Jungle jungle = JungleManager.getJungle(); JungleTree tree = jungle.getTreeByName("tree"); Node node = tree.getRootNode(); Children<Node> chs = node.getChildren();
--- a/src/test/alice/jungle/codesegment/DoubleJungleManager.java Fri Jul 12 11:27:00 2013 +0900 +++ b/src/test/alice/jungle/codesegment/DoubleJungleManager.java Fri Jul 12 11:45:12 2013 +0900 @@ -20,8 +20,8 @@ public class DoubleJungleManager { - static Jungle jungle1 = new NetworkDefaultJungle(null, "hoge", new DefaultTreeEditor(new DefaultTraverser())); - static Jungle jungle2 = new NetworkDefaultJungle(null, "hoge", new DefaultTreeEditor(new DefaultTraverser())); + static Jungle jungle1 = new NetworkDefaultJungle(null, "hoge", new DefaultTreeEditor(new DefaultTraverser()), ""); + static Jungle jungle2 = new NetworkDefaultJungle(null, "hoge", new DefaultTreeEditor(new DefaultTraverser()), ""); public DoubleJungleManager() {