HADOOP-15250. Split-DNS MultiHomed Server Network Cluster Network IPC Client Bind Addr Wrong
Contributed by Ajay Kumar
This commit is contained in:
parent
68c6ec719d
commit
8f42dafcf8
|
@ -341,6 +341,10 @@ public class CommonConfigurationKeys extends CommonConfigurationKeysPublic {
|
||||||
public static final String IPC_CLIENT_FALLBACK_TO_SIMPLE_AUTH_ALLOWED_KEY = "ipc.client.fallback-to-simple-auth-allowed";
|
public static final String IPC_CLIENT_FALLBACK_TO_SIMPLE_AUTH_ALLOWED_KEY = "ipc.client.fallback-to-simple-auth-allowed";
|
||||||
public static final boolean IPC_CLIENT_FALLBACK_TO_SIMPLE_AUTH_ALLOWED_DEFAULT = false;
|
public static final boolean IPC_CLIENT_FALLBACK_TO_SIMPLE_AUTH_ALLOWED_DEFAULT = false;
|
||||||
|
|
||||||
|
public static final String IPC_CLIENT_BIND_WILDCARD_ADDR_KEY = "ipc.client"
|
||||||
|
+ ".bind.wildcard.addr";
|
||||||
|
public static final boolean IPC_CLIENT_BIND_WILDCARD_ADDR_DEFAULT = false;
|
||||||
|
|
||||||
public static final String IPC_CLIENT_CONNECT_MAX_RETRIES_ON_SASL_KEY =
|
public static final String IPC_CLIENT_CONNECT_MAX_RETRIES_ON_SASL_KEY =
|
||||||
"ipc.client.connect.max.retries.on.sasl";
|
"ipc.client.connect.max.retries.on.sasl";
|
||||||
public static final int IPC_CLIENT_CONNECT_MAX_RETRIES_ON_SASL_DEFAULT = 5;
|
public static final int IPC_CLIENT_CONNECT_MAX_RETRIES_ON_SASL_DEFAULT = 5;
|
||||||
|
|
|
@ -135,6 +135,7 @@ public class Client implements AutoCloseable {
|
||||||
private final int connectionTimeout;
|
private final int connectionTimeout;
|
||||||
|
|
||||||
private final boolean fallbackAllowed;
|
private final boolean fallbackAllowed;
|
||||||
|
private final boolean bindToWildCardAddress;
|
||||||
private final byte[] clientId;
|
private final byte[] clientId;
|
||||||
private final int maxAsyncCalls;
|
private final int maxAsyncCalls;
|
||||||
private final AtomicInteger asyncCallCounter = new AtomicInteger(0);
|
private final AtomicInteger asyncCallCounter = new AtomicInteger(0);
|
||||||
|
@ -674,10 +675,10 @@ public class Client implements AutoCloseable {
|
||||||
InetAddress localAddr = NetUtils.getLocalInetAddress(host);
|
InetAddress localAddr = NetUtils.getLocalInetAddress(host);
|
||||||
if (localAddr != null) {
|
if (localAddr != null) {
|
||||||
this.socket.setReuseAddress(true);
|
this.socket.setReuseAddress(true);
|
||||||
if (LOG.isDebugEnabled()) {
|
localAddr = NetUtils.bindToLocalAddress(localAddr,
|
||||||
LOG.debug("Binding " + principal + " to " + localAddr);
|
bindToWildCardAddress);
|
||||||
}
|
LOG.debug("Binding {} to {}", principal, localAddr);
|
||||||
bindAddr = new InetSocketAddress(localAddr, 0);
|
this.socket.bind(new InetSocketAddress(localAddr, 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1277,6 +1278,13 @@ public class Client implements AutoCloseable {
|
||||||
CommonConfigurationKeys.IPC_CLIENT_CONNECT_TIMEOUT_DEFAULT);
|
CommonConfigurationKeys.IPC_CLIENT_CONNECT_TIMEOUT_DEFAULT);
|
||||||
this.fallbackAllowed = conf.getBoolean(CommonConfigurationKeys.IPC_CLIENT_FALLBACK_TO_SIMPLE_AUTH_ALLOWED_KEY,
|
this.fallbackAllowed = conf.getBoolean(CommonConfigurationKeys.IPC_CLIENT_FALLBACK_TO_SIMPLE_AUTH_ALLOWED_KEY,
|
||||||
CommonConfigurationKeys.IPC_CLIENT_FALLBACK_TO_SIMPLE_AUTH_ALLOWED_DEFAULT);
|
CommonConfigurationKeys.IPC_CLIENT_FALLBACK_TO_SIMPLE_AUTH_ALLOWED_DEFAULT);
|
||||||
|
this.bindToWildCardAddress = conf
|
||||||
|
.getBoolean(CommonConfigurationKeys.IPC_CLIENT_BIND_WILDCARD_ADDR_KEY,
|
||||||
|
CommonConfigurationKeys.IPC_CLIENT_BIND_WILDCARD_ADDR_DEFAULT);
|
||||||
|
LOG.debug("{} set to true. Will bind client sockets to wildcard "
|
||||||
|
+ "address.",
|
||||||
|
CommonConfigurationKeys.IPC_CLIENT_BIND_WILDCARD_ADDR_KEY);
|
||||||
|
|
||||||
this.clientId = ClientId.getClientId();
|
this.clientId = ClientId.getClientId();
|
||||||
this.sendParamsExecutor = clientExcecutorFactory.refAndGetInstance();
|
this.sendParamsExecutor = clientExcecutorFactory.refAndGetInstance();
|
||||||
this.maxAsyncCalls = conf.getInt(
|
this.maxAsyncCalls = conf.getInt(
|
||||||
|
|
|
@ -952,4 +952,20 @@ public class NetUtils {
|
||||||
}
|
}
|
||||||
return port;
|
return port;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return an @{@link InetAddress} to bind to. If bindWildCardAddress is true
|
||||||
|
* than returns null.
|
||||||
|
*
|
||||||
|
* @param localAddr
|
||||||
|
* @param bindWildCardAddress
|
||||||
|
* @returns InetAddress
|
||||||
|
*/
|
||||||
|
public static InetAddress bindToLocalAddress(InetAddress localAddr, boolean
|
||||||
|
bindWildCardAddress) {
|
||||||
|
if (!bindWildCardAddress) {
|
||||||
|
return localAddr;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3051,4 +3051,12 @@
|
||||||
System tags to group related properties together.
|
System tags to group related properties together.
|
||||||
</description>
|
</description>
|
||||||
</property>
|
</property>
|
||||||
|
|
||||||
|
<property>
|
||||||
|
<name>ipc.client.bind.wildcard.addr</name>
|
||||||
|
<value>false</value>
|
||||||
|
<description>When set to true Clients will bind socket to wildcard
|
||||||
|
address. (i.e 0.0.0.0)
|
||||||
|
</description>
|
||||||
|
</property>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|
|
@ -707,6 +707,14 @@ public class TestNetUtils {
|
||||||
assertEquals(defaultAddr.trim(), NetUtils.getHostPortString(addr));
|
assertEquals(defaultAddr.trim(), NetUtils.getHostPortString(addr));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testBindToLocalAddress() throws Exception {
|
||||||
|
assertNotNull(NetUtils
|
||||||
|
.bindToLocalAddress(NetUtils.getLocalInetAddress("127.0.0.1"), false));
|
||||||
|
assertNull(NetUtils
|
||||||
|
.bindToLocalAddress(NetUtils.getLocalInetAddress("127.0.0.1"), true));
|
||||||
|
}
|
||||||
|
|
||||||
private <T> void assertBetterArrayEquals(T[] expect, T[]got) {
|
private <T> void assertBetterArrayEquals(T[] expect, T[]got) {
|
||||||
String expectStr = StringUtils.join(expect, ", ");
|
String expectStr = StringUtils.join(expect, ", ");
|
||||||
String gotStr = StringUtils.join(got, ", ");
|
String gotStr = StringUtils.join(got, ", ");
|
||||||
|
|
Loading…
Reference in New Issue