comparison 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
comparison
equal deleted inserted replaced
50:459b50f1a6ee 51:9e782b4eb06e
14 import alice.jungle.datasegment.store.operations.DefaultTreeOperationLogContainer; 14 import alice.jungle.datasegment.store.operations.DefaultTreeOperationLogContainer;
15 15
16 public class ChildLogCheckCodeSegment extends CodeSegment { 16 public class ChildLogCheckCodeSegment extends CodeSegment {
17 17
18 Receiver childLog = ids.create(CommandType.TAKE); 18 Receiver childLog = ids.create(CommandType.TAKE);
19 Receiver host = ids.create(CommandType.PEEK);
19 20
20 public ChildLogCheckCodeSegment() { 21 public ChildLogCheckCodeSegment() {
21 childLog.setKey("childLog"); 22 host.setKey("host");
23 childLog.setKey("local","childLog");
22 } 24 }
23 25
24 public void run() { 26 public void run() {
27 System.out.println("--ChildLogCheckCodeSegment--");
28 String hostName = host.asString();
25 DefaultTreeOperationLogContainer container = childLog.asClass(DefaultTreeOperationLogContainer.class); 29 DefaultTreeOperationLogContainer container = childLog.asClass(DefaultTreeOperationLogContainer.class);
26 DefaultTreeOperationLog log = null; 30 DefaultTreeOperationLog log = null;
27 try { 31 try {
28 log = container.convert(); 32 log = container.convert();
29 } catch (IOException e) { 33 } catch (IOException e) {
30 e.printStackTrace(); 34 e.printStackTrace();
31 } 35 }
32 JungleTree tree = JungleManager.getJungle().getTreeByName("boards"); 36 String treeName = container.getTreeName();
37 if (JungleManager.getJungle().getTreeByName(treeName) == null) {
38 if(null == JungleManager.getJungle().createNewTree(treeName)){
39 throw new IllegalStateException();
40 }
41 }
42 JungleTree tree = JungleManager.getJungle().getTreeByName(treeName);
33 JungleTreeEditor editor = tree.getTreeEditor(); 43 JungleTreeEditor editor = tree.getTreeEditor();
34 Either<Error, JungleTreeEditor> either = JungleManager.edit(editor, log); 44 Either<Error, JungleTreeEditor> either = JungleManager.edit(editor, log);
35 if(either.isA()) { 45 if(either.isA()) {
36 throw new IllegalStateException(); 46 throw new IllegalStateException();
37 } 47 }
40 if(either.isA()) { 50 if(either.isA()) {
41 throw new IllegalStateException(); 51 throw new IllegalStateException();
42 } 52 }
43 ods.put("log", container); 53 ods.put("log", container);
44 new ChildLogCheckCodeSegment(); 54 new ChildLogCheckCodeSegment();
55 if(!hostName.equals("node0")) {
56
57 ods.put("parent", "childLog", container);
58 }
45 } 59 }
46 60
47 61
48 } 62 }