Mercurial > hg > Members > shoshi > jungle > jungle-core
changeset 363:a3afcd044259
Logupdate terminate
author | suruga |
---|---|
date | Fri, 02 Feb 2018 19:01:52 +0900 |
parents | afa721d9e9bb |
children | 5480020555e7 |
files | src/main/java/jp/ac/u_ryukyu/ie/cr/jungleNetwork/codesegment/LogUpdateCodeSegment.java src/test/java/jp/ac/u_ryukyu/ie/cr/jungleNetwork/logupdate/LogupdateFinish.java src/test/java/jp/ac/u_ryukyu/ie/cr/jungleNetwork/logupdate/LogupdateTestStartCodeSegment.java |
diffstat | 3 files changed, 18 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungleNetwork/codesegment/LogUpdateCodeSegment.java Thu Feb 01 19:32:33 2018 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungleNetwork/codesegment/LogUpdateCodeSegment.java Fri Feb 02 19:01:52 2018 +0900 @@ -34,7 +34,6 @@ public void run() { // int index = log.index; - NetworkTreeOperationLog netLog = log.asClass(NetworkTreeOperationLog.class); @SuppressWarnings("unchecked") List<String> list = clist.asClass(List.class); for (String node : list) {//他ノードへlogの書き込み @@ -43,8 +42,13 @@ System.out.println("LogUpdator: write to node " + node + " from " + log.from ); } } + JungleDistributedUpdator u = updator.asClass(JungleDistributedUpdator.class); + if (log.getVal() == null) { + ods.put("finish", 0); + return; + } + NetworkTreeOperationLog netLog = log.asClass(NetworkTreeOperationLog.class); - JungleDistributedUpdator u = updator.asClass(JungleDistributedUpdator.class); if (!log.from.equals("local")) {//ほかノードからのlogの更新 Either<Error, JungleTreeEditor> either = u.update(netLog); System.out.println("LogUpdator: Update from " + log.from);
--- a/src/test/java/jp/ac/u_ryukyu/ie/cr/jungleNetwork/logupdate/LogupdateFinish.java Thu Feb 01 19:32:33 2018 +0900 +++ b/src/test/java/jp/ac/u_ryukyu/ie/cr/jungleNetwork/logupdate/LogupdateFinish.java Fri Feb 02 19:01:52 2018 +0900 @@ -4,16 +4,19 @@ import alice.datasegment.CommandType; import alice.datasegment.ReceiveData; import alice.datasegment.Receiver; +import org.msgpack.type.ValueFactory; import java.util.List; public class LogupdateFinish extends CodeSegment { + private final String host; Receiver finish = ids.create(CommandType.TAKE); private Receiver clist = ids.create(CommandType.PEEK); - LogupdateFinish() { + LogupdateFinish(String host) { finish.setKey("finish"); clist.setKey("_CLIST"); + this.host = host; } @Override @@ -24,7 +27,7 @@ List<String> list = clist.asClass(List.class); for (String node : list) {//他ノードへlogの書き込み if (!node.equals(finish.from)) { - ods.put(node, "finish", 1); + ods.put(node, "log", ValueFactory.createNilValue()); } } for (String node : list) {//他ノードへlogの書き込み @@ -32,5 +35,9 @@ ods.finish(node); } } + if (host.equals("node0")) { + ods.put("manager","finish",0); + ods.finish("manager"); + } } }
--- a/src/test/java/jp/ac/u_ryukyu/ie/cr/jungleNetwork/logupdate/LogupdateTestStartCodeSegment.java Thu Feb 01 19:32:33 2018 +0900 +++ b/src/test/java/jp/ac/u_ryukyu/ie/cr/jungleNetwork/logupdate/LogupdateTestStartCodeSegment.java Fri Feb 02 19:01:52 2018 +0900 @@ -3,15 +3,12 @@ import alice.codesegment.CodeSegment; import alice.datasegment.CommandType; import alice.datasegment.Receiver; -import alice.topology.node.TopologyNodeConfig; -import jp.ac.u_ryukyu.ie.cr.jungle.DefaultJungle; import jp.ac.u_ryukyu.ie.cr.jungle.bbs.BBSTest; import jp.ac.u_ryukyu.ie.cr.jungleNetwork.codesegment.LogUpdateCodeSegment; import jp.ac.u_ryukyu.ie.cr.jungleNetwork.core.NetworkDefaultJungle; import jp.ac.u_ryukyu.ie.cr.jungleNetwork.persistent.AliceJournal; +import org.msgpack.type.ValueFactory; -import java.io.IOException; -import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -53,7 +50,7 @@ ods.put("updator", cassaBBS); new LogUpdateCodeSegment(); - new LogupdateFinish(); + new LogupdateFinish(host.asString()); if (config.isWriteMode()) { for (int i = config.writeCount;i>0;i--) { bbsTest.createMessage(); @@ -61,9 +58,7 @@ try { bbsTest.checkTime(); Thread.sleep(5000); - ods.put("finish",0); - ods.put("manager","finish",0); - ods.finish("manager"); + ods.put("log", ValueFactory.createNilValue()); } catch (Exception e) { e.printStackTrace(); }