Mercurial > hg > Members > nobuyasu > jungle-network
comparison src/jungle/test/codesegment/persistence/AliceJournal.java @ 17:c767e7af4d88
add TestPutAttributeCodeSegmnet and StartJungleCodeSegment
author | one |
---|---|
date | Fri, 28 Jun 2013 12:36:07 +0900 |
parents | |
children | e968224ad0ce |
comparison
equal
deleted
inserted
replaced
16:d2436fd71c61 | 17:c767e7af4d88 |
---|---|
1 package jungle.test.codesegment.persistence; | |
2 | |
3 import java.nio.ByteBuffer; | |
4 | |
5 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.ChangeList; | |
6 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.ChangeListReader; | |
7 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.ChangeListWriter; | |
8 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.Journal; | |
9 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.Result; | |
10 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.Command; | |
11 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.NodePath; | |
12 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.NodeOperation; | |
13 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.TreeOperation; | |
14 import jungle.test.datasegment.store.operations.DefaultNodeOperationContainer; | |
15 import jungle.test.datasegment.store.operations.DefaultTreeOperationContainer; | |
16 | |
17 public class AliceJournal implements Journal { | |
18 | |
19 private static final AliceChangeListWriter ALICE_WRITER = new AliceChangeListWriter(); | |
20 private static final AliceChangeListReader ALICE_READER = new AliceChangeListReader(); | |
21 @Override | |
22 public ChangeListReader getReader() { | |
23 return ALICE_READER; | |
24 } | |
25 @Override | |
26 public ChangeListWriter getWriter() { | |
27 return ALICE_WRITER; | |
28 } | |
29 | |
30 private static class AliceChangeListWriter implements ChangeListWriter | |
31 { | |
32 @Override | |
33 public Result write(ChangeList _operations) | |
34 { | |
35 | |
36 /* | |
37 for(TreeOperation op : _operations){ | |
38 DefaultTreeOperationContainer container = new DefaultTreeOperationContainer(); | |
39 container.unconvert(op); | |
40 | |
41 cs.ods.update("local", "op", op); | |
42 | |
43 } | |
44 | |
45 */ | |
46 | |
47 | |
48 | |
49 | |
50 for(TreeOperation op : _operations){ | |
51 NodePath p = op.getNodePath(); | |
52 NodeOperation nodeOp = op.getNodeOperation(); | |
53 Command c = nodeOp.getCommand(); | |
54 String args = ""; | |
55 switch(c){ | |
56 case PUT_ATTRIBUTE: | |
57 String key = nodeOp.getKey(); | |
58 ByteBuffer value = nodeOp.getValue(); | |
59 if(value.limit() < 100){ | |
60 args = String.format("key:%s,value:%s",key,new String(value.array())); | |
61 }else{ | |
62 args = String.format("key:%s,value:%d",key,value.limit()); | |
63 } | |
64 break; | |
65 case DELETE_ATTRIBUTE: | |
66 args = String.format("key:%s",nodeOp.getKey()); | |
67 break; | |
68 case APPEND_CHILD: | |
69 args = String.format("pos:%d",nodeOp.getPosition()); | |
70 break; | |
71 case DELETE_CHILD: | |
72 args = String.format("pos:%d",nodeOp.getPosition()); | |
73 break; | |
74 } | |
75 System.out.println(String.format("[%s:%s:%s]",c,p,args)); | |
76 } | |
77 return Result.SUCCESS; | |
78 } | |
79 } | |
80 | |
81 private static class AliceChangeListReader implements ChangeListReader | |
82 { | |
83 @Override | |
84 public ChangeListReader newReader() | |
85 { | |
86 return this; | |
87 } | |
88 | |
89 @Override | |
90 public ChangeList read() | |
91 { | |
92 return null; | |
93 } | |
94 } | |
95 | |
96 | |
97 } |