changeset 28:132c9bc28d6b

*** empty log message ***
author kono
date Wed, 20 Aug 2008 18:11:30 +0900
parents 1acf423ffdcb
children 7a74d7396d65
files src/fdl/MetaLinda.java src/fdl/test/TestMetaLinda.java src/fdl/test/TestMonitor.java
diffstat 3 files changed, 161 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/fdl/MetaLinda.java	Wed Aug 20 17:16:17 2008 +0900
+++ b/src/fdl/MetaLinda.java	Wed Aug 20 18:11:30 2008 +0900
@@ -105,6 +105,7 @@
 		for(r=replies;r!=null&&r.next!=null;r = r.next) {
 			if (r.next.ready()) {
 				// ready() may modify replies list
+				// bia callback
 				r.next = r.next.next;
 			}
 		}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/fdl/test/TestMetaLinda.java	Wed Aug 20 18:11:30 2008 +0900
@@ -0,0 +1,86 @@
+/*
+ * @(#)TestMetaLinda.java       1.1 06/04/01
+ *
+ * Copyright 2006  Shinji KONO
+ * 
+
+   Test PSX Lidna
+
+ */
+
+package fdl.test;
+
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.net.UnknownHostException;
+import java.nio.ByteBuffer;
+
+import fdl.FederatedLinda;
+import fdl.PSXLinda;
+import fdl.PSXReply;
+import fdl.PSX;
+
+
+/**
+ *   PSXLinda stream
+ *
+ * @author Shinji Kono
+ *
+ * @param host The host to connect to
+ * @param port The port to connect to at the host
+
+ */
+
+
+public class TestMetaLinda {
+	static int id;
+	public static void main (String args[]) {
+
+		FederatedLinda fdl;
+		PSXLinda psx;
+		String host;
+		int port = 10000;
+		PSXReply r;
+		InetSocketAddress localAddress;
+
+
+		try {
+			localAddress = new InetSocketAddress(InetAddress.getLocalHost(), port);
+			host = localAddress.getHostName();
+		} catch (UnknownHostException e) {
+			host = "localhost";
+		}
+
+		try {
+			fdl = FederatedLinda.init();
+			psx = fdl.open(host,port);
+			System.out.println("Connected.");
+
+			ByteBuffer data = ByteBuffer.allocate(10);
+
+			for(int i=0;i<10;i++) {
+				data.clear();
+				data.putInt(i);
+				data.flip();
+				psx.out(1,data);
+				r = psx.in(1);
+				if (r.ready()) {
+					System.out.println("Get:"+r.data);
+					r = psx.in(1);
+				}
+				psx.sync(100);
+			}
+
+			data.clear();
+			psx.out(PSX.META_STOP, data);
+			psx.sync();
+			
+		} catch (IOException e) {
+			System.err.println("Communication failure.");
+		}
+	}
+
+
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/fdl/test/TestMonitor.java	Wed Aug 20 18:11:30 2008 +0900
@@ -0,0 +1,74 @@
+package fdl.test;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+
+import fdl.ComDebug_Client;
+import fdl.FDLindaServ;
+import fdl.FederatedLinda;
+
+public class TestMonitor {
+
+	public FederatedLinda fdl;
+	public FDLindaServ fds;
+	public String localhost;
+	public static final int PORT = 10000;
+
+	class Server implements Runnable {
+		public void run() {
+			String[] args = {"-p",Integer.toString(PORT)};
+			FDLindaServ.main(args);
+		}
+	}
+
+	class Client implements Runnable {
+		public void run() {
+			String[] args = {};
+			sleep(4000);
+			TestMetaLinda.main(args);
+		}
+		public synchronized void sleep(int time) {
+			try {
+				wait(time);
+			} catch (InterruptedException e) {
+				e.printStackTrace();
+			}
+		}
+	}
+
+	class Monitor implements Runnable {
+		public void run() {
+			String[] args = {"-h",localhost,"-p",Integer.toString(PORT)};
+			sleep(2000);
+			ComDebug_Client.main(args);
+		}
+		public synchronized void sleep(int time) {
+			try {
+				wait(time);
+			} catch (InterruptedException e) {
+				e.printStackTrace();
+			}
+		}
+	}
+	
+	public static void main(String[] arg) {
+		TestLindaServer me = new TestLindaServer();
+		me.test1();
+	}
+	
+	public void test1() {
+		try {
+			localhost = InetAddress.getLocalHost().getHostName();
+		} catch (UnknownHostException e) {
+			return;
+		}
+		Server s = new Server();
+		Client c = new Client();
+		Monitor m = new Monitor();
+		new Thread(s).start();
+		new Thread(m).start();
+		new Thread(c).start();
+	}
+	
+
+}