YARN-5728. TestMiniYarnClusterNodeUtilization.testUpdateNodeUtilization timeout.
This commit is contained in:
parent
890e14c02a
commit
f8bed5e9a7
@ -21,6 +21,7 @@
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
|
import java.net.InetSocketAddress;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -36,6 +37,7 @@
|
|||||||
import org.apache.hadoop.fs.Path;
|
import org.apache.hadoop.fs.Path;
|
||||||
import org.apache.hadoop.ha.HAServiceProtocol;
|
import org.apache.hadoop.ha.HAServiceProtocol;
|
||||||
import org.apache.hadoop.metrics2.lib.DefaultMetricsSystem;
|
import org.apache.hadoop.metrics2.lib.DefaultMetricsSystem;
|
||||||
|
import org.apache.hadoop.net.NetUtils;
|
||||||
import org.apache.hadoop.security.token.Token;
|
import org.apache.hadoop.security.token.Token;
|
||||||
import org.apache.hadoop.net.ServerSocketUtil;
|
import org.apache.hadoop.net.ServerSocketUtil;
|
||||||
import org.apache.hadoop.service.AbstractService;
|
import org.apache.hadoop.service.AbstractService;
|
||||||
@ -446,7 +448,16 @@ public NodeManager getNodeManager(int i) {
|
|||||||
|
|
||||||
public static String getHostname() {
|
public static String getHostname() {
|
||||||
try {
|
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) {
|
catch (UnknownHostException ex) {
|
||||||
throw new RuntimeException(ex);
|
throw new RuntimeException(ex);
|
||||||
|
Loading…
Reference in New Issue
Block a user