Mercurial > hg > Members > nobuyasu > jungle-network
comparison src/alice/jungle/codesegment/LogUpdateCodeSegment.java @ 56:ccfe9b5e8f11
bug LogUpdateCodeSegment
author | one |
---|---|
date | Sun, 14 Jul 2013 21:26:49 +0900 |
parents | 61b2de3f7730 |
children | 1bfd13f831ea |
comparison
equal
deleted
inserted
replaced
55:25edf76b65dc | 56:ccfe9b5e8f11 |
---|---|
1 package alice.jungle.codesegment; | 1 package alice.jungle.codesegment; |
2 | 2 |
3 import java.io.IOException; | 3 import java.io.IOException; |
4 import java.util.Iterator; | |
4 | 5 |
5 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTree; | 6 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTree; |
6 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTreeEditor; | 7 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTreeEditor; |
8 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.core.Node; | |
7 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.logger.DefaultTreeOperationLog; | 9 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.logger.DefaultTreeOperationLog; |
10 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.DefaultEither; | |
11 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.DefaultError; | |
8 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either; | 12 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either; |
9 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error; | 13 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error; |
10 import jungle.test.bbs.JungleManager; | 14 import jungle.test.bbs.JungleManager; |
11 import alice.codesegment.CodeSegment; | 15 import alice.codesegment.CodeSegment; |
12 import alice.datasegment.CommandType; | 16 import alice.datasegment.CommandType; |
37 System.out.println("--LogUpdateCodeSegment--"); | 41 System.out.println("--LogUpdateCodeSegment--"); |
38 int index = parentLog.index; | 42 int index = parentLog.index; |
39 String h = host.asString(); | 43 String h = host.asString(); |
40 DefaultTreeOperationLogContainer container = parentLog.asClass(DefaultTreeOperationLogContainer.class); | 44 DefaultTreeOperationLogContainer container = parentLog.asClass(DefaultTreeOperationLogContainer.class); |
41 HashSetDataSegment ds = hashLog.asClass(HashSetDataSegment.class); | 45 HashSetDataSegment ds = hashLog.asClass(HashSetDataSegment.class); |
42 System.out.println(container.getHashLogString()); | |
43 if(ds.hash.contains(container.getHashLogString())) { | 46 if(ds.hash.contains(container.getHashLogString())) { |
44 ods.update("hashLog", ds); | 47 ods.update("hashLog", ds); |
45 new LogUpdateCodeSegment(index); | 48 new LogUpdateCodeSegment(index); |
46 return; | 49 return; |
47 } | 50 } |
72 ods.update("hashLog", ds); | 75 ods.update("hashLog", ds); |
73 System.out.println("ods.put log container"); | 76 System.out.println("ods.put log container"); |
74 ods.put("log", container); | 77 ods.put("log", container); |
75 new LogUpdateCodeSegment(index); | 78 new LogUpdateCodeSegment(index); |
76 } | 79 } |
80 | |
77 | 81 |
78 private boolean updaterIsMe(String host, DefaultTreeOperationLogContainer container) { | 82 private DefaultEither<DefaultError, Integer> checkTimeStamp(Node node, long newNodeTimeStamp) { |
79 return host.equals(container.getServerName()); | 83 int count = 0; |
84 long childTimeStamp = 0; | |
85 for(Iterator<Node> iter = node.getChildren().iterator();iter.hasNext();) { | |
86 Node n = iter.next(); | |
87 if(n.getAttributes().get("timestamp") == null) { | |
88 return DefaultEither.newA(new DefaultError()); | |
89 } | |
90 if(n.getAttributes().get("timestamp") != null) { | |
91 childTimeStamp = n.getAttributes().get("timestamp").getLong(); | |
92 if (newNodeTimeStamp < childTimeStamp) { | |
93 break; | |
94 } | |
95 } | |
96 count++; | |
97 } | |
98 return DefaultEither.newB(count); | |
80 } | 99 } |
100 | |
101 | |
102 | |
81 } | 103 } |