YARN-5728. TestMiniYarnClusterNodeUtilization.testUpdateNodeUtilization timeout.
(cherry picked from commit f8bed5e9a7d1ece127fb3da123bbfc26ada0016f) (cherry picked from commit 98c3544e9407e3e1dfae9806d4a8181508952bed) (cherry picked from commit d57784cbda491f591e1ebd5d7a60e2b5fd23f087)
This commit is contained in:
parent
db0bc8fafa
commit
222771c6ad
@ -21,6 +21,7 @@
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.Collection;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
@ -35,6 +36,7 @@
|
||||
import org.apache.hadoop.fs.Path;
|
||||
import org.apache.hadoop.ha.HAServiceProtocol;
|
||||
import org.apache.hadoop.metrics2.lib.DefaultMetricsSystem;
|
||||
import org.apache.hadoop.net.NetUtils;
|
||||
import org.apache.hadoop.security.token.Token;
|
||||
import org.apache.hadoop.service.AbstractService;
|
||||
import org.apache.hadoop.service.CompositeService;
|
||||
@ -440,7 +442,16 @@ public NodeManager getNodeManager(int i) {
|
||||
|
||||
public static String getHostname() {
|
||||
try {
|
||||
return InetAddress.getLocalHost().getHostName();
|
||||
String hostname = InetAddress.getLocalHost().getHostName();
|
||||
// Create InetSocketAddress to see whether it is resolved or not.
|
||||
// If not, just return "localhost".
|
||||
InetSocketAddress addr =
|
||||
NetUtils.createSocketAddrForHost(hostname, 1);
|
||||
if (addr.isUnresolved()) {
|
||||
return "localhost";
|
||||
} else {
|
||||
return hostname;
|
||||
}
|
||||
}
|
||||
catch (UnknownHostException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
|
Loading…
x
Reference in New Issue
Block a user