Mercurial > hg > FederatedLinda
annotate src/fdl/test/TestMetaLinda.java @ 35:fe338d497c72 meta-comdebug-wokred
FederatedLinda was static singleton. It does not work on Thread based test.
author | kono |
---|---|
date | Sun, 24 Aug 2008 19:07:28 +0900 |
parents | e7c5958fd285 |
children | d5bca4b5ee95 |
rev | line source |
---|---|
28 | 1 /* |
2 * @(#)TestMetaLinda.java 1.1 06/04/01 | |
3 * | |
4 * Copyright 2006 Shinji KONO | |
5 * | |
6 | |
7 Test PSX Lidna | |
8 | |
9 */ | |
10 | |
11 package fdl.test; | |
12 | |
13 import java.io.IOException; | |
14 import java.net.InetAddress; | |
15 import java.net.InetSocketAddress; | |
16 import java.net.UnknownHostException; | |
17 import java.nio.ByteBuffer; | |
18 | |
19 import fdl.FederatedLinda; | |
20 import fdl.PSXLinda; | |
21 import fdl.PSXReply; | |
22 import fdl.PSX; | |
23 | |
24 | |
25 /** | |
26 * PSXLinda stream | |
27 * | |
28 * @author Shinji Kono | |
29 * | |
30 * @param host The host to connect to | |
31 * @param port The port to connect to at the host | |
32 | |
33 */ | |
34 | |
35 | |
36 public class TestMetaLinda { | |
37 static int id; | |
38 public static void main (String args[]) { | |
39 | |
40 FederatedLinda fdl; | |
41 PSXLinda psx; | |
42 String host; | |
43 int port = 10000; | |
44 PSXReply r; | |
45 InetSocketAddress localAddress; | |
46 | |
47 | |
48 try { | |
49 localAddress = new InetSocketAddress(InetAddress.getLocalHost(), port); | |
50 host = localAddress.getHostName(); | |
51 } catch (UnknownHostException e) { | |
52 host = "localhost"; | |
53 } | |
54 | |
55 try { | |
56 fdl = FederatedLinda.init(); | |
57 psx = fdl.open(host,port); | |
58 System.out.println("Connected."); | |
59 | |
29 | 60 r = psx.in(1); |
28 | 61 |
62 for(int i=0;i<10;i++) { | |
33 | 63 ByteBuffer data = ByteBuffer.allocate(10); |
28 | 64 data.putInt(i); |
65 data.flip(); | |
66 psx.out(1,data); | |
33 | 67 } |
35
fe338d497c72
FederatedLinda was static singleton. It does not work on Thread based test.
kono
parents:
34
diff
changeset
|
68 for(int i=0;i<50;i++) { |
28 | 69 if (r.ready()) { |
29 | 70 System.err.println("Get:"+r.data.getInt()); |
28 | 71 r = psx.in(1); |
72 } | |
33 | 73 // System.out.println("syncing..."+i); |
34 | 74 psx.sync(100); |
28 | 75 } |
76 | |
33 | 77 System.out.println("Try to stop the server"); |
78 psx.out(PSX.META_STOP, null); | |
28 | 79 psx.sync(); |
80 | |
81 } catch (IOException e) { | |
82 System.err.println("Communication failure."); | |
83 } | |
84 } | |
85 | |
86 | |
87 } | |
88 |