# HG changeset patch # User kono # Date 1220064172 -32400 # Node ID dfc2afab1325467752302aaf54deb6317379ccbe # Parent 0607cc699ba3cd620630c3bfa751ead705aa5b4c *** empty log message *** diff -r 0607cc699ba3 -r dfc2afab1325 rep/channel/SelectionKeySimulator.java --- a/rep/channel/SelectionKeySimulator.java Sat Aug 30 11:25:27 2008 +0900 +++ b/rep/channel/SelectionKeySimulator.java Sat Aug 30 11:42:52 2008 +0900 @@ -4,7 +4,6 @@ import java.nio.channels.SelectableChannel; import java.nio.channels.SelectionKey; import java.nio.channels.Selector; -import java.nio.channels.ServerSocketChannel; public class SelectionKeySimulator

extends REPSelectionKey

{ @@ -53,6 +52,7 @@ return channel; } + @SuppressWarnings("unchecked") public REPSocketChannel

accept(REPPack

pack) throws IOException { assert(channel instanceof ServerChannelSimulator); ServerChannelSimulator

scs = (ServerChannelSimulator

) channel; diff -r 0607cc699ba3 -r dfc2afab1325 test/channeltest/testSeMa.java --- a/test/channeltest/testSeMa.java Sat Aug 30 11:25:27 2008 +0900 +++ b/test/channeltest/testSeMa.java Sat Aug 30 11:42:52 2008 +0900 @@ -33,17 +33,16 @@ @SuppressWarnings("unchecked") public void run() { - REPSelector selector=null; + REPSelector selector=null; REPServerSocketChannel scs; - REPPack pack = new StringPacker(); + REPPack pack = new StringPacker(); try { selector = REPSelector.create(); scs = REPServerSocketChannel.open(pack); scs.socket().setReuseAddress(true); scs.socket().bind(IP); scs.configureBlocking(false); - //selector.register(scs, SelectionKey.OP_ACCEPT, null); scs.register(selector, SelectionKey.OP_ACCEPT, null); } catch (IOException e1) { ns.writeLog("cannot create REPServerSocketChannel!, exit."); @@ -63,7 +62,6 @@ for(REPSelectionKey key : set) { if(key.isAcceptable()){ - ns.writeLog("gets acceptable channel", 1); REPSocketChannel channel = key.accept(pack); if(channel==null) continue; channel.configureBlocking(false); @@ -72,7 +70,6 @@ }else if(key.isReadable()){ ns.writeLog("gets readable channel", 1); - //SelectableChannelSimulator channel = key.channel(); REPSocketChannel channel = (REPSocketChannel) key.channel(pack); String packet; packet = channel.read(); diff -r 0607cc699ba3 -r dfc2afab1325 test/channeltest/testSeMaSlave.java --- a/test/channeltest/testSeMaSlave.java Sat Aug 30 11:25:27 2008 +0900 +++ b/test/channeltest/testSeMaSlave.java Sat Aug 30 11:42:52 2008 +0900 @@ -8,6 +8,8 @@ import java.nio.channels.Selector; import rep.channel.REPLogger; +import rep.channel.REPPack; +import rep.channel.REPSelectionKey; import rep.channel.REPSelector; import rep.channel.REPServerSocketChannel; import rep.channel.REPSocketChannel; @@ -31,11 +33,13 @@ } + @SuppressWarnings("unchecked") public void run() { - REPSelector selector; + REPSelector selector; REPSocketChannel masterCH ; try { - REPServerSocketChannel scs = REPServerSocketChannel.open(new StringPacker()); + REPPack pack = new StringPacker(); + REPServerSocketChannel scs = REPServerSocketChannel.open(pack); selector = REPSelector.create(); masterCH = connectToMaster(selector); scs.socket().bind(ownIP); @@ -50,18 +54,18 @@ selector.select(); - for(SelectionKey key : selector.selectedKeys()){ + for(REPSelectionKey key : selector.selectedKeys1()){ if(key.isAcceptable()){ - ns.writeLog("gets acceptable channel", 1); - REPServerSocketChannel sc = (REPServerSocketChannel) key.channel(); - REPSocketChannel channel = sc.accept1(); + REPSocketChannel channel = key.accept(pack); + if(channel==null) continue; + channel.configureBlocking(false); selector.register(channel, SelectionKey.OP_READ,null); ns.writeLog("accepts a client.", 1); }else if(key.isReadable()){ ns.writeLog("gets readable channel", 1); - REPSocketChannel channel = (REPSocketChannel) key.channel(); + REPSocketChannel channel = (REPSocketChannel) key.channel(pack); String packet = channel.read(); if (channel==masterCH){ ns.writeLog("receives String from master ==> `"+packet+"\'", 1);