< prev index next >
src/jdk.net/linux/classes/jdk/internal/net/rdma/RdmaSocketImpl.java
Print this page
*** 45,55 ****
import java.security.PrivilegedAction;
import java.util.Set;
import sun.net.ConnectionResetException;
import sun.net.ext.RdmaSocketOptions;
! public class RdmaSocketImpl extends SocketImpl
{
Socket socket = null;
ServerSocket serverSocket = null;
int timeout; // timeout in millisec
--- 45,55 ----
import java.security.PrivilegedAction;
import java.util.Set;
import sun.net.ConnectionResetException;
import sun.net.ext.RdmaSocketOptions;
! public abstract class RdmaSocketImpl extends SocketImpl
{
Socket socket = null;
ServerSocket serverSocket = null;
int timeout; // timeout in millisec
*** 86,95 ****
--- 86,110 ----
boolean isRdmaAvailable() {
return platformRdmaSocketImpl.isRdmaAvailable();
}
+ private static final Void checkSupported() {
+ if (PlatformRdmaSocketImpl.unsupported != null) {
+ Exception e = PlatformRdmaSocketImpl.unsupported;
+ throw new UnsupportedOperationException(e.getMessage(), e);
+ } else {
+ return null;
+ }
+ }
+
+ public RdmaSocketImpl() {
+ this(checkSupported());
+ }
+
+ private RdmaSocketImpl(Void unused) { }
+
void setSocket(Socket soc) {
this.socket = soc;
}
Socket getSocket() {
*** 103,113 ****
ServerSocket getServerSocket() {
return serverSocket;
}
@Override
! protected Set<SocketOption<?>> supportedOptions() { return null; }
protected synchronized void create(boolean stream) throws IOException {
fd = new FileDescriptor();
platformRdmaSocketImpl.rdmaSocketCreate(this);
}
--- 118,128 ----
ServerSocket getServerSocket() {
return serverSocket;
}
@Override
! protected abstract Set<SocketOption<?>> supportedOptions();
protected synchronized void create(boolean stream) throws IOException {
fd = new FileDescriptor();
platformRdmaSocketImpl.rdmaSocketCreate(this);
}
*** 177,193 ****
doConnect(address, port, timeout);
}
}
@Override
! protected <T> void setOption(SocketOption<T> name, T value)
! throws IOException {}
@SuppressWarnings("unchecked")
@Override
! protected <T> T getOption(SocketOption<T> name)
! throws IOException { return null; }
public void setOption(int opt, Object val) throws SocketException {
if (isClosedOrPending()) {
throw new SocketException("Socket Closed");
}
--- 192,208 ----
doConnect(address, port, timeout);
}
}
@Override
! protected abstract <T> void setOption(SocketOption<T> name, T value)
! throws IOException;
@SuppressWarnings("unchecked")
@Override
! protected abstract <T> T getOption(SocketOption<T> name)
! throws IOException;
public void setOption(int opt, Object val) throws SocketException {
if (isClosedOrPending()) {
throw new SocketException("Socket Closed");
}
*** 534,551 ****
--- 549,569 ----
public static final int SHUT_RD = 0;
public static final int SHUT_WR = 1;
static class PlatformRdmaSocketImpl {
+ private static UnsupportedOperationException unsupported;
@SuppressWarnings("unchecked")
private static PlatformRdmaSocketImpl newInstance(String cn) {
Class<PlatformRdmaSocketImpl> c;
try {
c = (Class<PlatformRdmaSocketImpl>)Class.forName(cn);
return c.getConstructor(new Class<?>[] {}).newInstance();
} catch (ReflectiveOperationException x) {
+ if (x.getCause() instanceof UnsupportedOperationException)
+ throw (UnsupportedOperationException)x.getCause();
throw new AssertionError(x);
}
}
private static PlatformRdmaSocketImpl create() {
*** 553,565 ****
new PrivilegedAction<String>() {
public String run() {
return System.getProperty("os.name");
}
});
! if ("Linux".equals(osname))
! return newInstance("jdk.internal.net.rdma.LinuxRdmaSocketImpl");
! return new PlatformRdmaSocketImpl();
}
private static final PlatformRdmaSocketImpl instance = create();
static PlatformRdmaSocketImpl get() {
--- 571,594 ----
new PrivilegedAction<String>() {
public String run() {
return System.getProperty("os.name");
}
});
! PlatformRdmaSocketImpl impl;
! UnsupportedOperationException uoe = null;
! if ("Linux".equals(osname)) {
! try {
! impl = newInstance("jdk.internal.net.rdma.LinuxRdmaSocketImpl");
! } catch (UnsupportedOperationException e) {
! uoe = e;
! impl = new PlatformRdmaSocketImpl();
! }
! } else {
! impl = new PlatformRdmaSocketImpl();
! }
! unsupported = uoe;
! return impl;
}
private static final PlatformRdmaSocketImpl instance = create();
static PlatformRdmaSocketImpl get() {
< prev index next >