changeset 114:3b877c9a44f5

gather old packages
author kazz
date Mon, 11 Oct 2010 14:29:37 +0900
parents 4205d029584c
children 847b864b1c89
files src/fdl/multiengine/MetaEngineExecutor.java src/fdl/multiengine/StopServerEngine.java src/fdl/old/test/metaTransfer/FDLServWithSend.java src/fdl/old/test/metaTransfer/MetaProtocolEngine.java src/fdl/old/test/metaTransfer/MetaProtocolEngine_not.java src/fdl/old/test/metaTransfer/Ring/FDLServWithSend.java src/fdl/old/test/metaTransfer/Ring/MetaProtocolEngine.java src/fdl/old/test/metaTransfer/Ring/Server.java src/fdl/old/test/metaTransfer/Ring/TestSend.java src/fdl/old/test/metaTransfer/Ring/TestTransfer.java src/fdl/old/test/metaTransfer/Ring/TestTransferRing.java src/fdl/old/test/metaTransfer/Ring/TestTransferThree.java src/fdl/old/test/metaTransfer/Server.java src/fdl/old/test/metaTransfer/TestSend.java src/fdl/old/test/metaTransfer/TestTransfer.java src/fdl/old/test/transfer/ProtocolEngine.java src/fdl/old/test/transfer/Server.java src/fdl/old/test/transfer/TestSend.java src/fdl/old/test/transfer/TestTransfer.java src/fdl/old/test/transfer/cluster/FDLServWithSendMeta.java src/fdl/old/test/transfer/cluster/HostCheck.java src/fdl/old/test/transfer/cluster/MetaProtocolEngine.java src/fdl/old/test/transfer/cluster/ProtocolEngine.java src/fdl/old/test/transfer/cluster/ProtocolEngineMain.java src/fdl/old/test/transfer/cluster/Server.java src/fdl/old/test/transfer/cluster/ServerMain.java src/fdl/old/test/transfer/cluster/TestGet.java src/fdl/old/test/transfer/cluster/TestSend.java src/fdl/old/test/transfer/three/ProtocolEngine.java src/fdl/old/test/transfer/three/Server.java src/fdl/old/test/transfer/three/TestGet.java src/fdl/old/test/transfer/three/TestSend.java src/fdl/old/test/transfer/three/TestTransfer.java src/fdl/old/test/transfer/two/ProtocolEngine.java src/fdl/old/test/transfer/two/Server.java src/fdl/old/test/transfer/two/TestGet.java src/fdl/old/test/transfer/two/TestSend.java src/fdl/old/test/transfer/two/TestTransfer.java src/fdl/old/test2/CountTest.java src/fdl/old/test2/Server.java src/fdl/old/test2/TestRead.java src/fdl/old/test2/TestRing.java src/fdl/old/test2/client.java src/fdl/old/test2/nodelist src/fdl/test/debug/AcceptXMLCallback.java src/fdl/test/debug/ConfigurationManager.java src/fdl/test/debug/ConfigurationManagerEngine.java src/fdl/test/debug/ConnectionXMLBuilder.java src/fdl/test/debug/Debug.java src/fdl/test/debug/DebugProperty.java src/fdl/test/debug/DebugStartCallback.java src/fdl/test/debug/FDLindaNode.java src/fdl/test/debug/MetaProtocolEngine.java src/fdl/test/debug/NodeInfo.java src/fdl/test/debug/NodeProperty.java src/fdl/test/debug/Routing.java src/fdl/test/debug/RoutingCallback.java src/fdl/test/debug/RoutingXMLBuilder.java src/fdl/test/debug/StartCallback.java src/fdl/test/debug/TreeProperty.java src/fdl/test/debug/TupleId.java src/fdl/test/debug/XMLBuilder.java src/fdl/test/debug2/AcceptXMLCallback.java src/fdl/test/debug2/ConfigurationManager.java src/fdl/test/debug2/ConfigurationManagerEngine.java src/fdl/test/debug2/ConnectionXMLBuilder.java src/fdl/test/debug2/Debug.java src/fdl/test/debug2/DebugProperty.java src/fdl/test/debug2/DebugStartCallback.java src/fdl/test/debug2/FDLindaNode.java src/fdl/test/debug2/MetaProtocolEngine.java src/fdl/test/debug2/NodeInfo.java src/fdl/test/debug2/NodeProperty.java src/fdl/test/debug2/Routing.java src/fdl/test/debug2/RoutingCallback.java src/fdl/test/debug2/RoutingXMLBuilder.java src/fdl/test/debug2/StartCallback.java src/fdl/test/debug2/TreeProperty.java src/fdl/test/debug2/TupleId.java src/fdl/test/debug2/XMLBuilder.java src/fdl/test/metaTransfer/FDLServWithSend.java src/fdl/test/metaTransfer/MetaProtocolEngine.java src/fdl/test/metaTransfer/MetaProtocolEngine_not.java src/fdl/test/metaTransfer/Ring/FDLServWithSend.java src/fdl/test/metaTransfer/Ring/MetaProtocolEngine.java src/fdl/test/metaTransfer/Ring/Server.java src/fdl/test/metaTransfer/Ring/TestSend.java src/fdl/test/metaTransfer/Ring/TestTransfer.java src/fdl/test/metaTransfer/Ring/TestTransferRing.java src/fdl/test/metaTransfer/Ring/TestTransferThree.java src/fdl/test/metaTransfer/Server.java src/fdl/test/metaTransfer/TestSend.java src/fdl/test/metaTransfer/TestTransfer.java src/fdl/test/transfer/ProtocolEngine.java src/fdl/test/transfer/Server.java src/fdl/test/transfer/TestSend.java src/fdl/test/transfer/TestTransfer.java src/fdl/test/transfer/cluster/FDLServWithSendMeta.java src/fdl/test/transfer/cluster/HostCheck.java src/fdl/test/transfer/cluster/MetaProtocolEngine.java src/fdl/test/transfer/cluster/ProtocolEngine.java src/fdl/test/transfer/cluster/ProtocolEngineMain.java src/fdl/test/transfer/cluster/Server.java src/fdl/test/transfer/cluster/ServerMain.java src/fdl/test/transfer/cluster/TestGet.java src/fdl/test/transfer/cluster/TestSend.java src/fdl/test/transfer/three/ProtocolEngine.java src/fdl/test/transfer/three/Server.java src/fdl/test/transfer/three/TestGet.java src/fdl/test/transfer/three/TestSend.java src/fdl/test/transfer/three/TestTransfer.java src/fdl/test/transfer/two/ProtocolEngine.java src/fdl/test/transfer/two/Server.java src/fdl/test/transfer/two/TestGet.java src/fdl/test/transfer/two/TestSend.java src/fdl/test/transfer/two/TestTransfer.java src/fdl/test2/CountTest.java src/fdl/test2/Server.java src/fdl/test2/TestRead.java src/fdl/test2/TestRing.java src/fdl/test2/client.java src/fdl/test2/nodelist
diffstat 117 files changed, 2597 insertions(+), 3349 deletions(-) [+]
line wrap: on
line diff
--- a/src/fdl/multiengine/MetaEngineExecutor.java	Mon Oct 11 04:43:46 2010 +0900
+++ b/src/fdl/multiengine/MetaEngineExecutor.java	Mon Oct 11 14:29:37 2010 +0900
@@ -26,7 +26,7 @@
 		engines.add(engine);
 	}
 	
-	public void deleteMetaEngine(MetaEngine engine) {
+	public void removeMetaEngine(MetaEngine engine) {
 		engines.remove(engine);
 	}
 	
--- a/src/fdl/multiengine/StopServerEngine.java	Mon Oct 11 04:43:46 2010 +0900
+++ b/src/fdl/multiengine/StopServerEngine.java	Mon Oct 11 14:29:37 2010 +0900
@@ -17,7 +17,7 @@
 		ml.in(TupleId.STOP.id,
 				new PSXCallback() { public void callback(ByteBuffer reply) {
 					mee.running = false; }});
-		mee.deleteMetaEngine(this);
+		mee.removeMetaEngine(this);
 	}
 
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/fdl/old/test/metaTransfer/FDLServWithSend.java	Mon Oct 11 14:29:37 2010 +0900
@@ -0,0 +1,23 @@
+package fdl.old.test.metaTransfer;
+
+import java.io.IOException;
+
+import fdl.FDLindaServ;
+import fdl.MetaLinda;
+
+
+public class FDLServWithSend extends FDLindaServ {
+	int port1;
+	public FDLServWithSend(int port,int port1) throws IOException {
+		super(port);
+		this.port1 = port1;
+	}
+
+	@Override public void mainLoop() {
+		System.out.println("change mainloop");
+		MetaLinda ml = new MetaLinda(this.tupleSpace,this);
+		MetaProtocolEngine mpe = new MetaProtocolEngine(ml,"MetaEngine", port1);
+		mpe.mainLoop(ml);
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/fdl/old/test/metaTransfer/MetaProtocolEngine.java	Mon Oct 11 14:29:37 2010 +0900
@@ -0,0 +1,95 @@
+package fdl.old.test.metaTransfer;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+import fdl.MetaEngine;
+import fdl.MetaLinda;
+import fdl.PSXLinda;
+import fdl.PSXReply;
+
+public class MetaProtocolEngine implements MetaEngine {
+	private int id = 10;
+	private boolean running = true;
+	
+	private PSXLinda psx;
+	private String name;
+	MetaLinda fdl1;
+	String host = "127.0.0.1";
+	int port1;
+	private PSXLinda psx1;
+	private ByteBuffer data2 = ByteBuffer.allocate(10);
+	private int count = 1;
+
+	
+	public MetaProtocolEngine(MetaLinda ml, String string, int port1) {
+		this.name = string;
+		this.port1 = port1;
+		this.fdl1 = ml;
+	}
+
+	public void mainLoop(MetaLinda ml){
+		boolean connect = true;
+		System.out.println("MetaEngine Start");
+		while(connect){
+		try {
+			initConnect();
+			transfer();
+			connect = false;
+		} catch (IOException e) {
+			try {
+				Thread.sleep(40);
+			} catch (InterruptedException e1) {
+			}
+		}
+		}
+	}
+
+	private void initConnect(){
+		System.out.println(name);
+		boolean connectpsx = true;
+		while(connectpsx){
+		try {
+			psx = fdl1.open(host,port1);
+			connectpsx = false;
+		} catch (IOException e) {
+			try {
+				Thread.sleep(40);
+			} catch (InterruptedException e1) {
+				e1.printStackTrace();
+			}
+		}
+		}
+		System.out.println("Connect "+port1);
+		psx1 = fdl1;
+	}
+
+	private void transfer() throws IOException {
+		PSXReply in = psx.in(id);
+		System.out.println("PSXReply "+port1);
+		while (running) {
+			if(in.ready()){
+				data2 = in.getData();
+				int i = data2.getInt();
+				data2.rewind();
+				//outしたbytebufferの変更をこれ以降やっちゃいけない
+				psx1.out(id,data2);
+				
+				System.out.println("IntData0 "+port1 +i);
+				fdl1.sync(0);
+				if (count++>3) {
+					running = false;
+					break;
+				}
+				System.out.println("IntData1 "+port1 +i);
+			}
+			fdl1.sync(0);
+		}
+		assertEquals(4,count);
+	}
+
+	
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/fdl/old/test/metaTransfer/MetaProtocolEngine_not.java	Mon Oct 11 14:29:37 2010 +0900
@@ -0,0 +1,69 @@
+package fdl.old.test.metaTransfer;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+import fdl.FederatedLinda;
+import fdl.MetaEngine;
+import fdl.MetaLinda;
+import fdl.PSXLinda;
+import fdl.PSXReply;
+
+
+public class MetaProtocolEngine_not implements MetaEngine {
+	private FederatedLinda fdlmeta;
+	private ByteBuffer data = ByteBuffer.allocate(1024);
+	private int id = 10;
+	private boolean running = true;
+	
+	//ここからsend用宣言
+	private PSXLinda sendpsx,getpsx;
+	private String host = "127.0.0.1";
+	private int port;
+			
+	public MetaProtocolEngine_not(MetaLinda fdlmeta, int port) {
+		this.port = port;
+	}
+	
+	public void metaOpen(int sendport){
+		try{
+		sendpsx = fdlmeta.open(host, sendport);
+		}catch (IOException e) {
+			e.printStackTrace();
+		}
+	}
+	
+	//meta部分のデータ取得
+	public void metaTrans() {
+		try {
+			getpsx = fdlmeta.open(host, 10001);
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+		PSXReply in = getpsx.in(id);
+		while (running) {
+			System.out.println(in);
+			System.out.println(in.ready());
+		if(in.ready()) {
+			data = in.getData();
+			sendpsx.out(id, data);
+			running = false;
+			break;
+		}
+		}
+	}
+
+	
+	public void mainLoop(MetaLinda ml) {
+		System.out.println("MetaProtocolEngine Start");
+		fdlmeta = FederatedLinda.init();
+		if( port == 10002 ) {
+			metaOpen(10003);
+			metaTrans();
+			fdlmeta.sync();
+			System.out.println("MetaProtocolEngine Connect");
+		}
+
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/fdl/old/test/metaTransfer/Ring/FDLServWithSend.java	Mon Oct 11 14:29:37 2010 +0900
@@ -0,0 +1,22 @@
+package fdl.old.test.metaTransfer.Ring;
+
+import java.io.IOException;
+
+import fdl.FDLindaServ;
+import fdl.MetaLinda;
+
+public class FDLServWithSend extends FDLindaServ {
+	int port1;
+	public FDLServWithSend(int port,int port1) throws IOException {
+		super(port);
+		this.port1 = port1;
+	}
+	
+	@Override public void mainLoop() {
+		System.out.println("change mainloop");
+		MetaLinda ml = new MetaLinda(this.tupleSpace,this);
+		MetaProtocolEngine mpe = new MetaProtocolEngine(ml,"MetaEngine", port1, port1);
+		mpe.mainLoop(ml);
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/fdl/old/test/metaTransfer/Ring/MetaProtocolEngine.java	Mon Oct 11 14:29:37 2010 +0900
@@ -0,0 +1,100 @@
+package fdl.old.test.metaTransfer.Ring;
+
+//import static org.junit.Assert.assertEquals;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+import fdl.MetaEngine;
+import fdl.MetaLinda;
+import fdl.PSXLinda;
+import fdl.PSXReply;
+
+public class MetaProtocolEngine implements MetaEngine {
+	int id = 10;
+	private boolean running = true;
+	
+	private PSXLinda psx;
+	private String name;
+	MetaLinda fdl1;
+	String host = "127.0.0.1";
+	int port1;
+	private PSXLinda psx1;
+	private ByteBuffer data = ByteBuffer.allocate(10);
+//	private int count = 1;
+	int port;
+
+	
+	public MetaProtocolEngine(MetaLinda ml, String string, int port1, int port) {
+		this.name = string;
+		this.port1 = port1;
+		this.fdl1 = ml;
+		this.port = port;
+	}
+
+	public void mainLoop(MetaLinda ml){
+		boolean connect = true;
+		System.out.println("MetaEngine Start");
+		while(connect){
+		try {
+			initConnect();
+			transfer(psx, psx1);
+			connect = false;
+		} catch (IOException e) {
+			try {
+				Thread.sleep(40);
+			} catch (InterruptedException e1) {
+			}
+		}
+		}
+	}
+
+	private void initConnect() throws IOException{
+		System.out.println(name);
+		//自分
+		psx = fdl1;
+		if (port == 10001){
+			sendData();
+			}
+		//相手
+		psx1 = fdl1.open(host,port1);
+		System.out.println("Connect "+port1);
+	}
+
+	private void sendData() throws IOException{
+		boolean connectSend = true;
+		ByteBuffer send = ByteBuffer.allocate(1024);
+		send.putInt(12);
+		send.flip();
+		while(connectSend){
+		psx.out(id, send);
+		fdl1.sync(1);
+		System.out.println("Send Data 10001");
+		connectSend = false;
+		}
+	}
+	
+	private void transfer(PSXLinda getpsx, PSXLinda sendpsx) throws IOException {
+		PSXReply in = getpsx.in(id);
+		System.out.println("PSXReply "+port1);
+		while (running) {
+			if(in.ready()){
+				data = in.getData();
+				int i = data.getInt();
+				data.rewind();
+				//outしたbytebufferの変更をこれ以降やっちゃいけない
+				sendpsx.out(id,data);
+				
+				System.out.println("IntData0 "+port1 +i);
+				fdl1.sync(1);
+				running = false;
+				System.out.println("IntData1 "+port1 +i);
+				break;
+			}
+			fdl1.sync(0);
+			}
+//		assertEquals(4,count);
+	}
+
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/fdl/old/test/metaTransfer/Ring/Server.java	Mon Oct 11 14:29:37 2010 +0900
@@ -0,0 +1,39 @@
+package fdl.old.test.metaTransfer.Ring;
+
+import java.io.IOException;
+
+import fdl.FDLindaServ;
+
+public class Server extends Thread {
+	int port1;
+	int port2;
+	int set;
+	private String name;
+	
+	public Server(String string, int i, int t, int s) {
+		port1 = i;
+		port2 = t;
+		name = string;
+		set = s;
+	}
+
+	public void run(){
+		String[] args = {"-p",Integer.toString(port1)};
+		System.out.println(name);
+		switch (set){
+		case 0:
+		try {
+			FDLServWithSend send = new FDLServWithSend(port1,port2);
+			send.mainLoop();
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+		break;
+		
+		case 1:
+		FDLindaServ.main(args);
+		break;
+		}
+	}
+
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/fdl/old/test/metaTransfer/Ring/TestSend.java	Mon Oct 11 14:29:37 2010 +0900
@@ -0,0 +1,47 @@
+package fdl.old.test.metaTransfer.Ring;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+import fdl.FederatedLinda;
+import fdl.PSXLinda;
+
+public class TestSend extends Thread {
+	PSXLinda psxsend;
+	FederatedLinda fdlsend;
+	
+	public void run(){
+		int id = 10;
+		int port = 10001;
+		boolean connect = true;
+		String host = "127.0.0.1";
+		ByteBuffer send = ByteBuffer.allocate(1024);
+		send.putInt(12);
+		send.flip();
+		while(connect){
+		try {
+		sendData(id, port, host, send);
+		connect = false;
+		} catch(IOException e) {
+			try {
+				Thread.sleep(40);
+			} catch (InterruptedException e1) {
+				e1.printStackTrace();
+			}
+		}
+		
+		}
+	}
+
+	private void sendData(int id, int port, String host, ByteBuffer send) throws IOException {
+		fdlsend = FederatedLinda.init();
+
+			psxsend = fdlsend.open(host,port);
+			System.out.println("Connect Host1");
+			psxsend.out(id, send);
+			fdlsend.sync(1);
+			System.out.println("Send Data");
+
+	}
+	
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/fdl/old/test/metaTransfer/Ring/TestTransfer.java	Mon Oct 11 14:29:37 2010 +0900
@@ -0,0 +1,29 @@
+package fdl.old.test.metaTransfer.Ring;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.IOException;
+
+import org.junit.Test;
+
+public class TestTransfer {
+	@Test
+	public void testTransfer() throws IOException {
+		int port1 = 10001;
+		int port2 = 10002;
+		
+		Server server1 = new Server("Server1",port1, port2,0);
+		server1.start();
+
+		Server server2 = new Server("Server2",port2, port1,1);
+		server2.start();
+		
+		try {
+			server2.join();
+		} catch (InterruptedException e) {
+			e.printStackTrace();
+		}
+		
+		assertEquals(1,1);
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/fdl/old/test/metaTransfer/Ring/TestTransferRing.java	Mon Oct 11 14:29:37 2010 +0900
@@ -0,0 +1,40 @@
+package fdl.old.test.metaTransfer.Ring;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+public class TestTransferRing {
+	Server[] servers;
+	final int serverCount = 3;
+	final int startPort = 10001;
+	@Test
+	public void testTransfer() {
+		int port = startPort;
+		
+		servers = new Server[serverCount];
+		
+		for (int i = 0; i < serverCount; i++) {
+			servers[i] = new Server("Server"+(i+1),port+i,netporot(port+i),0);
+			servers[i].start();
+		}
+		
+//		try {
+//			servers[3].join();
+//		} catch (InterruptedException e) {
+//			e.printStackTrace();
+//		}
+		
+
+		assertEquals(1,1);
+	}
+	private int netporot(int i) {
+		i++;
+		if(i >= startPort+serverCount) {
+			return startPort;
+		}
+		
+		return i;
+	}
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/fdl/old/test/metaTransfer/Ring/TestTransferThree.java	Mon Oct 11 14:29:37 2010 +0900
@@ -0,0 +1,22 @@
+package fdl.old.test.metaTransfer.Ring;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+public class TestTransferThree {
+	@Test
+	public void testTransfer() {
+		
+		Server server1 = new Server("Server1", 10001, 10002, 0);
+		server1.start();
+		Server server2 = new Server("Server2", 10002, 10001, 0);
+		server2.start();
+//		Server server3 = new Server("Server3", 10003, 10001, 0);
+//		server3.start();
+
+		assertEquals(1,1);
+	}
+
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/fdl/old/test/metaTransfer/Server.java	Mon Oct 11 14:29:37 2010 +0900
@@ -0,0 +1,20 @@
+package fdl.old.test.metaTransfer;
+
+import fdl.FDLindaServ;
+
+public class Server extends Thread {
+	int port;
+	private String name;
+	
+	public Server(String string, int i) {
+		port = i;
+		name = string;
+	}
+
+	public void run(){
+		String[] args = {"-p",Integer.toString(port)};
+		System.out.println(name);
+		FDLindaServ.main(args);
+	}
+
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/fdl/old/test/metaTransfer/TestSend.java	Mon Oct 11 14:29:37 2010 +0900
@@ -0,0 +1,47 @@
+package fdl.old.test.metaTransfer;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+import fdl.FederatedLinda;
+import fdl.PSXLinda;
+
+public class TestSend extends Thread {
+	PSXLinda psxsend;
+	FederatedLinda fdlsend;
+	
+	public void run(){
+		int id = 10;
+		int port = 10001;
+		boolean connect = true;
+		String host = "127.0.0.1";
+		ByteBuffer send = ByteBuffer.allocate(1024);
+		send.putInt(12);
+		send.flip();
+		while(connect){
+		try {
+		sendData(id, port, host, send);
+		connect = false;
+		} catch(IOException e) {
+			try {
+				Thread.sleep(40);
+			} catch (InterruptedException e1) {
+				e1.printStackTrace();
+			}
+		}
+		
+		}
+	}
+
+	private void sendData(int id, int port, String host, ByteBuffer send) throws IOException {
+		fdlsend = FederatedLinda.init();
+
+			psxsend = fdlsend.open(host,port);
+			System.out.println("Connect Host1");
+			psxsend.out(id, send);
+			fdlsend.sync(1);
+			System.out.println("Send Data");
+
+	}
+	
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/fdl/old/test/metaTransfer/TestTransfer.java	Mon Oct 11 14:29:37 2010 +0900
@@ -0,0 +1,27 @@
+package fdl.old.test.metaTransfer;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.IOException;
+
+import org.junit.Test;
+
+public class TestTransfer {
+	@Test
+	public void testTransfer() throws IOException {
+		int port1 = 10001;
+		int port2 = 10002;
+		
+//		Server server1 = new Server("Server1",port1);
+//		server1.start();
+//
+		Server server2 = new Server("Server2",port2);
+		server2.start();
+		
+
+		FDLServWithSend send = new FDLServWithSend(port1, port2);
+		send.mainLoop();
+		
+		assertEquals(1,1);
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/fdl/old/test/transfer/ProtocolEngine.java	Mon Oct 11 14:29:37 2010 +0900
@@ -0,0 +1,74 @@
+package fdl.old.test.transfer;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+import fdl.FederatedLinda;
+import fdl.PSXLinda;
+import fdl.PSXReply;
+
+
+public class ProtocolEngine extends Thread{
+	private PSXLinda psx;
+	private String name;
+	FederatedLinda fdl1;
+	String host = "127.0.0.1";
+	int port1 = 10001;
+	int port2 = 10002;
+	private int id = 10;
+	private PSXLinda psx1;
+	private boolean running = true;
+	private ByteBuffer data2 = ByteBuffer.allocate(10);
+
+	public ProtocolEngine(String string, int port1, int port2) {
+		this.name = string;
+		this.port1 = port1;
+		this.port2 = port2;
+	}
+
+	public void run(){
+		fdl1 = FederatedLinda.init();
+		try {
+			System.out.println(name);
+			psx = fdl1.open(host,port1);
+			System.out.println("Connect Host1");
+			psx1 = fdl1.open(host,port2);
+			System.out.println("Connect Host2");
+			// Host1にデータを送信する。
+			testSend(psx);
+			// psxにデータを用意
+			transfer(psx,psx1);
+			
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+	}
+	
+	private void testSend(PSXLinda psx2) throws IOException {
+		ByteBuffer send = ByteBuffer.allocate(10);
+		send.putInt(12);
+		send.flip();
+		psx2.out(id, send);
+		psx2.sync(1);
+	}
+	
+
+	private void transfer(PSXLinda getpsx, PSXLinda sendpsx) throws IOException {
+		PSXReply in = getpsx.in(id);
+		while (running) {
+			System.out.println(in.ready());
+			if(in.ready()){
+				//psx1にデータを書き出し
+				data2 = in.getData();
+				sendpsx.out(id,data2);
+				//runningフラグをfalseする
+				running = false;
+				fdl1.sync(0);
+				break;
+			}
+			fdl1.sync();
+		}
+		
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/fdl/old/test/transfer/Server.java	Mon Oct 11 14:29:37 2010 +0900
@@ -0,0 +1,20 @@
+package fdl.old.test.transfer;
+
+import fdl.FDLindaServ;
+
+public class Server extends Thread{
+	int port;
+	private String name;
+
+	public Server(String string, int i) {
+		port = i;
+		name = string;
+	}
+
+	public void run(){
+		String[] args = {"-p",Integer.toString(port)};
+		System.out.println(name);
+		FDLindaServ.main(args);
+	}
+
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/fdl/old/test/transfer/TestSend.java	Mon Oct 11 14:29:37 2010 +0900
@@ -0,0 +1,33 @@
+package fdl.old.test.transfer;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+import fdl.FederatedLinda;
+import fdl.PSXLinda;
+
+public class TestSend extends Thread {
+	PSXLinda psxsend;
+	FederatedLinda fdlsend;
+	
+	public void run(){
+		int id = 10;
+		int port = 10001;
+		String host = "127.0.0.1";
+		ByteBuffer send = ByteBuffer.allocate(1024);
+		send.putInt(12);
+		send.flip();
+		fdlsend = FederatedLinda.init();
+		try{
+			psxsend = fdlsend.open(host,port);
+			System.out.println("Connect Host1");
+			psxsend.out(id, send);
+			fdlsend.sync();
+			System.out.println("Send Data");
+		}catch (IOException e) {
+			System.out.println("例外:" + e);
+		}
+		
+	}
+	
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/fdl/old/test/transfer/TestTransfer.java	Mon Oct 11 14:29:37 2010 +0900
@@ -0,0 +1,25 @@
+package fdl.old.test.transfer;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+public class TestTransfer {
+	@Test
+	public void testTransfer() {
+		int port1 = 10001;
+		int port2 = 10002;
+		Server server1 = new Server("Server1",port1);
+		server1.start();
+		Server server2 = new Server("Server2",port2);
+		server2.start();
+		ProtocolEngine pe = new ProtocolEngine("ProtocolEngine",port1,port2);
+		pe.start();
+		try {
+			pe.join();
+		} catch (InterruptedException e) {
+			e.printStackTrace();
+		}
+		assertEquals(1,1);
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/fdl/old/test/transfer/cluster/FDLServWithSendMeta.java	Mon Oct 11 14:29:37 2010 +0900
@@ -0,0 +1,91 @@
+package fdl.old.test.transfer.cluster;
+
+import java.io.BufferedReader;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+
+import fdl.FDLindaServ;
+import fdl.MetaLinda;
+
+
+public class FDLServWithSendMeta extends FDLindaServ {
+
+	public FDLServWithSendMeta(int port) throws IOException {
+		super(port);
+	}
+	
+	static String nextHost = null;
+	private static int localport = 10000;
+	static int chknum;
+	private static String bufstring;
+	private static int bufsize;
+	private static String txt;
+	private static int ring;
+	
+	@Override public void mainLoop() {
+		MetaLinda ml = new MetaLinda(tupleSpace, this);
+		MetaProtocolEngine mpe = new MetaProtocolEngine(ml, nextHost, chknum, bufsize, txt);
+		mpe.mainLoop(ml);
+	}
+	
+	public static void main(String[] args){
+		for (int k=0; k<args.length; ++k) {
+			if("-bufsize".equals(args[k])){
+				bufstring = args[++k];
+			} else if("-ring".equals(args[k])){
+				txt = args[++k];
+				ring = Integer.valueOf(txt);
+			} else {
+				System.err.println("引数指定の誤り:未知の引数が指定されました");
+            }
+		}
+		bufsize = Integer.parseInt(bufstring);
+		try {
+			chkhost();
+			FDLServWithSendMeta serv = new FDLServWithSendMeta(localport);
+			serv.mainLoop();
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+	}
+	
+	private static void chkhost() throws UnknownHostException{
+		String localhost = null;
+		BufferedReader br = null;
+		String hostTable[] = new String[ring+1];
+		try {
+			br = new BufferedReader(new FileReader("nodelist"));
+			int i = 0;
+			while (br.ready()) {
+				String line = br.readLine();
+				hostTable[i] = line;
+				i++;
+			}
+			localhost = InetAddress.getLocalHost().getHostName();
+			for (int j=0; j<hostTable.length; j++) {
+				if(localhost.equals(hostTable[j])){
+					nextHost = hostTable[++j];
+					if(j == ring) {
+						nextHost = hostTable[0];
+					}
+				}
+			}
+			
+			if(localhost.equals(hostTable[0])) {
+				chknum = 1;
+			}
+				
+			System.out.println("localhost:"+localhost);
+			System.out.println("nexthost:"+nextHost);
+		
+		} catch (FileNotFoundException e) {
+			e.printStackTrace();
+		} catch (IOException e){
+			e.printStackTrace();
+		}
+	}
+	
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/fdl/old/test/transfer/cluster/HostCheck.java	Mon Oct 11 14:29:37 2010 +0900
@@ -0,0 +1,64 @@
+package fdl.old.test.transfer.cluster;
+
+import java.io.BufferedReader;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.net.InetAddress;
+
+public class HostCheck {
+	private static String bufstring;
+	private static String txt;
+	private static Integer ring;
+	private static int bufsize;
+	private static String nextHost;
+	private static int chknum;
+
+	public static void main(String[] args) {
+		String localhost = null;
+		BufferedReader br = null;
+		for (int k=0; k<args.length; ++k) {
+			if("-bufsize".equals(args[k])){
+				bufstring = args[++k];
+			} else if("-ring".equals(args[k])){
+				txt = args[++k];
+				ring = Integer.valueOf(txt);
+			} else {
+	        System.err.println("引数指定の誤り:未知の引数が指定されました");
+            }
+		}
+		String hostTable[] = new String[ring+1];
+		bufsize = Integer.parseInt(bufstring);
+		try {
+			br = new BufferedReader(new FileReader("nodelist"));
+			int i = 0;
+			while (br.ready()) {
+				String line = br.readLine();
+				hostTable[i] = line;
+				i++;
+			}
+			localhost = InetAddress.getLocalHost().getHostName();
+			for (int j=0; j<hostTable.length; j++){
+				if(localhost.equals(hostTable[j])){
+				nextHost = hostTable[++j];
+				if(j == ring) {
+					nextHost = hostTable[0];
+				}
+			}
+			}
+			if(localhost.equals(hostTable[0])) {
+				chknum = 1;
+			}
+			
+			System.out.println("localhost:"+localhost);
+			System.out.println("nexthost:"+nextHost);
+
+		} catch (FileNotFoundException e) {
+			e.printStackTrace();
+		} catch (IOException e){
+			e.printStackTrace();
+		}
+		ProtocolEngine pe = new ProtocolEngine(localhost, nextHost,chknum, bufsize, txt);
+		pe.start();
+	}
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/fdl/old/test/transfer/cluster/MetaProtocolEngine.java	Mon Oct 11 14:29:37 2010 +0900
@@ -0,0 +1,177 @@
+package fdl.old.test.transfer.cluster;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import fdl.MetaEngine;
+import fdl.MetaLinda;
+import fdl.PSXLinda;
+import fdl.PSXReply;
+
+public class MetaProtocolEngine implements MetaEngine {
+	private int id = 10;
+
+	private PSXLinda psxget;
+	MetaLinda fdlmeta;
+	String host;
+	int port = 10000;
+	private PSXLinda psxsend;
+	private int chknum;
+
+	SimpleDateFormat DF = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss.SSS");
+
+	private int bufsize;
+
+	private String time;
+	private long timelong;
+	private String start;
+	private String txt;
+	private String transfer;
+	private long transferlong;
+
+	public MetaProtocolEngine(MetaLinda ml, String host, int chknum, int bufsize, String txt) {
+		this.host = host;
+		this.fdlmeta = ml;
+		this.chknum = chknum;
+		this.bufsize = bufsize;
+		this.txt = txt;
+	}
+
+	public void mainLoop(MetaLinda ml){
+		psxget = fdlmeta;
+		if (chknum == 1) {
+			try {
+				sendData();
+				start = DF.format(new Date());
+				System.out.println("Start Time => "+start);
+			} catch (IOException e) {
+				e.printStackTrace();
+			}
+		}
+		boolean connect = true;
+		while(connect){
+			try {
+				initConnect();
+				transfer = DF.format(new Date());
+				transferlong = new Date().getTime();
+				System.out.println("transfer Time => "+transfer);
+				for(int l = 0; l < 1000; l++) {
+					transfer();
+				}
+				dataChk();
+				write();
+				connect = false;
+			} catch (IOException e) {
+				try {
+					Thread.sleep(40);
+				} catch (InterruptedException e1) {
+				}
+			}
+		}
+	}
+
+	private void initConnect(){
+		boolean connectpsx = true;
+		while(connectpsx){
+			try {
+				psxsend = fdlmeta.open(host, port);
+				connectpsx = false;
+			} catch (IOException e) {
+				try {
+					Thread.sleep(40);
+				} catch (InterruptedException e1) {
+					e1.printStackTrace();
+				}
+			}
+		}
+	}
+
+	private void sendData() throws IOException{
+		boolean connectSend = true;
+		ByteBuffer send = ByteBuffer.allocate(bufsize);
+		byte[] fdata = new byte[bufsize];
+		//		fdata = InetAddress.getLocalHost().getAddress();
+		for(int n=0; n < fdata.length; n++ ){
+			fdata[n] = 1;
+		}
+		send.put(fdata);
+		send.flip();
+		while(connectSend){
+			psxget.out(id, send);
+			psxget.sync(1);
+			System.out.println("Send Data");
+			connectSend = false;
+		}
+	}
+
+	public void transfer() throws IOException {
+		ByteBuffer data = ByteBuffer.allocate(bufsize);
+		boolean running = true;
+		PSXReply in = psxget.in(id);
+		while (running) {
+			if(in.ready()){
+				data = in.getData();
+				psxsend.out(id,data);
+				System.out.println("connect to => "+host);
+				psxsend.sync(1);
+				running = false;
+				break;
+			}
+			fdlmeta.sync(0);
+		}
+	}
+
+	public void dataChk() throws IOException{
+		fdlmeta.sync(1);
+		boolean running2 = true;
+		//		ByteBuffer data2 = ByteBuffer.allocate(bufsize);
+		PSXReply in2 = psxget.in(id);
+		//		byte[] fdata2 = new byte[bufsize];
+		//		byte[] fdata3 = new byte[bufsize];
+		//		fdata = InetAddress.getLocalHost().getAddress();
+		//		for(int n=0; n < fdata2.length; n++ ){
+		//			fdata2[n] = 1;
+		//		}
+		while (running2) {
+			psxget.sync(1);
+			if(in2.ready()) {
+				//				data2 = in2.getData();
+				//				data2.get(fdata3);
+				//				if (fdata2 == fdata3){
+				time = DF.format(new Date());
+				timelong = new Date().getTime();
+				System.out.println("Around Time => "+time);
+				//				}
+				running2 = false;
+				break;
+			}
+		}
+	}
+
+
+	public void write() throws IOException{
+		long result = (timelong - transferlong);
+		String diff = String.valueOf(result);
+		File read = new File("resultTime"+bufsize+"_"+txt+".txt");
+		read.createNewFile();
+		FileWriter filewrite = new FileWriter(read);
+		if (start != "null"){
+			filewrite.write("ServerStart => "+start+"\r\n");
+		}
+		if (transfer != "null") {
+			filewrite.write("TransferTime => "+transfer+"\r\n");
+		}
+		if (time != "null"){
+			filewrite.write("AroundTime => "+time+"\r\n");
+		}
+		if (diff != "null"){
+			filewrite.write("DiffTime => "+diff+"\r\n");
+		}
+		filewrite.close();
+	}
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/fdl/old/test/transfer/cluster/ProtocolEngine.java	Mon Oct 11 14:29:37 2010 +0900
@@ -0,0 +1,147 @@
+package fdl.old.test.transfer.cluster;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.net.InetAddress;
+import java.nio.ByteBuffer;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import fdl.FederatedLinda;
+import fdl.PSXLinda;
+import fdl.PSXReply;
+
+
+public class ProtocolEngine extends Thread{
+	static int id = 10;
+	static FederatedLinda fdl;
+	static PSXLinda getpsx;
+	static PSXLinda sendpsx;
+	static int port = 10000;
+	String getHost = null;
+	String sendHost = null;
+	private int chknum;
+	private int bufsize;
+	private String txt;
+	SimpleDateFormat DF = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss.SSS");
+	private String time;
+	private long timelong;
+	private String start;
+	private String transfer;
+	private long transferlong;
+	
+	public ProtocolEngine(String gethost, String sendhost, int chknum, int bufsize, String txt) {
+		this.getHost = gethost;
+		this.sendHost = sendhost;
+		this.chknum = chknum;
+		this.bufsize = bufsize;
+		this.txt = txt;
+	}
+
+	public void run(){
+		fdl = FederatedLinda.init();
+		try {
+			getpsx = fdl.open(getHost,port);
+			System.out.println("Connect Host1");
+			sendpsx = fdl.open(sendHost,port);
+			System.out.println("Connect Host2");
+			// Host1にデータを送信する。
+			if(chknum == 1){
+			testSend(getpsx);
+			start = DF.format(new Date());
+			System.out.println("Start Time => "+start);
+			}
+			// psxにデータを用意
+			transfer(getpsx,sendpsx);
+			dataChk();
+			write();
+			
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+	}
+	
+	private void write() throws IOException {
+		long result = (timelong - transferlong);
+		String diff = String.valueOf(result);
+		File read = new File("resultTime"+bufsize+"_"+txt+".txt");
+		read.createNewFile();
+		FileWriter filewrite = new FileWriter(read);
+		if (start != "null"){
+		filewrite.write("ServerStart => "+start+"\r\n");
+		}
+		if (transfer != "null") {
+		filewrite.write("TransferTime => "+transfer+"\r\n");
+		}
+		if (time != "null"){
+		filewrite.write("AroundTime => "+time+"\r\n");
+		}
+		if (diff != "null"){
+		filewrite.write("DiffTime => "+diff+"\r\n");
+		}
+		filewrite.close();
+	}
+
+	private void dataChk() throws IOException {
+		fdl.sync(1);
+		boolean running2 = true;
+		ByteBuffer data3 = ByteBuffer.allocate(bufsize);
+		PSXReply in2 = getpsx.in(id);
+		int localhost2 = InetAddress.getLocalHost().hashCode();
+		while (running2) {
+			getpsx.sync(1);
+			if(in2.ready()) {
+			data3 = in2.getData();
+			int i = data3.getInt();
+			if (i == localhost2){
+				time = DF.format(new Date());
+				timelong = new Date().getTime();
+				System.out.println("Around Time => "+time);
+			}
+			running2 = false;
+			break;
+			}
+		}
+		
+	}
+
+	private void testSend(PSXLinda psx2) throws IOException {
+		boolean connectSend = true;
+		ByteBuffer send = ByteBuffer.allocate(bufsize);
+		int localhost = InetAddress.getLocalHost().hashCode();
+		send.putInt(localhost);
+		send.flip();
+		while(connectSend){
+		psx2.out(id, send);
+		psx2.sync(1);
+		System.out.println("Send Data");
+		connectSend = false;
+		}
+	}
+	
+
+	private void transfer(PSXLinda getpsx, PSXLinda sendpsx) throws IOException {
+		ByteBuffer data2 = ByteBuffer.allocate(bufsize);
+		PSXReply in = getpsx.in(id);
+		boolean running = true;
+		while (running) {
+			if(in.ready()){
+				//psx1にデータを書き出し
+				data2 = in.getData();
+				sendpsx.out(id,data2);
+				//runningフラグをfalseする
+				running = false;
+				transfer = DF.format(new Date());
+				transferlong = new Date().getTime();
+				System.out.println("transfer Time => "+transfer);
+				System.out.println("connect to => "+sendHost);
+				sendpsx.sync(1);
+				break;
+			}
+			fdl.sync();
+		}
+		
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/fdl/old/test/transfer/cluster/ProtocolEngineMain.java	Mon Oct 11 14:29:37 2010 +0900
@@ -0,0 +1,72 @@
+package fdl.old.test.transfer.cluster;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import fdl.FederatedLinda;
+import fdl.PSXLinda;
+import fdl.PSXReply;
+
+public class ProtocolEngineMain {
+	static int id = 10;
+	static FederatedLinda fdl;
+	static PSXLinda getpsx;
+	static PSXLinda sendpsx;
+	static int port = 10000;
+	private static String getHost = null;
+	private static String sendHost = null;
+	
+	public static void main(String[] args) {
+		for (int i=0; i<args.length; ++i) {
+			if("-get".equals(args[i])){
+				getHost = args[++i];
+			} else if("-send".equals(args[i])){
+				sendHost = args[++i];
+			} else {
+	        System.err.println("引数指定の誤り:未知の引数が指定されました");
+            }
+		}
+		fdl = FederatedLinda.init();
+		try {
+			getpsx = fdl.open(getHost,port);
+			System.out.println("Connect Host1");
+			sendpsx = fdl.open(sendHost,port);
+			System.out.println("Connect Host2");
+			// Host1にデータを送信する。
+//			ByteBuffer send = ByteBuffer.allocate(10);
+//			send.putInt(12);
+//			send.flip();
+//			getpsx.out(id , send);
+//			fdl.sync(1);
+//			System.out.println("Send Data");
+			// psxにデータを用意
+			boolean running = true;
+			ByteBuffer data2 = ByteBuffer.allocate(10);
+			PSXReply in = getpsx.in(id);
+			while (running) {
+				if(in.ready()){
+					//psx1にデータを書き出し
+					data2 = in.getData();
+					sendpsx.out(id,data2);
+					int i = data2.getInt();
+					data2.rewind();
+					System.out.println("transfer Data => "+i);
+					//runningフラグをfalseする
+					running = false;
+					sendpsx.sync(1);
+					System.out.println("Transfer Data");
+					break;
+				}
+				SimpleDateFormat DF = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss.SSS");
+				System.out.println(DF.format(new Date()));
+				fdl.sync();
+			}
+			
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/fdl/old/test/transfer/cluster/Server.java	Mon Oct 11 14:29:37 2010 +0900
@@ -0,0 +1,16 @@
+package fdl.old.test.transfer.cluster;
+
+import fdl.FDLindaServ;
+
+public class Server extends Thread{
+	int port;
+
+	public Server() {
+	}
+
+	public void run(){
+		String[] args = {"-p",Integer.toString(port)};
+		FDLindaServ.main(args);
+	}
+
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/fdl/old/test/transfer/cluster/ServerMain.java	Mon Oct 11 14:29:37 2010 +0900
@@ -0,0 +1,12 @@
+package fdl.old.test.transfer.cluster;
+
+import fdl.FDLindaServ;
+
+public class ServerMain{	
+	public static void main(String[] args){
+		int port = 10000;
+		String[] args1 = {"-p",Integer.toString(port)};
+		FDLindaServ.main(args1);
+	}
+
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/fdl/old/test/transfer/cluster/TestGet.java	Mon Oct 11 14:29:37 2010 +0900
@@ -0,0 +1,48 @@
+package fdl.old.test.transfer.cluster;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+import fdl.FederatedLinda;
+import fdl.PSXLinda;
+import fdl.PSXReply;
+
+
+public class TestGet extends Thread {
+	private PSXLinda psxget;
+	private FederatedLinda fdlget;
+	private int port;
+	String host = "127.0.0.1";
+	private ByteBuffer data = ByteBuffer.allocate(1024);
+	
+	public TestGet(int port1) {
+		this.port = port1;
+	}
+	
+	public void run(){
+		int id = 10;
+		int i;
+		fdlget = FederatedLinda.init();
+		try {
+			System.out.println("TestGet Start");
+			psxget = fdlget.open(host, port);
+			System.out.println("Host1 connected");
+			//getにidのタプルを取り出す
+			PSXReply dataGet = psxget.in(id);
+			System.out.println("dataget");
+			System.out.println(dataGet.ready());
+			if(dataGet.ready()){
+				System.out.println(dataGet);
+				data = dataGet.getData();
+				fdlget.sync(1);
+				i = data.getInt();
+				System.out.println(i);
+			}
+		} catch (IOException e) {
+			try {
+				Thread.sleep(10);
+			} catch (InterruptedException e1) {
+			}
+		}
+		}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/fdl/old/test/transfer/cluster/TestSend.java	Mon Oct 11 14:29:37 2010 +0900
@@ -0,0 +1,46 @@
+package fdl.old.test.transfer.cluster;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+import fdl.FederatedLinda;
+import fdl.PSXLinda;
+
+public class TestSend {
+	static PSXLinda psxsend;
+	static FederatedLinda fdlsend;
+	private static int port = 10000;
+
+	public static void main(String[] args){
+		int id = 10;
+		int i;
+		String host = "cls001.cs.ie.u-ryukyu.ac.jp";
+		ByteBuffer send = ByteBuffer.allocate(1024);
+		send.putInt(12);
+		send.flip();
+		i = send.getInt();
+		send.rewind();
+		fdlsend = FederatedLinda.init();
+		boolean connect = true;
+		while(connect) {
+		try{
+			System.out.println("TestSend Start");
+			psxsend = fdlsend.open(host,port);
+			System.out.println("Set Data = " +i);
+			System.out.println("Connect Host1");
+			psxsend.out(id, send);
+			System.out.println("regist Que");
+			fdlsend.sync();
+			System.out.println("Send Data");
+			connect = false;
+		}catch (IOException e) {
+			try {
+				Thread.sleep(40);
+			} catch (InterruptedException e1) {
+			}
+		}
+		}
+	}
+
+	
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/fdl/old/test/transfer/three/ProtocolEngine.java	Mon Oct 11 14:29:37 2010 +0900
@@ -0,0 +1,82 @@
+package fdl.old.test.transfer.three;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+import fdl.FederatedLinda;
+import fdl.PSXLinda;
+import fdl.PSXReply;
+
+
+public class ProtocolEngine extends Thread{
+	private PSXLinda psx;
+	private String name;
+	FederatedLinda fdl1;
+	String host = "127.0.0.1";
+	int port1;
+	int port2;
+	private int id = 10;
+	private PSXLinda psx1;
+	private boolean running = true;
+	private ByteBuffer data2 = ByteBuffer.allocate(10);
+	private int count = 1;
+
+	public ProtocolEngine(String string, int port1, int port2) {
+		this.name = string;
+		this.port1 = port1;
+		this.port2 = port2;
+	}
+
+	public void run(){
+		fdl1 = FederatedLinda.init();
+		boolean connect = true;
+		while(connect){
+		try {
+			initConnect();
+			transfer();
+			connect = false;
+		} catch (IOException e) {
+			try {
+				Thread.sleep(40);
+			} catch (InterruptedException e1) {
+			}
+		}
+		}
+	}
+
+	private void initConnect() throws IOException {
+		System.out.println(name);
+		psx = fdl1.open(host,port1);
+		System.out.println("Connect "+port1);
+		psx1 = fdl1.open(host,port2);
+		System.out.println("Connect "+port2);
+	}
+
+	private void transfer() throws IOException {
+		PSXReply in = psx.in(id);
+		System.out.println("PSXReply "+port1 +": "+port2 +": ");
+		while (running) {
+			if(in.ready()){
+				data2 = in.getData();
+				int i = data2.getInt();
+				data2.rewind();
+				//outしたbytebufferの変更をこれ以降やっちゃいけない
+				psx1.out(id,data2);
+				
+				System.out.println("IntData0 "+port1 +": "+port2 +": " +i);
+				fdl1.sync(1);
+				if (count++>3) {
+					running = false;
+					break;
+				}
+				System.out.println("IntData1 "+port1 +": "+port2 +": " +i);
+			}
+			fdl1.sync();
+		}
+		assertEquals(4,count);
+	}
+	
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/fdl/old/test/transfer/three/Server.java	Mon Oct 11 14:29:37 2010 +0900
@@ -0,0 +1,20 @@
+package fdl.old.test.transfer.three;
+
+import fdl.FDLindaServ;
+
+public class Server extends Thread {
+	int port;
+	private String name;
+
+	public Server(String string, int i) {
+		port = i;
+		name = string;
+	}
+
+	public void run(){
+		String[] args = {"-p",Integer.toString(port)};
+		System.out.println(name+"start");
+		FDLindaServ.main(args);
+	}
+
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/fdl/old/test/transfer/three/TestGet.java	Mon Oct 11 14:29:37 2010 +0900
@@ -0,0 +1,55 @@
+package fdl.old.test.transfer.three;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+import fdl.FederatedLinda;
+import fdl.PSXLinda;
+import fdl.PSXReply;
+
+
+public class TestGet extends Thread {
+	PSXLinda psxget;
+	FederatedLinda fdlget;
+	private int port;
+	String host = "127.0.0.1";
+	private ByteBuffer data = ByteBuffer.allocate(10);
+	
+	public TestGet(int port1) {
+		this.port = port1;
+	}
+	
+	public void run(){
+		int id = 10;
+		int i;
+		fdlget = FederatedLinda.init();
+		boolean connecttest = true;
+		while(connecttest){
+		try {
+			getData(id);
+			i = data.getInt();
+			System.out.println(i);
+			connecttest = false;
+		} catch (IOException e) {
+				e.printStackTrace();
+				connecttest = true;
+		}
+		}
+	}
+
+	private void getData(int id) throws IOException {
+		psxget = fdlget.open(host, port);
+		PSXReply get = psxget.in(id);
+		boolean running = false;
+		while(running){
+			if(get.ready()){
+				data = get.getData();
+				running = false;
+				fdlget.sync(0);
+				break;
+			}
+		fdlget.sync();
+		}
+	}
+	
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/fdl/old/test/transfer/three/TestSend.java	Mon Oct 11 14:29:37 2010 +0900
@@ -0,0 +1,48 @@
+package fdl.old.test.transfer.three;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+import fdl.FederatedLinda;
+import fdl.PSXLinda;
+
+public class TestSend extends Thread {
+	PSXLinda psxsend;
+	FederatedLinda fdlsend;
+	private int port;
+	
+	public TestSend(int port1) {
+		this.port = port1;
+	}
+
+	public void run(){
+		int id = 10;
+		int i;
+		String host = "127.0.0.1";
+		ByteBuffer send = ByteBuffer.allocate(1024);
+		send.putInt(12);
+		send.flip();
+		i = send.getInt();
+		send.rewind();
+		fdlsend = FederatedLinda.init();
+		boolean connect = true;
+		while(connect) {
+		try{
+			psxsend = fdlsend.open(host,port);
+			System.out.println("Set Data = " +i);
+			System.out.println("Connect Host1");
+			psxsend.out(id, send);
+			System.out.println("regist Que");
+			fdlsend.sync(1);
+			System.out.println("Send Data");
+			connect = false;
+		}catch (IOException e) {
+			try {
+				Thread.sleep(20);
+			} catch (InterruptedException e1) {
+			}
+		}
+		}
+	}
+	
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/fdl/old/test/transfer/three/TestTransfer.java	Mon Oct 11 14:29:37 2010 +0900
@@ -0,0 +1,52 @@
+package fdl.old.test.transfer.three;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+
+public class TestTransfer {
+	Server[] servers;
+	ProtocolEngine[] engines;
+	final int serverCount = 3;
+	final int startPort = 10011;
+	@Test
+	public void testTransfer() {
+		int port = startPort;
+		servers = new Server[serverCount];
+		engines = new ProtocolEngine[serverCount];
+		
+		for (int i = 0; i < serverCount; i++) {
+			servers[i] = new Server("Server"+(i+1),port+i);
+			servers[i].start();
+		}
+		
+		TestSend send = new TestSend(startPort);
+		send.start();
+		try{
+			send.join();
+		} catch (InterruptedException e) {
+			e.printStackTrace();
+		}
+		
+		for (int i = 0; i < serverCount; i++) {
+			engines[i] = new ProtocolEngine("ProtocolEngine "+(i+1) +":port " +(port+i) +":port "+(netporot(port+i)),port+i,netporot(port+i));
+			engines[i].start();
+		}
+		try {
+			for (ProtocolEngine e: engines){
+				e.join();
+			}
+		} catch (InterruptedException e) {
+			e.printStackTrace();
+		}
+		assertEquals(1,1);
+	}
+	private int netporot(int i) {
+		i++;
+		if(i >= startPort+serverCount) {
+			return startPort;
+		}
+		return i;
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/fdl/old/test/transfer/two/ProtocolEngine.java	Mon Oct 11 14:29:37 2010 +0900
@@ -0,0 +1,67 @@
+package fdl.old.test.transfer.two;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+import fdl.FederatedLinda;
+import fdl.PSXLinda;
+import fdl.PSXReply;
+
+
+public class ProtocolEngine extends Thread{
+	private static PSXLinda psx;
+	private static String name;
+	static FederatedLinda fdl1;
+	static String host = "127.0.0.1";
+	static int port1 = 10001;
+	static int port2 = 10002;
+	private static int id = 10;
+	private static PSXLinda psx1;
+	private static boolean running;
+	private static ByteBuffer data2 = ByteBuffer.allocate(10);
+
+	public static void main(String[] args){
+		fdl1 = FederatedLinda.init();
+		try {
+			System.out.println(name);
+			psx = fdl1.open(host,port1);
+			System.out.println("Connect Host1");
+			psx1 = fdl1.open(host,port2);
+			System.out.println("Connect Host2");
+			// Host1にデータを送信する。
+			testSend(psx);
+			// psxにデータを用意
+			transfer(psx,psx1);
+			
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+	}
+	
+	private static void testSend(PSXLinda psx2) throws IOException {
+		ByteBuffer send = ByteBuffer.allocate(10);
+		send.putInt(12);
+		send.flip();
+		psx2.out(id, send);
+		psx2.sync(0);
+	}
+	
+
+	private static void transfer(PSXLinda psx2, PSXLinda psx12) throws IOException {
+		PSXReply in = psx2.in(id);
+		while (running) {
+			if(in.ready()){
+				//psx1にデータを書き出し
+				data2 = in.getData();
+				psx12.out(id,data2);
+				//runningフラグをfalseする
+				running = false;
+				fdl1.sync(0);
+				break;
+			}
+			fdl1.sync();
+		}
+		
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/fdl/old/test/transfer/two/Server.java	Mon Oct 11 14:29:37 2010 +0900
@@ -0,0 +1,20 @@
+package fdl.old.test.transfer.two;
+
+import fdl.FDLindaServ;
+
+public class Server extends Thread {
+	int port;
+	private String name;
+
+	public Server(String string, int i) {
+		port = i;
+		name = string;
+	}
+
+	public void run(){
+		String[] args = {"-p",Integer.toString(port)};
+		System.out.println(name);
+		FDLindaServ.main(args);
+	}
+
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/fdl/old/test/transfer/two/TestGet.java	Mon Oct 11 14:29:37 2010 +0900
@@ -0,0 +1,44 @@
+package fdl.old.test.transfer.two;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+import fdl.FederatedLinda;
+import fdl.PSXLinda;
+import fdl.PSXReply;
+
+
+public class TestGet extends Thread {
+	private static PSXLinda psxget;
+	private static FederatedLinda fdlget;
+	private static int port = 10001;
+	static String host = "127.0.0.1";
+	private static ByteBuffer data = ByteBuffer.allocate(1024);
+	
+	public static void main(String[] args){
+		int id = 10;
+		int i;
+		fdlget = FederatedLinda.init();
+		try {
+			System.out.println("TestGet Start");
+			psxget = fdlget.open(host, port);
+			System.out.println("Host1 connected");
+			//getにidのタプルを取り出す
+			PSXReply dataGet = psxget.in(id);
+			System.out.println("dataget");
+			System.out.println(dataGet.ready());
+			if(dataGet.ready()){
+				System.out.println(dataGet);
+				data = dataGet.getData();
+				fdlget.sync(1);
+				i = data.getInt();
+				System.out.println(i);
+			}
+		} catch (IOException e) {
+			try {
+				Thread.sleep(10);
+			} catch (InterruptedException e1) {
+			}
+		}
+		}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/fdl/old/test/transfer/two/TestSend.java	Mon Oct 11 14:29:37 2010 +0900
@@ -0,0 +1,50 @@
+package fdl.old.test.transfer.two;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+import fdl.FederatedLinda;
+import fdl.PSXLinda;
+
+public class TestSend extends Thread {
+	PSXLinda psxsend;
+	FederatedLinda fdlsend;
+	private int port;
+	
+	public TestSend(int port1) {
+		this.port = port1;
+	}
+
+	public void run(){
+		int id = 10;
+		int i;
+		String host = "127.0.0.1";
+		ByteBuffer send = ByteBuffer.allocate(1024);
+		send.putInt(12);
+		send.flip();
+		i = send.getInt();
+		send.rewind();
+		fdlsend = FederatedLinda.init();
+		boolean connect = true;
+		while(connect) {
+		try{
+			System.out.println("TestSend Start");
+			psxsend = fdlsend.open(host,port);
+			System.out.println("Set Data = " +i);
+			System.out.println("Connect Host1");
+			psxsend.out(id, send);
+			System.out.println("regist Que");
+			fdlsend.sync(1);
+			System.out.println("Send Data");
+			connect = false;
+		}catch (IOException e) {
+			try {
+				Thread.sleep(40);
+			} catch (InterruptedException e1) {
+			}
+		}
+		}
+	}
+
+	
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/fdl/old/test/transfer/two/TestTransfer.java	Mon Oct 11 14:29:37 2010 +0900
@@ -0,0 +1,21 @@
+package fdl.old.test.transfer.two;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+public class TestTransfer {
+	@Test
+	public void testTransfer() throws InterruptedException {
+		int port = 10001;
+		Server server = new Server("Server1",port);
+		server.start();
+		server.join();
+		TestSend send = new TestSend(port);
+		send.start();
+
+		send.join();
+
+		assertEquals(1,1);
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/fdl/old/test2/CountTest.java	Mon Oct 11 14:29:37 2010 +0900
@@ -0,0 +1,42 @@
+package fdl.old.test2;
+
+class CountA implements Runnable {
+
+	public void run() {
+		for (int i=0; i <= 5; i++) {
+			System.out.println("A: " + i);
+		}
+	}
+}
+
+class CountB implements Runnable {
+
+	public void run() {
+		for (int i=5; i >= 0; i--) {
+			System.out.println("	B: " + i);
+		}
+	}
+}
+
+class CountTest {
+	public static void main(String[] args) {
+		// ランナブルクラスのインスタンス化
+		CountA runA = new CountA();
+		CountB runB = new CountB();
+		System.out.println("Runnable Class のインスタンス化終了");
+
+		// スレッドのインスタンス化
+		Thread threadA = new Thread(runA);
+		Thread threadB = new Thread(runB);
+		System.out.println("Thread へ受け渡し終了");
+
+		// スレッドの開始
+		threadA.start();
+		threadB.start();
+		System.out.println("Thread の start() 終了");
+		System.out.println("適時自動的に run() が実行される");
+
+
+	}
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/fdl/old/test2/Server.java	Mon Oct 11 14:29:37 2010 +0900
@@ -0,0 +1,35 @@
+package fdl.old.test2;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.util.Date;
+
+public class Server extends Thread{
+	static int Port = 10007;
+    
+	public void run(){
+		try {
+		ServerSocket server = new ServerSocket(Port);
+		Socket sock =null;
+		System.out.println("Server Start");
+		sock = server.accept();
+		System.out.println("Connect");
+		PrintWriter ps = new PrintWriter(sock.getOutputStream());
+		Date d = new Date();
+		ps.print(d + "\r\n");
+		ps.flush();
+		sock.close(); // クライアントからの接続を切断
+	    System.out.println("Connection Closed");
+		} catch (IOException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+	} 
+
+    public static void main(String[] args) {
+    	Server sv = new Server();
+    	sv.start();
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/fdl/old/test2/TestRead.java	Mon Oct 11 14:29:37 2010 +0900
@@ -0,0 +1,26 @@
+package fdl.old.test2;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+
+public class TestRead {
+
+	    public static void main(String[] args) {
+	        try {
+	        	File inputFile = new File(args[0]);
+	        	FileReader in = new FileReader(inputFile);
+	            BufferedReader br = new BufferedReader(in);
+	            String line;
+	            while ((line = br.readLine()) != null) {
+	                System.out.println(line);
+	            }
+	            br.close();
+	            in.close();
+	        } catch (IOException e) {
+	            System.out.println(e);
+	        }
+	    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/fdl/old/test2/TestRing.java	Mon Oct 11 14:29:37 2010 +0900
@@ -0,0 +1,51 @@
+package fdl.old.test2;
+
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+import fdl.FederatedLinda;
+import fdl.PSXLinda;
+import fdl.PSXReply;
+
+public class TestRing {
+	static int id;
+	public static void main(String args[]){
+		
+		try{
+		FederatedLinda fdl;
+		PSXLinda psx;
+		String host = "127.0.0.1";
+		PSXReply r;
+
+		FileReader in = new FileReader("nodelist");
+		BufferedReader br = new BufferedReader(in);
+		String line;
+		
+		while ((line = br.readLine()) != null) {
+		int i1 = Integer.parseInt(line);
+		fdl = FederatedLinda.init();
+		psx = fdl.open(host,i1);
+		r = psx.in(65535);
+		fdl.sync(1);
+		
+		ByteBuffer data = ByteBuffer.allocate(10);
+		data.putInt(10);
+		data.flip();
+
+		psx.out(1,data);
+		while(!r.ready()){
+		psx.sync(0);
+		}
+		}
+        br.close();
+        in.close();
+
+
+		}catch (IOException e) {
+			System.err.println("Communication failure.");
+		}
+	
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/fdl/old/test2/client.java	Mon Oct 11 14:29:37 2010 +0900
@@ -0,0 +1,26 @@
+package fdl.old.test2;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.Socket;
+
+public class client {
+	public static void main(String arg[]) throws IOException{
+		String www = arg[0];
+		int port = 10007;
+		Socket sock;
+		BufferedReader dis;
+//		PrintWriter ps;
+		sock = new Socket(www,port);
+		dis = new BufferedReader(new InputStreamReader(sock.getInputStream()));
+//		ps = new PrintWriter(sock.getOutputStream(),true);
+//		ps.println("Get"+arg[1]);
+//		String s = null;
+//		while((s = dis.readLine()) != null){
+			System.out.println(dis);
+//		}
+		sock.close();
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/fdl/old/test2/nodelist	Mon Oct 11 14:29:37 2010 +0900
@@ -0,0 +1,2 @@
+10000
+10001
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/fdl/test/debug/AcceptXMLCallback.java	Mon Oct 11 14:29:37 2010 +0900
@@ -0,0 +1,117 @@
+package fdl.test.debug;
+
+import java.io.IOException;
+import java.io.StringReader;
+import java.nio.ByteBuffer;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+import fdl.PSXCallback;
+import fdl.PSXLindaImpl;
+
+class AcceptXMLCallback implements PSXCallback {
+	TupleId tid;
+	NodeProperty np;
+	TreeProperty tp;
+	DebugProperty dp;
+	
+	private DocumentBuilderFactory dbFactory = null;
+	private DocumentBuilder docBuilder = null;
+	
+	public AcceptXMLCallback(TupleId tid, NodeProperty np) {
+		this.tid = tid;
+		this.np = np;
+		dbFactory = DocumentBuilderFactory.newInstance();
+		try {
+			docBuilder = dbFactory.newDocumentBuilder();
+		} catch (ParserConfigurationException e) {
+			e.printStackTrace();
+		}
+
+	}
+	public void callback(ByteBuffer reply) {
+		String xml = new String(reply.array());
+		Debug.print(xml);
+		parseXML(xml);
+		
+		np.ml.in(tid.id, this);
+	}
+	protected void parseXML(String xml) {
+		Document doc = null;
+		try {
+			doc = docBuilder.parse(new InputSource(new StringReader(xml)));
+		} catch (SAXException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+		
+		Element root = doc.getDocumentElement();
+		if(root.getTagName().equals("connections")) {
+			np.nodeId = Integer.parseInt(root.getAttribute("id"));
+			if (np.nodeId == 0) {
+				np.ml.in(TupleId.START.id, new StartCallback(np, tp = new TreeProperty(np)));
+				np.ml.in(TupleId.DEBUGSTART.id, new DebugStartCallback(np, dp = new DebugProperty()));
+			}
+			NodeList connections = root.getElementsByTagName("connection");
+			makeConnections(connections);
+		} else if (root.getTagName().equals("routing")) {
+			Debug.print("Routing xml received!");
+
+			NodeList routing = root.getElementsByTagName("source");
+			for (int i = 0; i < routing.getLength(); i++) {
+				Element src = (Element) routing.item(i);
+				Integer srcId = Integer.parseInt(src.getAttribute("id"));
+				Routing r = np.nodes.get(TupleId.getTupleIdFromId(srcId));
+				NodeList dest = src.getElementsByTagName("dest");
+				for (int j = 0; j < dest.getLength(); j++) {
+					Element dst = (Element) dest.item(j);
+					r.route.add(Integer.parseInt(dst.getAttribute("id")));
+				}
+			}
+			
+		}
+		switch (tid) {
+		case MANAGE:
+			np.connected = true;
+			break;
+		case DEBUG:
+			np.debugConnected = true;
+			break;
+		}
+		if (np.connected && np.debugConnected) {
+			np.sendLocalHostName();
+			Debug.print("Send local host name");
+			np.connected = np.debugConnected = false;
+		}
+	}
+	private void makeConnections(NodeList connections) {
+		for (int i = 0; i < connections.getLength(); i++) {
+			Element connection = (Element)connections.item(i);
+			Element host = (Element)connection.getElementsByTagName("host").item(0);
+			Element port = (Element)connection.getElementsByTagName("port").item(0);
+			Element t = (Element)connection.getElementsByTagName("tid").item(0);
+			int srcId = Integer.parseInt(connection.getAttribute("id"));
+			String dstHostName = host.getTextContent();
+			int dstPort = Integer.parseInt(port.getAttribute("id"));
+			int dstId = Integer.parseInt(t.getAttribute("id"));
+			try {
+				PSXLindaImpl linda = (PSXLindaImpl) np.ml.open(dstHostName, dstPort);
+				Routing r = new Routing(linda, dstId);
+				np.nodes.put(TupleId.getTupleIdFromId(srcId), r);
+				np.ml.in(srcId, new RoutingCallback(TupleId.getTupleIdFromId(srcId), r, np, tp, dp));
+			} catch (IOException e) {
+				e.printStackTrace();
+			}
+		}
+	}
+	
+} 
--- a/src/fdl/test/debug/ConfigurationManagerEngine.java	Mon Oct 11 04:43:46 2010 +0900
+++ b/src/fdl/test/debug/ConfigurationManagerEngine.java	Mon Oct 11 14:29:37 2010 +0900
@@ -7,27 +7,10 @@
 
 public class ConfigurationManagerEngine implements MetaEngine {
 	public static final int DEFAULTPORT = 10000;
-
-	// tuple id
-	public static final int BODY = 100;
-	public static final int START = 101;
-	public static final int FINISH = 102;
 	
-	public static final int MANAGE = 60000;
-	public static final int DEBUG = 61000;
-	
-	public static final int TREETOP = MANAGE + 1;
-	public static final int TREELEFT = MANAGE + 2;
-	public static final int TREERIGHT = MANAGE + 3;
-
-	public static final int RINGLEFT = DEBUG + 1;
-	public static final int RINGRIGHT = DEBUG + 2;
-	
-	public static final int DEBUGSTART = DEBUG + 1000;
-	
-	private int nodeNum = 0;
-	private int relayNum = 0;
-	private int relaySize = 1;
+	public int nodeNum = 0;
+	public int relayNum = 0;
+	public int relaySize = 1;
 	private MetaLinda ml;
 	private NodeInfo[] nodes;
 	private boolean running = true;
@@ -39,7 +22,7 @@
 			String hostName = hostData[0];
 			int	port = DEFAULTPORT;
 			if (hostData.length > 1)
-				port = new Integer(hostData[1]).intValue();
+				port = Integer.parseInt(hostData[1]);
 			nodes[count] = new NodeInfo(hostName, port);
 			try {
 				nodes[count].linda = ml.open(hostName, port);
@@ -47,10 +30,10 @@
 				e.printStackTrace();
 			}
 			if (++count < nodeNum) {
-				ml.in(MANAGE, this);
+				ml.in(TupleId.MANAGE.id, this);
 			} else {
 				linkNodes();
-				ml.in(MANAGE, new ConfirmConnectionNode());
+				ml.in(TupleId.MANAGE.id, new ConfirmConnectionNode());
 			}
 		}
 	}
@@ -59,10 +42,10 @@
 		int count = 0;
 		public void callback(ByteBuffer reply) {
 			if (++count < nodeNum) {
-				ml.in(MANAGE, this);
+				ml.in(TupleId.MANAGE.id, this);
 			} else {
 				routingNodes();
-				ml.in(MANAGE, new ConfirmRoutingNode());
+				ml.in(TupleId.MANAGE.id, new ConfirmRoutingNode());
 			}
 		}
 
@@ -72,14 +55,14 @@
 		int count = 0;
 		public void callback(ByteBuffer reply) {
 			if (++count < nodeNum) {
-				ml.in(MANAGE, this);
+				ml.in(TupleId.MANAGE.id, this);
 			} else {
 				print("All link configured!");
 				// TREE実験開始を通知
-				// nodes[0].linda.out(START, ByteBuffer.wrap("test".getBytes()));
+				nodes[0].linda.out(TupleId.START.id, ByteBuffer.wrap("0".getBytes()));
 				// DebugRing 開始を通知
-				nodes[0].linda.out(DEBUGSTART, ByteBuffer.wrap(("relay,"+new Integer(relayNum).toString()+","+new Integer(relaySize)).getBytes()));
-				ml.in(MANAGE, new ConfirmFinish());
+				//nodes[0].linda.out(DEBUGSTART, ByteBuffer.wrap(("print," + BODY + ",").getBytes()));
+				ml.in(TupleId.START.id, new ConfirmFinish());
 			}
 		}
 
@@ -87,8 +70,8 @@
 	
 	private class ConfirmFinish implements PSXCallback {
 		public void callback(ByteBuffer reply) {
-			System.out.println(new Integer(nodeNum).toString() + "," + new String(reply.array()));
-			nodes[0].linda.out(DEBUGSTART, ByteBuffer.wrap("shutdown".getBytes()));
+			System.out.println(new String(reply.array()));
+			nodes[0].linda.out(TupleId.DEBUGSTART.id, ByteBuffer.wrap("shutdown".getBytes()));
 			print("Finish token");
 			try {
 				nodes[0].linda.sync(1);
@@ -99,6 +82,17 @@
 		}
 
 	}
+
+	private class RingLoop implements PSXCallback {
+		int counter = 0;
+		public void callback(ByteBuffer reply) {
+			nodes[0].linda.out(TupleId.DEBUGSTART.id, ByteBuffer.wrap(("print," + TupleId.BODY.id + ",").getBytes()));
+			print("ring=" + counter + ": \n" + new String(reply.array()));
+			counter++;
+			ml.in(TupleId.DEBUG.id, this);
+		}
+
+	}
 	
 	public ConfigurationManagerEngine(MetaLinda metaLinda, int nodeNum, int relayNum, int relaySize) {
 		// initialize
@@ -110,8 +104,9 @@
 	}
 
 	public void mainLoop(MetaLinda ml1) {
-		// regist poll tuple id
-		ml.in(MANAGE, new AcceptNewNode());
+		// resist poll tuple id
+		ml.in(TupleId.MANAGE.id, new AcceptNewNode());
+		ml.in(TupleId.DEBUG.id, new RingLoop());
 		while (running)
 			ml.sync(0);
 	}
@@ -123,24 +118,24 @@
 			int k;
 			if (i != 0) { // TOP
 				k = (i-1)/2;
-				tree.appendConnection(TREETOP, nodes[k].host, nodes[k].port, (i%2 == 0) ? TREERIGHT : TREELEFT);
+				tree.appendConnection(TupleId.TREETOP, nodes[k].host, nodes[k].port, (i%2 == 0) ? TupleId.TREERIGHT : TupleId.TREELEFT);
 			}
 			if ((k = 2*i+1) < nodes.length) // LEFT
-				tree.appendConnection(TREELEFT, nodes[k].host, nodes[k].port, TREETOP);
+				tree.appendConnection(TupleId.TREELEFT, nodes[k].host, nodes[k].port, TupleId.TREETOP);
 			if ((k = 2*i+2) < nodes.length) // RIGHT
-				tree.appendConnection(TREERIGHT, nodes[k].host, nodes[k].port, TREETOP);
+				tree.appendConnection(TupleId.TREERIGHT, nodes[k].host, nodes[k].port, TupleId.TREETOP);
 			nodes[i].connectionXML = tree.createXML();
-			nodes[i].linda.out(MANAGE, ByteBuffer.wrap(nodes[i].connectionXML.getBytes()));
+			nodes[i].linda.out(TupleId.MANAGE.id, ByteBuffer.wrap(nodes[i].connectionXML.getBytes()));
 			print(nodes[i].connectionXML);
 			
 			// XML for Ring Debug Topology
 			ConnectionXMLBuilder debug = new ConnectionXMLBuilder(i);
 			int left = (nodes.length + i - 1) % nodes.length;
 			int right = (i + 1) % nodes.length;
-			debug.appendConnection(RINGLEFT, nodes[left].host, nodes[left].port, RINGRIGHT);
-			debug.appendConnection(RINGRIGHT, nodes[right].host, nodes[right].port, RINGLEFT);
+			debug.appendConnection(TupleId.RINGLEFT, nodes[left].host, nodes[left].port, TupleId.RINGRIGHT);
+			debug.appendConnection(TupleId.RINGRIGHT, nodes[right].host, nodes[right].port, TupleId.RINGLEFT);
 			nodes[i].debugConnectionXML = debug.createXML();
-			nodes[i].linda.out(DEBUG, ByteBuffer.wrap(nodes[i].debugConnectionXML.getBytes()));
+			nodes[i].linda.out(TupleId.DEBUG.id, ByteBuffer.wrap(nodes[i].debugConnectionXML.getBytes()));
 			print(nodes[i].debugConnectionXML);
 		}
 	}
@@ -150,23 +145,23 @@
 			RoutingXMLBuilder tree = new RoutingXMLBuilder();
 			if (i != 0) { // TOP
 				if (2*i+1 < nodes.length) { // LEFT
-					tree.appendRoutingTable(TREETOP, TREELEFT);
-					tree.appendRoutingTable(TREELEFT, TREETOP);
+					tree.appendRoutingTable(TupleId.TREETOP, TupleId.TREELEFT);
+					tree.appendRoutingTable(TupleId.TREELEFT, TupleId.TREETOP);
 				}
 				if (2*i+2 < nodes.length) { // RIGHT
-					tree.appendRoutingTable(TREETOP, TREERIGHT);
-					tree.appendRoutingTable(TREERIGHT, TREETOP);
+					tree.appendRoutingTable(TupleId.TREETOP, TupleId.TREERIGHT);
+					tree.appendRoutingTable(TupleId.TREERIGHT, TupleId.TREETOP);
 				}
 			}
 			nodes[i].routingXML = tree.createXML();
-			nodes[i].linda.out(MANAGE, ByteBuffer.wrap(nodes[i].routingXML.getBytes()));
+			nodes[i].linda.out(TupleId.MANAGE.id, ByteBuffer.wrap(nodes[i].routingXML.getBytes()));
 			print(nodes[i].routingXML);
 			
 			RoutingXMLBuilder debug = new RoutingXMLBuilder();
-			debug.appendRoutingTable(RINGLEFT, RINGRIGHT);
-			debug.appendRoutingTable(RINGRIGHT, RINGLEFT);
+			debug.appendRoutingTable(TupleId.RINGLEFT, TupleId.RINGRIGHT);
+			debug.appendRoutingTable(TupleId.RINGRIGHT, TupleId.RINGLEFT);
 			nodes[i].debugRoutingXML = debug.createXML();
-			nodes[i].linda.out(DEBUG, ByteBuffer.wrap(nodes[i].debugRoutingXML.getBytes()));
+			nodes[i].linda.out(TupleId.DEBUG.id, ByteBuffer.wrap(nodes[i].debugRoutingXML.getBytes()));
 			print(nodes[i].debugRoutingXML);
 		}
 	}
--- a/src/fdl/test/debug/ConnectionXMLBuilder.java	Mon Oct 11 04:43:46 2010 +0900
+++ b/src/fdl/test/debug/ConnectionXMLBuilder.java	Mon Oct 11 14:29:37 2010 +0900
@@ -12,15 +12,15 @@
 		document.appendChild(connections);
 	}
 	
-	public void appendConnection(int mytid, String host, int port, int tid){
+	public void appendConnection(TupleId mytid, String host, int port, TupleId tid){
 		Element connection = document.createElement("connection");
-		connection.setAttribute("id", new Integer(mytid).toString());
+		connection.setAttribute("id", new Integer(mytid.id).toString());
 		Element h = document.createElement("host");
 		h.setTextContent(host);
 		Element p = document.createElement("port");
 		p.setAttribute("id", new Integer(port).toString());
 		Element t = document.createElement("tid");
-		t.setAttribute("id", new Integer(tid).toString());
+		t.setAttribute("id", new Integer(tid.id).toString());
 
 		connections.appendChild(connection);
 		connection.appendChild(h);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/fdl/test/debug/Debug.java	Mon Oct 11 14:29:37 2010 +0900
@@ -0,0 +1,21 @@
+package fdl.test.debug;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+
+public class Debug {
+	private static Debug d = new Debug(); // Singleton
+	private String localHostName;
+	private Debug() {
+		try {
+			localHostName = InetAddress.getLocalHost().getHostName();
+		} catch (UnknownHostException e) {
+			e.printStackTrace();
+		}
+	}
+	static void print(String str) {
+		System.err.println("[DEBUG] " + d.localHostName + ": " + str);
+		System.err.flush();
+	}
+	
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/fdl/test/debug/DebugProperty.java	Mon Oct 11 14:29:37 2010 +0900
@@ -0,0 +1,5 @@
+package fdl.test.debug;
+
+public class DebugProperty {
+	public int relayNum, relaySize, relayCounter;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/fdl/test/debug/DebugStartCallback.java	Mon Oct 11 14:29:37 2010 +0900
@@ -0,0 +1,39 @@
+package fdl.test.debug;
+
+import java.nio.ByteBuffer;
+//import java.util.Date;
+
+import fdl.PSXCallback;
+
+class DebugStartCallback implements PSXCallback {
+	public NodeProperty np;
+	public DebugProperty dp;
+	public DebugStartCallback(NodeProperty np, DebugProperty dp) {
+			this.np = np;
+			this.dp = dp;
+	}
+	public void callback(ByteBuffer reply) {
+		String[] commands = new String(reply.array()).split(",");
+		String command = commands[0];
+		if (command.equals("relay")) {
+			dp.relayNum = Integer.parseInt(commands[1]);
+			dp.relaySize = Integer.parseInt(commands[2]);
+			dp.relayCounter = 0;
+			Debug.print("relay num=" + dp.relayNum + " size=" + dp.relaySize);
+			Routing r = np.nodes.get(TupleId.RINGRIGHT);
+			// 実験開始
+			// TODO: startTime?
+			//startTime = new Date();
+			r.linda.out(r.dstId, ByteBuffer.wrap(new byte[dp.relaySize]));
+			np.ml.in(TupleId.DEBUGSTART.id, this);
+		} else if (command.equals("print")) {
+			Routing r = np.nodes.get(TupleId.RINGRIGHT);
+			r.linda.out(r.dstId, reply);
+			Debug.print("Send Debug Message: print");
+			np.ml.in(TupleId.DEBUGSTART.id, this);
+		} else if (command.equals("shutdown")) {
+			Routing r = np.nodes.get(TupleId.RINGRIGHT);
+			r.linda.out(r.dstId, ByteBuffer.wrap("shutdown".getBytes()));
+		}
+	}
+}
\ No newline at end of file
--- a/src/fdl/test/debug/MetaProtocolEngine.java	Mon Oct 11 04:43:46 2010 +0900
+++ b/src/fdl/test/debug/MetaProtocolEngine.java	Mon Oct 11 14:29:37 2010 +0900
@@ -1,18 +1,6 @@
 package fdl.test.debug;
 
-import java.io.*;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-
 import java.nio.ByteBuffer;
-import java.util.*;
-
-import javax.xml.parsers.*;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
-import org.xml.sax.SAXException;
 
 import fdl.*;
 
@@ -28,286 +16,27 @@
 
 public class MetaProtocolEngine implements MetaEngine {
 	// Fields
-	public static final int DEFAULTPORT = 10000;
-	
-	public static final int BODY = 100;
-	public static final int START = 101;
-	public static final int FINISH = 102;
-	
-	public static final int MANAGE = 60000;
-	public static final int DEBUG = 61000;
-	
-	public static final int TREETOP = MANAGE + 1;
-	public static final int TREELEFT = MANAGE + 2;
-	public static final int TREERIGHT = MANAGE + 3;
-
-	public static final int RINGLEFT = DEBUG + 1;
-	public static final int RINGRIGHT = DEBUG + 2;
-	
-	public static final int DEBUGSTART = DEBUG + 1000;
-	
-	private MetaLinda ml;
-	private String localHostName;
-	private int localPort;
-	private PSXLinda manager;
-	private String managerHostName;
-	private int managerPort = DEFAULTPORT;
-	private boolean running = true;
-	private boolean connected = false;
-	private boolean debugConnected = false;
-	private int nodeId;
-	private HashMap<Integer, Routing> nodes;
-	
-	private int relayNum, relaySize, relayCounter;
-	
-	private Date startTime, endTime;
-	
-	// Callback class
-	class AcceptXMLCallback implements PSXCallback {
-		int tid;
-		
-		private DocumentBuilderFactory dbFactory = null;
-		private DocumentBuilder docBuilder = null;
-		
-		public AcceptXMLCallback(int tid) {
-			this.tid = tid;
-			dbFactory = DocumentBuilderFactory.newInstance();
-			try {
-				docBuilder = dbFactory.newDocumentBuilder();
-			} catch (ParserConfigurationException e) {
-				e.printStackTrace();
-			}
-
-		}
-		public void callback(ByteBuffer reply) {
-			String xml = new String(reply.array());
-			print(xml);
-			parseXML(xml);
-			
-			ml.in(tid, this);
-		}
-		@SuppressWarnings("deprecation")
-		protected void parseXML(String xml) {
-			Document doc = null;
-			try {
-				doc = docBuilder.parse(new StringBufferInputStream(xml));
-			} catch (SAXException e) {
-				e.printStackTrace();
-			} catch (IOException e) {
-				e.printStackTrace();
-			}
-			
-			Element root = doc.getDocumentElement();
-			if(root.getTagName().equals("connections")) {
-				nodeId = Integer.parseInt(root.getAttribute("id"));
-				if (nodeId == 0) {
-					ml.in(START, new StartCallback());
-					ml.in(DEBUGSTART, new DebugStartCallback());
-				}
-				NodeList connections = root.getElementsByTagName("connection");
-				for (int i = 0; i < connections.getLength(); i++) {
-					Element connection = (Element)connections.item(i);
-					Element host = (Element)connection.getElementsByTagName("host").item(0);
-					Element port = (Element)connection.getElementsByTagName("port").item(0);
-					Element t = (Element)connection.getElementsByTagName("tid").item(0);
-					int srcId = Integer.parseInt(connection.getAttribute("id"));
-					String dstHostName = host.getTextContent();
-					int dstPort = Integer.parseInt(port.getAttribute("id"));
-					int dstId = Integer.parseInt(t.getAttribute("id"));
-					try {
-						PSXLindaImpl linda = (PSXLindaImpl) ml.open(dstHostName, dstPort);
-						Routing r = new Routing(linda, dstId);
-						nodes.put(srcId, r);
-						ml.in(srcId, new RoutingCallback(srcId, r));
-					} catch (IOException e) {
-						e.printStackTrace();
-					}
-				}
-			} else if (root.getTagName().equals("routing")) {
-				print("Routing xml received!");
-
-				NodeList routing = root.getElementsByTagName("source");
-				for (int i = 0; i < routing.getLength(); i++) {
-					Element src = (Element) routing.item(i);
-					Integer srcId = Integer.parseInt(src.getAttribute("id"));
-					Routing r = nodes.get(srcId);
-					NodeList dest = src.getElementsByTagName("dest");
-					for (int j = 0; j < dest.getLength(); j++) {
-						Element dst = (Element) dest.item(j);
-						r.route.add(Integer.parseInt(dst.getAttribute("id")));
-					}
-				}
-				
-			}
-			if (tid == MANAGE) connected = true;
-			else if (tid == DEBUG) debugConnected = true;
-			if (connected && debugConnected) {
-				sendLocalHostName();
-				print("Send local host name");
-				connected = debugConnected = false;
-			}
-		}
-		
-	} 
-
-	private class RoutingCallback implements PSXCallback {
-		int tid;
-		Routing routing;
-		
-		public RoutingCallback(int tid, Routing routing) {
-			this.tid = tid;
-			this.routing = routing;
-			ml.out(BODY, ByteBuffer.wrap("dummy".getBytes()));
-		} 
-		
-		public void callback(ByteBuffer reply) {
-			String str = new String(reply.array());
-			print("get message");
-			if (tid == TREETOP || tid == TREELEFT || tid == TREERIGHT) {
-				ml.in(BODY);
-				ml.out(BODY, reply);
-				print("Update body");
-			} else if (str.equals("shutdown") && (tid == RINGLEFT || tid == RINGRIGHT)) {
-				print("get shutdown command id: " + nodeId);
-				if (nodeId != 0) {
-					Routing r = null;
-					if (tid == RINGLEFT) { 
-						r = nodes.get(new Integer(RINGRIGHT));
-					} else if (tid == RINGRIGHT) { 
-						r = nodes.get(new Integer(RINGLEFT));
-					}
-					r.linda.out(r.dstId, ByteBuffer.wrap("shutdown".getBytes()));
-					print("out");
-					ml.fdl.queueExec();
-					print("sync");
-				} else {
-					print("shutdown reaches last node!");
-				}
-				running = false;
-				return;
-			} else if (nodeId == 0 && tid == RINGLEFT) {
-				relayCounter++;
-				print("" + relayCounter + " relay");
-				if (relayCounter >= relayNum) {
-					// 実験終了
-					endTime = new Date();
-					Double resultTime = new Double(((endTime.getTime() - startTime.getTime()) / (double)relayNum)); 
-					ByteBuffer data = ByteBuffer.wrap(resultTime.toString().getBytes());
-					manager.out(MANAGE, data);
-					ml.in(tid, this);
-					return;
-				}
-			}
-				
-			Iterator<Integer> it = routing.route.iterator();
-			while (it.hasNext()) {
-				Integer dstId = it.next();
-				Routing r = nodes.get(dstId);
-				r.linda.out(r.dstId, reply);
-				ml.in(tid, this);
-			}
-		}
-		
-	}
-	
-	private class StartCallback implements PSXCallback {
-		public void callback(ByteBuffer reply) {
-			Routing r;
-			
-			// 子があるならば、子にタプルを伝搬
-			if (nodes.containsKey(TREERIGHT)) {
-				r = nodes.get(TREERIGHT);
-				r.linda.out(r.dstId, reply);
-			}
-			if (nodes.containsKey(TREELEFT)) {
-				r = nodes.get(TREELEFT);
-				r.linda.out(r.dstId, reply);
-			}
-			ml.in(START, this);
-		}
-		
-	}
-	
-	private class DebugStartCallback implements PSXCallback {
-		public void callback(ByteBuffer reply) {
-			String[] commands = new String(reply.array()).split(",");
-			String command = commands[0];
-			if (command.equals("relay")) {
-				relayNum = Integer.parseInt(commands[1]);
-				relaySize = Integer.parseInt(commands[2]);
-				relayCounter = 0;
-				print("relay num=" + relayNum + " size=" + relaySize);
-				Routing r = nodes.get(RINGRIGHT);
-				// 実験開始
-				startTime = new Date();
-				r.linda.out(r.dstId, ByteBuffer.wrap(new byte[relaySize]));
-				ml.in(DEBUGSTART, this);
-			} else if (command.equals("shutdown")) {
-				Routing r = nodes.get(RINGRIGHT);
-				r.linda.out(r.dstId, ByteBuffer.wrap("shutdown".getBytes()));
-				//running = false;
-			}
-		}
-	}
+	private NodeProperty np;
 	
 	// Constructor
 	public MetaProtocolEngine(int port, MetaLinda ml, String managerHostName, int managerPort) {
-		this.ml = ml;
-		this.localPort = port;
-		this.managerHostName = managerHostName;
-		this.managerPort = managerPort;
-		this.nodes = new HashMap<Integer, Routing>();
-		try {
-			this.localHostName = InetAddress.getLocalHost().getHostName();
-		} catch (UnknownHostException e) {
-			e.printStackTrace();
-		}
-		manager = connectServer(this.managerHostName, this.managerPort);
-		sendLocalHostName();
+		this.np = new NodeProperty(port, ml, managerHostName, managerPort);
+		ml.out(TupleId.BODY.id, ByteBuffer.wrap("dummy".getBytes()));
 	}
 
 	public void mainLoop(MetaLinda ml) {
 		initPoller();
-		while (running) {
-			ml.sync(0);
+		while (np.running) {
+			np.ml.sync(0);
 		}
-		print("Terminated" + nodeId
-				+ " replies=" + ml.replies.size()
-				+ " qsize=" + ml.fdl.qsize);
+		Debug.print("Terminated" + np.nodeId
+				+ " replies=" + np.ml.replies.size()
+				+ " qsize=" + np.ml.fdl.qsize);
 	}
 	
 	protected void initPoller() {
-		ml.in(MANAGE, new AcceptXMLCallback(MANAGE));
-		ml.in(DEBUG, new AcceptXMLCallback(DEBUG));
-	}
-	
-	protected void sendLocalHostName() {
-		// TopologyManager に自分のホストネームを送信して、起動を伝える
-		ByteBuffer local = ByteBuffer.wrap((localHostName + ":" + localPort).getBytes());
-		manager.out(MANAGE, local);
+		np.ml.in(TupleId.MANAGE.id, new AcceptXMLCallback(TupleId.MANAGE, np));
+		np.ml.in(TupleId.DEBUG.id, new AcceptXMLCallback(TupleId.DEBUG, np));
 	}
 
-	protected PSXLinda connectServer(String hostName, int port) {
-		PSXLinda linda = null;
-		boolean connectPSX = true;
-		while (connectPSX) {
-			try {
-				linda = ml.open(hostName, port);
-				connectPSX = false;
-			} catch (IOException e) {
-				try {
-					Thread.sleep(40);
-				} catch (InterruptedException e1) {
-				}
-			}
-		}
-		print("Connect to " + hostName);
-		return linda;
-	}
-	
-	void print(String str) {
-		System.err.println("[DEBUG] " + localHostName + ": " + str);
-		System.err.flush();
-	}
-	
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/fdl/test/debug/NodeProperty.java	Mon Oct 11 14:29:37 2010 +0900
@@ -0,0 +1,66 @@
+package fdl.test.debug;
+
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.nio.ByteBuffer;
+import java.util.HashMap;
+
+import fdl.MetaLinda;
+import fdl.PSXLinda;
+
+public class NodeProperty {
+	public static int DEFAULTPORT = 10000;
+	
+	public String localHostName;
+	public int localPort;
+	public PSXLinda manager;
+	public String managerHostName;
+	public int managerPort = DEFAULTPORT;
+
+	public int nodeId;
+	public boolean running = true;
+	public boolean connected = false;
+	public boolean debugConnected = false;
+	public HashMap<TupleId, Routing> nodes = new HashMap<TupleId, Routing>();
+	public MetaLinda ml;
+	
+	public NodeProperty(int port, MetaLinda ml, String managerHostName, int managerPort) {
+		this.ml = ml;
+		this.localPort = port;
+		this.managerHostName = managerHostName;
+		this.managerPort = managerPort;
+		try {
+			this.localHostName = InetAddress.getLocalHost().getHostName();
+		} catch (UnknownHostException e) {
+			e.printStackTrace();
+		}
+		manager = connectServer(this.managerHostName, this.managerPort);
+		sendLocalHostName();
+	}
+	
+	protected void sendLocalHostName() {
+		// TopologyManager に自分のホストネームを送信して、起動を伝える
+		ByteBuffer local = ByteBuffer.wrap((localHostName + ":" + localPort).getBytes());
+		manager.out(TupleId.MANAGE.id, local);
+	}
+	
+	protected PSXLinda connectServer(String hostName, int port) {
+		PSXLinda linda = null;
+		boolean connectPSX = true;
+		while (connectPSX) {
+			try {
+				linda = ml.open(hostName, port);
+				connectPSX = false;
+			} catch (IOException e) {
+				try {
+					Thread.sleep(40);
+				} catch (InterruptedException e1) {
+				}
+			}
+		}
+		Debug.print("Connect to " + hostName);
+		return linda;
+	}
+	
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/fdl/test/debug/RoutingCallback.java	Mon Oct 11 14:29:37 2010 +0900
@@ -0,0 +1,141 @@
+package fdl.test.debug;
+
+import java.nio.ByteBuffer;
+import java.util.Date;
+
+import fdl.PSXCallback;
+import fdl.PSXReply;
+
+class RoutingCallback implements PSXCallback {
+	TupleId tid;
+	Routing routing;
+	NodeProperty np;
+	TreeProperty tp;
+	DebugProperty dp;
+	
+	public RoutingCallback(TupleId tid, Routing routing, NodeProperty np, TreeProperty tp, DebugProperty dp) {
+		this.tid = tid;
+		this.routing = routing;
+		this.np = np;
+		this.tp = tp;
+		this.dp = dp;
+	}
+
+	public void callback(ByteBuffer reply) {
+		Debug.print("get: " + new String(reply.array()));
+		String str = new String(reply.array());
+		String[] commands= str.split(",");
+		switch (tid) {
+		case TREETOP:
+		case TREELEFT:
+		case TREERIGHT:
+			np.ml.in(TupleId.BODY.id);
+			np.ml.out(TupleId.BODY.id, reply);
+			Debug.print("Update body: " + new String(reply.array()));
+			switch (tid) {
+			case TREETOP:
+				Routing r = np.nodes.get(tid);
+				if (r.route.isEmpty()) {
+					// TREE末端の処理
+					r.linda.out(r.dstId, reply); // 送ってきた方に送り返す
+					np.ml.in(tid.id, this);
+					Debug.print("UP! " + np.nodeId);
+					return;
+				}
+				break;
+			default:
+				switch (tid) {
+				case TREELEFT:
+					tp.leftFlag = true;
+					break;
+				case TREERIGHT:
+					tp.rightFlag = true;
+					break;
+				}
+				if (tp.leftFlag && tp.rightFlag) {
+					Debug.print("UP");
+					if (np.nodeId == 0) {
+						if (tp.treeCounter++ < tp.treeLoopNum) {
+							// int num = Integer.parseInt(new String(reply.array()));
+							tp.startTree(ByteBuffer.wrap((""+tp.treeCounter).getBytes()));
+						} else {
+							tp.endTime = new Date();
+							Double resultTime = new Double(((tp.endTime.getTime() - tp.startTime.getTime()) / (double)tp.treeLoopNum)); 
+							ByteBuffer data = ByteBuffer.wrap(resultTime.toString().getBytes());
+							np.manager.out(TupleId.START.id, data);
+							Debug.print("Finish Tree");
+						}
+					} else {
+						Routing r1 = np.nodes.get(TupleId.TREETOP);
+						r1.linda.out(r1.dstId, reply);
+					}
+				}
+				np.ml.in(tid.id, this);
+				return;
+			}
+			break;
+		case RINGLEFT:
+		case RINGRIGHT:
+			if (str.equals("shutdown")) {
+				Debug.print("get shutdown command id: " + np.nodeId);
+				if (np.nodeId != 0) {
+					Routing r = null;
+					r = np.nodes.get(tid.getMirrorId());
+					r.linda.out(r.dstId, ByteBuffer.wrap("shutdown".getBytes()));
+					np.ml.fdl.queueExec();
+				} else {
+					Debug.print("shutdown reaches last node!");
+				}
+				np.running = false;
+				return;
+			} else if (commands[0].equals("print")) {
+				Debug.print("Get Debug Message: print");
+				int printId = Integer.parseInt(commands[1]);
+				PSXReply rep = np.ml.rd(printId);
+				np.ml.sync(1);
+				str += "<debug id=\""
+					+ np.nodeId + "\"><host>"
+					+ np.localHostName + ":" + np.localPort
+					+ "</host><data id=\""
+					+ printId + "\">";
+				if (rep.ready())
+					str += new String(rep.data.array());
+				str += "</data></debug>\n";
+				np.ml.in(tid.id, this);
+				if (np.nodeId == 0) {
+					// 実験終了
+					np.manager.out(TupleId.DEBUG.id, ByteBuffer.wrap(str.getBytes()));
+				} else {
+					Routing r = np.nodes.get(tid.getMirrorId());
+					r.linda.out(r.dstId, ByteBuffer.wrap(str.getBytes()));
+				}
+				return;
+			}
+			break;
+		default:
+			if (np.nodeId == 0 && tid == TupleId.RINGLEFT) {
+				dp.relayCounter++;
+				Debug.print("" + dp.relayCounter + " relay");
+				if (dp.relayCounter >= dp.relayNum) {
+					// 実験終了
+					tp.endTime = new Date();
+					Double resultTime = new Double(((tp.endTime.getTime() - tp.startTime.getTime()) / (double)dp.relayNum)); 
+					ByteBuffer data = ByteBuffer.wrap(resultTime.toString().getBytes());
+					np.manager.out(TupleId.DEBUG.id, data);
+					np.ml.in(tid.id, this);
+					return;
+				}
+			}
+		}
+		for (Integer dstId : routing.route) {
+			if (dstId == TupleId.TREELEFT.id)
+				tp.leftFlag = false;
+			else if (dstId == TupleId.TREERIGHT.id)
+				tp.rightFlag = false;
+			Routing r = np.nodes.get(TupleId.getTupleIdFromId(dstId));
+			r.linda.out(r.dstId, reply);
+		}
+		np.ml.in(tid.id, this);
+	}
+
+}
--- a/src/fdl/test/debug/RoutingXMLBuilder.java	Mon Oct 11 04:43:46 2010 +0900
+++ b/src/fdl/test/debug/RoutingXMLBuilder.java	Mon Oct 11 14:29:37 2010 +0900
@@ -15,8 +15,8 @@
 		routingTable = new HashMap<Integer, Element>();
 	}
 	
-	private Element createRoutingTable(int src) {
-		Integer tupleId = new Integer(src);
+	private Element createRoutingTable(TupleId src) {
+		Integer tupleId = new Integer(src.id);
 		Element source = document.createElement("source");
 		source.setAttribute("id", tupleId.toString());
 		routing.appendChild(source);
@@ -24,12 +24,12 @@
 		return source;
 	}
 	
-	public void appendRoutingTable(int src, int dst) {
-		Element source = routingTable.get(new Integer(src));
+	public void appendRoutingTable(TupleId src, TupleId dst) {
+		Element source = routingTable.get(new Integer(src.id));
 		if (source == null)
 			source = createRoutingTable(src);
 		Element dest = document.createElement("dest");
-		dest.setAttribute("id", new Integer(dst).toString());
+		dest.setAttribute("id", new Integer(dst.id).toString());
 		source.appendChild(dest);
 	}
 	
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/fdl/test/debug/StartCallback.java	Mon Oct 11 14:29:37 2010 +0900
@@ -0,0 +1,27 @@
+package fdl.test.debug;
+
+import java.nio.ByteBuffer;
+import java.util.Date;
+
+import fdl.PSXCallback;
+
+class StartCallback implements PSXCallback {
+	NodeProperty np;
+	TreeProperty tp;
+	
+	public StartCallback(NodeProperty np, TreeProperty tp) {
+		this.np = np;
+		this.tp = tp;
+	}
+	
+	public void callback(ByteBuffer reply) {
+		Debug.print("Start Tree");
+		tp.startTime = new Date();
+		tp = new TreeProperty(np);
+		tp.startTree(reply);
+		np.ml.in(TupleId.BODY.id);
+		np.ml.out(TupleId.BODY.id, reply);
+		np.ml.in(TupleId.START.id, this);
+	}
+
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/fdl/test/debug/TreeProperty.java	Mon Oct 11 14:29:37 2010 +0900
@@ -0,0 +1,30 @@
+package fdl.test.debug;
+
+import java.nio.ByteBuffer;
+import java.util.Date;
+
+public class TreeProperty {
+	public boolean  rightFlag = true, leftFlag = true;
+	public int treeCounter = 0, treeLoopNum = 100;
+	public Date startTime, endTime;
+	public NodeProperty np;
+	
+	public TreeProperty(NodeProperty np) {
+		this.np = np;
+	}
+	
+	public void startTree(ByteBuffer reply) {
+		Routing r;
+		// 子があるならば、子にタプルを伝搬
+		if (np.nodes.containsKey(TupleId.TREERIGHT)) {
+			r = np.nodes.get(TupleId.TREERIGHT);
+			r.linda.out(r.dstId, reply);
+			rightFlag = false;
+		}
+		if (np.nodes.containsKey(TupleId.TREELEFT)) {
+			r = np.nodes.get(TupleId.TREELEFT);
+			r.linda.out(r.dstId, reply);
+			leftFlag = false;
+		}
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/fdl/test/debug/TupleId.java	Mon Oct 11 14:29:37 2010 +0900
@@ -0,0 +1,42 @@
+package fdl.test.debug;
+
+import java.util.HashMap;
+
+public enum TupleId {
+	BODY		(100),
+	START		(BODY.id+1),
+	FINISH		(BODY.id+2),
+	MANAGE		(60000),
+	TREETOP		(MANAGE.id+1),
+	TREELEFT	(MANAGE.id+2) { public TupleId getMirrorId() { return TREERIGHT; } },
+	TREERIGHT	(MANAGE.id+3) { public TupleId getMirrorId() { return TREELEFT; } },
+	DEBUG		(61000),
+	RINGLEFT	(DEBUG.id+1) { public TupleId getMirrorId() { return RINGRIGHT; } },
+	RINGRIGHT	(DEBUG.id+2) { public TupleId getMirrorId() { return RINGLEFT; } },
+	DEBUGSTART	(DEBUG.id+3);
+	
+	public int id;
+	public static HashMap<Integer, TupleId> hash = new HashMap<Integer, TupleId>();
+	
+	private TupleId(int id) {
+		this.id = id;
+	}
+	public TupleId getMirrorId() {
+		return this;
+	}
+	public static TupleId getTupleIdFromId(int id) {
+//		for (TupleId tid : TupleId.values()) {
+//			if (tid.id == id) {
+//				return tid;
+//			}
+//		}
+		return hash.get(id);
+	}
+	
+	static {
+		for (TupleId tid : TupleId.values()) {
+			hash.put(tid.id, tid);
+		}
+	}
+	
+}
--- a/src/fdl/test/debug2/AcceptXMLCallback.java	Mon Oct 11 04:43:46 2010 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,117 +0,0 @@
-package fdl.test.debug2;
-
-import java.io.IOException;
-import java.io.StringReader;
-import java.nio.ByteBuffer;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-
-import fdl.PSXCallback;
-import fdl.PSXLindaImpl;
-
-class AcceptXMLCallback implements PSXCallback {
-	TupleId tid;
-	NodeProperty np;
-	TreeProperty tp;
-	DebugProperty dp;
-	
-	private DocumentBuilderFactory dbFactory = null;
-	private DocumentBuilder docBuilder = null;
-	
-	public AcceptXMLCallback(TupleId tid, NodeProperty np) {
-		this.tid = tid;
-		this.np = np;
-		dbFactory = DocumentBuilderFactory.newInstance();
-		try {
-			docBuilder = dbFactory.newDocumentBuilder();
-		} catch (ParserConfigurationException e) {
-			e.printStackTrace();
-		}
-
-	}
-	public void callback(ByteBuffer reply) {
-		String xml = new String(reply.array());
-		Debug.print(xml);
-		parseXML(xml);
-		
-		np.ml.in(tid.id, this);
-	}
-	protected void parseXML(String xml) {
-		Document doc = null;
-		try {
-			doc = docBuilder.parse(new InputSource(new StringReader(xml)));
-		} catch (SAXException e) {
-			e.printStackTrace();
-		} catch (IOException e) {
-			e.printStackTrace();
-		}
-		
-		Element root = doc.getDocumentElement();
-		if(root.getTagName().equals("connections")) {
-			np.nodeId = Integer.parseInt(root.getAttribute("id"));
-			if (np.nodeId == 0) {
-				np.ml.in(TupleId.START.id, new StartCallback(np, tp = new TreeProperty(np)));
-				np.ml.in(TupleId.DEBUGSTART.id, new DebugStartCallback(np, dp = new DebugProperty()));
-			}
-			NodeList connections = root.getElementsByTagName("connection");
-			makeConnections(connections);
-		} else if (root.getTagName().equals("routing")) {
-			Debug.print("Routing xml received!");
-
-			NodeList routing = root.getElementsByTagName("source");
-			for (int i = 0; i < routing.getLength(); i++) {
-				Element src = (Element) routing.item(i);
-				Integer srcId = Integer.parseInt(src.getAttribute("id"));
-				Routing r = np.nodes.get(TupleId.getTupleIdFromId(srcId));
-				NodeList dest = src.getElementsByTagName("dest");
-				for (int j = 0; j < dest.getLength(); j++) {
-					Element dst = (Element) dest.item(j);
-					r.route.add(Integer.parseInt(dst.getAttribute("id")));
-				}
-			}
-			
-		}
-		switch (tid) {
-		case MANAGE:
-			np.connected = true;
-			break;
-		case DEBUG:
-			np.debugConnected = true;
-			break;
-		}
-		if (np.connected && np.debugConnected) {
-			np.sendLocalHostName();
-			Debug.print("Send local host name");
-			np.connected = np.debugConnected = false;
-		}
-	}
-	private void makeConnections(NodeList connections) {
-		for (int i = 0; i < connections.getLength(); i++) {
-			Element connection = (Element)connections.item(i);
-			Element host = (Element)connection.getElementsByTagName("host").item(0);
-			Element port = (Element)connection.getElementsByTagName("port").item(0);
-			Element t = (Element)connection.getElementsByTagName("tid").item(0);
-			int srcId = Integer.parseInt(connection.getAttribute("id"));
-			String dstHostName = host.getTextContent();
-			int dstPort = Integer.parseInt(port.getAttribute("id"));
-			int dstId = Integer.parseInt(t.getAttribute("id"));
-			try {
-				PSXLindaImpl linda = (PSXLindaImpl) np.ml.open(dstHostName, dstPort);
-				Routing r = new Routing(linda, dstId);
-				np.nodes.put(TupleId.getTupleIdFromId(srcId), r);
-				np.ml.in(srcId, new RoutingCallback(TupleId.getTupleIdFromId(srcId), r, np, tp, dp));
-			} catch (IOException e) {
-				e.printStackTrace();
-			}
-		}
-	}
-	
-} 
--- a/src/fdl/test/debug2/ConfigurationManager.java	Mon Oct 11 04:43:46 2010 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-package fdl.test.debug2;
-
-import java.io.IOException;
-
-import fdl.MetaEngine;
-
-/**
-* ConfigurationManager
-*
-* @author Kazuki Akamine
-*
-* FDLindaNode を管理する Server
-*  
-*/
-
-public class ConfigurationManager {
-	private static int nodeNum = 2;
-	private static int relayNum = 1;
-	private static int relaySize = 1024;
-	private static String usageString
-		= "ConfigurationManager -nodes NODENUM -relay RELAYNUM -size RELAYSIZE";
-	
-	public static void main(String[] args) {
-		for (int i = 0; i < args.length; i++) {
-			if ("-nodes".equals(args[i])) {
-				nodeNum = Integer.parseInt(args[++i]);
-			} else if ("-relay".equals(args[i])) {
-				relayNum = Integer.parseInt(args[++i]);
-			} else if ("-size".equals(args[i])) {
-				relaySize = Integer.parseInt(args[++i]);
-			} else {
-				System.err.println(usageString);
-			}
-		}
-		try {
-			FDLindaNode manager = new FDLindaNode(FDLindaNode.DEFAULTPORT);
-			MetaEngine me = new ConfigurationManagerEngine(manager.getMetaLinda(), nodeNum, relayNum, relaySize);
-			manager.setMetaEngine(me);
-			manager.mainLoop();
-		} catch (IOException e) {
-			e.printStackTrace();
-		}
-	}
-	
-}
--- a/src/fdl/test/debug2/ConfigurationManagerEngine.java	Mon Oct 11 04:43:46 2010 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,173 +0,0 @@
-package fdl.test.debug2;
-
-import java.io.IOException;
-import java.nio.ByteBuffer;
-
-import fdl.*;
-
-public class ConfigurationManagerEngine implements MetaEngine {
-	public static final int DEFAULTPORT = 10000;
-	
-	public int nodeNum = 0;
-	public int relayNum = 0;
-	public int relaySize = 1;
-	private MetaLinda ml;
-	private NodeInfo[] nodes;
-	private boolean running = true;
-	
-	private class AcceptNewNode implements PSXCallback {
-		int count = 0;
-		public void callback(ByteBuffer reply) {
-			String[] hostData = new String(reply.array()).split(":");
-			String hostName = hostData[0];
-			int	port = DEFAULTPORT;
-			if (hostData.length > 1)
-				port = Integer.parseInt(hostData[1]);
-			nodes[count] = new NodeInfo(hostName, port);
-			try {
-				nodes[count].linda = ml.open(hostName, port);
-			} catch (IOException e) {
-				e.printStackTrace();
-			}
-			if (++count < nodeNum) {
-				ml.in(TupleId.MANAGE.id, this);
-			} else {
-				linkNodes();
-				ml.in(TupleId.MANAGE.id, new ConfirmConnectionNode());
-			}
-		}
-	}
-	
-	private class ConfirmConnectionNode implements PSXCallback {
-		int count = 0;
-		public void callback(ByteBuffer reply) {
-			if (++count < nodeNum) {
-				ml.in(TupleId.MANAGE.id, this);
-			} else {
-				routingNodes();
-				ml.in(TupleId.MANAGE.id, new ConfirmRoutingNode());
-			}
-		}
-
-	}
-
-	private class ConfirmRoutingNode implements PSXCallback {
-		int count = 0;
-		public void callback(ByteBuffer reply) {
-			if (++count < nodeNum) {
-				ml.in(TupleId.MANAGE.id, this);
-			} else {
-				print("All link configured!");
-				// TREE実験開始を通知
-				nodes[0].linda.out(TupleId.START.id, ByteBuffer.wrap("0".getBytes()));
-				// DebugRing 開始を通知
-				//nodes[0].linda.out(DEBUGSTART, ByteBuffer.wrap(("print," + BODY + ",").getBytes()));
-				ml.in(TupleId.START.id, new ConfirmFinish());
-			}
-		}
-
-	}
-	
-	private class ConfirmFinish implements PSXCallback {
-		public void callback(ByteBuffer reply) {
-			System.out.println(new String(reply.array()));
-			nodes[0].linda.out(TupleId.DEBUGSTART.id, ByteBuffer.wrap("shutdown".getBytes()));
-			print("Finish token");
-			try {
-				nodes[0].linda.sync(1);
-			} catch (IOException e) {
-				e.printStackTrace();
-			}
-			running = false;
-		}
-
-	}
-
-	private class RingLoop implements PSXCallback {
-		int counter = 0;
-		public void callback(ByteBuffer reply) {
-			nodes[0].linda.out(TupleId.DEBUGSTART.id, ByteBuffer.wrap(("print," + TupleId.BODY.id + ",").getBytes()));
-			print("ring=" + counter + ": \n" + new String(reply.array()));
-			counter++;
-			ml.in(TupleId.DEBUG.id, this);
-		}
-
-	}
-	
-	public ConfigurationManagerEngine(MetaLinda metaLinda, int nodeNum, int relayNum, int relaySize) {
-		// initialize
-		this.ml = metaLinda;
-		this.nodeNum = nodeNum;
-		this.relayNum = relayNum;
-		this.relaySize = relaySize;
-		nodes = new NodeInfo[nodeNum];
-	}
-
-	public void mainLoop(MetaLinda ml1) {
-		// resist poll tuple id
-		ml.in(TupleId.MANAGE.id, new AcceptNewNode());
-		ml.in(TupleId.DEBUG.id, new RingLoop());
-		while (running)
-			ml.sync(0);
-	}
-	
-	private void linkNodes() {
-		for (int i = 0; i < nodes.length; i++) {
-			// XML for Tree Topology
-			ConnectionXMLBuilder tree = new ConnectionXMLBuilder(i);
-			int k;
-			if (i != 0) { // TOP
-				k = (i-1)/2;
-				tree.appendConnection(TupleId.TREETOP, nodes[k].host, nodes[k].port, (i%2 == 0) ? TupleId.TREERIGHT : TupleId.TREELEFT);
-			}
-			if ((k = 2*i+1) < nodes.length) // LEFT
-				tree.appendConnection(TupleId.TREELEFT, nodes[k].host, nodes[k].port, TupleId.TREETOP);
-			if ((k = 2*i+2) < nodes.length) // RIGHT
-				tree.appendConnection(TupleId.TREERIGHT, nodes[k].host, nodes[k].port, TupleId.TREETOP);
-			nodes[i].connectionXML = tree.createXML();
-			nodes[i].linda.out(TupleId.MANAGE.id, ByteBuffer.wrap(nodes[i].connectionXML.getBytes()));
-			print(nodes[i].connectionXML);
-			
-			// XML for Ring Debug Topology
-			ConnectionXMLBuilder debug = new ConnectionXMLBuilder(i);
-			int left = (nodes.length + i - 1) % nodes.length;
-			int right = (i + 1) % nodes.length;
-			debug.appendConnection(TupleId.RINGLEFT, nodes[left].host, nodes[left].port, TupleId.RINGRIGHT);
-			debug.appendConnection(TupleId.RINGRIGHT, nodes[right].host, nodes[right].port, TupleId.RINGLEFT);
-			nodes[i].debugConnectionXML = debug.createXML();
-			nodes[i].linda.out(TupleId.DEBUG.id, ByteBuffer.wrap(nodes[i].debugConnectionXML.getBytes()));
-			print(nodes[i].debugConnectionXML);
-		}
-	}
-	
-	private void routingNodes() {
-		for (int i = 0; i < nodes.length; i++) {
-			RoutingXMLBuilder tree = new RoutingXMLBuilder();
-			if (i != 0) { // TOP
-				if (2*i+1 < nodes.length) { // LEFT
-					tree.appendRoutingTable(TupleId.TREETOP, TupleId.TREELEFT);
-					tree.appendRoutingTable(TupleId.TREELEFT, TupleId.TREETOP);
-				}
-				if (2*i+2 < nodes.length) { // RIGHT
-					tree.appendRoutingTable(TupleId.TREETOP, TupleId.TREERIGHT);
-					tree.appendRoutingTable(TupleId.TREERIGHT, TupleId.TREETOP);
-				}
-			}
-			nodes[i].routingXML = tree.createXML();
-			nodes[i].linda.out(TupleId.MANAGE.id, ByteBuffer.wrap(nodes[i].routingXML.getBytes()));
-			print(nodes[i].routingXML);
-			
-			RoutingXMLBuilder debug = new RoutingXMLBuilder();
-			debug.appendRoutingTable(TupleId.RINGLEFT, TupleId.RINGRIGHT);
-			debug.appendRoutingTable(TupleId.RINGRIGHT, TupleId.RINGLEFT);
-			nodes[i].debugRoutingXML = debug.createXML();
-			nodes[i].linda.out(TupleId.DEBUG.id, ByteBuffer.wrap(nodes[i].debugRoutingXML.getBytes()));
-			print(nodes[i].debugRoutingXML);
-		}
-	}
-	
-	void print(String str) {
-		System.err.println("[DEBUG] ConfigurationManager: " + str);
-	}
-	
-}
--- a/src/fdl/test/debug2/ConnectionXMLBuilder.java	Mon Oct 11 04:43:46 2010 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,31 +0,0 @@
-package fdl.test.debug2;
-
-import org.w3c.dom.*;
-
-public class ConnectionXMLBuilder extends XMLBuilder {
-	private Element connections;
-	
-	public ConnectionXMLBuilder(int id) {
-		super();
-		connections = document.createElement("connections");
-		connections.setAttribute("id", new Integer(id).toString());
-		document.appendChild(connections);
-	}
-	
-	public void appendConnection(TupleId mytid, String host, int port, TupleId tid){
-		Element connection = document.createElement("connection");
-		connection.setAttribute("id", new Integer(mytid.id).toString());
-		Element h = document.createElement("host");
-		h.setTextContent(host);
-		Element p = document.createElement("port");
-		p.setAttribute("id", new Integer(port).toString());
-		Element t = document.createElement("tid");
-		t.setAttribute("id", new Integer(tid.id).toString());
-
-		connections.appendChild(connection);
-		connection.appendChild(h);
-		connection.appendChild(p);
-		connection.appendChild(t);
-	}
-	
-}
--- a/src/fdl/test/debug2/Debug.java	Mon Oct 11 04:43:46 2010 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,21 +0,0 @@
-package fdl.test.debug2;
-
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-
-public class Debug {
-	private static Debug d = new Debug(); // Singleton
-	private String localHostName;
-	private Debug() {
-		try {
-			localHostName = InetAddress.getLocalHost().getHostName();
-		} catch (UnknownHostException e) {
-			e.printStackTrace();
-		}
-	}
-	static void print(String str) {
-		System.err.println("[DEBUG] " + d.localHostName + ": " + str);
-		System.err.flush();
-	}
-	
-}
--- a/src/fdl/test/debug2/DebugProperty.java	Mon Oct 11 04:43:46 2010 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,5 +0,0 @@
-package fdl.test.debug2;
-
-public class DebugProperty {
-	public int relayNum, relaySize, relayCounter;
-}
--- a/src/fdl/test/debug2/DebugStartCallback.java	Mon Oct 11 04:43:46 2010 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,39 +0,0 @@
-package fdl.test.debug2;
-
-import java.nio.ByteBuffer;
-//import java.util.Date;
-
-import fdl.PSXCallback;
-
-class DebugStartCallback implements PSXCallback {
-	public NodeProperty np;
-	public DebugProperty dp;
-	public DebugStartCallback(NodeProperty np, DebugProperty dp) {
-			this.np = np;
-			this.dp = dp;
-	}
-	public void callback(ByteBuffer reply) {
-		String[] commands = new String(reply.array()).split(",");
-		String command = commands[0];
-		if (command.equals("relay")) {
-			dp.relayNum = Integer.parseInt(commands[1]);
-			dp.relaySize = Integer.parseInt(commands[2]);
-			dp.relayCounter = 0;
-			Debug.print("relay num=" + dp.relayNum + " size=" + dp.relaySize);
-			Routing r = np.nodes.get(TupleId.RINGRIGHT);
-			// 実験開始
-			// TODO: startTime?
-			//startTime = new Date();
-			r.linda.out(r.dstId, ByteBuffer.wrap(new byte[dp.relaySize]));
-			np.ml.in(TupleId.DEBUGSTART.id, this);
-		} else if (command.equals("print")) {
-			Routing r = np.nodes.get(TupleId.RINGRIGHT);
-			r.linda.out(r.dstId, reply);
-			Debug.print("Send Debug Message: print");
-			np.ml.in(TupleId.DEBUGSTART.id, this);
-		} else if (command.equals("shutdown")) {
-			Routing r = np.nodes.get(TupleId.RINGRIGHT);
-			r.linda.out(r.dstId, ByteBuffer.wrap("shutdown".getBytes()));
-		}
-	}
-}
\ No newline at end of file
--- a/src/fdl/test/debug2/FDLindaNode.java	Mon Oct 11 04:43:46 2010 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,75 +0,0 @@
-package fdl.test.debug2;
-
-import java.io.IOException;
-
-import fdl.FDLindaServ;
-import fdl.MetaLinda;
-import fdl.MetaEngine;
-
-/**
-* FDLindaNode
-*
-* @author Kazuki Akamine
-*
-* Federated Linda の Topology Node
-* 接続する機能までを実装 MetaEngine は外部から提供される
-*  
-*/
-
-public class FDLindaNode extends FDLindaServ {
-	// Fields
-	private MetaLinda ml;
-	public static final int DEFAULTPORT = 10000;
-	private static String manager;
-	private final static String usageString
-		= "Usage: FDLindaNode -manager SERVERNAME:PORT";
-
-	// Constructor
-	public FDLindaNode(int port) throws IOException {
-		super(port);
-		this.ml = new MetaLinda(tupleSpace, this);
-	}
-	
-	@Override public void mainLoop() {
-		me.mainLoop(ml);
-	}
-	public void setMetaEngine(MetaEngine me) {
-		this.me = me; 
-	}
-	public MetaLinda getMetaLinda() {
-		return ml;
-	}
-	
-	// main routine
-	public static void main(String[] args) {
-		int port = DEFAULTPORT;
-		for (int i = 0; i < args.length; i++) {
-			if ("-manager".equals(args[i])) {
-				manager = args[++i];
-			} else if ("-p".equals(args[i])) {
-				port = new Integer(args[++i]).intValue();
-			} else {
-				System.err.println(usageString);
-			}
-		}
-		
-		String[] managerData = manager.split(":");
-		String managerHostName = managerData[0];
-		int managerPort;
-		if (managerData.length > 1) {
-			managerPort = new Integer(managerData[1]).intValue();
-		} else {
-			managerPort = DEFAULTPORT; 
-		}
-		
-		try {
-			FDLindaNode node = new FDLindaNode(DEFAULTPORT);
-			MetaEngine me = new MetaProtocolEngine(port, node.getMetaLinda(), managerHostName, managerPort);
-			node.setMetaEngine(me);
-			node.mainLoop();
-		} catch (IOException e) {
-			e.printStackTrace();
-		}
-	}
-	
-}
--- a/src/fdl/test/debug2/MetaProtocolEngine.java	Mon Oct 11 04:43:46 2010 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,42 +0,0 @@
-package fdl.test.debug2;
-
-import java.nio.ByteBuffer;
-
-import fdl.*;
-
-/**
-* MetaProtocolEngine
-*
-* @author Kazuki Akamine
-* 
-* 接続する機能までを実装した MetaEngine
-* これを継承して、具体的な処理を書く
-*  
-*/
-
-public class MetaProtocolEngine implements MetaEngine {
-	// Fields
-	private NodeProperty np;
-	
-	// Constructor
-	public MetaProtocolEngine(int port, MetaLinda ml, String managerHostName, int managerPort) {
-		this.np = new NodeProperty(port, ml, managerHostName, managerPort);
-		ml.out(TupleId.BODY.id, ByteBuffer.wrap("dummy".getBytes()));
-	}
-
-	public void mainLoop(MetaLinda ml) {
-		initPoller();
-		while (np.running) {
-			np.ml.sync(0);
-		}
-		Debug.print("Terminated" + np.nodeId
-				+ " replies=" + np.ml.replies.size()
-				+ " qsize=" + np.ml.fdl.qsize);
-	}
-	
-	protected void initPoller() {
-		np.ml.in(TupleId.MANAGE.id, new AcceptXMLCallback(TupleId.MANAGE, np));
-		np.ml.in(TupleId.DEBUG.id, new AcceptXMLCallback(TupleId.DEBUG, np));
-	}
-
-}
--- a/src/fdl/test/debug2/NodeInfo.java	Mon Oct 11 04:43:46 2010 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,17 +0,0 @@
-package fdl.test.debug2;
-
-import fdl.PSXLinda;
-
-public class NodeInfo {
-	public String host;
-	public int port;
-	public PSXLinda linda;
-	public String connectionXML, debugConnectionXML;
-	public String routingXML, debugRoutingXML;
-	
-	public NodeInfo(String host, int port) {
-		this.host = host;
-		this.port = port;
-	}
-	
-}
--- a/src/fdl/test/debug2/NodeProperty.java	Mon Oct 11 04:43:46 2010 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,66 +0,0 @@
-package fdl.test.debug2;
-
-import java.io.IOException;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.nio.ByteBuffer;
-import java.util.HashMap;
-
-import fdl.MetaLinda;
-import fdl.PSXLinda;
-
-public class NodeProperty {
-	public static int DEFAULTPORT = 10000;
-	
-	public String localHostName;
-	public int localPort;
-	public PSXLinda manager;
-	public String managerHostName;
-	public int managerPort = DEFAULTPORT;
-
-	public int nodeId;
-	public boolean running = true;
-	public boolean connected = false;
-	public boolean debugConnected = false;
-	public HashMap<TupleId, Routing> nodes = new HashMap<TupleId, Routing>();
-	public MetaLinda ml;
-	
-	public NodeProperty(int port, MetaLinda ml, String managerHostName, int managerPort) {
-		this.ml = ml;
-		this.localPort = port;
-		this.managerHostName = managerHostName;
-		this.managerPort = managerPort;
-		try {
-			this.localHostName = InetAddress.getLocalHost().getHostName();
-		} catch (UnknownHostException e) {
-			e.printStackTrace();
-		}
-		manager = connectServer(this.managerHostName, this.managerPort);
-		sendLocalHostName();
-	}
-	
-	protected void sendLocalHostName() {
-		// TopologyManager に自分のホストネームを送信して、起動を伝える
-		ByteBuffer local = ByteBuffer.wrap((localHostName + ":" + localPort).getBytes());
-		manager.out(TupleId.MANAGE.id, local);
-	}
-	
-	protected PSXLinda connectServer(String hostName, int port) {
-		PSXLinda linda = null;
-		boolean connectPSX = true;
-		while (connectPSX) {
-			try {
-				linda = ml.open(hostName, port);
-				connectPSX = false;
-			} catch (IOException e) {
-				try {
-					Thread.sleep(40);
-				} catch (InterruptedException e1) {
-				}
-			}
-		}
-		Debug.print("Connect to " + hostName);
-		return linda;
-	}
-	
-}
--- a/src/fdl/test/debug2/Routing.java	Mon Oct 11 04:43:46 2010 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,17 +0,0 @@
-package fdl.test.debug2;
-
-import java.util.LinkedList;
-
-import fdl.*;
-
-public class Routing {
-	PSXLinda linda;
-	int dstId;
-	LinkedList<Integer> route;
-	
-	public Routing(PSXLinda linda, int dstId) {
-		this.linda = linda;
-		this.dstId = dstId;
-		this.route = new LinkedList<Integer>();
-	}
-}
--- a/src/fdl/test/debug2/RoutingCallback.java	Mon Oct 11 04:43:46 2010 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,141 +0,0 @@
-package fdl.test.debug2;
-
-import java.nio.ByteBuffer;
-import java.util.Date;
-
-import fdl.PSXCallback;
-import fdl.PSXReply;
-
-class RoutingCallback implements PSXCallback {
-	TupleId tid;
-	Routing routing;
-	NodeProperty np;
-	TreeProperty tp;
-	DebugProperty dp;
-	
-	public RoutingCallback(TupleId tid, Routing routing, NodeProperty np, TreeProperty tp, DebugProperty dp) {
-		this.tid = tid;
-		this.routing = routing;
-		this.np = np;
-		this.tp = tp;
-		this.dp = dp;
-	}
-
-	public void callback(ByteBuffer reply) {
-		Debug.print("get: " + new String(reply.array()));
-		String str = new String(reply.array());
-		String[] commands= str.split(",");
-		switch (tid) {
-		case TREETOP:
-		case TREELEFT:
-		case TREERIGHT:
-			np.ml.in(TupleId.BODY.id);
-			np.ml.out(TupleId.BODY.id, reply);
-			Debug.print("Update body: " + new String(reply.array()));
-			switch (tid) {
-			case TREETOP:
-				Routing r = np.nodes.get(tid);
-				if (r.route.isEmpty()) {
-					// TREE末端の処理
-					r.linda.out(r.dstId, reply); // 送ってきた方に送り返す
-					np.ml.in(tid.id, this);
-					Debug.print("UP! " + np.nodeId);
-					return;
-				}
-				break;
-			default:
-				switch (tid) {
-				case TREELEFT:
-					tp.leftFlag = true;
-					break;
-				case TREERIGHT:
-					tp.rightFlag = true;
-					break;
-				}
-				if (tp.leftFlag && tp.rightFlag) {
-					Debug.print("UP");
-					if (np.nodeId == 0) {
-						if (tp.treeCounter++ < tp.treeLoopNum) {
-							// int num = Integer.parseInt(new String(reply.array()));
-							tp.startTree(ByteBuffer.wrap((""+tp.treeCounter).getBytes()));
-						} else {
-							tp.endTime = new Date();
-							Double resultTime = new Double(((tp.endTime.getTime() - tp.startTime.getTime()) / (double)tp.treeLoopNum)); 
-							ByteBuffer data = ByteBuffer.wrap(resultTime.toString().getBytes());
-							np.manager.out(TupleId.START.id, data);
-							Debug.print("Finish Tree");
-						}
-					} else {
-						Routing r1 = np.nodes.get(TupleId.TREETOP);
-						r1.linda.out(r1.dstId, reply);
-					}
-				}
-				np.ml.in(tid.id, this);
-				return;
-			}
-			break;
-		case RINGLEFT:
-		case RINGRIGHT:
-			if (str.equals("shutdown")) {
-				Debug.print("get shutdown command id: " + np.nodeId);
-				if (np.nodeId != 0) {
-					Routing r = null;
-					r = np.nodes.get(tid.getMirrorId());
-					r.linda.out(r.dstId, ByteBuffer.wrap("shutdown".getBytes()));
-					np.ml.fdl.queueExec();
-				} else {
-					Debug.print("shutdown reaches last node!");
-				}
-				np.running = false;
-				return;
-			} else if (commands[0].equals("print")) {
-				Debug.print("Get Debug Message: print");
-				int printId = Integer.parseInt(commands[1]);
-				PSXReply rep = np.ml.rd(printId);
-				np.ml.sync(1);
-				str += "<debug id=\""
-					+ np.nodeId + "\"><host>"
-					+ np.localHostName + ":" + np.localPort
-					+ "</host><data id=\""
-					+ printId + "\">";
-				if (rep.ready())
-					str += new String(rep.data.array());
-				str += "</data></debug>\n";
-				np.ml.in(tid.id, this);
-				if (np.nodeId == 0) {
-					// 実験終了
-					np.manager.out(TupleId.DEBUG.id, ByteBuffer.wrap(str.getBytes()));
-				} else {
-					Routing r = np.nodes.get(tid.getMirrorId());
-					r.linda.out(r.dstId, ByteBuffer.wrap(str.getBytes()));
-				}
-				return;
-			}
-			break;
-		default:
-			if (np.nodeId == 0 && tid == TupleId.RINGLEFT) {
-				dp.relayCounter++;
-				Debug.print("" + dp.relayCounter + " relay");
-				if (dp.relayCounter >= dp.relayNum) {
-					// 実験終了
-					tp.endTime = new Date();
-					Double resultTime = new Double(((tp.endTime.getTime() - tp.startTime.getTime()) / (double)dp.relayNum)); 
-					ByteBuffer data = ByteBuffer.wrap(resultTime.toString().getBytes());
-					np.manager.out(TupleId.DEBUG.id, data);
-					np.ml.in(tid.id, this);
-					return;
-				}
-			}
-		}
-		for (Integer dstId : routing.route) {
-			if (dstId == TupleId.TREELEFT.id)
-				tp.leftFlag = false;
-			else if (dstId == TupleId.TREERIGHT.id)
-				tp.rightFlag = false;
-			Routing r = np.nodes.get(TupleId.getTupleIdFromId(dstId));
-			r.linda.out(r.dstId, reply);
-		}
-		np.ml.in(tid.id, this);
-	}
-
-}
--- a/src/fdl/test/debug2/RoutingXMLBuilder.java	Mon Oct 11 04:43:46 2010 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,36 +0,0 @@
-package fdl.test.debug2;
-
-import java.util.*;
-
-import org.w3c.dom.Element;
-
-public class RoutingXMLBuilder extends XMLBuilder {
-	private Element routing;
-	private HashMap<Integer, Element> routingTable;
-	
-	public RoutingXMLBuilder() {
-		super();
-		routing = document.createElement("routing");
-		document.appendChild(routing);
-		routingTable = new HashMap<Integer, Element>();
-	}
-	
-	private Element createRoutingTable(TupleId src) {
-		Integer tupleId = new Integer(src.id);
-		Element source = document.createElement("source");
-		source.setAttribute("id", tupleId.toString());
-		routing.appendChild(source);
-		routingTable.put(tupleId, source);
-		return source;
-	}
-	
-	public void appendRoutingTable(TupleId src, TupleId dst) {
-		Element source = routingTable.get(new Integer(src.id));
-		if (source == null)
-			source = createRoutingTable(src);
-		Element dest = document.createElement("dest");
-		dest.setAttribute("id", new Integer(dst.id).toString());
-		source.appendChild(dest);
-	}
-	
-}
--- a/src/fdl/test/debug2/StartCallback.java	Mon Oct 11 04:43:46 2010 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,27 +0,0 @@
-package fdl.test.debug2;
-
-import java.nio.ByteBuffer;
-import java.util.Date;
-
-import fdl.PSXCallback;
-
-class StartCallback implements PSXCallback {
-	NodeProperty np;
-	TreeProperty tp;
-	
-	public StartCallback(NodeProperty np, TreeProperty tp) {
-		this.np = np;
-		this.tp = tp;
-	}
-	
-	public void callback(ByteBuffer reply) {
-		Debug.print("Start Tree");
-		tp.startTime = new Date();
-		tp = new TreeProperty(np);
-		tp.startTree(reply);
-		np.ml.in(TupleId.BODY.id);
-		np.ml.out(TupleId.BODY.id, reply);
-		np.ml.in(TupleId.START.id, this);
-	}
-
-}
\ No newline at end of file
--- a/src/fdl/test/debug2/TreeProperty.java	Mon Oct 11 04:43:46 2010 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +0,0 @@
-package fdl.test.debug2;
-
-import java.nio.ByteBuffer;
-import java.util.Date;
-
-public class TreeProperty {
-	public boolean  rightFlag = true, leftFlag = true;
-	public int treeCounter = 0, treeLoopNum = 100;
-	public Date startTime, endTime;
-	public NodeProperty np;
-	
-	public TreeProperty(NodeProperty np) {
-		this.np = np;
-	}
-	
-	public void startTree(ByteBuffer reply) {
-		Routing r;
-		// 子があるならば、子にタプルを伝搬
-		if (np.nodes.containsKey(TupleId.TREERIGHT)) {
-			r = np.nodes.get(TupleId.TREERIGHT);
-			r.linda.out(r.dstId, reply);
-			rightFlag = false;
-		}
-		if (np.nodes.containsKey(TupleId.TREELEFT)) {
-			r = np.nodes.get(TupleId.TREELEFT);
-			r.linda.out(r.dstId, reply);
-			leftFlag = false;
-		}
-	}
-}
--- a/src/fdl/test/debug2/TupleId.java	Mon Oct 11 04:43:46 2010 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,42 +0,0 @@
-package fdl.test.debug2;
-
-import java.util.HashMap;
-
-public enum TupleId {
-	BODY		(100),
-	START		(BODY.id+1),
-	FINISH		(BODY.id+2),
-	MANAGE		(60000),
-	TREETOP		(MANAGE.id+1),
-	TREELEFT	(MANAGE.id+2) { public TupleId getMirrorId() { return TREERIGHT; } },
-	TREERIGHT	(MANAGE.id+3) { public TupleId getMirrorId() { return TREELEFT; } },
-	DEBUG		(61000),
-	RINGLEFT	(DEBUG.id+1) { public TupleId getMirrorId() { return RINGRIGHT; } },
-	RINGRIGHT	(DEBUG.id+2) { public TupleId getMirrorId() { return RINGLEFT; } },
-	DEBUGSTART	(DEBUG.id+3);
-	
-	public int id;
-	public static HashMap<Integer, TupleId> hash = new HashMap<Integer, TupleId>();
-	
-	private TupleId(int id) {
-		this.id = id;
-	}
-	public TupleId getMirrorId() {
-		return this;
-	}
-	public static TupleId getTupleIdFromId(int id) {
-//		for (TupleId tid : TupleId.values()) {
-//			if (tid.id == id) {
-//				return tid;
-//			}
-//		}
-		return hash.get(id);
-	}
-	
-	static {
-		for (TupleId tid : TupleId.values()) {
-			hash.put(tid.id, tid);
-		}
-	}
-	
-}
--- a/src/fdl/test/debug2/XMLBuilder.java	Mon Oct 11 04:43:46 2010 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,40 +0,0 @@
-package fdl.test.debug2;
-
-import java.io.*;
-import javax.xml.parsers.*;
-import javax.xml.transform.*;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-import org.w3c.dom.*;
-
-public class XMLBuilder {
-	protected Document document;
-	protected Transformer transformer;
-	public XMLBuilder() {
-		DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
-		DocumentBuilder docBuilder = null;
-		try {
-			docBuilder = dbFactory.newDocumentBuilder();
-		} catch (ParserConfigurationException e) {
-			e.printStackTrace();
-		}
-		document = docBuilder.newDocument();
-		TransformerFactory tFactory = TransformerFactory.newInstance();
-		try {
-			transformer = tFactory.newTransformer();
-			transformer.setOutputProperty(OutputKeys.INDENT, "yes");
-		} catch (TransformerConfigurationException e) {
-			e.printStackTrace();
-		}
-	}
-	
-	public String createXML() {
-		StringWriter sw = new StringWriter();
-		try {
-			transformer.transform(new DOMSource(document), new StreamResult(sw));
-		} catch (TransformerException e) {
-			e.printStackTrace();
-		}
-		return sw.toString();
-	}
-}
--- a/src/fdl/test/metaTransfer/FDLServWithSend.java	Mon Oct 11 04:43:46 2010 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,23 +0,0 @@
-package fdl.test.metaTransfer;
-
-import java.io.IOException;
-
-import fdl.FDLindaServ;
-import fdl.MetaLinda;
-
-
-public class FDLServWithSend extends FDLindaServ {
-	int port1;
-	public FDLServWithSend(int port,int port1) throws IOException {
-		super(port);
-		this.port1 = port1;
-	}
-
-	@Override public void mainLoop() {
-		System.out.println("change mainloop");
-		MetaLinda ml = new MetaLinda(this.tupleSpace,this);
-		MetaProtocolEngine mpe = new MetaProtocolEngine(ml,"MetaEngine", port1);
-		mpe.mainLoop(ml);
-	}
-
-}
--- a/src/fdl/test/metaTransfer/MetaProtocolEngine.java	Mon Oct 11 04:43:46 2010 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,95 +0,0 @@
-package fdl.test.metaTransfer;
-
-import static org.junit.Assert.assertEquals;
-
-import java.io.IOException;
-import java.nio.ByteBuffer;
-
-import fdl.MetaEngine;
-import fdl.MetaLinda;
-import fdl.PSXLinda;
-import fdl.PSXReply;
-
-public class MetaProtocolEngine implements MetaEngine {
-	private int id = 10;
-	private boolean running = true;
-	
-	private PSXLinda psx;
-	private String name;
-	MetaLinda fdl1;
-	String host = "127.0.0.1";
-	int port1;
-	private PSXLinda psx1;
-	private ByteBuffer data2 = ByteBuffer.allocate(10);
-	private int count = 1;
-
-	
-	public MetaProtocolEngine(MetaLinda ml, String string, int port1) {
-		this.name = string;
-		this.port1 = port1;
-		this.fdl1 = ml;
-	}
-
-	public void mainLoop(MetaLinda ml){
-		boolean connect = true;
-		System.out.println("MetaEngine Start");
-		while(connect){
-		try {
-			initConnect();
-			transfer();
-			connect = false;
-		} catch (IOException e) {
-			try {
-				Thread.sleep(40);
-			} catch (InterruptedException e1) {
-			}
-		}
-		}
-	}
-
-	private void initConnect(){
-		System.out.println(name);
-		boolean connectpsx = true;
-		while(connectpsx){
-		try {
-			psx = fdl1.open(host,port1);
-			connectpsx = false;
-		} catch (IOException e) {
-			try {
-				Thread.sleep(40);
-			} catch (InterruptedException e1) {
-				e1.printStackTrace();
-			}
-		}
-		}
-		System.out.println("Connect "+port1);
-		psx1 = fdl1;
-	}
-
-	private void transfer() throws IOException {
-		PSXReply in = psx.in(id);
-		System.out.println("PSXReply "+port1);
-		while (running) {
-			if(in.ready()){
-				data2 = in.getData();
-				int i = data2.getInt();
-				data2.rewind();
-				//outしたbytebufferの変更をこれ以降やっちゃいけない
-				psx1.out(id,data2);
-				
-				System.out.println("IntData0 "+port1 +i);
-				fdl1.sync(0);
-				if (count++>3) {
-					running = false;
-					break;
-				}
-				System.out.println("IntData1 "+port1 +i);
-			}
-			fdl1.sync(0);
-		}
-		assertEquals(4,count);
-	}
-
-	
-}
-
--- a/src/fdl/test/metaTransfer/MetaProtocolEngine_not.java	Mon Oct 11 04:43:46 2010 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,69 +0,0 @@
-package fdl.test.metaTransfer;
-
-import java.io.IOException;
-import java.nio.ByteBuffer;
-
-import fdl.FederatedLinda;
-import fdl.MetaEngine;
-import fdl.MetaLinda;
-import fdl.PSXLinda;
-import fdl.PSXReply;
-
-
-public class MetaProtocolEngine_not implements MetaEngine {
-	private FederatedLinda fdlmeta;
-	private ByteBuffer data = ByteBuffer.allocate(1024);
-	private int id = 10;
-	private boolean running = true;
-	
-	//ここからsend用宣言
-	private PSXLinda sendpsx,getpsx;
-	private String host = "127.0.0.1";
-	private int port;
-			
-	public MetaProtocolEngine_not(MetaLinda fdlmeta, int port) {
-		this.port = port;
-	}
-	
-	public void metaOpen(int sendport){
-		try{
-		sendpsx = fdlmeta.open(host, sendport);
-		}catch (IOException e) {
-			e.printStackTrace();
-		}
-	}
-	
-	//meta部分のデータ取得
-	public void metaTrans() {
-		try {
-			getpsx = fdlmeta.open(host, 10001);
-		} catch (IOException e) {
-			e.printStackTrace();
-		}
-		PSXReply in = getpsx.in(id);
-		while (running) {
-			System.out.println(in);
-			System.out.println(in.ready());
-		if(in.ready()) {
-			data = in.getData();
-			sendpsx.out(id, data);
-			running = false;
-			break;
-		}
-		}
-	}
-
-	
-	public void mainLoop(MetaLinda ml) {
-		System.out.println("MetaProtocolEngine Start");
-		fdlmeta = FederatedLinda.init();
-		if( port == 10002 ) {
-			metaOpen(10003);
-			metaTrans();
-			fdlmeta.sync();
-			System.out.println("MetaProtocolEngine Connect");
-		}
-
-	}
-
-}
--- a/src/fdl/test/metaTransfer/Ring/FDLServWithSend.java	Mon Oct 11 04:43:46 2010 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,22 +0,0 @@
-package fdl.test.metaTransfer.Ring;
-
-import java.io.IOException;
-
-import fdl.FDLindaServ;
-import fdl.MetaLinda;
-
-public class FDLServWithSend extends FDLindaServ {
-	int port1;
-	public FDLServWithSend(int port,int port1) throws IOException {
-		super(port);
-		this.port1 = port1;
-	}
-	
-	@Override public void mainLoop() {
-		System.out.println("change mainloop");
-		MetaLinda ml = new MetaLinda(this.tupleSpace,this);
-		MetaProtocolEngine mpe = new MetaProtocolEngine(ml,"MetaEngine", port1, port1);
-		mpe.mainLoop(ml);
-	}
-
-}
--- a/src/fdl/test/metaTransfer/Ring/MetaProtocolEngine.java	Mon Oct 11 04:43:46 2010 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,100 +0,0 @@
-package fdl.test.metaTransfer.Ring;
-
-//import static org.junit.Assert.assertEquals;
-
-import java.io.IOException;
-import java.nio.ByteBuffer;
-
-import fdl.MetaEngine;
-import fdl.MetaLinda;
-import fdl.PSXLinda;
-import fdl.PSXReply;
-
-public class MetaProtocolEngine implements MetaEngine {
-	int id = 10;
-	private boolean running = true;
-	
-	private PSXLinda psx;
-	private String name;
-	MetaLinda fdl1;
-	String host = "127.0.0.1";
-	int port1;
-	private PSXLinda psx1;
-	private ByteBuffer data = ByteBuffer.allocate(10);
-//	private int count = 1;
-	int port;
-
-	
-	public MetaProtocolEngine(MetaLinda ml, String string, int port1, int port) {
-		this.name = string;
-		this.port1 = port1;
-		this.fdl1 = ml;
-		this.port = port;
-	}
-
-	public void mainLoop(MetaLinda ml){
-		boolean connect = true;
-		System.out.println("MetaEngine Start");
-		while(connect){
-		try {
-			initConnect();
-			transfer(psx, psx1);
-			connect = false;
-		} catch (IOException e) {
-			try {
-				Thread.sleep(40);
-			} catch (InterruptedException e1) {
-			}
-		}
-		}
-	}
-
-	private void initConnect() throws IOException{
-		System.out.println(name);
-		//自分
-		psx = fdl1;
-		if (port == 10001){
-			sendData();
-			}
-		//相手
-		psx1 = fdl1.open(host,port1);
-		System.out.println("Connect "+port1);
-	}
-
-	private void sendData() throws IOException{
-		boolean connectSend = true;
-		ByteBuffer send = ByteBuffer.allocate(1024);
-		send.putInt(12);
-		send.flip();
-		while(connectSend){
-		psx.out(id, send);
-		fdl1.sync(1);
-		System.out.println("Send Data 10001");
-		connectSend = false;
-		}
-	}
-	
-	private void transfer(PSXLinda getpsx, PSXLinda sendpsx) throws IOException {
-		PSXReply in = getpsx.in(id);
-		System.out.println("PSXReply "+port1);
-		while (running) {
-			if(in.ready()){
-				data = in.getData();
-				int i = data.getInt();
-				data.rewind();
-				//outしたbytebufferの変更をこれ以降やっちゃいけない
-				sendpsx.out(id,data);
-				
-				System.out.println("IntData0 "+port1 +i);
-				fdl1.sync(1);
-				running = false;
-				System.out.println("IntData1 "+port1 +i);
-				break;
-			}
-			fdl1.sync(0);
-			}
-//		assertEquals(4,count);
-	}
-
-}
-
--- a/src/fdl/test/metaTransfer/Ring/Server.java	Mon Oct 11 04:43:46 2010 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,39 +0,0 @@
-package fdl.test.metaTransfer.Ring;
-
-import java.io.IOException;
-
-import fdl.FDLindaServ;
-
-public class Server extends Thread {
-	int port1;
-	int port2;
-	int set;
-	private String name;
-	
-	public Server(String string, int i, int t, int s) {
-		port1 = i;
-		port2 = t;
-		name = string;
-		set = s;
-	}
-
-	public void run(){
-		String[] args = {"-p",Integer.toString(port1)};
-		System.out.println(name);
-		switch (set){
-		case 0:
-		try {
-			FDLServWithSend send = new FDLServWithSend(port1,port2);
-			send.mainLoop();
-		} catch (IOException e) {
-			e.printStackTrace();
-		}
-		break;
-		
-		case 1:
-		FDLindaServ.main(args);
-		break;
-		}
-	}
-
-}
\ No newline at end of file
--- a/src/fdl/test/metaTransfer/Ring/TestSend.java	Mon Oct 11 04:43:46 2010 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-package fdl.test.metaTransfer.Ring;
-
-import java.io.IOException;
-import java.nio.ByteBuffer;
-
-import fdl.FederatedLinda;
-import fdl.PSXLinda;
-
-public class TestSend extends Thread {
-	PSXLinda psxsend;
-	FederatedLinda fdlsend;
-	
-	public void run(){
-		int id = 10;
-		int port = 10001;
-		boolean connect = true;
-		String host = "127.0.0.1";
-		ByteBuffer send = ByteBuffer.allocate(1024);
-		send.putInt(12);
-		send.flip();
-		while(connect){
-		try {
-		sendData(id, port, host, send);
-		connect = false;
-		} catch(IOException e) {
-			try {
-				Thread.sleep(40);
-			} catch (InterruptedException e1) {
-				e1.printStackTrace();
-			}
-		}
-		
-		}
-	}
-
-	private void sendData(int id, int port, String host, ByteBuffer send) throws IOException {
-		fdlsend = FederatedLinda.init();
-
-			psxsend = fdlsend.open(host,port);
-			System.out.println("Connect Host1");
-			psxsend.out(id, send);
-			fdlsend.sync(1);
-			System.out.println("Send Data");
-
-	}
-	
-}
--- a/src/fdl/test/metaTransfer/Ring/TestTransfer.java	Mon Oct 11 04:43:46 2010 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +0,0 @@
-package fdl.test.metaTransfer.Ring;
-
-import static org.junit.Assert.assertEquals;
-
-import java.io.IOException;
-
-import org.junit.Test;
-
-public class TestTransfer {
-	@Test
-	public void testTransfer() throws IOException {
-		int port1 = 10001;
-		int port2 = 10002;
-		
-		Server server1 = new Server("Server1",port1, port2,0);
-		server1.start();
-
-		Server server2 = new Server("Server2",port2, port1,1);
-		server2.start();
-		
-		try {
-			server2.join();
-		} catch (InterruptedException e) {
-			e.printStackTrace();
-		}
-		
-		assertEquals(1,1);
-	}
-}
--- a/src/fdl/test/metaTransfer/Ring/TestTransferRing.java	Mon Oct 11 04:43:46 2010 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,40 +0,0 @@
-package fdl.test.metaTransfer.Ring;
-
-import static org.junit.Assert.assertEquals;
-
-import org.junit.Test;
-
-public class TestTransferRing {
-	Server[] servers;
-	final int serverCount = 3;
-	final int startPort = 10001;
-	@Test
-	public void testTransfer() {
-		int port = startPort;
-		
-		servers = new Server[serverCount];
-		
-		for (int i = 0; i < serverCount; i++) {
-			servers[i] = new Server("Server"+(i+1),port+i,netporot(port+i),0);
-			servers[i].start();
-		}
-		
-//		try {
-//			servers[3].join();
-//		} catch (InterruptedException e) {
-//			e.printStackTrace();
-//		}
-		
-
-		assertEquals(1,1);
-	}
-	private int netporot(int i) {
-		i++;
-		if(i >= startPort+serverCount) {
-			return startPort;
-		}
-		
-		return i;
-	}
-}
-
--- a/src/fdl/test/metaTransfer/Ring/TestTransferThree.java	Mon Oct 11 04:43:46 2010 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,22 +0,0 @@
-package fdl.test.metaTransfer.Ring;
-
-import static org.junit.Assert.assertEquals;
-
-import org.junit.Test;
-
-public class TestTransferThree {
-	@Test
-	public void testTransfer() {
-		
-		Server server1 = new Server("Server1", 10001, 10002, 0);
-		server1.start();
-		Server server2 = new Server("Server2", 10002, 10001, 0);
-		server2.start();
-//		Server server3 = new Server("Server3", 10003, 10001, 0);
-//		server3.start();
-
-		assertEquals(1,1);
-	}
-
-}
-
--- a/src/fdl/test/metaTransfer/Server.java	Mon Oct 11 04:43:46 2010 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,20 +0,0 @@
-package fdl.test.metaTransfer;
-
-import fdl.FDLindaServ;
-
-public class Server extends Thread {
-	int port;
-	private String name;
-	
-	public Server(String string, int i) {
-		port = i;
-		name = string;
-	}
-
-	public void run(){
-		String[] args = {"-p",Integer.toString(port)};
-		System.out.println(name);
-		FDLindaServ.main(args);
-	}
-
-}
\ No newline at end of file
--- a/src/fdl/test/metaTransfer/TestSend.java	Mon Oct 11 04:43:46 2010 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-package fdl.test.metaTransfer;
-
-import java.io.IOException;
-import java.nio.ByteBuffer;
-
-import fdl.FederatedLinda;
-import fdl.PSXLinda;
-
-public class TestSend extends Thread {
-	PSXLinda psxsend;
-	FederatedLinda fdlsend;
-	
-	public void run(){
-		int id = 10;
-		int port = 10001;
-		boolean connect = true;
-		String host = "127.0.0.1";
-		ByteBuffer send = ByteBuffer.allocate(1024);
-		send.putInt(12);
-		send.flip();
-		while(connect){
-		try {
-		sendData(id, port, host, send);
-		connect = false;
-		} catch(IOException e) {
-			try {
-				Thread.sleep(40);
-			} catch (InterruptedException e1) {
-				e1.printStackTrace();
-			}
-		}
-		
-		}
-	}
-
-	private void sendData(int id, int port, String host, ByteBuffer send) throws IOException {
-		fdlsend = FederatedLinda.init();
-
-			psxsend = fdlsend.open(host,port);
-			System.out.println("Connect Host1");
-			psxsend.out(id, send);
-			fdlsend.sync(1);
-			System.out.println("Send Data");
-
-	}
-	
-}
--- a/src/fdl/test/metaTransfer/TestTransfer.java	Mon Oct 11 04:43:46 2010 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,27 +0,0 @@
-package fdl.test.metaTransfer;
-
-import static org.junit.Assert.assertEquals;
-
-import java.io.IOException;
-
-import org.junit.Test;
-
-public class TestTransfer {
-	@Test
-	public void testTransfer() throws IOException {
-		int port1 = 10001;
-		int port2 = 10002;
-		
-//		Server server1 = new Server("Server1",port1);
-//		server1.start();
-//
-		Server server2 = new Server("Server2",port2);
-		server2.start();
-		
-
-		FDLServWithSend send = new FDLServWithSend(port1, port2);
-		send.mainLoop();
-		
-		assertEquals(1,1);
-	}
-}
--- a/src/fdl/test/transfer/ProtocolEngine.java	Mon Oct 11 04:43:46 2010 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,74 +0,0 @@
-package fdl.test.transfer;
-
-import java.io.IOException;
-import java.nio.ByteBuffer;
-
-import fdl.FederatedLinda;
-import fdl.PSXLinda;
-import fdl.PSXReply;
-
-
-public class ProtocolEngine extends Thread{
-	private PSXLinda psx;
-	private String name;
-	FederatedLinda fdl1;
-	String host = "127.0.0.1";
-	int port1 = 10001;
-	int port2 = 10002;
-	private int id = 10;
-	private PSXLinda psx1;
-	private boolean running = true;
-	private ByteBuffer data2 = ByteBuffer.allocate(10);
-
-	public ProtocolEngine(String string, int port1, int port2) {
-		this.name = string;
-		this.port1 = port1;
-		this.port2 = port2;
-	}
-
-	public void run(){
-		fdl1 = FederatedLinda.init();
-		try {
-			System.out.println(name);
-			psx = fdl1.open(host,port1);
-			System.out.println("Connect Host1");
-			psx1 = fdl1.open(host,port2);
-			System.out.println("Connect Host2");
-			// Host1にデータを送信する。
-			testSend(psx);
-			// psxにデータを用意
-			transfer(psx,psx1);
-			
-		} catch (IOException e) {
-			e.printStackTrace();
-		}
-	}
-	
-	private void testSend(PSXLinda psx2) throws IOException {
-		ByteBuffer send = ByteBuffer.allocate(10);
-		send.putInt(12);
-		send.flip();
-		psx2.out(id, send);
-		psx2.sync(1);
-	}
-	
-
-	private void transfer(PSXLinda getpsx, PSXLinda sendpsx) throws IOException {
-		PSXReply in = getpsx.in(id);
-		while (running) {
-			System.out.println(in.ready());
-			if(in.ready()){
-				//psx1にデータを書き出し
-				data2 = in.getData();
-				sendpsx.out(id,data2);
-				//runningフラグをfalseする
-				running = false;
-				fdl1.sync(0);
-				break;
-			}
-			fdl1.sync();
-		}
-		
-	}
-
-}
--- a/src/fdl/test/transfer/Server.java	Mon Oct 11 04:43:46 2010 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,20 +0,0 @@
-package fdl.test.transfer;
-
-import fdl.FDLindaServ;
-
-public class Server extends Thread{
-	int port;
-	private String name;
-
-	public Server(String string, int i) {
-		port = i;
-		name = string;
-	}
-
-	public void run(){
-		String[] args = {"-p",Integer.toString(port)};
-		System.out.println(name);
-		FDLindaServ.main(args);
-	}
-
-}
\ No newline at end of file
--- a/src/fdl/test/transfer/TestSend.java	Mon Oct 11 04:43:46 2010 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,33 +0,0 @@
-package fdl.test.transfer;
-
-import java.io.IOException;
-import java.nio.ByteBuffer;
-
-import fdl.FederatedLinda;
-import fdl.PSXLinda;
-
-public class TestSend extends Thread {
-	PSXLinda psxsend;
-	FederatedLinda fdlsend;
-	
-	public void run(){
-		int id = 10;
-		int port = 10001;
-		String host = "127.0.0.1";
-		ByteBuffer send = ByteBuffer.allocate(1024);
-		send.putInt(12);
-		send.flip();
-		fdlsend = FederatedLinda.init();
-		try{
-			psxsend = fdlsend.open(host,port);
-			System.out.println("Connect Host1");
-			psxsend.out(id, send);
-			fdlsend.sync();
-			System.out.println("Send Data");
-		}catch (IOException e) {
-			System.out.println("例外:" + e);
-		}
-		
-	}
-	
-}
--- a/src/fdl/test/transfer/TestTransfer.java	Mon Oct 11 04:43:46 2010 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,25 +0,0 @@
-package fdl.test.transfer;
-
-import static org.junit.Assert.assertEquals;
-
-import org.junit.Test;
-
-public class TestTransfer {
-	@Test
-	public void testTransfer() {
-		int port1 = 10001;
-		int port2 = 10002;
-		Server server1 = new Server("Server1",port1);
-		server1.start();
-		Server server2 = new Server("Server2",port2);
-		server2.start();
-		ProtocolEngine pe = new ProtocolEngine("ProtocolEngine",port1,port2);
-		pe.start();
-		try {
-			pe.join();
-		} catch (InterruptedException e) {
-			e.printStackTrace();
-		}
-		assertEquals(1,1);
-	}
-}
--- a/src/fdl/test/transfer/cluster/FDLServWithSendMeta.java	Mon Oct 11 04:43:46 2010 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,91 +0,0 @@
-package fdl.test.transfer.cluster;
-
-import java.io.BufferedReader;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.io.IOException;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-
-import fdl.FDLindaServ;
-import fdl.MetaLinda;
-
-
-public class FDLServWithSendMeta extends FDLindaServ {
-
-	public FDLServWithSendMeta(int port) throws IOException {
-		super(port);
-	}
-	
-	static String nextHost = null;
-	private static int localport = 10000;
-	static int chknum;
-	private static String bufstring;
-	private static int bufsize;
-	private static String txt;
-	private static int ring;
-	
-	@Override public void mainLoop() {
-		MetaLinda ml = new MetaLinda(tupleSpace, this);
-		MetaProtocolEngine mpe = new MetaProtocolEngine(ml, nextHost, chknum, bufsize, txt);
-		mpe.mainLoop(ml);
-	}
-	
-	public static void main(String[] args){
-		for (int k=0; k<args.length; ++k) {
-			if("-bufsize".equals(args[k])){
-				bufstring = args[++k];
-			} else if("-ring".equals(args[k])){
-				txt = args[++k];
-				ring = Integer.valueOf(txt);
-			} else {
-				System.err.println("引数指定の誤り:未知の引数が指定されました");
-            }
-		}
-		bufsize = Integer.parseInt(bufstring);
-		try {
-			chkhost();
-			FDLServWithSendMeta serv = new FDLServWithSendMeta(localport);
-			serv.mainLoop();
-		} catch (IOException e) {
-			e.printStackTrace();
-		}
-	}
-	
-	private static void chkhost() throws UnknownHostException{
-		String localhost = null;
-		BufferedReader br = null;
-		String hostTable[] = new String[ring+1];
-		try {
-			br = new BufferedReader(new FileReader("nodelist"));
-			int i = 0;
-			while (br.ready()) {
-				String line = br.readLine();
-				hostTable[i] = line;
-				i++;
-			}
-			localhost = InetAddress.getLocalHost().getHostName();
-			for (int j=0; j<hostTable.length; j++) {
-				if(localhost.equals(hostTable[j])){
-					nextHost = hostTable[++j];
-					if(j == ring) {
-						nextHost = hostTable[0];
-					}
-				}
-			}
-			
-			if(localhost.equals(hostTable[0])) {
-				chknum = 1;
-			}
-				
-			System.out.println("localhost:"+localhost);
-			System.out.println("nexthost:"+nextHost);
-		
-		} catch (FileNotFoundException e) {
-			e.printStackTrace();
-		} catch (IOException e){
-			e.printStackTrace();
-		}
-	}
-	
-}
--- a/src/fdl/test/transfer/cluster/HostCheck.java	Mon Oct 11 04:43:46 2010 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,64 +0,0 @@
-package fdl.test.transfer.cluster;
-
-import java.io.BufferedReader;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.io.IOException;
-import java.net.InetAddress;
-
-public class HostCheck {
-	private static String bufstring;
-	private static String txt;
-	private static Integer ring;
-	private static int bufsize;
-	private static String nextHost;
-	private static int chknum;
-
-	public static void main(String[] args) {
-		String localhost = null;
-		BufferedReader br = null;
-		for (int k=0; k<args.length; ++k) {
-			if("-bufsize".equals(args[k])){
-				bufstring = args[++k];
-			} else if("-ring".equals(args[k])){
-				txt = args[++k];
-				ring = Integer.valueOf(txt);
-			} else {
-	        System.err.println("引数指定の誤り:未知の引数が指定されました");
-            }
-		}
-		String hostTable[] = new String[ring+1];
-		bufsize = Integer.parseInt(bufstring);
-		try {
-			br = new BufferedReader(new FileReader("nodelist"));
-			int i = 0;
-			while (br.ready()) {
-				String line = br.readLine();
-				hostTable[i] = line;
-				i++;
-			}
-			localhost = InetAddress.getLocalHost().getHostName();
-			for (int j=0; j<hostTable.length; j++){
-				if(localhost.equals(hostTable[j])){
-				nextHost = hostTable[++j];
-				if(j == ring) {
-					nextHost = hostTable[0];
-				}
-			}
-			}
-			if(localhost.equals(hostTable[0])) {
-				chknum = 1;
-			}
-			
-			System.out.println("localhost:"+localhost);
-			System.out.println("nexthost:"+nextHost);
-
-		} catch (FileNotFoundException e) {
-			e.printStackTrace();
-		} catch (IOException e){
-			e.printStackTrace();
-		}
-		ProtocolEngine pe = new ProtocolEngine(localhost, nextHost,chknum, bufsize, txt);
-		pe.start();
-	}
-}
\ No newline at end of file
--- a/src/fdl/test/transfer/cluster/MetaProtocolEngine.java	Mon Oct 11 04:43:46 2010 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,177 +0,0 @@
-package fdl.test.transfer.cluster;
-
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-import fdl.MetaEngine;
-import fdl.MetaLinda;
-import fdl.PSXLinda;
-import fdl.PSXReply;
-
-public class MetaProtocolEngine implements MetaEngine {
-	private int id = 10;
-
-	private PSXLinda psxget;
-	MetaLinda fdlmeta;
-	String host;
-	int port = 10000;
-	private PSXLinda psxsend;
-	private int chknum;
-
-	SimpleDateFormat DF = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss.SSS");
-
-	private int bufsize;
-
-	private String time;
-	private long timelong;
-	private String start;
-	private String txt;
-	private String transfer;
-	private long transferlong;
-
-	public MetaProtocolEngine(MetaLinda ml, String host, int chknum, int bufsize, String txt) {
-		this.host = host;
-		this.fdlmeta = ml;
-		this.chknum = chknum;
-		this.bufsize = bufsize;
-		this.txt = txt;
-	}
-
-	public void mainLoop(MetaLinda ml){
-		psxget = fdlmeta;
-		if (chknum == 1) {
-			try {
-				sendData();
-				start = DF.format(new Date());
-				System.out.println("Start Time => "+start);
-			} catch (IOException e) {
-				e.printStackTrace();
-			}
-		}
-		boolean connect = true;
-		while(connect){
-			try {
-				initConnect();
-				transfer = DF.format(new Date());
-				transferlong = new Date().getTime();
-				System.out.println("transfer Time => "+transfer);
-				for(int l = 0; l < 1000; l++) {
-					transfer();
-				}
-				dataChk();
-				write();
-				connect = false;
-			} catch (IOException e) {
-				try {
-					Thread.sleep(40);
-				} catch (InterruptedException e1) {
-				}
-			}
-		}
-	}
-
-	private void initConnect(){
-		boolean connectpsx = true;
-		while(connectpsx){
-			try {
-				psxsend = fdlmeta.open(host, port);
-				connectpsx = false;
-			} catch (IOException e) {
-				try {
-					Thread.sleep(40);
-				} catch (InterruptedException e1) {
-					e1.printStackTrace();
-				}
-			}
-		}
-	}
-
-	private void sendData() throws IOException{
-		boolean connectSend = true;
-		ByteBuffer send = ByteBuffer.allocate(bufsize);
-		byte[] fdata = new byte[bufsize];
-		//		fdata = InetAddress.getLocalHost().getAddress();
-		for(int n=0; n < fdata.length; n++ ){
-			fdata[n] = 1;
-		}
-		send.put(fdata);
-		send.flip();
-		while(connectSend){
-			psxget.out(id, send);
-			psxget.sync(1);
-			System.out.println("Send Data");
-			connectSend = false;
-		}
-	}
-
-	public void transfer() throws IOException {
-		ByteBuffer data = ByteBuffer.allocate(bufsize);
-		boolean running = true;
-		PSXReply in = psxget.in(id);
-		while (running) {
-			if(in.ready()){
-				data = in.getData();
-				psxsend.out(id,data);
-				System.out.println("connect to => "+host);
-				psxsend.sync(1);
-				running = false;
-				break;
-			}
-			fdlmeta.sync(0);
-		}
-	}
-
-	public void dataChk() throws IOException{
-		fdlmeta.sync(1);
-		boolean running2 = true;
-		//		ByteBuffer data2 = ByteBuffer.allocate(bufsize);
-		PSXReply in2 = psxget.in(id);
-		//		byte[] fdata2 = new byte[bufsize];
-		//		byte[] fdata3 = new byte[bufsize];
-		//		fdata = InetAddress.getLocalHost().getAddress();
-		//		for(int n=0; n < fdata2.length; n++ ){
-		//			fdata2[n] = 1;
-		//		}
-		while (running2) {
-			psxget.sync(1);
-			if(in2.ready()) {
-				//				data2 = in2.getData();
-				//				data2.get(fdata3);
-				//				if (fdata2 == fdata3){
-				time = DF.format(new Date());
-				timelong = new Date().getTime();
-				System.out.println("Around Time => "+time);
-				//				}
-				running2 = false;
-				break;
-			}
-		}
-	}
-
-
-	public void write() throws IOException{
-		long result = (timelong - transferlong);
-		String diff = String.valueOf(result);
-		File read = new File("resultTime"+bufsize+"_"+txt+".txt");
-		read.createNewFile();
-		FileWriter filewrite = new FileWriter(read);
-		if (start != "null"){
-			filewrite.write("ServerStart => "+start+"\r\n");
-		}
-		if (transfer != "null") {
-			filewrite.write("TransferTime => "+transfer+"\r\n");
-		}
-		if (time != "null"){
-			filewrite.write("AroundTime => "+time+"\r\n");
-		}
-		if (diff != "null"){
-			filewrite.write("DiffTime => "+diff+"\r\n");
-		}
-		filewrite.close();
-	}
-}
-
--- a/src/fdl/test/transfer/cluster/ProtocolEngine.java	Mon Oct 11 04:43:46 2010 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,147 +0,0 @@
-package fdl.test.transfer.cluster;
-
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.net.InetAddress;
-import java.nio.ByteBuffer;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-import fdl.FederatedLinda;
-import fdl.PSXLinda;
-import fdl.PSXReply;
-
-
-public class ProtocolEngine extends Thread{
-	static int id = 10;
-	static FederatedLinda fdl;
-	static PSXLinda getpsx;
-	static PSXLinda sendpsx;
-	static int port = 10000;
-	String getHost = null;
-	String sendHost = null;
-	private int chknum;
-	private int bufsize;
-	private String txt;
-	SimpleDateFormat DF = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss.SSS");
-	private String time;
-	private long timelong;
-	private String start;
-	private String transfer;
-	private long transferlong;
-	
-	public ProtocolEngine(String gethost, String sendhost, int chknum, int bufsize, String txt) {
-		this.getHost = gethost;
-		this.sendHost = sendhost;
-		this.chknum = chknum;
-		this.bufsize = bufsize;
-		this.txt = txt;
-	}
-
-	public void run(){
-		fdl = FederatedLinda.init();
-		try {
-			getpsx = fdl.open(getHost,port);
-			System.out.println("Connect Host1");
-			sendpsx = fdl.open(sendHost,port);
-			System.out.println("Connect Host2");
-			// Host1にデータを送信する。
-			if(chknum == 1){
-			testSend(getpsx);
-			start = DF.format(new Date());
-			System.out.println("Start Time => "+start);
-			}
-			// psxにデータを用意
-			transfer(getpsx,sendpsx);
-			dataChk();
-			write();
-			
-		} catch (IOException e) {
-			e.printStackTrace();
-		}
-	}
-	
-	private void write() throws IOException {
-		long result = (timelong - transferlong);
-		String diff = String.valueOf(result);
-		File read = new File("resultTime"+bufsize+"_"+txt+".txt");
-		read.createNewFile();
-		FileWriter filewrite = new FileWriter(read);
-		if (start != "null"){
-		filewrite.write("ServerStart => "+start+"\r\n");
-		}
-		if (transfer != "null") {
-		filewrite.write("TransferTime => "+transfer+"\r\n");
-		}
-		if (time != "null"){
-		filewrite.write("AroundTime => "+time+"\r\n");
-		}
-		if (diff != "null"){
-		filewrite.write("DiffTime => "+diff+"\r\n");
-		}
-		filewrite.close();
-	}
-
-	private void dataChk() throws IOException {
-		fdl.sync(1);
-		boolean running2 = true;
-		ByteBuffer data3 = ByteBuffer.allocate(bufsize);
-		PSXReply in2 = getpsx.in(id);
-		int localhost2 = InetAddress.getLocalHost().hashCode();
-		while (running2) {
-			getpsx.sync(1);
-			if(in2.ready()) {
-			data3 = in2.getData();
-			int i = data3.getInt();
-			if (i == localhost2){
-				time = DF.format(new Date());
-				timelong = new Date().getTime();
-				System.out.println("Around Time => "+time);
-			}
-			running2 = false;
-			break;
-			}
-		}
-		
-	}
-
-	private void testSend(PSXLinda psx2) throws IOException {
-		boolean connectSend = true;
-		ByteBuffer send = ByteBuffer.allocate(bufsize);
-		int localhost = InetAddress.getLocalHost().hashCode();
-		send.putInt(localhost);
-		send.flip();
-		while(connectSend){
-		psx2.out(id, send);
-		psx2.sync(1);
-		System.out.println("Send Data");
-		connectSend = false;
-		}
-	}
-	
-
-	private void transfer(PSXLinda getpsx, PSXLinda sendpsx) throws IOException {
-		ByteBuffer data2 = ByteBuffer.allocate(bufsize);
-		PSXReply in = getpsx.in(id);
-		boolean running = true;
-		while (running) {
-			if(in.ready()){
-				//psx1にデータを書き出し
-				data2 = in.getData();
-				sendpsx.out(id,data2);
-				//runningフラグをfalseする
-				running = false;
-				transfer = DF.format(new Date());
-				transferlong = new Date().getTime();
-				System.out.println("transfer Time => "+transfer);
-				System.out.println("connect to => "+sendHost);
-				sendpsx.sync(1);
-				break;
-			}
-			fdl.sync();
-		}
-		
-	}
-
-}
--- a/src/fdl/test/transfer/cluster/ProtocolEngineMain.java	Mon Oct 11 04:43:46 2010 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,72 +0,0 @@
-package fdl.test.transfer.cluster;
-
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-import fdl.FederatedLinda;
-import fdl.PSXLinda;
-import fdl.PSXReply;
-
-public class ProtocolEngineMain {
-	static int id = 10;
-	static FederatedLinda fdl;
-	static PSXLinda getpsx;
-	static PSXLinda sendpsx;
-	static int port = 10000;
-	private static String getHost = null;
-	private static String sendHost = null;
-	
-	public static void main(String[] args) {
-		for (int i=0; i<args.length; ++i) {
-			if("-get".equals(args[i])){
-				getHost = args[++i];
-			} else if("-send".equals(args[i])){
-				sendHost = args[++i];
-			} else {
-	        System.err.println("引数指定の誤り:未知の引数が指定されました");
-            }
-		}
-		fdl = FederatedLinda.init();
-		try {
-			getpsx = fdl.open(getHost,port);
-			System.out.println("Connect Host1");
-			sendpsx = fdl.open(sendHost,port);
-			System.out.println("Connect Host2");
-			// Host1にデータを送信する。
-//			ByteBuffer send = ByteBuffer.allocate(10);
-//			send.putInt(12);
-//			send.flip();
-//			getpsx.out(id , send);
-//			fdl.sync(1);
-//			System.out.println("Send Data");
-			// psxにデータを用意
-			boolean running = true;
-			ByteBuffer data2 = ByteBuffer.allocate(10);
-			PSXReply in = getpsx.in(id);
-			while (running) {
-				if(in.ready()){
-					//psx1にデータを書き出し
-					data2 = in.getData();
-					sendpsx.out(id,data2);
-					int i = data2.getInt();
-					data2.rewind();
-					System.out.println("transfer Data => "+i);
-					//runningフラグをfalseする
-					running = false;
-					sendpsx.sync(1);
-					System.out.println("Transfer Data");
-					break;
-				}
-				SimpleDateFormat DF = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss.SSS");
-				System.out.println(DF.format(new Date()));
-				fdl.sync();
-			}
-			
-		} catch (IOException e) {
-			e.printStackTrace();
-		}
-	}
-
-}
--- a/src/fdl/test/transfer/cluster/Server.java	Mon Oct 11 04:43:46 2010 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,16 +0,0 @@
-package fdl.test.transfer.cluster;
-
-import fdl.FDLindaServ;
-
-public class Server extends Thread{
-	int port;
-
-	public Server() {
-	}
-
-	public void run(){
-		String[] args = {"-p",Integer.toString(port)};
-		FDLindaServ.main(args);
-	}
-
-}
\ No newline at end of file
--- a/src/fdl/test/transfer/cluster/ServerMain.java	Mon Oct 11 04:43:46 2010 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,12 +0,0 @@
-package fdl.test.transfer.cluster;
-
-import fdl.FDLindaServ;
-
-public class ServerMain{	
-	public static void main(String[] args){
-		int port = 10000;
-		String[] args1 = {"-p",Integer.toString(port)};
-		FDLindaServ.main(args1);
-	}
-
-}
\ No newline at end of file
--- a/src/fdl/test/transfer/cluster/TestGet.java	Mon Oct 11 04:43:46 2010 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,48 +0,0 @@
-package fdl.test.transfer.cluster;
-
-import java.io.IOException;
-import java.nio.ByteBuffer;
-
-import fdl.FederatedLinda;
-import fdl.PSXLinda;
-import fdl.PSXReply;
-
-
-public class TestGet extends Thread {
-	private PSXLinda psxget;
-	private FederatedLinda fdlget;
-	private int port;
-	String host = "127.0.0.1";
-	private ByteBuffer data = ByteBuffer.allocate(1024);
-	
-	public TestGet(int port1) {
-		this.port = port1;
-	}
-	
-	public void run(){
-		int id = 10;
-		int i;
-		fdlget = FederatedLinda.init();
-		try {
-			System.out.println("TestGet Start");
-			psxget = fdlget.open(host, port);
-			System.out.println("Host1 connected");
-			//getにidのタプルを取り出す
-			PSXReply dataGet = psxget.in(id);
-			System.out.println("dataget");
-			System.out.println(dataGet.ready());
-			if(dataGet.ready()){
-				System.out.println(dataGet);
-				data = dataGet.getData();
-				fdlget.sync(1);
-				i = data.getInt();
-				System.out.println(i);
-			}
-		} catch (IOException e) {
-			try {
-				Thread.sleep(10);
-			} catch (InterruptedException e1) {
-			}
-		}
-		}
-}
--- a/src/fdl/test/transfer/cluster/TestSend.java	Mon Oct 11 04:43:46 2010 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,46 +0,0 @@
-package fdl.test.transfer.cluster;
-
-import java.io.IOException;
-import java.nio.ByteBuffer;
-
-import fdl.FederatedLinda;
-import fdl.PSXLinda;
-
-public class TestSend {
-	static PSXLinda psxsend;
-	static FederatedLinda fdlsend;
-	private static int port = 10000;
-
-	public static void main(String[] args){
-		int id = 10;
-		int i;
-		String host = "cls001.cs.ie.u-ryukyu.ac.jp";
-		ByteBuffer send = ByteBuffer.allocate(1024);
-		send.putInt(12);
-		send.flip();
-		i = send.getInt();
-		send.rewind();
-		fdlsend = FederatedLinda.init();
-		boolean connect = true;
-		while(connect) {
-		try{
-			System.out.println("TestSend Start");
-			psxsend = fdlsend.open(host,port);
-			System.out.println("Set Data = " +i);
-			System.out.println("Connect Host1");
-			psxsend.out(id, send);
-			System.out.println("regist Que");
-			fdlsend.sync();
-			System.out.println("Send Data");
-			connect = false;
-		}catch (IOException e) {
-			try {
-				Thread.sleep(40);
-			} catch (InterruptedException e1) {
-			}
-		}
-		}
-	}
-
-	
-}
--- a/src/fdl/test/transfer/three/ProtocolEngine.java	Mon Oct 11 04:43:46 2010 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,82 +0,0 @@
-package fdl.test.transfer.three;
-
-import static org.junit.Assert.assertEquals;
-
-import java.io.IOException;
-import java.nio.ByteBuffer;
-
-import fdl.FederatedLinda;
-import fdl.PSXLinda;
-import fdl.PSXReply;
-
-
-public class ProtocolEngine extends Thread{
-	private PSXLinda psx;
-	private String name;
-	FederatedLinda fdl1;
-	String host = "127.0.0.1";
-	int port1;
-	int port2;
-	private int id = 10;
-	private PSXLinda psx1;
-	private boolean running = true;
-	private ByteBuffer data2 = ByteBuffer.allocate(10);
-	private int count = 1;
-
-	public ProtocolEngine(String string, int port1, int port2) {
-		this.name = string;
-		this.port1 = port1;
-		this.port2 = port2;
-	}
-
-	public void run(){
-		fdl1 = FederatedLinda.init();
-		boolean connect = true;
-		while(connect){
-		try {
-			initConnect();
-			transfer();
-			connect = false;
-		} catch (IOException e) {
-			try {
-				Thread.sleep(40);
-			} catch (InterruptedException e1) {
-			}
-		}
-		}
-	}
-
-	private void initConnect() throws IOException {
-		System.out.println(name);
-		psx = fdl1.open(host,port1);
-		System.out.println("Connect "+port1);
-		psx1 = fdl1.open(host,port2);
-		System.out.println("Connect "+port2);
-	}
-
-	private void transfer() throws IOException {
-		PSXReply in = psx.in(id);
-		System.out.println("PSXReply "+port1 +": "+port2 +": ");
-		while (running) {
-			if(in.ready()){
-				data2 = in.getData();
-				int i = data2.getInt();
-				data2.rewind();
-				//outしたbytebufferの変更をこれ以降やっちゃいけない
-				psx1.out(id,data2);
-				
-				System.out.println("IntData0 "+port1 +": "+port2 +": " +i);
-				fdl1.sync(1);
-				if (count++>3) {
-					running = false;
-					break;
-				}
-				System.out.println("IntData1 "+port1 +": "+port2 +": " +i);
-			}
-			fdl1.sync();
-		}
-		assertEquals(4,count);
-	}
-	
-
-}
--- a/src/fdl/test/transfer/three/Server.java	Mon Oct 11 04:43:46 2010 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,20 +0,0 @@
-package fdl.test.transfer.three;
-
-import fdl.FDLindaServ;
-
-public class Server extends Thread {
-	int port;
-	private String name;
-
-	public Server(String string, int i) {
-		port = i;
-		name = string;
-	}
-
-	public void run(){
-		String[] args = {"-p",Integer.toString(port)};
-		System.out.println(name+"start");
-		FDLindaServ.main(args);
-	}
-
-}
\ No newline at end of file
--- a/src/fdl/test/transfer/three/TestGet.java	Mon Oct 11 04:43:46 2010 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,55 +0,0 @@
-package fdl.test.transfer.three;
-
-import java.io.IOException;
-import java.nio.ByteBuffer;
-
-import fdl.FederatedLinda;
-import fdl.PSXLinda;
-import fdl.PSXReply;
-
-
-public class TestGet extends Thread {
-	PSXLinda psxget;
-	FederatedLinda fdlget;
-	private int port;
-	String host = "127.0.0.1";
-	private ByteBuffer data = ByteBuffer.allocate(10);
-	
-	public TestGet(int port1) {
-		this.port = port1;
-	}
-	
-	public void run(){
-		int id = 10;
-		int i;
-		fdlget = FederatedLinda.init();
-		boolean connecttest = true;
-		while(connecttest){
-		try {
-			getData(id);
-			i = data.getInt();
-			System.out.println(i);
-			connecttest = false;
-		} catch (IOException e) {
-				e.printStackTrace();
-				connecttest = true;
-		}
-		}
-	}
-
-	private void getData(int id) throws IOException {
-		psxget = fdlget.open(host, port);
-		PSXReply get = psxget.in(id);
-		boolean running = false;
-		while(running){
-			if(get.ready()){
-				data = get.getData();
-				running = false;
-				fdlget.sync(0);
-				break;
-			}
-		fdlget.sync();
-		}
-	}
-	
-}
--- a/src/fdl/test/transfer/three/TestSend.java	Mon Oct 11 04:43:46 2010 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,48 +0,0 @@
-package fdl.test.transfer.three;
-
-import java.io.IOException;
-import java.nio.ByteBuffer;
-
-import fdl.FederatedLinda;
-import fdl.PSXLinda;
-
-public class TestSend extends Thread {
-	PSXLinda psxsend;
-	FederatedLinda fdlsend;
-	private int port;
-	
-	public TestSend(int port1) {
-		this.port = port1;
-	}
-
-	public void run(){
-		int id = 10;
-		int i;
-		String host = "127.0.0.1";
-		ByteBuffer send = ByteBuffer.allocate(1024);
-		send.putInt(12);
-		send.flip();
-		i = send.getInt();
-		send.rewind();
-		fdlsend = FederatedLinda.init();
-		boolean connect = true;
-		while(connect) {
-		try{
-			psxsend = fdlsend.open(host,port);
-			System.out.println("Set Data = " +i);
-			System.out.println("Connect Host1");
-			psxsend.out(id, send);
-			System.out.println("regist Que");
-			fdlsend.sync(1);
-			System.out.println("Send Data");
-			connect = false;
-		}catch (IOException e) {
-			try {
-				Thread.sleep(20);
-			} catch (InterruptedException e1) {
-			}
-		}
-		}
-	}
-	
-}
--- a/src/fdl/test/transfer/three/TestTransfer.java	Mon Oct 11 04:43:46 2010 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,52 +0,0 @@
-package fdl.test.transfer.three;
-
-import static org.junit.Assert.assertEquals;
-
-import org.junit.Test;
-
-
-public class TestTransfer {
-	Server[] servers;
-	ProtocolEngine[] engines;
-	final int serverCount = 3;
-	final int startPort = 10011;
-	@Test
-	public void testTransfer() {
-		int port = startPort;
-		servers = new Server[serverCount];
-		engines = new ProtocolEngine[serverCount];
-		
-		for (int i = 0; i < serverCount; i++) {
-			servers[i] = new Server("Server"+(i+1),port+i);
-			servers[i].start();
-		}
-		
-		TestSend send = new TestSend(startPort);
-		send.start();
-		try{
-			send.join();
-		} catch (InterruptedException e) {
-			e.printStackTrace();
-		}
-		
-		for (int i = 0; i < serverCount; i++) {
-			engines[i] = new ProtocolEngine("ProtocolEngine "+(i+1) +":port " +(port+i) +":port "+(netporot(port+i)),port+i,netporot(port+i));
-			engines[i].start();
-		}
-		try {
-			for (ProtocolEngine e: engines){
-				e.join();
-			}
-		} catch (InterruptedException e) {
-			e.printStackTrace();
-		}
-		assertEquals(1,1);
-	}
-	private int netporot(int i) {
-		i++;
-		if(i >= startPort+serverCount) {
-			return startPort;
-		}
-		return i;
-	}
-}
--- a/src/fdl/test/transfer/two/ProtocolEngine.java	Mon Oct 11 04:43:46 2010 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,67 +0,0 @@
-package fdl.test.transfer.two;
-
-import java.io.IOException;
-import java.nio.ByteBuffer;
-
-import fdl.FederatedLinda;
-import fdl.PSXLinda;
-import fdl.PSXReply;
-
-
-public class ProtocolEngine extends Thread{
-	private static PSXLinda psx;
-	private static String name;
-	static FederatedLinda fdl1;
-	static String host = "127.0.0.1";
-	static int port1 = 10001;
-	static int port2 = 10002;
-	private static int id = 10;
-	private static PSXLinda psx1;
-	private static boolean running;
-	private static ByteBuffer data2 = ByteBuffer.allocate(10);
-
-	public static void main(String[] args){
-		fdl1 = FederatedLinda.init();
-		try {
-			System.out.println(name);
-			psx = fdl1.open(host,port1);
-			System.out.println("Connect Host1");
-			psx1 = fdl1.open(host,port2);
-			System.out.println("Connect Host2");
-			// Host1にデータを送信する。
-			testSend(psx);
-			// psxにデータを用意
-			transfer(psx,psx1);
-			
-		} catch (IOException e) {
-			e.printStackTrace();
-		}
-	}
-	
-	private static void testSend(PSXLinda psx2) throws IOException {
-		ByteBuffer send = ByteBuffer.allocate(10);
-		send.putInt(12);
-		send.flip();
-		psx2.out(id, send);
-		psx2.sync(0);
-	}
-	
-
-	private static void transfer(PSXLinda psx2, PSXLinda psx12) throws IOException {
-		PSXReply in = psx2.in(id);
-		while (running) {
-			if(in.ready()){
-				//psx1にデータを書き出し
-				data2 = in.getData();
-				psx12.out(id,data2);
-				//runningフラグをfalseする
-				running = false;
-				fdl1.sync(0);
-				break;
-			}
-			fdl1.sync();
-		}
-		
-	}
-
-}
--- a/src/fdl/test/transfer/two/Server.java	Mon Oct 11 04:43:46 2010 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,20 +0,0 @@
-package fdl.test.transfer.two;
-
-import fdl.FDLindaServ;
-
-public class Server extends Thread {
-	int port;
-	private String name;
-
-	public Server(String string, int i) {
-		port = i;
-		name = string;
-	}
-
-	public void run(){
-		String[] args = {"-p",Integer.toString(port)};
-		System.out.println(name);
-		FDLindaServ.main(args);
-	}
-
-}
\ No newline at end of file
--- a/src/fdl/test/transfer/two/TestGet.java	Mon Oct 11 04:43:46 2010 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,44 +0,0 @@
-package fdl.test.transfer.two;
-
-import java.io.IOException;
-import java.nio.ByteBuffer;
-
-import fdl.FederatedLinda;
-import fdl.PSXLinda;
-import fdl.PSXReply;
-
-
-public class TestGet extends Thread {
-	private static PSXLinda psxget;
-	private static FederatedLinda fdlget;
-	private static int port = 10001;
-	static String host = "127.0.0.1";
-	private static ByteBuffer data = ByteBuffer.allocate(1024);
-	
-	public static void main(String[] args){
-		int id = 10;
-		int i;
-		fdlget = FederatedLinda.init();
-		try {
-			System.out.println("TestGet Start");
-			psxget = fdlget.open(host, port);
-			System.out.println("Host1 connected");
-			//getにidのタプルを取り出す
-			PSXReply dataGet = psxget.in(id);
-			System.out.println("dataget");
-			System.out.println(dataGet.ready());
-			if(dataGet.ready()){
-				System.out.println(dataGet);
-				data = dataGet.getData();
-				fdlget.sync(1);
-				i = data.getInt();
-				System.out.println(i);
-			}
-		} catch (IOException e) {
-			try {
-				Thread.sleep(10);
-			} catch (InterruptedException e1) {
-			}
-		}
-		}
-}
--- a/src/fdl/test/transfer/two/TestSend.java	Mon Oct 11 04:43:46 2010 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,50 +0,0 @@
-package fdl.test.transfer.two;
-
-import java.io.IOException;
-import java.nio.ByteBuffer;
-
-import fdl.FederatedLinda;
-import fdl.PSXLinda;
-
-public class TestSend extends Thread {
-	PSXLinda psxsend;
-	FederatedLinda fdlsend;
-	private int port;
-	
-	public TestSend(int port1) {
-		this.port = port1;
-	}
-
-	public void run(){
-		int id = 10;
-		int i;
-		String host = "127.0.0.1";
-		ByteBuffer send = ByteBuffer.allocate(1024);
-		send.putInt(12);
-		send.flip();
-		i = send.getInt();
-		send.rewind();
-		fdlsend = FederatedLinda.init();
-		boolean connect = true;
-		while(connect) {
-		try{
-			System.out.println("TestSend Start");
-			psxsend = fdlsend.open(host,port);
-			System.out.println("Set Data = " +i);
-			System.out.println("Connect Host1");
-			psxsend.out(id, send);
-			System.out.println("regist Que");
-			fdlsend.sync(1);
-			System.out.println("Send Data");
-			connect = false;
-		}catch (IOException e) {
-			try {
-				Thread.sleep(40);
-			} catch (InterruptedException e1) {
-			}
-		}
-		}
-	}
-
-	
-}
--- a/src/fdl/test/transfer/two/TestTransfer.java	Mon Oct 11 04:43:46 2010 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,21 +0,0 @@
-package fdl.test.transfer.two;
-
-import static org.junit.Assert.assertEquals;
-
-import org.junit.Test;
-
-public class TestTransfer {
-	@Test
-	public void testTransfer() throws InterruptedException {
-		int port = 10001;
-		Server server = new Server("Server1",port);
-		server.start();
-		server.join();
-		TestSend send = new TestSend(port);
-		send.start();
-
-		send.join();
-
-		assertEquals(1,1);
-	}
-}
--- a/src/fdl/test2/CountTest.java	Mon Oct 11 04:43:46 2010 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,42 +0,0 @@
-package fdl.test2;
-
-class CountA implements Runnable {
-
-	public void run() {
-		for (int i=0; i <= 5; i++) {
-			System.out.println("A: " + i);
-		}
-	}
-}
-
-class CountB implements Runnable {
-
-	public void run() {
-		for (int i=5; i >= 0; i--) {
-			System.out.println("	B: " + i);
-		}
-	}
-}
-
-class CountTest {
-	public static void main(String[] args) {
-		// ランナブルクラスのインスタンス化
-		CountA runA = new CountA();
-		CountB runB = new CountB();
-		System.out.println("Runnable Class のインスタンス化終了");
-
-		// スレッドのインスタンス化
-		Thread threadA = new Thread(runA);
-		Thread threadB = new Thread(runB);
-		System.out.println("Thread へ受け渡し終了");
-
-		// スレッドの開始
-		threadA.start();
-		threadB.start();
-		System.out.println("Thread の start() 終了");
-		System.out.println("適時自動的に run() が実行される");
-
-
-	}
-}
-
--- a/src/fdl/test2/Server.java	Mon Oct 11 04:43:46 2010 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +0,0 @@
-package fdl.test2;
-
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.net.ServerSocket;
-import java.net.Socket;
-import java.util.Date;
-
-public class Server extends Thread{
-	static int Port = 10007;
-    
-	public void run(){
-		try {
-		ServerSocket server = new ServerSocket(Port);
-		Socket sock =null;
-		System.out.println("Server Start");
-		sock = server.accept();
-		System.out.println("Connect");
-		PrintWriter ps = new PrintWriter(sock.getOutputStream());
-		Date d = new Date();
-		ps.print(d + "\r\n");
-		ps.flush();
-		sock.close(); // クライアントからの接続を切断
-	    System.out.println("Connection Closed");
-		} catch (IOException e) {
-			// TODO Auto-generated catch block
-			e.printStackTrace();
-		}
-	} 
-
-    public static void main(String[] args) {
-    	Server sv = new Server();
-    	sv.start();
-    }
-}
\ No newline at end of file
--- a/src/fdl/test2/TestRead.java	Mon Oct 11 04:43:46 2010 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,26 +0,0 @@
-package fdl.test2;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-
-public class TestRead {
-
-	    public static void main(String[] args) {
-	        try {
-	        	File inputFile = new File(args[0]);
-	        	FileReader in = new FileReader(inputFile);
-	            BufferedReader br = new BufferedReader(in);
-	            String line;
-	            while ((line = br.readLine()) != null) {
-	                System.out.println(line);
-	            }
-	            br.close();
-	            in.close();
-	        } catch (IOException e) {
-	            System.out.println(e);
-	        }
-	    }
-
-}
--- a/src/fdl/test2/TestRing.java	Mon Oct 11 04:43:46 2010 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,51 +0,0 @@
-package fdl.test2;
-
-import java.io.BufferedReader;
-import java.io.FileReader;
-import java.io.IOException;
-import java.nio.ByteBuffer;
-
-import fdl.FederatedLinda;
-import fdl.PSXLinda;
-import fdl.PSXReply;
-
-public class TestRing {
-	static int id;
-	public static void main(String args[]){
-		
-		try{
-		FederatedLinda fdl;
-		PSXLinda psx;
-		String host = "127.0.0.1";
-		PSXReply r;
-
-		FileReader in = new FileReader("nodelist");
-		BufferedReader br = new BufferedReader(in);
-		String line;
-		
-		while ((line = br.readLine()) != null) {
-		int i1 = Integer.parseInt(line);
-		fdl = FederatedLinda.init();
-		psx = fdl.open(host,i1);
-		r = psx.in(65535);
-		fdl.sync(1);
-		
-		ByteBuffer data = ByteBuffer.allocate(10);
-		data.putInt(10);
-		data.flip();
-
-		psx.out(1,data);
-		while(!r.ready()){
-		psx.sync(0);
-		}
-		}
-        br.close();
-        in.close();
-
-
-		}catch (IOException e) {
-			System.err.println("Communication failure.");
-		}
-	
-	}
-}
--- a/src/fdl/test2/client.java	Mon Oct 11 04:43:46 2010 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,26 +0,0 @@
-package fdl.test2;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.net.Socket;
-
-public class client {
-	public static void main(String arg[]) throws IOException{
-		String www = arg[0];
-		int port = 10007;
-		Socket sock;
-		BufferedReader dis;
-//		PrintWriter ps;
-		sock = new Socket(www,port);
-		dis = new BufferedReader(new InputStreamReader(sock.getInputStream()));
-//		ps = new PrintWriter(sock.getOutputStream(),true);
-//		ps.println("Get"+arg[1]);
-//		String s = null;
-//		while((s = dis.readLine()) != null){
-			System.out.println(dis);
-//		}
-		sock.close();
-	}
-
-}
--- a/src/fdl/test2/nodelist	Mon Oct 11 04:43:46 2010 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-10000
-10001