changeset 37:2a366abc3f1f

*** empty log message ***
author kono
date Sun, 24 Aug 2008 21:21:40 +0900
parents d5bca4b5ee95
children 9a0cb612f576
files src/fdl/ComDebug_Client.java src/fdl/CommDebugHook.java src/fdl/MetaLinda.java src/fdl/MetaLogEngine.java src/fdl/test/ComDebug_Client.java src/fdl/test/TestMonitor.java
diffstat 6 files changed, 110 insertions(+), 105 deletions(-) [+]
line wrap: on
line diff
--- a/src/fdl/ComDebug_Client.java	Sun Aug 24 21:06:39 2008 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,102 +0,0 @@
-package fdl;
-
-
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.util.LinkedList;
-
-/*
- * それぞれのLinda Serverのmeta protocolに接続して、順々にモニタデータを
- * 受け取って表示する。
- */
-public class ComDebug_Client {
-
-	static int id;
-	static final boolean debug = false;
-	PSXCallback debugCallback ; 
-
-	FederatedLinda fdl;
-	PSXLinda psx;
-	LinkedList<String> hosts = new LinkedList<String>();
-	LinkedList<Integer> ports = new LinkedList<Integer>();
-	LinkedList<PSXLinda> psxs = new LinkedList<PSXLinda>();
-
-	public static void main(String[] args) {
-		ComDebug_Client com = new ComDebug_Client();
-		com.run(args);
-	}
-
-	public void run(String[] args) {
-		int connect_num = 1;
-		final String usages = "usage: ComDebug_Client [-h host -p port]*";
-		//引数判定
-		try {
-			if (args.length < 2) {
-				System.err.println(usages);
-			}
-
-			for (int i=0; i<args.length; ++i) {
-				if("-h".equals(args[i])) {
-					hosts.add(args[++i]);
-					System.err.println("host = "+hosts.getLast());
-				} else if("-p".equals(args[i])) {
-					ports.add(Integer.parseInt(args[++i]));
-					System.err.println("port = "+ports.getLast());
-				} else {
-					System.err.println(usages); return;
-				}
-			}
-			if (hosts.size()!=ports.size()) {
-				System.err.println("-h and -p pairs are always necessary.");
-				System.exit(1);
-			}
-		} catch (NumberFormatException e) {
-			e.printStackTrace();
-		}
-
-
-		try {
-			fdl = FederatedLinda.init();
-			for(int i=0;i<hosts.size();i++) {
-				String host = hosts.get(i);
-				int port = ports.get(i);
-
-				psx = fdl.open(host,port);
-				psxs.add(psx);
-				class MyCallBack implements PSXCallback {
-					PSXLinda psx;
-					public MyCallBack(PSXLinda psx) {
-						this.psx = psx;
-					}
-					public void callback(ByteBuffer reply) {
-						int p = psxs.indexOf(psx);
-						System.out.println("PSXReply("+p+") =>"+reply);
-					}
-				}
-				psx.in(65535, new MyCallBack(psx)); 
-
-				System.err.println("COM_DEBUG Connected.["+host+":"+port+"]");
-				psx.out(PSX.META_MONITOR, null);
-				debugCallback = 
-					new PSXCallback() {
-					public void callback(ByteBuffer reply) {
-						System.err.println("COM_DEBUG: "+PSX.getdataString(reply));
-						psx.out(PSX.META_MONITOR, null);
-						psx.in(PSX.META_MONITOR_DATA,debugCallback); 
-					}
-				};
-				psx.out(PSX.META_MONITOR, null);
-				psx.in(PSX.META_MONITOR_DATA,debugCallback); 
-
-				connect_num++;
-			}
-			while(true) {
-				fdl.sync(1000);
-			}
-		} catch (IOException nfex) {
-			nfex.printStackTrace();
-			System.out.println("Faild.");
-			return;
-		}
-	}
-}
--- a/src/fdl/CommDebugHook.java	Sun Aug 24 21:06:39 2008 +0900
+++ b/src/fdl/CommDebugHook.java	Sun Aug 24 21:21:40 2008 +0900
@@ -7,6 +7,8 @@
 public class CommDebugHook implements IOHandlerHook {
 
 	public LinkedList<String> logs = new LinkedList<String>();
+	// String conversion is too expensive, should use ByteBuffer directory or
+	// create log object for the purpose.
 
 	public void closeHook(SelectionKey key) {
 		if (key!=null) logs.add(closeLog(key));
--- a/src/fdl/MetaLinda.java	Sun Aug 24 21:06:39 2008 +0900
+++ b/src/fdl/MetaLinda.java	Sun Aug 24 21:21:40 2008 +0900
@@ -128,7 +128,10 @@
 	}
 
 	public void send(ByteBuffer command, ByteBuffer data) {
-		
+	}
+
+	public void setTupleSpaceHook(IOHandlerHook hook) {
+		ts.hook = hook;
 	}
 }
 
--- a/src/fdl/MetaLogEngine.java	Sun Aug 24 21:06:39 2008 +0900
+++ b/src/fdl/MetaLogEngine.java	Sun Aug 24 21:21:40 2008 +0900
@@ -18,7 +18,7 @@
 	
 	PSXCallback monitor_callback_start =
 			new PSXCallback() {public void callback(ByteBuffer reply) { 
-				meta.ts.hook = commDebug = new CommDebugHook();
+				meta.setTupleSpaceHook(commDebug = new CommDebugHook());
 				meta.out(PSX.META_MONITOR_DATA, null);
 				meta.in(PSX.META_MONITOR,monitor_callback);
 	}};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/fdl/test/ComDebug_Client.java	Sun Aug 24 21:21:40 2008 +0900
@@ -0,0 +1,103 @@
+package fdl.test;
+
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.LinkedList;
+
+import fdl.FederatedLinda;
+import fdl.PSX;
+import fdl.PSXCallback;
+import fdl.PSXLinda;
+
+/*
+ * それぞれのLinda Serverのmeta protocolに接続して、順々にモニタデータを
+ * 受け取って表示する。
+ */
+public class ComDebug_Client {
+
+	static int id;
+	static final boolean debug = false;
+	PSXCallback debugCallback ; 
+
+	FederatedLinda fdl;
+	PSXLinda psx;
+	LinkedList<String> hosts = new LinkedList<String>();
+	LinkedList<Integer> ports = new LinkedList<Integer>();
+	LinkedList<PSXLinda> psxs = new LinkedList<PSXLinda>();
+
+	public static void main(String[] args) {
+		ComDebug_Client com = new ComDebug_Client();
+		com.run(args);
+	}
+
+	public void run(String[] args) {
+		int connect_num = 1;
+		final String usages = "usage: ComDebug_Client [-h host -p port]*";
+		//引数判定
+		try {
+			if (args.length < 2) {
+				System.err.println(usages);
+			}
+
+			for (int i=0; i<args.length; ++i) {
+				if("-h".equals(args[i])) {
+					hosts.add(args[++i]);
+					System.err.println("host = "+hosts.getLast());
+				} else if("-p".equals(args[i])) {
+					ports.add(Integer.parseInt(args[++i]));
+					System.err.println("port = "+ports.getLast());
+				} else {
+					System.err.println(usages); return;
+				}
+			}
+			if (hosts.size()!=ports.size()) {
+				System.err.println("-h and -p pairs are always necessary.");
+				System.exit(1);
+			}
+		} catch (NumberFormatException e) {
+			e.printStackTrace();
+		}
+
+
+		try {
+			fdl = FederatedLinda.init();
+			for(int i=0;i<hosts.size();i++) {
+				String host = hosts.get(i);
+				int port = ports.get(i);
+
+				psx = fdl.open(host,port);
+				psxs.add(psx);
+				PSXCallback checkid = new PSXCallback() {
+					public void callback(ByteBuffer reply) {
+						int p = psxs.indexOf(psx);
+						System.out.println("PSXReply("+p+") =>"+reply);
+					}
+				};
+				psx.in(65535, checkid);
+
+				System.err.println("COM_DEBUG Connected.["+host+":"+port+"]");
+				psx.out(PSX.META_MONITOR, null);
+				debugCallback = 
+					new PSXCallback() {
+					public void callback(ByteBuffer reply) {
+						System.err.println("COM_DEBUG: "+PSX.getdataString(reply));
+						psx.out(PSX.META_MONITOR, null);
+						psx.in(PSX.META_MONITOR_DATA,debugCallback); 
+					}
+				};
+				psx.out(PSX.META_MONITOR, null);
+				psx.in(PSX.META_MONITOR_DATA,debugCallback); 
+
+				connect_num++;
+			}
+			while(true) {
+				fdl.sync(1000);
+			}
+		} catch (IOException nfex) {
+			nfex.printStackTrace();
+			System.out.println("Faild.");
+			return;
+		}
+	}
+}
--- a/src/fdl/test/TestMonitor.java	Sun Aug 24 21:06:39 2008 +0900
+++ b/src/fdl/test/TestMonitor.java	Sun Aug 24 21:21:40 2008 +0900
@@ -3,7 +3,6 @@
 import java.net.InetAddress;
 import java.net.UnknownHostException;
 
-import fdl.ComDebug_Client;
 import fdl.FDLindaServ;
 import fdl.FederatedLinda;