< prev index next >

test/jdk/jdk/net/RdmaSockets/rsocket/Selector/Connect.java

Print this page
rev 53031 : [mq]: selector_Connect
rev 53029 : imported patch jdk12-8195160-version25.patch

*** 21,59 **** * questions. */ /* @test * @bug 8195160 ! * @summary Test Test Making lots of Selectors * @requires (os.family == "linux") * @library .. /test/lib * @build jdk.test.lib.Utils TestServers * @build RsocketTest * @run main/othervm Connect */ import java.net.InetAddress; import java.net.InetSocketAddress; - import java.net.StandardProtocolFamily; import java.nio.ByteBuffer; import java.nio.channels.SelectionKey; import java.nio.channels.Selector; import java.nio.channels.SocketChannel; - import java.nio.channels.spi.SelectorProvider; import java.util.Iterator; import java.util.Set; import jdk.net.RdmaSockets; - import jtreg.SkippedException; ! public class Connect implements Runnable { static int success = 0; ! static int LIMIT = 30; ! static SocketChannel sc; ! static InetSocketAddress isa; ! static boolean connected; public static void main(String[] args) throws Exception { if (!RsocketTest.isRsocketAvailable()) throw new SkippedException("rsocket is not available"); --- 21,54 ---- * questions. */ /* @test * @bug 8195160 ! * @summary Test making lots of Selectors * @requires (os.family == "linux") * @library .. /test/lib * @build jdk.test.lib.Utils TestServers * @build RsocketTest * @run main/othervm Connect */ import java.net.InetAddress; import java.net.InetSocketAddress; import java.nio.ByteBuffer; import java.nio.channels.SelectionKey; import java.nio.channels.Selector; import java.nio.channels.SocketChannel; import java.util.Iterator; import java.util.Set; import jdk.net.RdmaSockets; import jtreg.SkippedException; + import static java.net.StandardProtocolFamily.INET; ! public class Connect { static int success = 0; ! static final int LIMIT = 30; public static void main(String[] args) throws Exception { if (!RsocketTest.isRsocketAvailable()) throw new SkippedException("rsocket is not available");
*** 65,100 **** static void scaleTest(TestServers.DayTimeServer daytimeServer) throws Exception { InetAddress myAddress = daytimeServer.getAddress(); ! isa = new InetSocketAddress(myAddress, daytimeServer.getPort()); for (int j=0; j<LIMIT; j++) { ! sc = RdmaSockets.openSocketChannel(StandardProtocolFamily.INET); sc.configureBlocking(false); - Thread t = new Thread (new Connect()); - t.start(); - t.join(); if (!connected) { ! Selector RSelector = RdmaSockets.openSelector(); ! SelectionKey RKey = sc.register (RSelector, SelectionKey.OP_CONNECT); while (!connected) { ! int keysAdded = RSelector.select(100); if (keysAdded > 0) { ! Set<SelectionKey> readyKeys = RSelector.selectedKeys(); Iterator<SelectionKey> i = readyKeys.iterator(); while (i.hasNext()) { SelectionKey sk = i.next(); SocketChannel nextReady = (SocketChannel)sk.channel(); connected = nextReady.finishConnect(); } readyKeys.clear(); } } ! RSelector.close(); } readAndClose(sc); } } --- 60,94 ---- static void scaleTest(TestServers.DayTimeServer daytimeServer) throws Exception { InetAddress myAddress = daytimeServer.getAddress(); ! InetSocketAddress isa = new InetSocketAddress(myAddress, daytimeServer.getPort()); for (int j=0; j<LIMIT; j++) { ! SocketChannel sc = RdmaSockets.openSocketChannel(INET); sc.configureBlocking(false); + boolean connected = sc.connect(isa); + System.out.println("connected = " + connected); if (!connected) { ! Selector selector = RdmaSockets.openSelector(); ! sc.register(selector, SelectionKey.OP_CONNECT); while (!connected) { ! int keysAdded = selector.select(100); if (keysAdded > 0) { ! Set<SelectionKey> readyKeys = selector.selectedKeys(); Iterator<SelectionKey> i = readyKeys.iterator(); while (i.hasNext()) { SelectionKey sk = i.next(); SocketChannel nextReady = (SocketChannel)sk.channel(); connected = nextReady.finishConnect(); } readyKeys.clear(); } } ! selector.close(); } readAndClose(sc); } }
*** 105,120 **** n = sc.read(bb); sc.close(); success++; System.out.println("success count = " + success); } - - public void run() { - try { - connected = sc.connect(isa); - System.out.println("connected = " + connected); - } catch (Exception e) { - e.printStackTrace(); - throw new RuntimeException("Test Failed!"); - } - } } --- 99,104 ----
< prev index next >