Mercurial > hg > Members > nobuyasu > jungle-network
comparison src/alice/jungle/persistence/NetworkJournal.java @ 85:e641f559559c
Added some files for persistent
author | one |
---|---|
date | Mon, 28 Oct 2013 17:21:56 +0900 |
parents | 82d1d3dac7bc |
children | f142dd4abc74 |
comparison
equal
deleted
inserted
replaced
84:82d1d3dac7bc | 85:e641f559559c |
---|---|
17 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.ChangeList; | 17 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.ChangeList; |
18 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.ChangeListReader; | 18 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.ChangeListReader; |
19 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.ChangeListWriter; | 19 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.ChangeListWriter; |
20 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.Journal; | 20 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.Journal; |
21 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.Result; | 21 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.Result; |
22 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.ChangeSet; | |
23 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.TreeOperation; | 22 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.TreeOperation; |
24 | 23 |
25 public class NetworkJournal implements Journal { | 24 public class NetworkJournal implements Journal { |
26 | 25 |
27 private static final NetworkChangeListWriter WRITER = new NetworkChangeListWriter(); | 26 private static final NetworkChangeListWriter WRITER = new NetworkChangeListWriter(); |
51 public void close() throws IOException { | 50 public void close() throws IOException { |
52 out.close(); | 51 out.close(); |
53 in.close(); | 52 in.close(); |
54 } | 53 } |
55 | 54 |
55 public void setOutputFile(File file) throws FileNotFoundException { | |
56 out = new FileOutputStream(file); | |
57 } | |
58 | |
59 public void setInputFile(File file) throws FileNotFoundException { | |
60 in = new FileInputStream(file); | |
61 } | |
62 | |
56 public void setOutputStream(OutputStream _out) { | 63 public void setOutputStream(OutputStream _out) { |
57 out = _out; | 64 out = _out; |
58 } | 65 } |
59 | 66 |
60 public OutputStream getOutputStream() { | 67 public OutputStream getOutputStream() { |
81 } catch (IOException e) { | 88 } catch (IOException e) { |
82 return null; | 89 return null; |
83 } | 90 } |
84 return Result.SUCCESS; | 91 return Result.SUCCESS; |
85 } | 92 } |
86 | |
87 public Result write(ChangeSet cs) | |
88 { | |
89 NetworkTreeOperationLog log = new NetworkTreeOperationLog(cs.uuid(),cs.getChangeList()); | |
90 try { | |
91 msgpack.write(out, log); | |
92 out.flush(); | |
93 } catch (IOException e) { | |
94 return null; | |
95 } | |
96 return Result.SUCCESS; | |
97 } | |
98 | |
99 } | 93 } |
100 | 94 |
101 public static MessagePack getMessagePack() { | 95 public static MessagePack getMessagePack() { |
102 return msgpack; | 96 return msgpack; |
103 } | 97 } |
104 | 98 |
105 private static class NetworkChangeListReader implements ChangeListReader | 99 private static class NetworkChangeListReader implements ChangeListReader |
106 { | 100 { |
107 | |
108 | |
109 @Override | 101 @Override |
110 public ChangeListReader newReader() | 102 public ChangeListReader newReader() |
111 { | 103 { |
112 return this; | 104 return this; |
113 } | 105 } |