Mercurial > hg > Database > jungle-network
comparison src/alice/jungle/persistence/PersistentChangeListReader.java @ 86:bcaf28f8244d
Added PersistentChageList and PersistentJournalTest
author | one |
---|---|
date | Tue, 29 Oct 2013 16:52:12 +0900 |
parents | e641f559559c |
children | f3f89613c7e3 |
comparison
equal
deleted
inserted
replaced
85:e641f559559c | 86:bcaf28f8244d |
---|---|
1 package alice.jungle.persistence; | 1 package alice.jungle.persistence; |
2 | 2 |
3 import java.io.EOFException; | 3 import java.io.EOFException; |
4 import java.io.IOException; | 4 import java.io.IOException; |
5 import java.io.InputStream; | 5 import java.io.InputStream; |
6 import java.util.Iterator; | |
7 | 6 |
8 import org.msgpack.MessagePack; | 7 import org.msgpack.MessagePack; |
9 | 8 |
10 import alice.jungle.operations.NetworkTreeOperationLog; | 9 import alice.jungle.operations.NetworkTreeOperationLog; |
11 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.ChangeList; | 10 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.ChangeList; |
12 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.ChangeListReader; | 11 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.ChangeListReader; |
13 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.TreeOperation; | |
14 | 12 |
15 public class PersistentChangeListReader implements ChangeListReader { | 13 public class PersistentChangeListReader implements ChangeListReader { |
16 | 14 |
17 private static InputStream in; | 15 private static InputStream in; |
18 MessagePack msgpack = NetworkJournal.getMessagePack(); | 16 MessagePack msgpack = NetworkJournal.getMessagePack(); |
34 @Override | 32 @Override |
35 public ChangeList read() | 33 public ChangeList read() |
36 { | 34 { |
37 try { | 35 try { |
38 final NetworkTreeOperationLog readLog = msgpack.read(in, NetworkTreeOperationLog.class); | 36 final NetworkTreeOperationLog readLog = msgpack.read(in, NetworkTreeOperationLog.class); |
39 ChangeList cl = new ChangeList() { | 37 PersistentChangeList cl = new PersistentChangeList(readLog); |
40 @Override | |
41 public Iterator<TreeOperation> iterator() { | |
42 return readLog.iterator(); | |
43 } | |
44 }; | |
45 return cl; | 38 return cl; |
46 } catch (EOFException e){ | 39 } catch (EOFException e){ |
47 | 40 |
48 } catch (IOException e) { | 41 } catch (IOException e) { |
49 } | 42 } |
50 return null; | 43 return null; |
51 } | 44 } |
52 | |
53 } | 45 } |