src/jdk.net/share/classes/jdk/net/RdmaSockets.java
branchrsocket-branch
changeset 57120 64301e5a0da8
parent 57117 7f1b415bfede
child 57121 ff7b5750a610
equal deleted inserted replaced
57117:7f1b415bfede 57120:64301e5a0da8
     1 /*
     1 /*
     2  * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
    26 package jdk.net;
    26 package jdk.net;
    27 
    27 
    28 import java.net.ProtocolFamily;
    28 import java.net.ProtocolFamily;
    29 import java.net.ServerSocket;
    29 import java.net.ServerSocket;
    30 import java.net.Socket;
    30 import java.net.Socket;
    31 import java.net.SocketException;
       
    32 import java.net.SocketOption;
       
    33 import java.net.StandardSocketOptions;
       
    34 import java.nio.channels.Selector;
    31 import java.nio.channels.Selector;
    35 import java.nio.channels.ServerSocketChannel;
    32 import java.nio.channels.ServerSocketChannel;
    36 import java.nio.channels.SocketChannel;
    33 import java.nio.channels.SocketChannel;
    37 import java.nio.channels.spi.SelectorProvider;
       
    38 import java.io.IOException;
    34 import java.io.IOException;
    39 import java.util.Objects;
    35 import java.util.Objects;
    40 import jdk.internal.net.rdma.RdmaPollSelectorProvider;
    36 import jdk.internal.net.rdma.RdmaPollSelectorProvider;
    41 import jdk.internal.net.rdma.RdmaSocketProvider;
    37 import jdk.internal.net.rdma.RdmaSocketProvider;
    42 
    38 
   157      *         platform.
   153      *         platform.
   158      */
   154      */
   159     public static SocketChannel openSocketChannel(ProtocolFamily family)
   155     public static SocketChannel openSocketChannel(ProtocolFamily family)
   160             throws IOException {
   156             throws IOException {
   161         Objects.requireNonNull(family, "protocol family is null");
   157         Objects.requireNonNull(family, "protocol family is null");
   162         SelectorProvider provider = RdmaPollSelectorProvider.provider();
   158         return RdmaPollSelectorProvider.provider().openSocketChannel(family);
   163         return ((RdmaPollSelectorProvider)provider).openSocketChannel(family);
       
   164     }
   159     }
   165 
   160 
   166     /**
   161     /**
   167      * Opens a server socket channel to an RDMA socket. A newly created socket
   162      * Opens a server socket channel to an RDMA socket. A newly created socket
   168      * channel is {@link SocketChannel#isOpen() open} but not yet bound to a
   163      * channel is {@link SocketChannel#isOpen() open} but not yet bound to a
   187      *         platform.
   182      *         platform.
   188      */
   183      */
   189     public static ServerSocketChannel openServerSocketChannel(
   184     public static ServerSocketChannel openServerSocketChannel(
   190             ProtocolFamily family) throws IOException {
   185             ProtocolFamily family) throws IOException {
   191         Objects.requireNonNull(family, "protocol family is null");
   186         Objects.requireNonNull(family, "protocol family is null");
   192         SelectorProvider provider = RdmaPollSelectorProvider.provider();
   187         return RdmaPollSelectorProvider.provider().openServerSocketChannel(family);
   193         return ((RdmaPollSelectorProvider)provider)
       
   194                 .openServerSocketChannel(family);
       
   195     }
   188     }
   196 
   189 
   197     /**
   190     /**
   198      * Opens a selector to multiplex selectable channels to RDMA sockets.
   191      * Opens a selector to multiplex selectable channels to RDMA sockets.
   199      *
   192      *
   201      *         If an I/O error occurs
   194      *         If an I/O error occurs
   202      * @throws UnsupportedOperationException
   195      * @throws UnsupportedOperationException
   203      *         If RDMA sockets are not supported on this platform
   196      *         If RDMA sockets are not supported on this platform
   204      */
   197      */
   205     public static Selector openSelector() throws IOException {
   198     public static Selector openSelector() throws IOException {
   206         SelectorProvider provider = RdmaPollSelectorProvider.provider();
   199         return RdmaPollSelectorProvider.provider().openSelector();
   207         return provider.openSelector();
       
   208     }
   200     }
   209 }
   201 }