comparison src/alice/jungle/datasegment/store/operations/DefaultTreeOperationLogContainer.java @ 34:bf696a6334b2

add LogUpdateCodeSegment
author one
date Tue, 02 Jul 2013 11:52:32 +0900
parents afccf06c4063
children 1255ae20d52e
comparison
equal deleted inserted replaced
33:afccf06c4063 34:bf696a6334b2
23 23
24 @Message 24 @Message
25 public class DefaultTreeOperationLogContainer { 25 public class DefaultTreeOperationLogContainer {
26 26
27 Value logValue; 27 Value logValue;
28 String treeName;
29 String uuid;
28 30
29 public static void main(String[] args) throws IOException { 31 public static void main(String[] args) throws IOException {
30 String key = "hoge"; 32 String key = "hoge";
31 ByteBuffer b = ByteBuffer.wrap("messagepack value".getBytes()); 33 ByteBuffer b = ByteBuffer.wrap("messagepack value".getBytes());
32 PutAttributeOperation putOp = new PutAttributeOperation(key, b); 34 PutAttributeOperation putOp = new PutAttributeOperation(key, b);
39 list.add(op); 41 list.add(op);
40 DefaultTreeOperationLog log = new DefaultTreeOperationLog(list, list.size()); 42 DefaultTreeOperationLog log = new DefaultTreeOperationLog(list, list.size());
41 43
42 DefaultTreeOperationLogContainer logContainer = new DefaultTreeOperationLogContainer(); 44 DefaultTreeOperationLogContainer logContainer = new DefaultTreeOperationLogContainer();
43 logContainer.unconvert(log); 45 logContainer.unconvert(log);
46 logContainer.setUUID("uuid");
47 logContainer.setTreeName("treeName");
44 48
45 MessagePack msgpack = new MessagePack(); 49 MessagePack msgpack = new MessagePack();
46 Value logContainerValue = msgpack.unconvert(logContainer); 50 Value logContainerValue = msgpack.unconvert(logContainer);
47 DefaultTreeOperationLogContainer convertedLogContainer = msgpack.convert(logContainerValue, 51 DefaultTreeOperationLogContainer convertedLogContainer = msgpack.convert(logContainerValue,
48 DefaultTreeOperationLogContainer.class); 52 DefaultTreeOperationLogContainer.class);
49 53
50 TreeOperationLog convertedLog = convertedLogContainer.convert(); 54 TreeOperationLog convertedLog = convertedLogContainer.convert();
55 System.out.println("uuid = "+ convertedLogContainer.getUUID());
56 System.out.println("treeName = "+ convertedLogContainer.getTreeName());
51 for (TreeOperation treeOp : convertedLog) { 57 for (TreeOperation treeOp : convertedLog) {
52 NodePath path = treeOp.getNodePath(); 58 NodePath path = treeOp.getNodePath();
53 NodeOperation nodeOp = treeOp.getNodeOperation(); 59 NodeOperation nodeOp = treeOp.getNodeOperation();
54 Command c = nodeOp.getCommand(); 60 Command c = nodeOp.getCommand();
55 String str = ""; 61 String str = "";
78 for (int i: path ) { 84 for (int i: path ) {
79 System.out.println(i); 85 System.out.println(i);
80 } 86 }
81 87
82 } 88 }
83
84
85 } 89 }
86 90
87 public DefaultTreeOperationLogContainer() { 91 public DefaultTreeOperationLogContainer() {
88 92 logValue = null;
93 treeName = "";
94 uuid = "";
95 }
96
97 public void setTreeName(String _treeName) {
98 treeName = _treeName;
99 }
100
101 public void setUUID(String _uuid) {
102 uuid = _uuid;
103 }
104
105 public String getUUID() {
106 return uuid;
107 }
108
109 public String getTreeName() {
110 return treeName;
89 } 111 }
90 112
91 public void unconvert(Iterable<TreeOperation> _log) throws IOException { 113 public void unconvert(Iterable<TreeOperation> _log) throws IOException {
92 MessagePack msgpack = new MessagePack(); 114 MessagePack msgpack = new MessagePack();
93 List<Value> list = new LinkedList<Value>(); 115 List<Value> list = new LinkedList<Value>();