< prev index next >

src/jdk.net/linux/classes/jdk/internal/net/rdma/LinuxRdmaSocketImpl.java

Print this page




  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 package jdk.internal.net.rdma;
  26 
  27 import java.io.IOException;
  28 import java.io.InputStream;
  29 import java.net.SocketException;
  30 import java.net.InetAddress;
  31 import java.net.SocketImpl;
  32 import sun.net.ext.RdmaSocketOptions;
  33 import static jdk.internal.net.rdma.RdmaSocketImpl.PlatformRdmaSocketImpl;
  34 
  35 class LinuxRdmaSocketImpl extends PlatformRdmaSocketImpl
  36 {









  37     static {
  38         java.security.AccessController.doPrivileged(
  39             new java.security.PrivilegedAction<>() {
  40                 public Void run() {
  41                     System.loadLibrary("net");
  42                     System.loadLibrary("extnet");
  43                     return null;
  44                 }
  45             });


  46         initProto();








  47     }
  48 
  49     public LinuxRdmaSocketImpl() { }
  50 
  51     static final RdmaSocketOptions rdmaOptions =
  52             RdmaSocketOptions.getInstance();
  53 
  54     private static volatile boolean checkedRdma;
  55     private static volatile boolean isRdmaAvailable;
  56 
  57     boolean isRdmaAvailable() {
  58         if (!checkedRdma) {
  59             isRdmaAvailable = isRdmaAvailable0();
  60             checkedRdma = true;
  61         }
  62         return isRdmaAvailable;
  63     }
  64 
  65     protected synchronized RdmaSocketInputStream getRdmaInputStream(
  66             RdmaSocketImpl impl) throws IOException {
  67         return new RdmaSocketInputStream(impl);
  68     }
  69 
  70     protected synchronized RdmaSocketOutputStream getRdmaOutputStream(
  71             RdmaSocketImpl impl) throws IOException {
  72         return new RdmaSocketOutputStream(impl);
  73     }
  74 
  75     protected void rdmaSocketShutdownInput(int howto, RdmaSocketImpl impl,
  76             InputStream socketInputStream) throws IOException {
  77         rdmaSocketShutdown(howto, impl);
  78         if (socketInputStream != null) {
  79             ((RdmaSocketInputStream)socketInputStream).setEOF(true);
  80         }
  81     }
  82 
  83     static native void initProto();
  84 
  85     private static native boolean isRdmaAvailable0();
  86 
  87     native void rdmaSocketCreate(RdmaSocketImpl impl) throws IOException;
  88 
  89     native void rdmaSocketConnect(RdmaSocketImpl impl, InetAddress address, int port, int timeout)
  90         throws IOException;
  91 
  92     native void rdmaSocketBind(RdmaSocketImpl impl, InetAddress address, int port)
  93         throws IOException;
  94 
  95     native void rdmaSocketListen(RdmaSocketImpl impl, int count) throws IOException;
  96 
  97     native void rdmaSocketAccept(SocketImpl impl, RdmaSocketImpl s) throws IOException;
  98 
  99     native int rdmaSocketAvailable(RdmaSocketImpl impl) throws IOException;
 100 
 101     native void rdmaSocketClose(boolean useDeferredClose, RdmaSocketImpl impl) throws IOException;
 102 
 103     native void rdmaSocketShutdown(int howto, RdmaSocketImpl impl) throws IOException;


  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 package jdk.internal.net.rdma;
  26 
  27 import java.io.IOException;
  28 import java.io.InputStream;
  29 import java.net.SocketException;
  30 import java.net.InetAddress;
  31 import java.net.SocketImpl;
  32 import sun.net.ext.RdmaSocketOptions;
  33 import static jdk.internal.net.rdma.RdmaSocketImpl.PlatformRdmaSocketImpl;
  34 
  35 class LinuxRdmaSocketImpl extends PlatformRdmaSocketImpl
  36 {
  37     private static final UnsupportedOperationException unsupported;
  38 
  39     private static final Void checkSupported() {
  40         if (unsupported != null)
  41             throw new UnsupportedOperationException(unsupported.getMessage(), unsupported);
  42         else
  43             return null;
  44     }
  45 
  46     static {
  47         java.security.AccessController.doPrivileged(
  48             new java.security.PrivilegedAction<>() {
  49                 public Void run() {
  50                     System.loadLibrary("net");
  51                     System.loadLibrary("extnet");
  52                     return null;
  53                 }
  54             });
  55         UnsupportedOperationException uoe = null;
  56         try {
  57             initProto();
  58         } catch (UnsupportedOperationException e) {
  59             uoe = e;
  60         }
  61         unsupported = uoe;
  62     }
  63 
  64     public LinuxRdmaSocketImpl() {
  65         this(checkSupported());
  66     }
  67 
  68     private LinuxRdmaSocketImpl(Void unused) { }
  69 
  70     static final RdmaSocketOptions rdmaOptions =
  71             RdmaSocketOptions.getInstance();
  72 
  73     private static volatile boolean checkedRdma;
  74     private static volatile boolean isRdmaAvailable;
  75 
  76     boolean isRdmaAvailable() {
  77         if (!checkedRdma) {
  78             isRdmaAvailable = isRdmaAvailable0();
  79             checkedRdma = true;
  80         }
  81         return isRdmaAvailable;
  82     }
  83 
  84     protected synchronized RdmaSocketInputStream getRdmaInputStream(
  85             RdmaSocketImpl impl) throws IOException {
  86         return new RdmaSocketInputStream(impl);
  87     }
  88 
  89     protected synchronized RdmaSocketOutputStream getRdmaOutputStream(
  90             RdmaSocketImpl impl) throws IOException {
  91         return new RdmaSocketOutputStream(impl);
  92     }
  93 
  94     protected void rdmaSocketShutdownInput(int howto, RdmaSocketImpl impl,
  95             InputStream socketInputStream) throws IOException {
  96         rdmaSocketShutdown(howto, impl);
  97         if (socketInputStream != null) {
  98             ((RdmaSocketInputStream)socketInputStream).setEOF(true);
  99         }
 100     }
 101 
 102     static native void initProto() throws UnsupportedOperationException;
 103 
 104     private static native boolean isRdmaAvailable0();
 105 
 106     native void rdmaSocketCreate(RdmaSocketImpl impl) throws IOException;
 107 
 108     native void rdmaSocketConnect(RdmaSocketImpl impl, InetAddress address, int port, int timeout)
 109         throws IOException;
 110 
 111     native void rdmaSocketBind(RdmaSocketImpl impl, InetAddress address, int port)
 112         throws IOException;
 113 
 114     native void rdmaSocketListen(RdmaSocketImpl impl, int count) throws IOException;
 115 
 116     native void rdmaSocketAccept(SocketImpl impl, RdmaSocketImpl s) throws IOException;
 117 
 118     native int rdmaSocketAvailable(RdmaSocketImpl impl) throws IOException;
 119 
 120     native void rdmaSocketClose(boolean useDeferredClose, RdmaSocketImpl impl) throws IOException;
 121 
 122     native void rdmaSocketShutdown(int howto, RdmaSocketImpl impl) throws IOException;
< prev index next >