annotate src/alice/codesegment/OutputDataSegment.java @ 41:f9334781344a

add close api
author kazz <kazz@cr.ie.u-ryukyu.ac.jp>
date Thu, 02 Feb 2012 10:48:39 +0900
parents 20616fe4d28a
children a76e603c43a0
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
b5a21baf0b07 implements RingTopology
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 11
diff changeset
35 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
36 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
37 }
b5a21baf0b07 implements RingTopology
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 11
diff changeset
38
b5a21baf0b07 implements RingTopology
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 11
diff changeset
39 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
40 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
41 }
b5a21baf0b07 implements RingTopology
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 11
diff changeset
42
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
43 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
44 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
45 try {
40
20616fe4d28a add log viewer
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 39
diff changeset
46 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
47 } 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
48 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
49 }
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
50 }
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
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 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
53 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
54 try {
40
20616fe4d28a add log viewer
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 39
diff changeset
55 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
56 } 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
57 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
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
30
b5a21baf0b07 implements RingTopology
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 11
diff changeset
61 public void finish(String managerKey) {
b5a21baf0b07 implements RingTopology
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 11
diff changeset
62 DataSegment.get(managerKey).finish();
b5a21baf0b07 implements RingTopology
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 11
diff changeset
63 }
b5a21baf0b07 implements RingTopology
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 11
diff changeset
64
41
f9334781344a add close api
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 40
diff changeset
65 public void close(String managerKey) {
f9334781344a add close api
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 40
diff changeset
66 DataSegment.get(managerKey).close();
f9334781344a add close api
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 40
diff changeset
67 }
30
b5a21baf0b07 implements RingTopology
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 11
diff changeset
68
11
2ea5acb0ed16 add OutputDataSegment
one
parents:
diff changeset
69 }