Mercurial > hg > Members > nobuyasu > jungle-network
annotate src/main/java/alice/jungle/datasegment/container/DefaultTreeOperationLogContainer.java @ 105:f9e29a52efd3
Move some files
author | one |
---|---|
date | Tue, 26 Nov 2013 06:43:10 +0900 |
parents | src/alice/jungle/datasegment/store/container/DefaultTreeOperationLogContainer.java@2c7b3f2b2ee1 |
children |
rev | line source |
---|---|
105 | 1 package alice.jungle.datasegment.container; |
7 | 2 |
3 import java.io.IOException; | |
4 import java.util.LinkedList; | |
5 import java.util.List; | |
6 | |
7 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.NodePath; | |
8 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.logger.DefaultTreeOperationLog; | |
9 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.DefaultTreeOperation; | |
10 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.NodeOperation; | |
11 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.TreeOperation; | |
12 | |
13 import org.msgpack.MessagePack; | |
14 import org.msgpack.annotation.Message; | |
15 import org.msgpack.template.ListTemplate; | |
16 import org.msgpack.template.ValueTemplate; | |
17 import org.msgpack.type.Value; | |
18 | |
62 | 19 import alice.codesegment.SingletonMessage; |
20 | |
7 | 21 @Message |
22 public class DefaultTreeOperationLogContainer { | |
23 | |
24 Value logValue; | |
53
f47a02368099
implemented timestamp in DefaultTreeOperationLogContainer
one
parents:
52
diff
changeset
|
25 String treeName; |
f47a02368099
implemented timestamp in DefaultTreeOperationLogContainer
one
parents:
52
diff
changeset
|
26 String uuid; |
f47a02368099
implemented timestamp in DefaultTreeOperationLogContainer
one
parents:
52
diff
changeset
|
27 String updaterName; |
f47a02368099
implemented timestamp in DefaultTreeOperationLogContainer
one
parents:
52
diff
changeset
|
28 String revision; |
f47a02368099
implemented timestamp in DefaultTreeOperationLogContainer
one
parents:
52
diff
changeset
|
29 long timestamp; |
9 | 30 |
7 | 31 public DefaultTreeOperationLogContainer() { |
34 | 32 logValue = null; |
33 treeName = ""; | |
34 uuid = ""; | |
53
f47a02368099
implemented timestamp in DefaultTreeOperationLogContainer
one
parents:
52
diff
changeset
|
35 updaterName = ""; |
f47a02368099
implemented timestamp in DefaultTreeOperationLogContainer
one
parents:
52
diff
changeset
|
36 revision = ""; |
56 | 37 timestamp = Long.MAX_VALUE; |
34 | 38 } |
39 | |
40 public void setTreeName(String _treeName) { | |
41 treeName = _treeName; | |
42 } | |
43 | |
43 | 44 public String getTreeName() { |
45 return treeName; | |
46 } | |
47 | |
34 | 48 public void setUUID(String _uuid) { |
49 uuid = _uuid; | |
50 } | |
51 | |
52 public String getUUID() { | |
53 return uuid; | |
54 } | |
43 | 55 |
49 | 56 public void setUpdaterName(String _updaterName) { |
57 updaterName = _updaterName; | |
43 | 58 } |
34 | 59 |
43 | 60 public String getServerName() { |
49 | 61 return updaterName; |
43 | 62 } |
63 | |
52 | 64 public void setRevision(String _revision) { |
43 | 65 revision = _revision; |
66 } | |
67 | |
52 | 68 public String getRevision() { |
43 | 69 return revision; |
7 | 70 } |
53
f47a02368099
implemented timestamp in DefaultTreeOperationLogContainer
one
parents:
52
diff
changeset
|
71 |
f47a02368099
implemented timestamp in DefaultTreeOperationLogContainer
one
parents:
52
diff
changeset
|
72 public void setTimeStamp(long t) { |
f47a02368099
implemented timestamp in DefaultTreeOperationLogContainer
one
parents:
52
diff
changeset
|
73 timestamp = t; |
f47a02368099
implemented timestamp in DefaultTreeOperationLogContainer
one
parents:
52
diff
changeset
|
74 } |
f47a02368099
implemented timestamp in DefaultTreeOperationLogContainer
one
parents:
52
diff
changeset
|
75 |
f47a02368099
implemented timestamp in DefaultTreeOperationLogContainer
one
parents:
52
diff
changeset
|
76 public long getTimeStamp() { |
f47a02368099
implemented timestamp in DefaultTreeOperationLogContainer
one
parents:
52
diff
changeset
|
77 return timestamp; |
f47a02368099
implemented timestamp in DefaultTreeOperationLogContainer
one
parents:
52
diff
changeset
|
78 } |
7 | 79 |
33 | 80 public void unconvert(Iterable<TreeOperation> _log) throws IOException { |
62 | 81 MessagePack msgpack = SingletonMessage.getInstance(); |
7 | 82 List<Value> list = new LinkedList<Value>(); |
83 for(TreeOperation op : _log) { | |
84 NodeOperation nOp = op.getNodeOperation(); | |
85 NodePath nodePath = op.getNodePath(); | |
8
ee93e16d5a3f
implement unconvert and convert method in DefaultTreeOperationLog class
one
parents:
7
diff
changeset
|
86 DefaultTreeOperation treeOp = new DefaultTreeOperation(nodePath, nOp); |
7 | 87 DefaultTreeOperationContainer container = new DefaultTreeOperationContainer(); |
8
ee93e16d5a3f
implement unconvert and convert method in DefaultTreeOperationLog class
one
parents:
7
diff
changeset
|
88 container.unconvert(treeOp); |
7 | 89 Value v = msgpack.unconvert(container); |
90 list.add(v); | |
91 } | |
92 Value listValue = msgpack.unconvert(list); | |
93 logValue = listValue; | |
94 } | |
95 | |
96 public DefaultTreeOperationLog convert() throws IOException { | |
62 | 97 MessagePack msgpack = SingletonMessage.getInstance(); |
7 | 98 msgpack.register(List.class, new ListTemplate(ValueTemplate.getInstance())); |
99 List<Value> listValue = msgpack.convert(logValue, List.class); | |
100 List<TreeOperation> logList = new LinkedList<TreeOperation>(); | |
101 for(Value v: listValue) { | |
102 DefaultTreeOperationContainer container = msgpack.convert(v, DefaultTreeOperationContainer.class); | |
103 logList.add(container.convert()); | |
104 } | |
105 DefaultTreeOperationLog log = new DefaultTreeOperationLog(logList, logList.size()); | |
106 return log; | |
107 } | |
108 | |
52 | 109 public String getHashLogString() { |
56 | 110 return treeName + revision + updaterName; |
52 | 111 } |
112 | |
7 | 113 |
114 } |