Mercurial > hg > Members > tatsuki > Alice
view src/alice/datasegment/DataSegmentManager.java @ 28:98ab26e09a98
Configuration Manager work and implements reverseKey
author | kazz <kazz@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 17 Jan 2012 08:41:34 +0900 |
parents | 72dd27d952b0 |
children | b5a21baf0b07 |
line wrap: on
line source
package alice.datasegment; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.atomic.AtomicInteger; import org.msgpack.type.Value; import alice.codesegment.CodeSegment; public abstract class DataSegmentManager { protected ConcurrentHashMap<String, DataSegmentKey> dataSegments = new ConcurrentHashMap<String, DataSegmentKey>(); protected ConcurrentHashMap<Integer, Command> seqHash = new ConcurrentHashMap<Integer, Command>(); public LinkedBlockingQueue<Command> replyQueue = new LinkedBlockingQueue<Command>(); protected AtomicInteger seq = new AtomicInteger(1); protected Runnable replyThread = new Runnable() { @Override public void run() { while (true) { try { Command reply = replyQueue.take(); Command cmd = seqHash.get(reply.seq); cmd.cs.ids.reply(cmd.receiver, new DataSegmentValue(reply.index, reply.val, reply.reverseKey)); } catch (InterruptedException e) { e.printStackTrace(); } } } }; public abstract void put(String key, Value val); public abstract void update(String key, Value val); public void take(DataSegmentReceiver receiver, String key, CodeSegment cs) { take(receiver, key, 0, cs); } public abstract void take(DataSegmentReceiver receiver, String key, int index, CodeSegment cs); public void peek(DataSegmentReceiver receiver, String key, CodeSegment cs) { peek(receiver, key, 0, cs); } public abstract void peek(DataSegmentReceiver receiver, String key, int index, CodeSegment cs); public abstract void remove(String key); }