fix leader election using bind address for http
@@ -1404,13 +1404,30 @@ private void startLeaderElectionService() throws IOException {
}
String httpAddress;
+ /*
+ * httpServer.getHttpAddress() return the bind address. If we use 0.0.0.0 to listen to all interfaces the leader
+ * election system will return 0.0.0.0 as the http address and the client will not be able to connect to the UI
+ * to mitigate this we retunr the address used by the RPC. This address will work because the http server is
+ * listening on very interfaces
+ * */
+
if (DFSUtil.getHttpPolicy(conf).isHttpEnabled()) {
+ if (httpServer.getHttpAddress().getAddress().getHostAddress().equals("0.0.0.0")) {
+ httpAddress = rpcServer.getRpcAddress().getAddress().getHostAddress() + ":" + httpServer.getHttpAddress()
+ .getPort();
+ } else {
httpAddress = httpServer.getHttpAddress().getAddress().getHostAddress() + ":" + httpServer.getHttpAddress()
.getPort();
+ }
+ } else {
+ if (httpServer.getHttpsAddress().getAddress().getHostAddress().equals("0.0.0.0")) {
+ httpAddress = rpcServer.getRpcAddress().getAddress().getHostAddress() + ":" + httpServer.getHttpsAddress()
+ .getPort();
} else {
httpAddress = httpServer.getHttpsAddress().getAddress().getHostAddress() + ":" + httpServer.getHttpsAddress()
.getPort();
}
+ }
leaderElection =
new LeaderElection(new HdfsLeDescriptorFactory(), leadercheckInterval,
