diff src/alice/datasegment/RemoteDataSegmentManager.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 f54dcbebde3a
children b5a21baf0b07
line wrap: on
line diff
--- a/src/alice/datasegment/RemoteDataSegmentManager.java	Tue Jan 17 03:52:39 2012 +0900
+++ b/src/alice/datasegment/RemoteDataSegmentManager.java	Tue Jan 17 08:41:34 2012 +0900
@@ -21,18 +21,18 @@
 	@Deprecated
 	public RemoteDataSegmentManager(Connection connection) {
 		this.connection = connection;
-		new IncomingTcpConnection(connection, this).start();
+		new IncomingTcpConnection(connection, this, "").start();
 		new OutboundTcpConnection(connection).start();
 		new Thread(replyThread, "RemoteDataSegmentManager-"
 		+ connection.socket.getInetAddress().getHostName()
 		+ ":" + connection.socket.getPort()).start();
 	}
 	
-	public RemoteDataSegmentManager(String key, final String hostName, final int port) {
+	public RemoteDataSegmentManager(String connectionKey, final String reverseKey, final String hostName, final int port) {
 		connection = new Connection();
 		final RemoteDataSegmentManager manager = this;
-		new Thread(replyThread, "RemoteDataSegmentManager-" + key).start();
-		new Thread("Connect-" + key) {
+		new Thread(replyThread, "RemoteDataSegmentManager-" + connectionKey).start();
+		new Thread("Connect-" + connectionKey) {
 			public void run() {
 				boolean connect = true;
 				do {
@@ -51,7 +51,7 @@
 						}
 					}
 				} while (connect);
-				new IncomingTcpConnection(connection, manager).start();
+				new IncomingTcpConnection(connection, manager, reverseKey).start();
 				new OutboundTcpConnection(connection).start();
 			}
 		}.start();
@@ -59,18 +59,18 @@
 	
 	@Override
 	public void put(String key, Value val) {
-		connection.sendCommand(new Command(CommandType.PUT, null, key, val, 0, 0, null, null));
+		connection.sendCommand(new Command(CommandType.PUT, null, key, val, 0, 0, null, null, null));
 	}
 
 	@Override
 	public void update(String key, Value val) {
-		connection.sendCommand(new Command(CommandType.UPDATE, null, key, val, 0, 0, null, null));
+		connection.sendCommand(new Command(CommandType.UPDATE, null, key, val, 0, 0, null, null, null));
 	}
 
 	@Override
 	public void take(DataSegmentReceiver receiver, String key, int index, CodeSegment cs) {
 		int seq = this.seq.getAndIncrement();
-		Command cmd = new Command(CommandType.TAKE, receiver, key, null, index, seq, replyQueue, cs);
+		Command cmd = new Command(CommandType.TAKE, receiver, key, null, index, seq, replyQueue, cs, null);
 		seqHash.put(seq, cmd);
 		connection.sendCommand(cmd);		
 	}
@@ -78,14 +78,14 @@
 	@Override
 	public void peek(DataSegmentReceiver receiver, String key, int index, CodeSegment cs) {
 		int seq = this.seq.getAndIncrement();
-		Command cmd = new Command(CommandType.PEEK, receiver, key, null, index, seq, replyQueue, cs);
+		Command cmd = new Command(CommandType.PEEK, receiver, key, null, index, seq, replyQueue, cs, null);
 		seqHash.put(seq, cmd);
 		connection.sendCommand(cmd);
 	}
 
 	@Override
 	public void remove(String key) {
-		connection.sendCommand(new Command(CommandType.REMOVE, null, key, null, 0, 0, null, null));
+		connection.sendCommand(new Command(CommandType.REMOVE, null, key, null, 0, 0, null, null, null));
 	}
 
 }