diff src/alice/daemon/IncomingTcpConnection.java @ 14:e3f1b21718b0

implements RemoteDataSegment
author kazz <kazz@cr.ie.u-ryukyu.ac.jp>
date Sun, 15 Jan 2012 00:56:25 +0900
parents 30f97d776a3e
children 433e601a8e28
line wrap: on
line diff
--- a/src/alice/daemon/IncomingTcpConnection.java	Fri Jan 13 19:04:59 2012 +0900
+++ b/src/alice/daemon/IncomingTcpConnection.java	Sun Jan 15 00:56:25 2012 +0900
@@ -10,15 +10,16 @@
 import alice.datasegment.CommandType;
 import alice.datasegment.DataSegment;
 import alice.datasegment.DataSegmentKey;
+import alice.datasegment.DataSegmentManager;
 import alice.datasegment.LocalDataSegmentManager;
-import alice.datasegment.SocketDataSegmentManager;
 
 public class IncomingTcpConnection extends Thread {
 	
 	public Connection connection;
-	public SocketDataSegmentManager manager;
+	public DataSegmentManager manager;
 	
-	public IncomingTcpConnection(Connection connection) {
+	public IncomingTcpConnection(Connection connection, DataSegmentManager manager) {
+		this.manager = manager;
 		this.connection = connection;
 	}
 	
@@ -45,28 +46,28 @@
 				msgBuf.rewind();
 				CommandMessage msg = msgpack.read(msgBuf, CommandMessage.class);
 				CommandType type = CommandType.getCommandTypeFromId(msg.type);
-				LocalDataSegmentManager manager = (LocalDataSegmentManager)DataSegment.get("local"); 
-				DataSegmentKey dsKey = manager.getDataSegmentKey(msg.key);
+				LocalDataSegmentManager lmanager = (LocalDataSegmentManager)DataSegment.get("local"); 
+				DataSegmentKey dsKey = lmanager.getDataSegmentKey(msg.key);
 				switch (type) {
 				case UPDATE:
-					dsKey.addCommand(new Command(type, null, msg.val, 0, 0, null, null));
+					dsKey.addCommand(new Command(type, null, null, msg.val, 0, 0, null, null));
 					break;
 				case PUT:
-					dsKey.addCommand(new Command(type, null, msg.val, 0, 0, null, null));
+					dsKey.addCommand(new Command(type, null, null, msg.val, 0, 0, null, null));
 					break;
 				case PEEK:
 					//Command(CommandType cmdType, String argKey, Value val, int index, int seq, BlockingQueue<Command> replyQueue, CodeSegment cs) {
-					dsKey.addCommand(new Command(type, null, null, msg.index, msg.seq, connection.sendQueue, null));
+					dsKey.addCommand(new Command(type, null, null, null, msg.index, msg.seq, connection.sendQueue, null));
 					break;
 				case TAKE:
-					dsKey.addCommand(new Command(type, null, null, msg.index, msg.seq, connection.sendQueue, null));
+					dsKey.addCommand(new Command(type, null, null, null, msg.index, msg.seq, connection.sendQueue, null));
 					break;	
 				case REMOVE:
-					dsKey.addCommand(new Command(type, null, null, 0, 0, null, null));
+					dsKey.addCommand(new Command(type, null, null, null, 0, 0, null, null));
 					break;
 				case REPLY:
 					try {
-						manager.replyQueue.put(new Command(type, null, msg.val, msg.index, msg.seq, null, null));
+						manager.replyQueue.put(new Command(type, null, null, msg.val, msg.index, msg.seq, null, null));
 					} catch (InterruptedException e) {
 						e.printStackTrace();
 					}