Mercurial > hg > FederatedLinda
view src/fdl/test/transfer/cluster/ProtocolEngine.java @ 56:0143623aa465
(no commit message)
author | axmo |
---|---|
date | Wed, 11 Feb 2009 20:43:55 +0900 |
parents | |
children | 48bb577a313f |
line wrap: on
line source
package fdl.test.transfer.cluster; import java.io.IOException; import java.nio.ByteBuffer; import fdl.FederatedLinda; import fdl.PSXLinda; import fdl.PSXReply; public class ProtocolEngine { 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); getpsx.sync(); 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); //runningフラグをfalseする running = false; sendpsx.sync(); System.out.println("Transfer Data"); break; } fdl.sync(); } } catch (IOException e) { e.printStackTrace(); } } }