# HG changeset patch # User kazz # Date 1329833636 -32400 # Node ID 82a1c25ca0c87e4d941ce3a5fff451c528ae4de6 # Parent 4bfd81352cfa1e0a397add6a46e404a6213f29b2 remove unused thread diff -r 4bfd81352cfa -r 82a1c25ca0c8 src/alice/datasegment/KeyCommand.java --- a/src/alice/datasegment/KeyCommand.java Tue Feb 21 22:55:17 2012 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,17 +0,0 @@ -package alice.datasegment; - -public class KeyCommand { - - DataSegmentKey key; - Command cmd; - - public KeyCommand(DataSegmentKey key, Command cmd) { - this.key = key; - this.cmd = cmd; - } - - public void runCommand() { - key.runCommand(cmd); - } - -} \ No newline at end of file diff -r 4bfd81352cfa -r 82a1c25ca0c8 src/alice/datasegment/LocalDataSegmentManager.java --- a/src/alice/datasegment/LocalDataSegmentManager.java Tue Feb 21 22:55:17 2012 +0900 +++ b/src/alice/datasegment/LocalDataSegmentManager.java Tue Feb 21 23:13:56 2012 +0900 @@ -14,7 +14,6 @@ private String reverseKey = "local"; private ConcurrentHashMap dataSegments = new ConcurrentHashMap(); - private LinkedBlockingQueue cmdQueue = new LinkedBlockingQueue(); private Logger logger = Logger.getLogger("local"); private ThreadPoolExecutor dataSegmentExecutor = new ThreadPoolExecutor(Runtime.getRuntime().availableProcessors(), // initial number of threads @@ -23,38 +22,29 @@ TimeUnit.SECONDS, new LinkedBlockingQueue()); - private Runnable keyCommandThread = new Runnable() { + public LocalDataSegmentManager() { + new Thread(replyThread, "LocalDataSegmentManager-replyCommand").start(); + } - @Override - public void run() { - while (true) { - KeyCommand keyCmd = null; - try { - keyCmd = cmdQueue.take(); - } catch (InterruptedException e) { - e.printStackTrace(); - } - keyCmd.runCommand(); - } + private class RunCommand implements Runnable { + + DataSegmentKey key; + Command cmd; + + public RunCommand(DataSegmentKey key, Command cmd) { + this.key = key; + this.cmd = cmd; } - }; - - public LocalDataSegmentManager() { - new Thread(replyThread, "LocalDataSegmentManager-replyCommand").start(); - new Thread(keyCommandThread, "LocalDataSegmentManager-runKeyCommand").start(); + @Override + public void run() { + key.runCommand(cmd); + } + } - - public void submitCommand(final DataSegmentKey key, final Command cmd) { - Runnable runCommand = new Runnable() { - - @Override - public void run() { - key.runCommand(cmd); - } - - }; - dataSegmentExecutor.execute(runCommand); + + public void submitCommand(DataSegmentKey key, Command cmd) { + dataSegmentExecutor.execute(new RunCommand(key, cmd)); } public DataSegmentKey getDataSegmentKey(String key) {