Mercurial > hg > Database > Alice
annotate src/main/java/alice/datasegment/DataSegmentManager.java @ 527:bfec2c3ff1b8 dispose
change unzip
author | Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 30 Apr 2015 18:14:02 +0900 |
parents | 928907206d21 |
children | b3c9554ccb1b |
rev | line source |
---|---|
345 | 1 package alice.datasegment; |
2 | |
3 import java.util.concurrent.ConcurrentHashMap; | |
4 import java.util.concurrent.LinkedBlockingQueue; | |
5 import java.util.concurrent.atomic.AtomicInteger; | |
6 | |
7 import org.apache.log4j.Logger; | |
8 | |
9 import alice.codesegment.CodeSegment; | |
10 | |
11 public abstract class DataSegmentManager { | |
419 | 12 |
13 protected ConcurrentHashMap<Integer, Command> seqHash = new ConcurrentHashMap<Integer, Command>(); | |
14 protected LinkedBlockingQueue<Command> replyQueue = new LinkedBlockingQueue<Command>(); | |
15 protected AtomicInteger seq = new AtomicInteger(1); // waiting for PUT or UPDATE at unique sequence number | |
16 // but it doesn't need for Local | |
17 | |
18 protected Runnable replyThread = new Runnable() { | |
19 Logger logger = Logger.getLogger("reply"); | |
20 @Override | |
523
145c425db88d
add CompressedLDSM
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
503
diff
changeset
|
21 public void run() {//SEDAのREPLYスレッドのなごり。消してもいい。 |
419 | 22 while (true) { |
23 try { | |
24 Command reply = replyQueue.take(); | |
25 Command cmd = getAndRemoveCmd(reply.seq); | |
26 if (cmd == null) { | |
27 logger.warn("conflict sequence number"); | |
28 continue; | |
29 } | |
30 cmd.cs.ids.reply(cmd.receiver, reply); | |
31 if (logger.isDebugEnabled()) | |
32 logger.debug(reply.getCommandString() + " " + cmd.getCommandString()); | |
33 } catch (InterruptedException e) { | |
34 e.printStackTrace(); | |
35 } | |
36 } | |
37 } | |
38 | |
39 }; | |
345 | 40 |
419 | 41 public Command getAndRemoveCmd(int index){ |
42 return seqHash.remove(index); | |
43 } | |
44 | |
45 public void addReplyCommand(Command cmd) { | |
46 try { | |
47 replyQueue.put(cmd); | |
48 } catch (InterruptedException e) { | |
49 e.printStackTrace(); | |
50 } | |
51 } | |
52 | |
523
145c425db88d
add CompressedLDSM
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
503
diff
changeset
|
53 //各コマンドの抽象クラス |
527 | 54 public abstract void put(String key, ReceiveData rData, SendOption option); |
55 public abstract void update(String key, ReceiveData rData, SendOption option); | |
56 public abstract void peek(Receiver receiver, CodeSegment cs, SendOption option); | |
57 public abstract void take(Receiver receiver, CodeSegment cs, SendOption option); | |
526
928907206d21
remove CompressedRDSM & CompressedLDSM class
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
523
diff
changeset
|
58 |
419 | 59 public abstract void remove(String key); |
60 public abstract void shutdown(); | |
61 public abstract void close(); | |
62 public abstract void finish(); | |
63 | |
64 public abstract void ping(String returnKey); | |
65 public abstract void response(String returnKey); | |
496 | 66 |
483 | 67 public abstract void setSendError(boolean b); |
419 | 68 |
345 | 69 } |