Mercurial > hg > FederatedLinda
changeset 4:2023d9b31af9
fix parameter
author | fuchita |
---|---|
date | Tue, 12 Feb 2008 09:15:25 +0900 |
parents | ae7e0e92c651 |
children | 4391c9fac885 |
files | src/fdl/AcceptHandler.java src/fdl/ComDebug.java src/fdl/ComDebug_Client.java src/fdl/FDLindaServ.java src/fdl/PSXLinda.java src/fdl/TestEtc.java |
diffstat | 6 files changed, 37 insertions(+), 51 deletions(-) [+] |
line wrap: on
line diff
--- a/src/fdl/AcceptHandler.java Mon Feb 11 11:54:15 2008 +0900 +++ b/src/fdl/AcceptHandler.java Tue Feb 12 09:15:25 2008 +0900 @@ -1,15 +1,15 @@ package fdl; import java.io.IOException; -import java.net.InetAddress; -import java.net.InetSocketAddress; -import java.net.UnknownHostException; +//import java.net.InetAddress; +//import java.net.InetSocketAddress; +//import java.net.UnknownHostException; import java.nio.ByteBuffer; import java.nio.channels.ClosedChannelException; import java.nio.channels.SelectionKey; import java.nio.channels.ServerSocketChannel; import java.nio.channels.SocketChannel; -import java.util.LinkedList; +//import java.util.LinkedList; public class AcceptHandler implements TupleHandler, PSXQueueInterface { //public Hashtable<Integer, Tuple> tuple_space; @@ -35,11 +35,6 @@ channel.configureBlocking(false); System.out.println("Server: accepted "+channel.socket()); - //ByteBuffer command = ByteBuffer.allocate(LINDA_HEADER_SIZE); - //LinkedList<SocketChannel> reportCh_list = ComDebug.Report_Channellist; - //AcceptwishComDebug(key, command, reportCh_list); - - //初期生成 if((tmpTuple = tuple_space[MAX_TUPLE-1]) == null) { tmpTuple = tuple_space[MAX_TUPLE-1] = new Tuple(); @@ -52,11 +47,6 @@ } user++; - - //data set - //ByteBuffer data = ByteBuffer.allocate(SHORT_SIZE); - //data.rewind(); - //data.putShort((short) (user)); ByteBuffer data = ByteBuffer.allocate(2); data.clear();
--- a/src/fdl/ComDebug.java Mon Feb 11 11:54:15 2008 +0900 +++ b/src/fdl/ComDebug.java Tue Feb 12 09:15:25 2008 +0900 @@ -119,7 +119,7 @@ public void reportCh_remove(SelectionKey key, LinkedList<SocketChannel> reportCh_list) throws IOException { - //レポートするチャンネルが0ならreturn + //レポートチャンネルが0ならreturn if(reportCh_list.isEmpty()) { return; }else {
--- a/src/fdl/ComDebug_Client.java Mon Feb 11 11:54:15 2008 +0900 +++ b/src/fdl/ComDebug_Client.java Tue Feb 12 09:15:25 2008 +0900 @@ -2,21 +2,21 @@ import java.io.IOException; -import java.nio.ByteBuffer; -import java.nio.CharBuffer; +//import java.nio.ByteBuffer; +//import java.nio.CharBuffer; public class ComDebug_Client implements PSXQueueInterface{ static int id; + static final boolean debug = false; public static void main(String[] args) { FederatedLinda fdl; PSXLinda psx; - String host = "ged.cr.ie.u-ryukyu.ac.jp"; + String host = "localhost"; int port = 10000; int connect_num = 1; - final String usages = "usage: ComDebug_Client [-h host -p port]"; //引数判定 @@ -46,6 +46,9 @@ psx = fdl.open(host,port); r = psx.in(65535); fdl.sync(1); + if(debug == true){ + System.out.println("PSXReply =>"+r.toString()); + } System.out.println("COM_DEBUG Connected.["+host+":"+port+"]"); psx.in(PRIVILEGED_ID_START+connect_num); @@ -59,16 +62,4 @@ return; } } - - /***private static void print_comdata(PSXReply r) { - String comdata =""; - ByteBuffer data = r.getData(); - CharBuffer chardata = data.asCharBuffer(); - comdata = chardata.toString(); - - System.out.println("Com_data =>"); - System.out.println(data); - //System.out.println(comdata); - - }***/ }
--- a/src/fdl/FDLindaServ.java Mon Feb 11 11:54:15 2008 +0900 +++ b/src/fdl/FDLindaServ.java Tue Feb 12 09:15:25 2008 +0900 @@ -2,7 +2,9 @@ package fdl; import java.io.IOException; +import java.net.InetAddress; import java.net.InetSocketAddress; +//import java.nio.ByteOrder; import java.nio.channels.SelectionKey; import java.nio.channels.Selector; import java.nio.channels.ServerSocketChannel; @@ -15,8 +17,7 @@ static final int MAX_UAER = 4; static final int MAX_TUPLE = 65536; static final int DEF_PORT = 10000; - static final String PATHNAME = "/tmp/ldserv"; - public static final int TIMEOUT = 5*1000; + //public static final int TIMEOUT = 5*1000; public static Tuple[] tuple_space; @SuppressWarnings("unchecked") @@ -24,9 +25,11 @@ @SuppressWarnings("unused") final String usages = "usage: FDLindaServ [-p port]"; int port = DEF_PORT; - + //バイトオーダー確認 + //System.out.println(ByteOrder.nativeOrder().toString()); + tuple_space = new Tuple[MAX_TUPLE]; - Selector selector = SelectorProvider.provider().openSelector(); + //引数判定 try { for (int i=0; i<args.length; ++i) { @@ -39,16 +42,16 @@ } catch (NumberFormatException e) { e.printStackTrace(); } - - try { - //セレクタを生成 - - + //セレクタを生成 + Selector selector = SelectorProvider.provider().openSelector(); + try { //ソケット・チャネルを生成・設定 ServerSocketChannel ssChannel = SelectorProvider.provider().openServerSocketChannel(); - ssChannel.socket().bind(new InetSocketAddress(port)); + InetSocketAddress address = new InetSocketAddress(InetAddress.getLocalHost(), port); + //ssChannel.socket().bind(new InetSocketAddress(port)); + ssChannel.socket().bind(address); ssChannel.configureBlocking(false); - ssChannel.socket().setReuseAddress(true); + //ssChannel.socket().setReuseAddress(true); System.out.println("Server: litening at "+ssChannel); //セレクタにチャンネルを登録 //ssChannel.register(selector, SelectionKey.OP_ACCEPT, new AcceptHandler(tuple_space)); @@ -58,7 +61,7 @@ // セレクタによる監視 while (selector.keys().size() > 0) { @SuppressWarnings("unused") - int KeyCount = selector.select(TIMEOUT); + int KeyCount = selector.select(); // Iteratorを用意 Iterator it = selector.selectedKeys().iterator(); while (it.hasNext()) { @@ -75,14 +78,14 @@ } } catch (IOException exc) { exc.printStackTrace(); - } finally { + } /*finally { try { for (SelectionKey key: selector.keys()) { key.channel().close(); } } catch(IOException ex) { ex.printStackTrace(); - } - } + }*/ + //} } }
--- a/src/fdl/PSXLinda.java Mon Feb 11 11:54:15 2008 +0900 +++ b/src/fdl/PSXLinda.java Tue Feb 12 09:15:25 2008 +0900 @@ -13,7 +13,7 @@ package fdl; import java.io.IOException; -import java.net.InetAddress; +//import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.Socket; import java.nio.ByteBuffer; @@ -31,7 +31,7 @@ Initialize connection channel for a tuple space one instance for each Tuple space connection - + */ public class PSXLinda implements PSXQueueInterface {
--- a/src/fdl/TestEtc.java Mon Feb 11 11:54:15 2008 +0900 +++ b/src/fdl/TestEtc.java Tue Feb 12 09:15:25 2008 +0900 @@ -2,7 +2,7 @@ package fdl; import java.io.IOException; -import java.nio.ByteBuffer; +//import java.nio.ByteBuffer; public class TestEtc implements PSXQueueInterface { static final int MAX_REQ = 1; @@ -30,8 +30,10 @@ String local[] = split[1].split(" "); String remote[] = split[2].split("]"); - String localAddress = local[0]; - String remoteAddress = remote[0]; + @SuppressWarnings("unused") + final String localAddress = local[0]; + @SuppressWarnings("unused") + final String remoteAddress = remote[0]; System.out.println(local[0]); System.out.println(remote[0]);