Mercurial > hg > Members > nobuyasu > jungle-network
annotate src/main/java/alice/jungle/persistent/AliceJournal.java @ 135:2e8034524259
Added NetworkJournal and SingletonMessageFromAlice class
author | Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Sun, 12 Jan 2014 06:18:37 +0900 |
parents | 895ab2907db3 |
children |
rev | line source |
---|---|
105 | 1 package alice.jungle.persistent; |
31 | 2 |
135
2e8034524259
Added NetworkJournal and SingletonMessageFromAlice class
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
116
diff
changeset
|
3 import java.io.File; |
2e8034524259
Added NetworkJournal and SingletonMessageFromAlice class
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
116
diff
changeset
|
4 import java.io.FileNotFoundException; |
116 | 5 import java.util.Iterator; |
6 | |
17 | 7 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.ChangeList; |
8 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.ChangeListReader; | |
9 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.ChangeListWriter; | |
10 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.Result; | |
11 | |
135
2e8034524259
Added NetworkJournal and SingletonMessageFromAlice class
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
116
diff
changeset
|
12 public class AliceJournal implements NetworkJournal { |
17 | 13 |
14 private static final AliceChangeListWriter ALICE_WRITER = new AliceChangeListWriter(); | |
15 private static final AliceChangeListReader ALICE_READER = new AliceChangeListReader(); | |
16 @Override | |
17 public ChangeListReader getReader() { | |
18 return ALICE_READER; | |
19 } | |
20 @Override | |
21 public ChangeListWriter getWriter() { | |
22 return ALICE_WRITER; | |
23 } | |
24 | |
25 private static class AliceChangeListWriter implements ChangeListWriter | |
26 { | |
27 @Override | |
28 public Result write(ChangeList _operations) | |
29 { | |
63 | 30 /* |
17 | 31 for(TreeOperation op : _operations){ |
32 NodePath p = op.getNodePath(); | |
33 NodeOperation nodeOp = op.getNodeOperation(); | |
34 Command c = nodeOp.getCommand(); | |
35 String args = ""; | |
36 switch(c){ | |
37 case PUT_ATTRIBUTE: | |
38 String key = nodeOp.getKey(); | |
39 ByteBuffer value = nodeOp.getValue(); | |
40 if(value.limit() < 100){ | |
41 args = String.format("key:%s,value:%s",key,new String(value.array())); | |
42 }else{ | |
43 args = String.format("key:%s,value:%d",key,value.limit()); | |
44 } | |
45 break; | |
46 case DELETE_ATTRIBUTE: | |
47 args = String.format("key:%s",nodeOp.getKey()); | |
48 break; | |
49 case APPEND_CHILD: | |
50 args = String.format("pos:%d",nodeOp.getPosition()); | |
51 break; | |
52 case DELETE_CHILD: | |
53 args = String.format("pos:%d",nodeOp.getPosition()); | |
54 break; | |
55 } | |
56 System.out.println(String.format("[%s:%s:%s]",c,p,args)); | |
57 } | |
63 | 58 */ |
17 | 59 return Result.SUCCESS; |
60 } | |
61 } | |
62 | |
63 private static class AliceChangeListReader implements ChangeListReader | |
64 { | |
65 @Override | |
66 public ChangeListReader newReader() | |
67 { | |
68 return this; | |
69 } | |
70 | |
71 @Override | |
72 public ChangeList read() | |
73 { | |
74 return null; | |
75 } | |
116 | 76 |
77 @Override | |
78 public Iterator<ChangeList> iterator() { | |
79 return null; | |
80 } | |
81 | |
17 | 82 } |
135
2e8034524259
Added NetworkJournal and SingletonMessageFromAlice class
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
116
diff
changeset
|
83 |
2e8034524259
Added NetworkJournal and SingletonMessageFromAlice class
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
116
diff
changeset
|
84 @Override |
2e8034524259
Added NetworkJournal and SingletonMessageFromAlice class
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
116
diff
changeset
|
85 public void setInputFile(File file) throws FileNotFoundException { |
2e8034524259
Added NetworkJournal and SingletonMessageFromAlice class
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
116
diff
changeset
|
86 |
2e8034524259
Added NetworkJournal and SingletonMessageFromAlice class
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
116
diff
changeset
|
87 } |
2e8034524259
Added NetworkJournal and SingletonMessageFromAlice class
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
116
diff
changeset
|
88 @Override |
2e8034524259
Added NetworkJournal and SingletonMessageFromAlice class
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
116
diff
changeset
|
89 public void setOutputFile(File file) throws FileNotFoundException { |
2e8034524259
Added NetworkJournal and SingletonMessageFromAlice class
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
116
diff
changeset
|
90 |
2e8034524259
Added NetworkJournal and SingletonMessageFromAlice class
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
116
diff
changeset
|
91 } |
17 | 92 |
93 | |
94 } |