Mercurial > hg > Members > nobuyasu > jungle-network
view src/jungle/app/bbs/codesegment/ChildLogCheckCodeSegment.java @ 66:29127ac788a6
move some files
author | one |
---|---|
date | Tue, 20 Aug 2013 17:38:09 +0900 |
parents | src/jungle/test/bbs/codesegment/ChildLogCheckCodeSegment.java@ebf42371454b |
children | 87ec5dd0dc27 |
line wrap: on
line source
package jungle.app.bbs.codesegment; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTreeEditor; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error; import jungle.app.bbs.JungleManager; import alice.codesegment.CodeSegment; import alice.datasegment.CommandType; import alice.datasegment.Receiver; import alice.jungle.datasegment.HashSetDataSegment; import alice.jungle.datasegment.store.operations.DefaultTreeOperationLogContainer; public class ChildLogCheckCodeSegment extends CodeSegment { Receiver host = ids.create(CommandType.PEEK); Receiver childLog = ids.create(CommandType.TAKE); Receiver hashLog = ids.create(CommandType.PEEK); public ChildLogCheckCodeSegment() { host.setKey("host"); childLog.setKey("local","childLog"); hashLog.setKey("hashLog"); } public ChildLogCheckCodeSegment(int index) { host.setKey("host"); childLog.setKey("local","childLog", index); hashLog.setKey("hashLog"); } public void run() { int index = childLog.index; String hostName = host.asString(); DefaultTreeOperationLogContainer container = childLog.asClass(DefaultTreeOperationLogContainer.class); HashSetDataSegment ds = hashLog.asClass(HashSetDataSegment.class); if(ds.hash.contains(container.getHashLogString())) { ods.update("hashLog", ds); new LogUpdateCodeSegment(index); return; } Either<Error, JungleTreeEditor> either = JungleManager.update(container); if(either.isA()) { throw new IllegalStateException(); } ds.hash.add(container.getHashLogString()); ods.update("hashLog", ds); ods.put("log", container); new ChildLogCheckCodeSegment(index); if(!hostName.equals("node0")) { ods.put("parent", "childLog", container); } } }