Mercurial > hg > Members > nobuyasu > jungle-network
comparison src/alice/jungle/codesegment/LogUpdateCodeSegment.java @ 52:61b2de3f7730
add HashSetDataSegment and HashLogUpdateCodeSegment.
fix bugs
author | one |
---|---|
date | Sat, 13 Jul 2013 17:10:14 +0900 |
parents | 9e782b4eb06e |
children | ccfe9b5e8f11 |
comparison
equal
deleted
inserted
replaced
51:9e782b4eb06e | 52:61b2de3f7730 |
---|---|
9 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error; | 9 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error; |
10 import jungle.test.bbs.JungleManager; | 10 import jungle.test.bbs.JungleManager; |
11 import alice.codesegment.CodeSegment; | 11 import alice.codesegment.CodeSegment; |
12 import alice.datasegment.CommandType; | 12 import alice.datasegment.CommandType; |
13 import alice.datasegment.Receiver; | 13 import alice.datasegment.Receiver; |
14 import alice.jungle.datasegment.HashSetDataSegment; | |
14 import alice.jungle.datasegment.store.operations.DefaultTreeOperationLogContainer; | 15 import alice.jungle.datasegment.store.operations.DefaultTreeOperationLogContainer; |
15 import alice.jungle.transaction.NetworkDefaultJungleTreeEditor; | 16 import alice.jungle.transaction.NetworkDefaultJungleTreeEditor; |
16 | 17 |
17 public class LogUpdateCodeSegment extends CodeSegment { | 18 public class LogUpdateCodeSegment extends CodeSegment { |
18 | 19 |
19 public Receiver arg1 = ids.create(CommandType.PEEK); | 20 Receiver parentLog = ids.create(CommandType.PEEK); |
20 public Receiver host = ids.create(CommandType.PEEK); | 21 Receiver host = ids.create(CommandType.PEEK); |
22 Receiver hashLog = ids.create(CommandType.PEEK); | |
21 | 23 |
22 public LogUpdateCodeSegment() { | 24 public LogUpdateCodeSegment() { |
23 arg1.setKey("parent", "log"); | 25 parentLog.setKey("parent", "log"); |
24 host.setKey("host"); | 26 host.setKey("host"); |
27 hashLog.setKey("hashLog"); | |
25 } | 28 } |
26 | 29 |
27 public LogUpdateCodeSegment(int index) { | 30 public LogUpdateCodeSegment(int index) { |
28 arg1.setKey("parent", "log", index); | 31 parentLog.setKey("parent", "log", index); |
29 host.setKey("host"); | 32 host.setKey("host"); |
33 hashLog.setKey("hashLog"); | |
30 } | 34 } |
31 | 35 |
32 public void run() { | 36 public void run() { |
33 System.out.println("--LogUpdateCodeSegment--"); | 37 System.out.println("--LogUpdateCodeSegment--"); |
34 int index = arg1.index; | 38 int index = parentLog.index; |
35 String h = host.asString(); | 39 String h = host.asString(); |
36 DefaultTreeOperationLogContainer container = arg1.asClass(DefaultTreeOperationLogContainer.class); | 40 DefaultTreeOperationLogContainer container = parentLog.asClass(DefaultTreeOperationLogContainer.class); |
37 if(updaterIsMe(h, container)) { | 41 HashSetDataSegment ds = hashLog.asClass(HashSetDataSegment.class); |
42 System.out.println(container.getHashLogString()); | |
43 if(ds.hash.contains(container.getHashLogString())) { | |
44 ods.update("hashLog", ds); | |
38 new LogUpdateCodeSegment(index); | 45 new LogUpdateCodeSegment(index); |
39 return; | 46 return; |
40 } | 47 } |
41 DefaultTreeOperationLog log = null; | 48 DefaultTreeOperationLog log = null; |
42 try { | 49 try { |
59 editor = either.b(); | 66 editor = either.b(); |
60 either = editor.success(); | 67 either = editor.success(); |
61 if(either.isA()) { | 68 if(either.isA()) { |
62 throw new IllegalStateException(); | 69 throw new IllegalStateException(); |
63 } | 70 } |
71 ds.hash.add(container.getHashLogString()); | |
72 ods.update("hashLog", ds); | |
73 System.out.println("ods.put log container"); | |
64 ods.put("log", container); | 74 ods.put("log", container); |
65 new LogUpdateCodeSegment(index); | 75 new LogUpdateCodeSegment(index); |
66 } | 76 } |
67 | 77 |
68 private boolean updaterIsMe(String host, DefaultTreeOperationLogContainer container) { | 78 private boolean updaterIsMe(String host, DefaultTreeOperationLogContainer container) { |