Mercurial > hg > Database > jungle-network
view src/jungle/test/bbs/codesegment/ChildLogCheckCodeSegment.java @ 51:9e782b4eb06e
add HashSetConvertDataSegment
author | one |
---|---|
date | Sat, 13 Jul 2013 15:59:47 +0900 |
parents | 459b50f1a6ee |
children | 61b2de3f7730 |
line wrap: on
line source
package jungle.test.bbs.codesegment; import java.io.IOException; 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.bbs.JungleManager; import alice.codesegment.CodeSegment; import alice.datasegment.CommandType; import alice.datasegment.Receiver; import alice.jungle.datasegment.store.operations.DefaultTreeOperationLogContainer; public class ChildLogCheckCodeSegment extends CodeSegment { Receiver childLog = ids.create(CommandType.TAKE); Receiver host = ids.create(CommandType.PEEK); public ChildLogCheckCodeSegment() { host.setKey("host"); childLog.setKey("local","childLog"); } public void run() { System.out.println("--ChildLogCheckCodeSegment--"); String hostName = host.asString(); DefaultTreeOperationLogContainer container = childLog.asClass(DefaultTreeOperationLogContainer.class); DefaultTreeOperationLog log = null; try { log = container.convert(); } catch (IOException e) { e.printStackTrace(); } String treeName = container.getTreeName(); if (JungleManager.getJungle().getTreeByName(treeName) == null) { if(null == JungleManager.getJungle().createNewTree(treeName)){ throw new IllegalStateException(); } } JungleTree tree = JungleManager.getJungle().getTreeByName(treeName); JungleTreeEditor editor = tree.getTreeEditor(); Either<Error, JungleTreeEditor> either = JungleManager.edit(editor, log); if(either.isA()) { throw new IllegalStateException(); } editor = either.b(); either = editor.success(); if(either.isA()) { throw new IllegalStateException(); } ods.put("log", container); new ChildLogCheckCodeSegment(); if(!hostName.equals("node0")) { ods.put("parent", "childLog", container); } } }