src/jdk.net/share/classes/jdk/net/RdmaSockets.java
author bpb
Mon, 04 Feb 2019 13:23:24 -0800
branchrsocket-branch
changeset 57142 78d016915473
parent 57123 919516f93dcf
child 57149 87484051dbba
permissions -rw-r--r--
rsocket-branch: RDMASockets change name to family in NPE doc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
57115
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
     1
/*
57120
64301e5a0da8 rsocket-branch: cleanup in selector provider and friends
chegar
parents: 57117
diff changeset
     2
 * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
57115
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
     4
 *
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    10
 *
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    15
 * accompanied this code).
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    16
 *
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    20
 *
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    23
 * questions.
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    24
 */
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    25
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    26
package jdk.net;
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    27
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    28
import java.net.ProtocolFamily;
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    29
import java.net.ServerSocket;
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    30
import java.net.Socket;
57123
919516f93dcf rsocket-branch: Update RDMA selector provider and API
chegar
parents: 57121
diff changeset
    31
import java.net.StandardProtocolFamily;
57115
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    32
import java.nio.channels.Selector;
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    33
import java.nio.channels.ServerSocketChannel;
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    34
import java.nio.channels.SocketChannel;
57123
919516f93dcf rsocket-branch: Update RDMA selector provider and API
chegar
parents: 57121
diff changeset
    35
import java.nio.channels.spi.SelectorProvider;
57115
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    36
import java.io.IOException;
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    37
import java.util.Objects;
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    38
import jdk.internal.net.rdma.RdmaPollSelectorProvider;
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    39
import jdk.internal.net.rdma.RdmaSocketProvider;
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    40
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    41
/**
57123
919516f93dcf rsocket-branch: Update RDMA selector provider and API
chegar
parents: 57121
diff changeset
    42
 * Factory methods for creating RDMA-based TCP sockets and socket channels.
57115
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    43
 *
57123
919516f93dcf rsocket-branch: Update RDMA selector provider and API
chegar
parents: 57121
diff changeset
    44
 * <p>The {@link #openSocket(ProtocolFamily) openSocket} and {@link
919516f93dcf rsocket-branch: Update RDMA selector provider and API
chegar
parents: 57121
diff changeset
    45
 * #openServerSocket(ProtocolFamily) openServerSocket} methods create RDMA-based
919516f93dcf rsocket-branch: Update RDMA selector provider and API
chegar
parents: 57121
diff changeset
    46
 * TCP sockets.
57115
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    47
 *
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    48
 * <p>The {@link #openSelector() openSelector}, {@link
57123
919516f93dcf rsocket-branch: Update RDMA selector provider and API
chegar
parents: 57121
diff changeset
    49
 * #openSocketChannel(ProtocolFamily) openSocketChannel}, and {@link
919516f93dcf rsocket-branch: Update RDMA selector provider and API
chegar
parents: 57121
diff changeset
    50
 * #openServerSocketChannel(ProtocolFamily) openServerSocketChannel} methods
919516f93dcf rsocket-branch: Update RDMA selector provider and API
chegar
parents: 57121
diff changeset
    51
 * create selectors and selectable channels for use with RDMA sockets. These
919516f93dcf rsocket-branch: Update RDMA selector provider and API
chegar
parents: 57121
diff changeset
    52
 * selectors and channels are created by the RDMA selector provider, which is
919516f93dcf rsocket-branch: Update RDMA selector provider and API
chegar
parents: 57121
diff changeset
    53
 * not the {@linkplain SelectorProvider#provider() default} system-wide selector
919516f93dcf rsocket-branch: Update RDMA selector provider and API
chegar
parents: 57121
diff changeset
    54
 * provider. Consequently, selectable channels to RDMA sockets may not be
919516f93dcf rsocket-branch: Update RDMA selector provider and API
chegar
parents: 57121
diff changeset
    55
 * multiplexed with selectable channels created by the default system-wide
919516f93dcf rsocket-branch: Update RDMA selector provider and API
chegar
parents: 57121
diff changeset
    56
 * selector provider. The RDMA selector provider does not support datagram
919516f93dcf rsocket-branch: Update RDMA selector provider and API
chegar
parents: 57121
diff changeset
    57
 * channels or pipes. Its {@link SelectorProvider#openDatagramChannel
919516f93dcf rsocket-branch: Update RDMA selector provider and API
chegar
parents: 57121
diff changeset
    58
 * openDatagramChannel} and {@link SelectorProvider#openPipe openPipe} methods
919516f93dcf rsocket-branch: Update RDMA selector provider and API
chegar
parents: 57121
diff changeset
    59
 * throw {@link UnsupportedOperationException UnsupportedOperationException}.
919516f93dcf rsocket-branch: Update RDMA selector provider and API
chegar
parents: 57121
diff changeset
    60
 *
919516f93dcf rsocket-branch: Update RDMA selector provider and API
chegar
parents: 57121
diff changeset
    61
 * @implNote The RDMA selector provider supports socket channels of type
919516f93dcf rsocket-branch: Update RDMA selector provider and API
chegar
parents: 57121
diff changeset
    62
 * {@link StandardProtocolFamily#INET INET} and {@link
919516f93dcf rsocket-branch: Update RDMA selector provider and API
chegar
parents: 57121
diff changeset
    63
 * StandardProtocolFamily#INET6 INET6}. Its {@link
919516f93dcf rsocket-branch: Update RDMA selector provider and API
chegar
parents: 57121
diff changeset
    64
 * SelectorProvider#openSocketChannel() openSocketChannel} and {@link
919516f93dcf rsocket-branch: Update RDMA selector provider and API
chegar
parents: 57121
diff changeset
    65
 * SelectorProvider#openServerSocketChannel() openServerSocketChannel}
919516f93dcf rsocket-branch: Update RDMA selector provider and API
chegar
parents: 57121
diff changeset
    66
 * methods create selectable channels with a family of {@link
919516f93dcf rsocket-branch: Update RDMA selector provider and API
chegar
parents: 57121
diff changeset
    67
 * StandardProtocolFamily#INET6 INET6}, if the underlying platform supports
919516f93dcf rsocket-branch: Update RDMA selector provider and API
chegar
parents: 57121
diff changeset
    68
 * IPv6. Otherwise, it creates selectable channels with a family of {@link
919516f93dcf rsocket-branch: Update RDMA selector provider and API
chegar
parents: 57121
diff changeset
    69
 * StandardProtocolFamily#INET INET}.
57115
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    70
 *
57121
ff7b5750a610 rsocket-branch: update @since tags in API
chegar
parents: 57120
diff changeset
    71
 * @since 13
57115
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    72
 */
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    73
public class RdmaSockets {
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    74
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    75
    private RdmaSockets() {}
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    76
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    77
    /**
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    78
     * Creates an unbound and unconnected RDMA socket.
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    79
     *
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    80
     * <p> An RDMA socket supports the same socket options that {@link
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    81
     * java.net.Socket java.net.Socket} defines. In addition, it supports the
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    82
     * socket options specified by {@link RdmaSocketOptions}.
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    83
     *
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    84
     * <p> When binding the socket to a local address, or invoking {@code
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    85
     * connect} to connect the socket, the socket address specified to those
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    86
     * methods must correspond to the protocol family specified here.
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    87
     *
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    88
     * @param   family
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    89
     *          The protocol family
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    90
     *
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    91
     * @throws IOException
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    92
     *         If an I/O error occurs
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    93
     * @throws NullPointerException
57142
78d016915473 rsocket-branch: RDMASockets change name to family in NPE doc
bpb
parents: 57123
diff changeset
    94
     *         If {@code family} is {@code null}
57115
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    95
     * @throws UnsupportedOperationException
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    96
     *         If RDMA sockets are not supported on this platform or if the
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    97
     *         specified protocol family is not supported. For example, if
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    98
     *         the parameter is {@link java.net.StandardProtocolFamily#INET6
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
    99
     *         StandardProtocolFamily.INET6} but IPv6 is not enabled on the
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   100
     *         platform.
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   101
     */
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   102
    public static Socket openSocket(ProtocolFamily family) throws IOException {
57117
7f1b415bfede rsocket-branch: fix null arg checking in factories
chegar
parents: 57115
diff changeset
   103
        Objects.requireNonNull(family, "protocol family is null");
57115
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   104
        return RdmaSocketProvider.openSocket(family);
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   105
    }
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   106
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   107
    /**
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   108
     * Creates an unbound RDMA server socket.
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   109
     *
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   110
     * <p> An RDMA socket supports the same socket options that {@link
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   111
     * java.net.ServerSocket java.net.ServerSocket} defines.
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   112
     *
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   113
     * <p> When binding the socket to an address, the socket address specified
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   114
     * to the {@code bind} method must correspond to the protocol family
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   115
     * specified here.
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   116
     *
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   117
     * @param   family
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   118
     *          The protocol family
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   119
     *
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   120
     * @throws IOException
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   121
     *         If an I/O error occurs
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   122
     * @throws NullPointerException
57142
78d016915473 rsocket-branch: RDMASockets change name to family in NPE doc
bpb
parents: 57123
diff changeset
   123
     *         If {@code family} is {@code null}
57115
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   124
     * @throws UnsupportedOperationException
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   125
     *         If RDMA sockets are not supported on this platform or if the
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   126
     *         specified protocol family is not supported. For example, if
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   127
     *         the parameter is {@link java.net.StandardProtocolFamily#INET6
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   128
     *         StandardProtocolFamily.INET6} but IPv6 is not enabled on the
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   129
     *         platform.
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   130
     */
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   131
    public static ServerSocket openServerSocket(ProtocolFamily family)
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   132
            throws IOException {
57117
7f1b415bfede rsocket-branch: fix null arg checking in factories
chegar
parents: 57115
diff changeset
   133
        Objects.requireNonNull(family, "protocol family is null");
57115
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   134
        return RdmaSocketProvider.openServerSocket(family);
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   135
    }
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   136
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   137
    /**
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   138
     * Opens a socket channel to an RDMA socket. A newly created socket channel
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   139
     * is {@link SocketChannel#isOpen() open}, not yet bound to a {@link
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   140
     * SocketChannel#getLocalAddress() local address}, and not yet
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   141
     * {@link SocketChannel#isConnected() connected}.
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   142
     *
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   143
     * <p> A socket channel to an RDMA socket supports all of the socket options
57142
78d016915473 rsocket-branch: RDMASockets change name to family in NPE doc
bpb
parents: 57123
diff changeset
   144
     * specified by {@link SocketChannel java.nio.channels.SocketChannel}. In
78d016915473 rsocket-branch: RDMASockets change name to family in NPE doc
bpb
parents: 57123
diff changeset
   145
     * addition, it supports the socket options specified by
78d016915473 rsocket-branch: RDMASockets change name to family in NPE doc
bpb
parents: 57123
diff changeset
   146
     * {@link RdmaSocketOptions}.
57115
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   147
     *
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   148
     * <p> When binding the channel's socket to a local address, or invoking
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   149
     * {@code connect} to connect channel's socket, the socket address specified
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   150
     * to those methods must correspond to the protocol family specified here.
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   151
     *
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   152
     * @param   family
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   153
     *          The protocol family
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   154
     *
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   155
     * @throws IOException
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   156
     *         If an I/O error occurs
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   157
     * @throws NullPointerException
57142
78d016915473 rsocket-branch: RDMASockets change name to family in NPE doc
bpb
parents: 57123
diff changeset
   158
     *         If {@code family} is {@code null}
57115
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   159
     * @throws UnsupportedOperationException
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   160
     *         If RDMA sockets are not supported on this platform or if the
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   161
     *         specified protocol family is not supported. For example, if
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   162
     *         the parameter is {@link java.net.StandardProtocolFamily#INET6
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   163
     *         StandardProtocolFamily.INET6} but IPv6 is not enabled on the
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   164
     *         platform.
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   165
     */
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   166
    public static SocketChannel openSocketChannel(ProtocolFamily family)
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   167
            throws IOException {
57117
7f1b415bfede rsocket-branch: fix null arg checking in factories
chegar
parents: 57115
diff changeset
   168
        Objects.requireNonNull(family, "protocol family is null");
57120
64301e5a0da8 rsocket-branch: cleanup in selector provider and friends
chegar
parents: 57117
diff changeset
   169
        return RdmaPollSelectorProvider.provider().openSocketChannel(family);
57115
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   170
    }
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   171
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   172
    /**
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   173
     * Opens a server socket channel to an RDMA socket. A newly created socket
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   174
     * channel is {@link SocketChannel#isOpen() open} but not yet bound to a
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   175
     * {@link SocketChannel#getLocalAddress() local address}.
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   176
     *
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   177
     * <p> When binding the channel's socket to an address, the socket address
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   178
     * specified to the {@code bind} method must correspond to the protocol
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   179
     * family specified here.
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   180
     *
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   181
     * @param   family
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   182
     *          The protocol family
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   183
     *
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   184
     * @throws IOException
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   185
     *         If an I/O error occurs
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   186
     * @throws NullPointerException
57142
78d016915473 rsocket-branch: RDMASockets change name to family in NPE doc
bpb
parents: 57123
diff changeset
   187
     *         If {@code family} is {@code null}
57115
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   188
     * @throws UnsupportedOperationException
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   189
     *         If RDMA sockets are not supported on this platform or if the
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   190
     *         specified protocol family is not supported. For example, if
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   191
     *         the parameter is {@link java.net.StandardProtocolFamily#INET6
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   192
     *         StandardProtocolFamily.INET6} but IPv6 is not enabled on the
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   193
     *         platform.
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   194
     */
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   195
    public static ServerSocketChannel openServerSocketChannel(
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   196
            ProtocolFamily family) throws IOException {
57117
7f1b415bfede rsocket-branch: fix null arg checking in factories
chegar
parents: 57115
diff changeset
   197
        Objects.requireNonNull(family, "protocol family is null");
57120
64301e5a0da8 rsocket-branch: cleanup in selector provider and friends
chegar
parents: 57117
diff changeset
   198
        return RdmaPollSelectorProvider.provider().openServerSocketChannel(family);
57115
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   199
    }
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   200
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   201
    /**
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   202
     * Opens a selector to multiplex selectable channels to RDMA sockets.
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   203
     *
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   204
     * @throws IOException
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   205
     *         If an I/O error occurs
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   206
     * @throws UnsupportedOperationException
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   207
     *         If RDMA sockets are not supported on this platform
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   208
     */
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   209
    public static Selector openSelector() throws IOException {
57120
64301e5a0da8 rsocket-branch: cleanup in selector provider and friends
chegar
parents: 57117
diff changeset
   210
        return RdmaPollSelectorProvider.provider().openSelector();
57115
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   211
    }
512e7cc6ccce Initial load of JEP 337 implementation
alanb
parents:
diff changeset
   212
}