Package org.apache.hadoop.hbase
Class TestIPv6NIOServerSocketChannel
java.lang.Object
org.apache.hadoop.hbase.TestIPv6NIOServerSocketChannel
This tests whether ServerSocketChannel works over ipv6, which ZooKeeper depends on. On Windows
Oracle JDK 6, creating a ServerSocketChannel throws java.net.SocketException: Address family not
supported by protocol family exception. It is a known JVM bug, seems to be only resolved for
JDK7: http://bugs.sun.com/view_bug.do?bug_id=6230761 For this test, we check that whether we are
effected by this bug, and if so the test ensures that we are running with
java.net.preferIPv4Stack=true, so that ZK will not fail to bind to ipv6 address using
ClientCnxnSocketNIO.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final HBaseClassTestRule
private static final org.slf4j.Logger
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprivate void
bindNIOServerSocket
(InetAddress inetAddr) Creates a NIO ServerSocketChannel, and gets the ServerSocket from there.private void
bindServerSocket
(InetAddress inetAddr) Creates and binds a regular ServerSocket.void
Checks whether we are running with java.net.preferIPv4Stack=truestatic void
void
Checks whether we are effected by the JDK issue on windows, and if so ensures that we are running with preferIPv4Stack=true.void
Tests whether every InetAddress we obtain by resolving can open a ServerSocketChannel.
-
Field Details
-
CLASS_RULE
-
LOG
-
-
Constructor Details
-
TestIPv6NIOServerSocketChannel
public TestIPv6NIOServerSocketChannel()
-
-
Method Details
-
bindServerSocket
Creates and binds a regular ServerSocket.- Throws:
IOException
-
bindNIOServerSocket
Creates a NIO ServerSocketChannel, and gets the ServerSocket from there. Then binds the obtained socket. This fails on Windows with Oracle JDK1.6.0u33, if the passed InetAddress is a IPv6 address. Works on Oracle JDK 1.7.- Throws:
IOException
-
testServerSocket
Checks whether we are effected by the JDK issue on windows, and if so ensures that we are running with preferIPv4Stack=true.- Throws:
IOException
-
ensurePreferIPv4
Checks whether we are running with java.net.preferIPv4Stack=true- Throws:
IOException
-
testServerSocketFromLocalhostResolution
Tests whether every InetAddress we obtain by resolving can open a ServerSocketChannel.- Throws:
IOException
-
main
- Throws:
Exception
-