YARN-11123. ResourceManager webapps test failures due to org.apache.hadoop.metrics2.MetricsException and subsequent java.net.BindException: Address already in use. Contributed by Szilard Nemeth

This commit is contained in:
Szilard Nemeth 2022-05-08 23:05:08 +02:00 committed by Benjamin Teke
parent dad2900b87
commit eced5bec68
3 changed files with 18 additions and 2 deletions

View File

@ -25,6 +25,11 @@ import org.apache.hadoop.yarn.exceptions.YarnRuntimeException;
public class WebAppException extends YarnRuntimeException {
private static final long serialVersionUID = 1L;
private WebApp webApp;
public WebApp getWebApp() {
return webApp;
}
public WebAppException(String msg) {
super(msg);
@ -35,6 +40,11 @@ public class WebAppException extends YarnRuntimeException {
}
public WebAppException(String msg, Throwable cause) {
this(msg, cause, null);
}
public WebAppException(String msg, Throwable cause, WebApp webApp) {
super(msg, cause);
this.webApp = webApp;
}
}

View File

@ -476,7 +476,7 @@ public class WebApps {
LOG.info("Web app " + name + " started at "
+ httpServer.getConnectorAddress(0).getPort());
} catch (IOException e) {
throw new WebAppException("Error starting http server", e);
throw new WebAppException("Error starting http server", e, webApp);
}
return webApp;
}

View File

@ -23,6 +23,7 @@ import org.apache.hadoop.classification.VisibleForTesting;
import com.sun.jersey.spi.container.servlet.ServletContainer;
import org.apache.hadoop.yarn.metrics.GenericEventTypeMetrics;
import org.apache.hadoop.yarn.webapp.WebAppException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.Marker;
@ -1440,7 +1441,12 @@ public class ResourceManager extends CompositeService
IsResourceManagerActiveServlet.PATH_SPEC,
IsResourceManagerActiveServlet.class);
webApp = builder.start(new RMWebApp(this), uiWebAppContext);
try {
webApp = builder.start(new RMWebApp(this), uiWebAppContext);
} catch (WebAppException e) {
webApp = e.getWebApp();
throw e;
}
}
private String getWebAppsPath(String appName) {