Mercurial > hg > Database > Alice
comparison src/alice/datasegment/RemoteDataSegmentManager.java @ 14:e3f1b21718b0
implements RemoteDataSegment
author | kazz <kazz@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Sun, 15 Jan 2012 00:56:25 +0900 |
parents | src/alice/datasegment/RemoteDataSegment.java@30f97d776a3e |
children | 72dd27d952b0 |
comparison
equal
deleted
inserted
replaced
13:30f97d776a3e | 14:e3f1b21718b0 |
---|---|
1 package alice.datasegment; | |
2 | |
3 import org.msgpack.type.Value; | |
4 | |
5 import alice.codesegment.CodeSegment; | |
6 import alice.daemon.Connection; | |
7 import alice.daemon.IncomingTcpConnection; | |
8 import alice.daemon.OutboundTcpConnection; | |
9 | |
10 public class RemoteDataSegmentManager extends DataSegmentManager { | |
11 | |
12 Connection connection; | |
13 | |
14 public RemoteDataSegmentManager(Connection connection) { | |
15 this.connection = connection; | |
16 new IncomingTcpConnection(connection, this).start(); | |
17 new OutboundTcpConnection(connection).start(); | |
18 new Thread(replyThread).start(); | |
19 } | |
20 | |
21 @Override | |
22 public void put(String key, Value val) { | |
23 connection.sendCommand(new Command(CommandType.PUT, null, key, val, 0, 0, null, null)); | |
24 } | |
25 | |
26 @Override | |
27 public void update(String key, Value val) { | |
28 connection.sendCommand(new Command(CommandType.UPDATE, null, key, val, 0, 0, null, null)); | |
29 } | |
30 | |
31 @Override | |
32 public void take(String argKey, String key, int index, CodeSegment cs) { | |
33 int seq = this.seq.getAndIncrement(); | |
34 Command cmd = new Command(CommandType.TAKE, argKey, key, null, index, seq, replyQueue, cs); | |
35 seqHash.put(seq, cmd); | |
36 connection.sendCommand(cmd); | |
37 } | |
38 | |
39 @Override | |
40 public void peek(String argKey, String key, int index, CodeSegment cs) { | |
41 int seq = this.seq.getAndIncrement(); | |
42 Command cmd = new Command(CommandType.PEEK, argKey, key, null, index, seq, replyQueue, cs); | |
43 seqHash.put(seq, cmd); | |
44 connection.sendCommand(cmd); | |
45 } | |
46 | |
47 @Override | |
48 public void remove(String key) { | |
49 connection.sendCommand(new Command(CommandType.REMOVE, null, key, null, 0, 0, null, null)); | |
50 } | |
51 | |
52 } |