Mercurial > hg > Database > Alice
annotate src/alice/codesegment/OutputDataSegment.java @ 76:4a2ecd0a5e8f working
refactor test code segments
author | kazz <kazz@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 29 Feb 2012 22:02:31 +0900 |
parents | 3c5c567c47d7 |
children | f84e1684c6be |
rev | line source |
---|---|
11 | 1 package alice.codesegment; |
2 | |
34
ca079a730d0b
added method to OutputDataSegment and Receiver, to convert type from Value to Class<?> without MessagePack
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
30
diff
changeset
|
3 import java.io.IOException; |
ca079a730d0b
added method to OutputDataSegment and Receiver, to convert type from Value to Class<?> without MessagePack
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
30
diff
changeset
|
4 |
ca079a730d0b
added method to OutputDataSegment and Receiver, to convert type from Value to Class<?> without MessagePack
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
30
diff
changeset
|
5 import org.msgpack.MessagePack; |
11 | 6 import org.msgpack.type.Value; |
30 | 7 import org.msgpack.type.ValueFactory; |
11 | 8 |
9 import alice.datasegment.DataSegment; | |
10 | |
11 public class OutputDataSegment { | |
12 | |
39 | 13 CodeSegment cs; |
14 | |
15 public OutputDataSegment(CodeSegment codeSegment) { | |
16 this.cs = codeSegment; | |
17 } | |
18 | |
11 | 19 public void put(String managerKey, String key, Value val) { |
40 | 20 DataSegment.get(managerKey).put(key, val, cs); |
11 | 21 } |
22 | |
23 public void update(String managerKey, String key, Value val) { | |
40 | 24 DataSegment.get(managerKey).update(key, val, cs); |
11 | 25 } |
26 | |
30 | 27 public void put(String managerKey, String key, String val) { |
40 | 28 DataSegment.get(managerKey).put(key, ValueFactory.createRawValue(val), cs); |
30 | 29 } |
30 | |
31 public void update(String managerKey, String key, String val) { | |
40 | 32 DataSegment.get(managerKey).update(key, ValueFactory.createRawValue(val), cs); |
30 | 33 } |
34 | |
60 | 35 public void put(String managerKey, String key, byte[] val) { |
66 | 36 DataSegment.get(managerKey).put(key, ValueFactory.createRawValue(val, true), cs); |
60 | 37 } |
38 | |
39 public void update(String managerKey, String key, byte[] val) { | |
66 | 40 DataSegment.get(managerKey).update(key, ValueFactory.createRawValue(val, true), cs); |
60 | 41 } |
42 | |
30 | 43 public void put(String managerKey, String key, int val) { |
40 | 44 DataSegment.get(managerKey).put(key, ValueFactory.createIntegerValue(val), cs); |
30 | 45 } |
46 | |
47 public void update(String managerKey, String key, int val) { | |
40 | 48 DataSegment.get(managerKey).update(key, ValueFactory.createIntegerValue(val), cs); |
30 | 49 } |
50 | |
34
ca079a730d0b
added method to OutputDataSegment and Receiver, to convert type from Value to Class<?> without MessagePack
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
30
diff
changeset
|
51 public <T> void put(String managerKey, String key, T val) { |
ca079a730d0b
added method to OutputDataSegment and Receiver, to convert type from Value to Class<?> without MessagePack
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
30
diff
changeset
|
52 MessagePack msgpack = new MessagePack(); |
ca079a730d0b
added method to OutputDataSegment and Receiver, to convert type from Value to Class<?> without MessagePack
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
30
diff
changeset
|
53 try { |
40 | 54 DataSegment.get(managerKey).put(key, msgpack.unconvert(val), cs); |
34
ca079a730d0b
added method to OutputDataSegment and Receiver, to convert type from Value to Class<?> without MessagePack
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
30
diff
changeset
|
55 } catch (IOException e) { |
ca079a730d0b
added method to OutputDataSegment and Receiver, to convert type from Value to Class<?> without MessagePack
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
30
diff
changeset
|
56 e.printStackTrace(); |
ca079a730d0b
added method to OutputDataSegment and Receiver, to convert type from Value to Class<?> without MessagePack
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
30
diff
changeset
|
57 } |
ca079a730d0b
added method to OutputDataSegment and Receiver, to convert type from Value to Class<?> without MessagePack
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
30
diff
changeset
|
58 } |
ca079a730d0b
added method to OutputDataSegment and Receiver, to convert type from Value to Class<?> without MessagePack
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
30
diff
changeset
|
59 |
ca079a730d0b
added method to OutputDataSegment and Receiver, to convert type from Value to Class<?> without MessagePack
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
30
diff
changeset
|
60 public <T> void update(String managerKey, String key, T val) { |
ca079a730d0b
added method to OutputDataSegment and Receiver, to convert type from Value to Class<?> without MessagePack
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
30
diff
changeset
|
61 MessagePack msgpack = new MessagePack(); |
ca079a730d0b
added method to OutputDataSegment and Receiver, to convert type from Value to Class<?> without MessagePack
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
30
diff
changeset
|
62 try { |
40 | 63 DataSegment.get(managerKey).update(key, msgpack.unconvert(val), cs); |
34
ca079a730d0b
added method to OutputDataSegment and Receiver, to convert type from Value to Class<?> without MessagePack
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
30
diff
changeset
|
64 } catch (IOException e) { |
ca079a730d0b
added method to OutputDataSegment and Receiver, to convert type from Value to Class<?> without MessagePack
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
30
diff
changeset
|
65 e.printStackTrace(); |
ca079a730d0b
added method to OutputDataSegment and Receiver, to convert type from Value to Class<?> without MessagePack
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
30
diff
changeset
|
66 } |
ca079a730d0b
added method to OutputDataSegment and Receiver, to convert type from Value to Class<?> without MessagePack
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
30
diff
changeset
|
67 } |
ca079a730d0b
added method to OutputDataSegment and Receiver, to convert type from Value to Class<?> without MessagePack
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
30
diff
changeset
|
68 |
76
4a2ecd0a5e8f
refactor test code segments
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
69 /** |
4a2ecd0a5e8f
refactor test code segments
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
70 * kill the Alice process after send other messages. |
4a2ecd0a5e8f
refactor test code segments
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
71 * |
4a2ecd0a5e8f
refactor test code segments
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
72 * @param managerKey |
4a2ecd0a5e8f
refactor test code segments
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
73 */ |
4a2ecd0a5e8f
refactor test code segments
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
74 |
30 | 75 public void finish(String managerKey) { |
76 DataSegment.get(managerKey).finish(); | |
77 } | |
78 | |
76
4a2ecd0a5e8f
refactor test code segments
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
79 /** |
4a2ecd0a5e8f
refactor test code segments
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
80 * close socket for RemoteDataSegment after send other messages. |
4a2ecd0a5e8f
refactor test code segments
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
81 * |
4a2ecd0a5e8f
refactor test code segments
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
82 * @param managerKey |
4a2ecd0a5e8f
refactor test code segments
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
83 */ |
4a2ecd0a5e8f
refactor test code segments
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
66
diff
changeset
|
84 |
41 | 85 public void close(String managerKey) { |
86 DataSegment.get(managerKey).close(); | |
87 } | |
30 | 88 |
11 | 89 } |