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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11
2ea5acb0ed16 add OutputDataSegment
one
parents:
diff changeset
1 package alice.codesegment;
2ea5acb0ed16 add OutputDataSegment
one
parents:
diff changeset
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
2ea5acb0ed16 add OutputDataSegment
one
parents:
diff changeset
6 import org.msgpack.type.Value;
30
b5a21baf0b07 implements RingTopology
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 11
diff changeset
7 import org.msgpack.type.ValueFactory;
11
2ea5acb0ed16 add OutputDataSegment
one
parents:
diff changeset
8
2ea5acb0ed16 add OutputDataSegment
one
parents:
diff changeset
9 import alice.datasegment.DataSegment;
2ea5acb0ed16 add OutputDataSegment
one
parents:
diff changeset
10
2ea5acb0ed16 add OutputDataSegment
one
parents:
diff changeset
11 public class OutputDataSegment {
2ea5acb0ed16 add OutputDataSegment
one
parents:
diff changeset
12
39
3155337e754e add logger
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 34
diff changeset
13 CodeSegment cs;
3155337e754e add logger
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 34
diff changeset
14
3155337e754e add logger
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 34
diff changeset
15 public OutputDataSegment(CodeSegment codeSegment) {
3155337e754e add logger
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 34
diff changeset
16 this.cs = codeSegment;
3155337e754e add logger
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 34
diff changeset
17 }
3155337e754e add logger
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 34
diff changeset
18
11
2ea5acb0ed16 add OutputDataSegment
one
parents:
diff changeset
19 public void put(String managerKey, String key, Value val) {
40
20616fe4d28a add log viewer
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 39
diff changeset
20 DataSegment.get(managerKey).put(key, val, cs);
11
2ea5acb0ed16 add OutputDataSegment
one
parents:
diff changeset
21 }
2ea5acb0ed16 add OutputDataSegment
one
parents:
diff changeset
22
2ea5acb0ed16 add OutputDataSegment
one
parents:
diff changeset
23 public void update(String managerKey, String key, Value val) {
40
20616fe4d28a add log viewer
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 39
diff changeset
24 DataSegment.get(managerKey).update(key, val, cs);
11
2ea5acb0ed16 add OutputDataSegment
one
parents:
diff changeset
25 }
2ea5acb0ed16 add OutputDataSegment
one
parents:
diff changeset
26
30
b5a21baf0b07 implements RingTopology
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 11
diff changeset
27 public void put(String managerKey, String key, String val) {
40
20616fe4d28a add log viewer
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 39
diff changeset
28 DataSegment.get(managerKey).put(key, ValueFactory.createRawValue(val), cs);
30
b5a21baf0b07 implements RingTopology
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 11
diff changeset
29 }
b5a21baf0b07 implements RingTopology
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 11
diff changeset
30
b5a21baf0b07 implements RingTopology
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 11
diff changeset
31 public void update(String managerKey, String key, String val) {
40
20616fe4d28a add log viewer
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 39
diff changeset
32 DataSegment.get(managerKey).update(key, ValueFactory.createRawValue(val), cs);
30
b5a21baf0b07 implements RingTopology
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 11
diff changeset
33 }
b5a21baf0b07 implements RingTopology
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 11
diff changeset
34
60
a76e603c43a0 add ring relay size
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 41
diff changeset
35 public void put(String managerKey, String key, byte[] val) {
66
3c5c567c47d7 logger off for experiment
kazz
parents: 60
diff changeset
36 DataSegment.get(managerKey).put(key, ValueFactory.createRawValue(val, true), cs);
60
a76e603c43a0 add ring relay size
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 41
diff changeset
37 }
a76e603c43a0 add ring relay size
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 41
diff changeset
38
a76e603c43a0 add ring relay size
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 41
diff changeset
39 public void update(String managerKey, String key, byte[] val) {
66
3c5c567c47d7 logger off for experiment
kazz
parents: 60
diff changeset
40 DataSegment.get(managerKey).update(key, ValueFactory.createRawValue(val, true), cs);
60
a76e603c43a0 add ring relay size
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 41
diff changeset
41 }
a76e603c43a0 add ring relay size
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 41
diff changeset
42
30
b5a21baf0b07 implements RingTopology
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 11
diff changeset
43 public void put(String managerKey, String key, int val) {
40
20616fe4d28a add log viewer
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 39
diff changeset
44 DataSegment.get(managerKey).put(key, ValueFactory.createIntegerValue(val), cs);
30
b5a21baf0b07 implements RingTopology
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 11
diff changeset
45 }
b5a21baf0b07 implements RingTopology
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 11
diff changeset
46
b5a21baf0b07 implements RingTopology
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 11
diff changeset
47 public void update(String managerKey, String key, int val) {
40
20616fe4d28a add log viewer
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 39
diff changeset
48 DataSegment.get(managerKey).update(key, ValueFactory.createIntegerValue(val), cs);
30
b5a21baf0b07 implements RingTopology
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 11
diff changeset
49 }
b5a21baf0b07 implements RingTopology
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 11
diff changeset
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
20616fe4d28a add log viewer
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 39
diff changeset
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
20616fe4d28a add log viewer
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 39
diff changeset
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
b5a21baf0b07 implements RingTopology
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 11
diff changeset
75 public void finish(String managerKey) {
b5a21baf0b07 implements RingTopology
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 11
diff changeset
76 DataSegment.get(managerKey).finish();
b5a21baf0b07 implements RingTopology
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 11
diff changeset
77 }
b5a21baf0b07 implements RingTopology
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 11
diff changeset
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
f9334781344a add close api
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 40
diff changeset
85 public void close(String managerKey) {
f9334781344a add close api
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 40
diff changeset
86 DataSegment.get(managerKey).close();
f9334781344a add close api
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 40
diff changeset
87 }
30
b5a21baf0b07 implements RingTopology
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 11
diff changeset
88
11
2ea5acb0ed16 add OutputDataSegment
one
parents:
diff changeset
89 }