HDFS-8268. Port conflict log for data node server is not sufficient (Contributed by Mohammad Shahid Khan)

This commit is contained in:
Vinayakumar B 2015-05-22 16:15:15 +05:30
parent ab7958f227
commit 0c6638c2ea
2 changed files with 33 additions and 6 deletions

View File

@ -802,6 +802,9 @@ Release 2.8.0 - UNRELEASED
HDFS-8454. Remove unnecessary throttling in TestDatanodeDeath. HDFS-8454. Remove unnecessary throttling in TestDatanodeDeath.
(Arpit Agarwal) (Arpit Agarwal)
HDFS-8268. Port conflict log for data node server is not sufficient
(Mohammad Shahid Khan via vinayakumarb)
Release 2.7.1 - UNRELEASED Release 2.7.1 - UNRELEASED
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -42,8 +42,10 @@
import java.io.Closeable; import java.io.Closeable;
import java.io.IOException; import java.io.IOException;
import java.net.BindException;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.net.SocketAddress; import java.net.SocketAddress;
import java.net.SocketException;
import java.nio.channels.ServerSocketChannel; import java.nio.channels.ServerSocketChannel;
import java.security.GeneralSecurityException; import java.security.GeneralSecurityException;
@ -142,19 +144,41 @@ public InetSocketAddress getHttpsAddress() {
return httpsAddress; return httpsAddress;
} }
public void start() { public void start() throws IOException {
if (httpServer != null) { if (httpServer != null) {
ChannelFuture f = httpServer.bind(DataNode.getInfoAddr(conf)); InetSocketAddress infoAddr = DataNode.getInfoAddr(conf);
f.syncUninterruptibly(); ChannelFuture f = httpServer.bind(infoAddr);
try {
f.syncUninterruptibly();
} catch (Throwable e) {
if (e instanceof BindException) {
throw NetUtils.wrapException(null, 0, infoAddr.getHostName(),
infoAddr.getPort(), (SocketException) e);
} else {
throw e;
}
}
httpAddress = (InetSocketAddress) f.channel().localAddress(); httpAddress = (InetSocketAddress) f.channel().localAddress();
LOG.info("Listening HTTP traffic on " + httpAddress); LOG.info("Listening HTTP traffic on " + httpAddress);
} }
if (httpsServer != null) { if (httpsServer != null) {
InetSocketAddress secInfoSocAddr = NetUtils.createSocketAddr(conf.getTrimmed( InetSocketAddress secInfoSocAddr =
DFS_DATANODE_HTTPS_ADDRESS_KEY, DFS_DATANODE_HTTPS_ADDRESS_DEFAULT)); NetUtils.createSocketAddr(conf.getTrimmed(
DFS_DATANODE_HTTPS_ADDRESS_KEY,
DFS_DATANODE_HTTPS_ADDRESS_DEFAULT));
ChannelFuture f = httpsServer.bind(secInfoSocAddr); ChannelFuture f = httpsServer.bind(secInfoSocAddr);
f.syncUninterruptibly();
try {
f.syncUninterruptibly();
} catch (Throwable e) {
if (e instanceof BindException) {
throw NetUtils.wrapException(null, 0, secInfoSocAddr.getHostName(),
secInfoSocAddr.getPort(), (SocketException) e);
} else {
throw e;
}
}
httpsAddress = (InetSocketAddress) f.channel().localAddress(); httpsAddress = (InetSocketAddress) f.channel().localAddress();
LOG.info("Listening HTTPS traffic on " + httpsAddress); LOG.info("Listening HTTPS traffic on " + httpsAddress);
} }