changeset 172:82a1c25ca0c8

remove unused thread
author kazz <kazz@cr.ie.u-ryukyu.ac.jp>
date Tue, 21 Feb 2012 23:13:56 +0900
parents 4bfd81352cfa
children 409d7679cf7b
files src/alice/datasegment/KeyCommand.java src/alice/datasegment/LocalDataSegmentManager.java
diffstat 2 files changed, 19 insertions(+), 46 deletions(-) [+]
line wrap: on
line diff
--- 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
--- 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<String, DataSegmentKey> dataSegments = new ConcurrentHashMap<String, DataSegmentKey>();
-	private LinkedBlockingQueue<KeyCommand> cmdQueue = new LinkedBlockingQueue<KeyCommand>();
 	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<Runnable>());
 	
-	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) {