comparison src/alice/jungle/datasegment/store/container/DefaultTreeOperationLogContainer.java @ 75:87ec5dd0dc27

Rename from alice.jungle.datasegment.store.operation to alice.jungle.datasegment.store.container
author one
date Tue, 15 Oct 2013 14:43:29 +0900
parents src/alice/jungle/datasegment/store/operations/DefaultTreeOperationLogContainer.java@89e39301ccaa
children 2c7b3f2b2ee1
comparison
equal deleted inserted replaced
74:19e278488b42 75:87ec5dd0dc27
1 package alice.jungle.datasegment.store.container;
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
19 import alice.codesegment.SingletonMessage;
20
21 @Message
22 public class DefaultTreeOperationLogContainer {
23
24 Value logValue;
25 String treeName;
26 String uuid;
27 String updaterName;
28 String revision;
29 int position;
30 long timestamp;
31
32 public DefaultTreeOperationLogContainer() {
33 logValue = null;
34 treeName = "";
35 uuid = "";
36 updaterName = "";
37 revision = "";
38 position = 0;
39 timestamp = Long.MAX_VALUE;
40 }
41
42 public void setTreeName(String _treeName) {
43 treeName = _treeName;
44 }
45
46 public String getTreeName() {
47 return treeName;
48 }
49
50 public void setUUID(String _uuid) {
51 uuid = _uuid;
52 }
53
54 public String getUUID() {
55 return uuid;
56 }
57
58 public void setUpdaterName(String _updaterName) {
59 updaterName = _updaterName;
60 }
61
62 public String getServerName() {
63 return updaterName;
64 }
65
66 public void setRevision(String _revision) {
67 revision = _revision;
68 }
69
70 public String getRevision() {
71 return revision;
72 }
73
74 public void setPosition(int p) {
75 position = p;
76 }
77
78 public int getPosition() {
79 return position;
80 }
81
82 public void setTimeStamp(long t) {
83 timestamp = t;
84 }
85
86 public long getTimeStamp() {
87 return timestamp;
88 }
89
90 public void unconvert(Iterable<TreeOperation> _log) throws IOException {
91 MessagePack msgpack = SingletonMessage.getInstance();
92 List<Value> list = new LinkedList<Value>();
93 for(TreeOperation op : _log) {
94 NodeOperation nOp = op.getNodeOperation();
95 NodePath nodePath = op.getNodePath();
96 DefaultTreeOperation treeOp = new DefaultTreeOperation(nodePath, nOp);
97 DefaultTreeOperationContainer container = new DefaultTreeOperationContainer();
98 container.unconvert(treeOp);
99 Value v = msgpack.unconvert(container);
100 list.add(v);
101 }
102 Value listValue = msgpack.unconvert(list);
103 logValue = listValue;
104 }
105
106 public DefaultTreeOperationLog convert() throws IOException {
107 MessagePack msgpack = SingletonMessage.getInstance();
108 msgpack.register(List.class, new ListTemplate(ValueTemplate.getInstance()));
109 List<Value> listValue = msgpack.convert(logValue, List.class);
110 List<TreeOperation> logList = new LinkedList<TreeOperation>();
111 for(Value v: listValue) {
112 DefaultTreeOperationContainer container = msgpack.convert(v, DefaultTreeOperationContainer.class);
113 logList.add(container.convert());
114 }
115 DefaultTreeOperationLog log = new DefaultTreeOperationLog(logList, logList.size());
116 return log;
117 }
118
119 public String getHashLogString() {
120 return treeName + revision + updaterName;
121 }
122
123
124 }