Index: hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/conf/YarnConfiguration.java =================================================================== --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/conf/YarnConfiguration.java (revision 1510366) +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/conf/YarnConfiguration.java (working copy) @@ -718,7 +718,20 @@ public static final String YARN_APP_CONTAINER_LOG_SIZE = YARN_PREFIX + "app.container.log.filesize"; + + // ////////////////////////////// + // Application History Server Configs + // ////////////////////////////// + public static final String AHS_PREFIX = "yarn.ahs."; + + public static final String AHS_WEB_ADDRESS = AHS_PREFIX + "webapp.address"; + + public static final int DEFAULT_AHS_WEB_PORT = 19887; + public static final String DEFAULT_AHS_WEB_ADDRESS = "0.0.0.0:" + + DEFAULT_AHS_WEB_PORT; + + //////////////////////////////// // Other Configs //////////////////////////////// Index: hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/webapp/YarnWebParams.java =================================================================== --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/webapp/YarnWebParams.java (revision 1510366) +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/webapp/YarnWebParams.java (working copy) @@ -24,6 +24,7 @@ public interface YarnWebParams { String NM_NODENAME = "nm.id"; String APPLICATION_ID = "app.id"; + String APPLICATION_ATTEMPT_ID = "appattempt.id"; String CONTAINER_ID = "container.id"; String CONTAINER_LOG_TYPE= "log.type"; String ENTITY_STRING = "entity.string"; Index: hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/AHSWebServer.java =================================================================== --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/AHSWebServer.java (revision 1510366) +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/AHSWebServer.java (working copy) @@ -18,12 +18,44 @@ package org.apache.hadoop.yarn.server.applicationhistoryservice; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.apache.hadoop.service.AbstractService; +import org.apache.hadoop.yarn.conf.YarnConfiguration; +import org.apache.hadoop.yarn.exceptions.YarnRuntimeException; +import org.apache.hadoop.yarn.server.applicationhistoryservice.webapp.AHSWebApp; +import org.apache.hadoop.yarn.webapp.WebApps; public class AHSWebServer extends AbstractService { + private static final Log LOG = LogFactory.getLog(AHSWebServer.class); + private AHSWebApp webApp; + private final AHSClientService ahsClientService; - public AHSWebServer() { + public AHSWebServer(ApplicationHistoryReader appHistoryReader, AHSClientService ahsClientService) { super(AHSWebServer.class.getName()); + this.ahsClientService = ahsClientService; + webApp = new AHSWebApp(appHistoryReader); } -} + @Override + protected void serviceStart() throws Exception { + String bindAddress = getConfig().get(YarnConfiguration.AHS_WEB_ADDRESS, + YarnConfiguration.DEFAULT_AHS_WEB_ADDRESS); + LOG.info("Instantiating AHSWebApp at " + bindAddress); + try { + WebApps.$for("applicationhistory", AHSClientService.class, + ahsClientService, "ws").with(getConfig()).at(bindAddress).start( + webApp); + } catch (Exception e) { + String msg = "AHSWebapps failed to start."; + LOG.error(msg, e); + throw new YarnRuntimeException(msg, e); + } + super.serviceStart(); + } + + @Override + protected void serviceStop() throws Exception { + super.serviceStop(); + } +} \ No newline at end of file Index: hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/ApplicationHistoryServer.java =================================================================== --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/ApplicationHistoryServer.java (revision 1510366) +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/ApplicationHistoryServer.java (working copy) @@ -33,10 +33,13 @@ @Override protected void serviceInit(Configuration conf) throws Exception { - super.serviceInit(conf); AHSClientService ahsClientService = new AHSClientService(); addService(ahsClientService); - AHSWebServer webServer = new AHSWebServer(); + + // TODO Need to intialize the application history reader + ApplicationHistoryReader appHistoryReader = null; + AHSWebServer webServer = new AHSWebServer(appHistoryReader, ahsClientService); addService(webServer); + super.serviceInit(conf); } } Index: hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/AHSJAXBContextResolver.java =================================================================== --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/AHSJAXBContextResolver.java (revision 0) +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/AHSJAXBContextResolver.java (working copy) @@ -0,0 +1,61 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.yarn.server.applicationhistoryservice.webapp; + +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + +import javax.ws.rs.ext.ContextResolver; +import javax.ws.rs.ext.Provider; +import javax.xml.bind.JAXBContext; + +import org.apache.hadoop.yarn.server.applicationhistoryservice.webapp.dao.AHSAppAttemptInfo; +import org.apache.hadoop.yarn.server.applicationhistoryservice.webapp.dao.AHSAppAttemptsInfo; +import org.apache.hadoop.yarn.server.applicationhistoryservice.webapp.dao.AHSAppInfo; +import org.apache.hadoop.yarn.server.applicationhistoryservice.webapp.dao.AHSAppsInfo; +import org.apache.hadoop.yarn.server.applicationhistoryservice.webapp.dao.AHSContainerInfo; +import org.apache.hadoop.yarn.server.applicationhistoryservice.webapp.dao.AHSContainersInfo; + +import com.google.inject.Singleton; +import com.sun.jersey.api.json.JSONConfiguration; +import com.sun.jersey.api.json.JSONJAXBContext; + +@Singleton +@Provider +@SuppressWarnings("unchecked") +public class AHSJAXBContextResolver implements ContextResolver { + + private JAXBContext context; + private final Set types; + + private final Class[] cTypes = { AHSAppsInfo.class, AHSAppInfo.class, + AHSAppAttemptsInfo.class, AHSAppAttemptInfo.class, + AHSContainersInfo.class, AHSContainerInfo.class }; + + public AHSJAXBContextResolver() throws Exception { + this.types = new HashSet(Arrays.asList(cTypes)); + this.context = new JSONJAXBContext(JSONConfiguration.natural() + .rootUnwrapping(false).build(), cTypes); + } + + @Override + public JAXBContext getContext(Class objectType) { + return (types.contains(objectType)) ? context : null; + } +} \ No newline at end of file Index: hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/AHSWebApp.java =================================================================== --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/AHSWebApp.java (revision 0) +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/AHSWebApp.java (working copy) @@ -0,0 +1,57 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.yarn.server.applicationhistoryservice.webapp; + +import static org.apache.hadoop.yarn.util.StringHelper.pajoin; + +import org.apache.hadoop.yarn.server.applicationhistoryservice.ApplicationHistoryReader; +import org.apache.hadoop.yarn.webapp.GenericExceptionHandler; +import org.apache.hadoop.yarn.webapp.WebApp; +import org.apache.hadoop.yarn.webapp.YarnWebParams; + +public class AHSWebApp extends WebApp implements YarnWebParams { + + private final ApplicationHistoryReader appHistoryReader; + + public AHSWebApp(ApplicationHistoryReader appHistoryReader) { + this.appHistoryReader = appHistoryReader; + } + + @Override + public void setup() { + bind(AHSWebServices.class); + bind(GenericExceptionHandler.class); + bind(AHSJAXBContextResolver.class); + bind(ApplicationHistoryReader.class).toInstance( + this.appHistoryReader); + route("/", ApplicationHistoryController.class, "applicationHistory"); + route("/about", ApplicationHistoryController.class, "about"); + route("/applicationhistory", ApplicationHistoryController.class, + "applicationHistory"); + route(pajoin("/application", YarnWebParams.APPLICATION_ID), ApplicationHistoryController.class, + "application"); + route(pajoin("/appattempts", YarnWebParams.APPLICATION_ID), ApplicationHistoryController.class, + "appAttempts"); + route(pajoin("/appattempt", YarnWebParams.APPLICATION_ATTEMPT_ID), ApplicationHistoryController.class, + "appAttempt"); + route(pajoin("/containers", YarnWebParams.APPLICATION_ID), + ApplicationHistoryController.class, "containers"); + route(pajoin("/container", YarnWebParams.CONTAINER_ID), + ApplicationHistoryController.class, "container"); + } +} Index: hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/AHSWebServices.java =================================================================== --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/AHSWebServices.java (revision 0) +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/AHSWebServices.java (working copy) @@ -0,0 +1,256 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.yarn.server.applicationhistoryservice.webapp; + +import java.io.IOException; +import java.util.Collection; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; + +import org.apache.hadoop.yarn.api.records.ApplicationAttemptId; +import org.apache.hadoop.yarn.api.records.ApplicationId; +import org.apache.hadoop.yarn.api.records.ContainerId; +import org.apache.hadoop.yarn.factories.RecordFactory; +import org.apache.hadoop.yarn.factory.providers.RecordFactoryProvider; +import org.apache.hadoop.yarn.server.applicationhistoryservice.ApplicationHistoryReader; +import org.apache.hadoop.yarn.server.applicationhistoryservice.records.ApplicationAttemptHistoryData; +import org.apache.hadoop.yarn.server.applicationhistoryservice.records.ApplicationHistoryData; +import org.apache.hadoop.yarn.server.applicationhistoryservice.records.ContainerHistoryData; +import org.apache.hadoop.yarn.server.applicationhistoryservice.webapp.dao.AHSAppAttemptInfo; +import org.apache.hadoop.yarn.server.applicationhistoryservice.webapp.dao.AHSAppAttemptsInfo; +import org.apache.hadoop.yarn.server.applicationhistoryservice.webapp.dao.AHSAppInfo; +import org.apache.hadoop.yarn.server.applicationhistoryservice.webapp.dao.AHSAppsInfo; +import org.apache.hadoop.yarn.server.applicationhistoryservice.webapp.dao.AHSContainerInfo; +import org.apache.hadoop.yarn.server.applicationhistoryservice.webapp.dao.AHSContainersInfo; +import org.apache.hadoop.yarn.server.applicationhistoryservice.webapp.dao.AHSInfo; +import org.apache.hadoop.yarn.util.ConverterUtils; +import org.apache.hadoop.yarn.webapp.NotFoundException; + +import com.google.inject.Inject; + +@Path("/ws/v1/applicationhistory") +public class AHSWebServices { + + @Context + private HttpServletResponse response; + + private ApplicationHistoryReader appHistoryReader; + + private static RecordFactory recordFactory = RecordFactoryProvider + .getRecordFactory(null); + + @Inject + public AHSWebServices(ApplicationHistoryReader appHistoryReader) { + this.appHistoryReader = appHistoryReader; + } + + private void init() { + // clear content type + response.setContentType(null); + } + + @GET + @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) + public AHSInfo get() { + return getAHSInfo(); + } + + @GET + @Path("/info") + @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) + public AHSInfo getAHSInfo() { + init(); + return new AHSInfo(); + } + + @GET + @Path("/apps/{appid}") + @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) + public AHSAppInfo getApp(@Context HttpServletRequest hsr, + @PathParam("appid") String appId) { + init(); + if (appId == null || appId.isEmpty()) { + throw new NotFoundException("appId, " + appId + ", is empty or null"); + } + ApplicationId id = ConverterUtils.toApplicationId(recordFactory, appId); + if (id == null) { + throw new NotFoundException("appId is null"); + } + ApplicationHistoryData application; + try { + application = appHistoryReader.getApplication(id); + } catch (IOException e) { + throw new RuntimeException("Failed to get the application for appId:" + + appId, e); + } + if (application == null) { + throw new NotFoundException("app with id: " + appId + " not found"); + } + return new AHSAppInfo(application); + } + + @GET + @Path("/apps") + @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) + public AHSAppsInfo getApps() { + init(); + + Collection appsData; + try { + appsData = appHistoryReader.getAllApplications().values(); + } catch (IOException e) { + throw new RuntimeException("Failed to get all applications", e); + } + if (appsData == null) { + throw new NotFoundException("All Applications data is empty."); + } + AHSAppsInfo appsInfo = new AHSAppsInfo(); + for (ApplicationHistoryData appData : appsData) { + appsInfo.add(new AHSAppInfo(appData)); + } + return appsInfo; + } + + @GET + @Path("/{appid}/appattempts") + @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) + public AHSAppAttemptsInfo getAppAttempts(@PathParam("appid") String appId) { + init(); + if (appId == null || appId.isEmpty()) { + throw new NotFoundException("appId, " + appId + ", is empty or null"); + } + ApplicationId id = ConverterUtils.toApplicationId(recordFactory, appId); + if (id == null) { + throw new NotFoundException("appId is null"); + } + + Collection attempts; + try { + attempts = appHistoryReader.getApplicationAttempts(id).values(); + } catch (IOException e) { + throw new RuntimeException( + "Failed to get appattempts for appId:" + appId, e); + } + if (attempts == null) { + throw new NotFoundException("appattempts for appId: " + appId + + " not found"); + } + AHSAppAttemptsInfo appAttemptsInfo = new AHSAppAttemptsInfo(); + for (ApplicationAttemptHistoryData appAttemptHistoryData : attempts) { + appAttemptsInfo.add(new AHSAppAttemptInfo(appAttemptHistoryData)); + } + return appAttemptsInfo; + } + + @GET + @Path("/appattempts/{appattemptid}") + @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) + public AHSAppAttemptInfo getAppAttempt(@Context HttpServletRequest hsr, + @PathParam("appattemptid") String appAttemptId) { + init(); + if (appAttemptId == null || appAttemptId.isEmpty()) { + throw new NotFoundException("appAttemptId, " + appAttemptId + + ", is empty or null"); + } + ApplicationAttemptId id = ConverterUtils + .toApplicationAttemptId(appAttemptId); + if (id == null) { + throw new NotFoundException("appAttempt is null"); + } + ApplicationAttemptHistoryData appAttemptHistoryData; + try { + appAttemptHistoryData = appHistoryReader.getApplicationAttempt(id); + } catch (Exception e) { + throw new RuntimeException("Failed to get the application for appId:" + + appAttemptId, e); + } + if (appAttemptHistoryData == null) { + throw new NotFoundException("app with id: " + appAttemptId + " not found"); + } + return new AHSAppAttemptInfo(appAttemptHistoryData); + } + + @GET + @Path("/{appattemptid}/containers") + @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) + public AHSContainersInfo getContainers( + @PathParam("appattemptid") String appAttemptId) { + init(); + if (appAttemptId == null || appAttemptId.isEmpty()) { + throw new NotFoundException("appAttemptId, " + appAttemptId + + ", is empty or null"); + } + ApplicationAttemptId id = ConverterUtils + .toApplicationAttemptId(appAttemptId); + if (id == null) { + throw new NotFoundException("appAttemptId is null"); + } + + Collection containers; + try { + containers = appHistoryReader.getContainers(id).values(); + } catch (IOException e) { + throw new RuntimeException("Failed to get containers for appAttemptId:" + + appAttemptId, e); + } + if (containers == null) { + throw new NotFoundException("appattempts for appAttemptId: " + + appAttemptId + " not found"); + } + AHSContainersInfo containersInfo = new AHSContainersInfo(); + for (ContainerHistoryData containerInfo : containers) { + containersInfo.add(new AHSContainerInfo(containerInfo)); + } + return containersInfo; + } + + @GET + @Path("/containers/{containerid}") + @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) + public AHSContainerInfo getContainer(@Context HttpServletRequest hsr, + @PathParam("containerid") String containerId) { + init(); + if (containerId == null || containerId.isEmpty()) { + throw new NotFoundException("containerId, " + containerId + + ", is empty or null"); + } + ContainerId id = ConverterUtils.toContainerId(containerId); + if (id == null) { + throw new NotFoundException("containerId is null"); + } + ContainerHistoryData containerHistoryData; + try { + containerHistoryData = appHistoryReader.getContainer(id); + } catch (Exception e) { + throw new RuntimeException("Failed to get the application for appId:" + + containerId, e); + } + if (containerHistoryData == null) { + throw new NotFoundException("app with id: " + containerId + " not found"); + } + return new AHSContainerInfo(containerHistoryData); + } + +} Index: hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/ApplicationHistoryController.java =================================================================== --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/ApplicationHistoryController.java (revision 0) +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/ApplicationHistoryController.java (working copy) @@ -0,0 +1,59 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.yarn.server.applicationhistoryservice.webapp; + +import org.apache.hadoop.yarn.webapp.Controller; +import org.apache.hadoop.yarn.webapp.YarnWebParams; + +public class ApplicationHistoryController extends Controller implements + YarnWebParams { + + public void applicationHistory() { + render(ApplicationHistoryPage.class); + } + + public void about() { + render(AHSAboutPage.class); + } + + public void application() { + render(AHSApplicationPage.class); + } + + public void appAttempts() { + render(AHSAppAttemptsPage.class); + } + + public void appAttempt() { + render(AHSAppAttemptPage.class); + } + + public void containers() { + render(AHSAppContainersPage.class); + } + + public void container() { + render(AHSAppContainerPage.class); + } + + @Override + public void index() { + } + + +} \ No newline at end of file Index: hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/dao/AHSAppAttemptInfo.java =================================================================== --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/dao/AHSAppAttemptInfo.java (revision 0) +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/dao/AHSAppAttemptInfo.java (working copy) @@ -0,0 +1,94 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.yarn.server.applicationhistoryservice.webapp.dao; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlRootElement; + +import org.apache.hadoop.yarn.api.records.ContainerId; +import org.apache.hadoop.yarn.api.records.FinalApplicationStatus; +import org.apache.hadoop.yarn.server.applicationhistoryservice.records.ApplicationAttemptHistoryData; + +@XmlRootElement(name = "applicationAttempt") +@XmlAccessorType(XmlAccessType.FIELD) +public class AHSAppAttemptInfo { + + private String applicationAttemptId; + private String host; + private int rpcPort; + private FinalApplicationStatus finalApplicationStatus; + private String trackingURL; + private String masterContainerId; + private String diagnosticsInfo; + + public AHSAppAttemptInfo() { + } + + public AHSAppAttemptInfo(ApplicationAttemptHistoryData appAttemptHistoryData) { + applicationAttemptId = appAttemptHistoryData.getApplicationAttemptId() + .toString(); + host = appAttemptHistoryData.getHost(); + if (host == null) { + host = ""; + } + rpcPort = appAttemptHistoryData.getRPCPort(); + finalApplicationStatus = appAttemptHistoryData.getFinalApplicationStatus(); + trackingURL = appAttemptHistoryData.getTrackingURL(); + if (trackingURL == null) { + trackingURL = ""; + } + ContainerId masterContainerId = appAttemptHistoryData + .getMasterContainerId(); + this.masterContainerId = (masterContainerId == null) ? "" + : masterContainerId.toString(); + diagnosticsInfo = appAttemptHistoryData.getDiagnosticsInfo(); + if (diagnosticsInfo == null) { + diagnosticsInfo = ""; + } + } + + public String getApplicationAttemptId() { + return applicationAttemptId; + } + + public String getHost() { + return host; + } + + public int getRpcPort() { + return rpcPort; + } + + public FinalApplicationStatus getFinalApplicationStatus() { + return finalApplicationStatus; + } + + public String getTrackingURL() { + return trackingURL; + } + + public String getMasterContainerId() { + return masterContainerId; + } + + public String getDiagnosticsInfo() { + return diagnosticsInfo; + } + +} Index: hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/dao/AHSAppAttemptsInfo.java =================================================================== --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/dao/AHSAppAttemptsInfo.java (revision 0) +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/dao/AHSAppAttemptsInfo.java (working copy) @@ -0,0 +1,40 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.yarn.server.applicationhistoryservice.webapp.dao; + +import java.util.ArrayList; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement(name = "appAttempts") +@XmlAccessorType(XmlAccessType.FIELD) +public class AHSAppAttemptsInfo { + @XmlElement(name = "appAttempt") + private ArrayList attempts = new ArrayList(); + + public void add(AHSAppAttemptInfo info) { + this.attempts.add(info); + } + + public ArrayList getAttempts() { + return this.attempts; + } +} Index: hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/dao/AHSAppInfo.java =================================================================== --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/dao/AHSAppInfo.java (revision 0) +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/dao/AHSAppInfo.java (working copy) @@ -0,0 +1,117 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.yarn.server.applicationhistoryservice.webapp.dao; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlRootElement; + +import org.apache.hadoop.yarn.api.records.ApplicationId; +import org.apache.hadoop.yarn.api.records.FinalApplicationStatus; +import org.apache.hadoop.yarn.server.applicationhistoryservice.records.ApplicationHistoryData; +import org.apache.hadoop.yarn.util.Times; + +@XmlRootElement(name = "application") +@XmlAccessorType(XmlAccessType.FIELD) +public class AHSAppInfo { + + private String appIdNum; + private ApplicationId applicationId; + private String id; + private String user; + private String name; + private String queue; + private FinalApplicationStatus finalStatus; + private String diagnostics; + private String applicationType; + private long startedTime; + private long finishedTime; + private long elapsedTime; + + public AHSAppInfo() { + } // JAXB needs this + + public AHSAppInfo(ApplicationHistoryData app) { + if (app != null) { + this.applicationId = app.getApplicationId(); + this.applicationType = app.getApplicationType(); + this.appIdNum = String.valueOf(app.getApplicationId().getId()); + this.id = app.getApplicationId().toString(); + this.user = app.getUser().toString(); + this.name = app.getApplicationName(); + this.queue = app.getQueue().toString(); + this.diagnostics = app.getDiagnosticsInfo(); + if (diagnostics == null || diagnostics.isEmpty()) { + this.diagnostics = ""; + } + this.finalStatus = app.getFinalApplicationStatus(); + this.startedTime = app.getStartTime(); + this.finishedTime = app.getFinishTime(); + this.elapsedTime = Times.elapsed(app.getStartTime(), app.getFinishTime()); + } + } + + public ApplicationId getApplicationId() { + return this.applicationId; + } + + public String getAppId() { + return this.id; + } + + public String getAppIdNum() { + return this.appIdNum; + } + + public String getUser() { + return this.user; + } + + public String getQueue() { + return this.queue; + } + + public String getName() { + return this.name; + } + + public String getNote() { + return this.diagnostics; + } + + public String getFinalStatus() { + return this.finalStatus.toString(); + } + + public long getStartTime() { + return this.startedTime; + } + + public long getFinishTime() { + return this.finishedTime; + } + + public long getElapsedTime() { + return this.elapsedTime; + } + + public String getApplicationType() { + return this.applicationType; + } + +} Index: hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/dao/AHSAppsInfo.java =================================================================== --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/dao/AHSAppsInfo.java (revision 0) +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/dao/AHSAppsInfo.java (working copy) @@ -0,0 +1,40 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.yarn.server.applicationhistoryservice.webapp.dao; + +import java.util.ArrayList; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement(name = "apps") +@XmlAccessorType(XmlAccessType.FIELD) +public class AHSAppsInfo { + @XmlElement(name = "app") + private ArrayList apps = new ArrayList(); + + public void add(AHSAppInfo info) { + this.apps.add(info); + } + + public ArrayList getAttempts() { + return this.apps; + } +} Index: hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/dao/AHSContainerInfo.java =================================================================== --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/dao/AHSContainerInfo.java (revision 0) +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/dao/AHSContainerInfo.java (working copy) @@ -0,0 +1,103 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.yarn.server.applicationhistoryservice.webapp.dao; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlRootElement; + +import org.apache.hadoop.yarn.api.records.ContainerState; +import org.apache.hadoop.yarn.api.records.Resource; +import org.apache.hadoop.yarn.server.applicationhistoryservice.records.ContainerHistoryData; + +@XmlRootElement(name = "container") +@XmlAccessorType(XmlAccessType.FIELD) +public class AHSContainerInfo { + + private String containerId; + + private Resource resource; + + private String nodeId; + + private int priority; + + private String diagnosticsInfo; + + private ContainerState finalContainerStatus; + + private long startTime; + + private long finishTime; + + private String logURL; + + public AHSContainerInfo() { + } + + public AHSContainerInfo(ContainerHistoryData containerHistoryData) { + containerId = containerHistoryData.getContainerId().toString(); + resource = containerHistoryData.getAllocatedResource(); + nodeId = containerHistoryData.getAssignedNode().toString(); + priority = containerHistoryData.getPriority().getPriority(); + diagnosticsInfo = containerHistoryData.getDiagnosticsInfo(); + finalContainerStatus = containerHistoryData.getFinalContainerStatus(); + startTime = containerHistoryData.getStartTime(); + finishTime = containerHistoryData.getFinishTime(); + logURL = containerHistoryData.getLogURL(); + if (logURL == null) { + logURL = ""; + } + } + + public String getContainerId() { + return containerId; + } + + public Resource getResource() { + return resource; + } + + public String getNodeId() { + return nodeId; + } + + public int getPriority() { + return priority; + } + + public String getDiagnosticsInfo() { + return diagnosticsInfo; + } + + public ContainerState getFinalContainerStatus() { + return finalContainerStatus; + } + + public long getStartTime() { + return startTime; + } + + public long getFinishTime() { + return finishTime; + } + + public String getLogURL() { + return logURL; + } +} Index: hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/dao/AHSContainersInfo.java =================================================================== --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/dao/AHSContainersInfo.java (revision 0) +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/dao/AHSContainersInfo.java (working copy) @@ -0,0 +1,40 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.yarn.server.applicationhistoryservice.webapp.dao; + +import java.util.ArrayList; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement(name = "containers") +@XmlAccessorType(XmlAccessType.FIELD) +public class AHSContainersInfo { + @XmlElement(name = "container") + private ArrayList containers = new ArrayList(); + + public void add(AHSContainerInfo info) { + this.containers.add(info); + } + + public ArrayList getAttempts() { + return this.containers; + } +} Index: hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/dao/AHSInfo.java =================================================================== --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/dao/AHSInfo.java (revision 0) +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/dao/AHSInfo.java (working copy) @@ -0,0 +1,57 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.yarn.server.applicationhistoryservice.webapp.dao; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlRootElement; + +import org.apache.hadoop.util.VersionInfo; + +@XmlRootElement +@XmlAccessorType(XmlAccessType.FIELD) +public class AHSInfo { + + protected long startedOn; + protected String hadoopVersion; + protected String hadoopBuildVersion; + protected String hadoopVersionBuiltOn; + + public AHSInfo() { + this.startedOn = 1l; + this.hadoopVersion = VersionInfo.getVersion(); + this.hadoopBuildVersion = VersionInfo.getBuildVersion(); + this.hadoopVersionBuiltOn = VersionInfo.getDate(); + } + + public String getHadoopVersion() { + return this.hadoopVersion; + } + + public String getHadoopBuildVersion() { + return this.hadoopBuildVersion; + } + + public String getHadoopVersionBuiltOn() { + return this.hadoopVersionBuiltOn; + } + + public long getStartedOn() { + return this.startedOn; + } +}