diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/ApplicationBaseProtocol.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/ApplicationBaseProtocol.java new file mode 100644 index 0000000..85c554c --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/ApplicationBaseProtocol.java @@ -0,0 +1,358 @@ +/** + * 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.api; + +import java.io.IOException; + +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceAudience.Public; +import org.apache.hadoop.classification.InterfaceStability.Stable; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.io.retry.Idempotent; +import org.apache.hadoop.yarn.api.protocolrecords.CancelDelegationTokenRequest; +import org.apache.hadoop.yarn.api.protocolrecords.CancelDelegationTokenResponse; +import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationAttemptReportRequest; +import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationAttemptReportResponse; +import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationAttemptsRequest; +import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationAttemptsResponse; +import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationReportRequest; +import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationReportResponse; +import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationsRequest; +import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationsResponse; +import org.apache.hadoop.yarn.api.protocolrecords.GetContainerReportRequest; +import org.apache.hadoop.yarn.api.protocolrecords.GetContainerReportResponse; +import org.apache.hadoop.yarn.api.protocolrecords.GetContainersRequest; +import org.apache.hadoop.yarn.api.protocolrecords.GetContainersResponse; +import org.apache.hadoop.yarn.api.protocolrecords.GetDelegationTokenRequest; +import org.apache.hadoop.yarn.api.protocolrecords.GetDelegationTokenResponse; +import org.apache.hadoop.yarn.api.protocolrecords.RenewDelegationTokenRequest; +import org.apache.hadoop.yarn.api.protocolrecords.RenewDelegationTokenResponse; +import org.apache.hadoop.yarn.api.records.ApplicationAttemptId; +import org.apache.hadoop.yarn.api.records.ApplicationAttemptReport; +import org.apache.hadoop.yarn.api.records.ApplicationId; +import org.apache.hadoop.yarn.api.records.ApplicationReport; +import org.apache.hadoop.yarn.api.records.ContainerId; +import org.apache.hadoop.yarn.api.records.ContainerReport; +import org.apache.hadoop.yarn.api.records.Token; +import org.apache.hadoop.yarn.exceptions.YarnException; + +/** + * + *

+ * The protocol between clients and the ResourceManager or + * ApplicationHistoryServer to get information on applications, + * application attempts and containers. + *

+ * + */ +public interface ApplicationBaseProtocol { + + /** + *

+ * The interface used by clients to get a report of an Application from the + * ResourceManager or ApplicationHistoryServer. + *

+ * + *

+ * The client, via {@link GetApplicationReportRequest} provides the + * {@link ApplicationId} of the application. + *

+ * + *

+ * In secure mode,the ResourceManager or + * ApplicationHistoryServer verifies access to the application, + * queue etc. before accepting the request. + *

+ * + *

+ * The ResourceManager or ApplicationHistoryServer + * responds with a {@link GetApplicationReportResponse} which includes the + * {@link ApplicationReport} for the application. + *

+ * + *

+ * If the user does not have VIEW_APP access then the following + * fields in the report will be set to stubbed values: + *

+ *

+ * + * @param request + * request for an application report + * @return application report + * @throws YarnException + * @throws IOException + */ + @Public + @Stable + @Idempotent + public GetApplicationReportResponse getApplicationReport( + GetApplicationReportRequest request) + throws YarnException, IOException; + + /** + *

+ * The interface used by clients to get a report of Applications matching the + * filters defined by {@link GetApplicationsRequest} in the cluster from the + * ResourceManager or ApplicationHistoryServer. + *

+ * + *

+ * The ResourceManager or ApplicationHistoryServer + * responds with a {@link GetApplicationsResponse} which includes the + * {@link ApplicationReport} for the applications. + *

+ * + *

+ * If the user does not have VIEW_APP access for an application + * then the corresponding report will be filtered as described in + * {@link #getApplicationReport(GetApplicationReportRequest)}. + *

+ * + * @param request + * request for report on applications + * @return report on applications matching the given application types defined + * in the request + * @throws YarnException + * @throws IOException + * @see GetApplicationsRequest + */ + @Public + @Stable + @Idempotent + public GetApplicationsResponse getApplications( + GetApplicationsRequest request) + throws YarnException, IOException; + + /** + *

+ * The interface used by clients to get a report of an Application Attempt + * from the ResourceManager or + * ApplicationHistoryServer + *

+ * + *

+ * The client, via {@link GetApplicationAttemptReportRequest} provides the + * {@link ApplicationAttemptId} of the application attempt. + *

+ * + *

+ * In secure mode,the ResourceManager or + * ApplicationHistoryServer verifies access to the method before + * accepting the request. + *

+ * + *

+ * The ResourceManager or ApplicationHistoryServer + * responds with a {@link GetApplicationAttemptReportResponse} which includes + * the {@link ApplicationAttemptReport} for the application attempt. + *

+ * + *

+ * If the user does not have VIEW_APP access then the following + * fields in the report will be set to stubbed values: + *

+ *

+ * + * @param request + * request for an application attempt report + * @return application attempt report + * @throws YarnException + * @throws IOException + */ + @Public + @Unstable + @Idempotent + public GetApplicationAttemptReportResponse getApplicationAttemptReport( + GetApplicationAttemptReportRequest request) throws YarnException, + IOException; + + /** + *

+ * The interface used by clients to get a report of all Application attempts + * in the cluster from the ResourceManager or + * ApplicationHistoryServer + *

+ * + *

+ * The ResourceManager or ApplicationHistoryServer + * responds with a {@link GetApplicationAttemptsRequest} which includes the + * {@link ApplicationAttemptReport} for all the applications attempts of a + * specified application attempt. + *

+ * + *

+ * If the user does not have VIEW_APP access for an application + * then the corresponding report will be filtered as described in + * {@link #getApplicationAttemptReport(GetApplicationAttemptReportRequest)}. + *

+ * + * @param request + * request for reports on all application attempts of an application + * @return reports on all application attempts of an application + * @throws YarnException + * @throws IOException + */ + @Public + @Unstable + @Idempotent + public GetApplicationAttemptsResponse getApplicationAttempts( + GetApplicationAttemptsRequest request) throws YarnException, IOException; + + /** + *

+ * The interface used by clients to get a report of an Container from the + * ResourceManager or ApplicationHistoryServer + *

+ * + *

+ * The client, via {@link GetContainerReportRequest} provides the + * {@link ContainerId} of the container. + *

+ * + *

+ * In secure mode,the ResourceManager or + * ApplicationHistoryServer verifies access to the method before + * accepting the request. + *

+ * + *

+ * The ResourceManager or ApplicationHistoryServer + * responds with a {@link GetContainerReportResponse} which includes the + * {@link ContainerReport} for the container. + *

+ * + * @param request + * request for a container report + * @return container report + * @throws YarnException + * @throws IOException + */ + @Public + @Unstable + @Idempotent + public GetContainerReportResponse getContainerReport( + GetContainerReportRequest request) throws YarnException, IOException; + + /** + *

+ * The interface used by clients to get a report of Containers for an + * application attempt from the ResourceManager or + * ApplicationHistoryServer + *

+ * + *

+ * The client, via {@link GetContainersRequest} provides the + * {@link ApplicationAttemptId} of the application attempt. + *

+ * + *

+ * In secure mode,the ResourceManager or + * ApplicationHistoryServer verifies access to the method before + * accepting the request. + *

+ * + *

+ * The ResourceManager or ApplicationHistoryServer + * responds with a {@link GetContainersResponse} which includes a list of + * {@link ContainerReport} for all the containers of a specific application + * attempt. + *

+ * + * @param request + * request for a list of container reports of an application attempt. + * @return reports on all containers of an application attempt + * @throws YarnException + * @throws IOException + */ + @Public + @Unstable + @Idempotent + public GetContainersResponse getContainers(GetContainersRequest request) + throws YarnException, IOException; + + /** + *

+ * The interface used by clients to get delegation token, enabling the + * containers to be able to talk to the service using those tokens. + * + *

+ * The ResourceManager or ApplicationHistoryServer + * responds with the delegation {@link Token} that can be used by the client + * to speak to this service. + * + * @param request + * request to get a delegation token for the client. + * @return delegation token that can be used to talk to this service + * @throws YarnException + * @throws IOException + */ + @Public + @Stable + @Idempotent + public GetDelegationTokenResponse getDelegationToken( + GetDelegationTokenRequest request) + throws YarnException, IOException; + + /** + * Renew an existing delegation {@link Token}. + * + * @param request + * the delegation token to be renewed. + * @return the new expiry time for the delegation token. + * @throws YarnException + * @throws IOException + */ + @Private + @Unstable + @Idempotent + public RenewDelegationTokenResponse renewDelegationToken( + RenewDelegationTokenRequest request) throws YarnException, + IOException; + + /** + * Cancel an existing delegation {@link Token}. + * + * @param request + * the delegation token to be cancelled. + * @return an empty response. + * @throws YarnException + * @throws IOException + */ + @Private + @Unstable + @Idempotent + public CancelDelegationTokenResponse cancelDelegationToken( + CancelDelegationTokenRequest request) throws YarnException, + IOException; + +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/ApplicationClientProtocol.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/ApplicationClientProtocol.java index e449c1e..3047da9 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/ApplicationClientProtocol.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/ApplicationClientProtocol.java @@ -20,31 +20,15 @@ import java.io.IOException; -import org.apache.hadoop.classification.InterfaceAudience.Private; import org.apache.hadoop.classification.InterfaceAudience.Public; import org.apache.hadoop.classification.InterfaceStability.Stable; import org.apache.hadoop.classification.InterfaceStability.Unstable; import org.apache.hadoop.io.retry.Idempotent; -import org.apache.hadoop.yarn.api.protocolrecords.CancelDelegationTokenRequest; -import org.apache.hadoop.yarn.api.protocolrecords.CancelDelegationTokenResponse; -import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationAttemptReportRequest; -import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationAttemptReportResponse; -import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationAttemptsRequest; -import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationAttemptsResponse; -import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationsRequest; -import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationsResponse; import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationReportRequest; -import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationReportResponse; import org.apache.hadoop.yarn.api.protocolrecords.GetClusterMetricsRequest; import org.apache.hadoop.yarn.api.protocolrecords.GetClusterMetricsResponse; import org.apache.hadoop.yarn.api.protocolrecords.GetClusterNodesRequest; import org.apache.hadoop.yarn.api.protocolrecords.GetClusterNodesResponse; -import org.apache.hadoop.yarn.api.protocolrecords.GetContainerReportRequest; -import org.apache.hadoop.yarn.api.protocolrecords.GetContainerReportResponse; -import org.apache.hadoop.yarn.api.protocolrecords.GetContainersRequest; -import org.apache.hadoop.yarn.api.protocolrecords.GetContainersResponse; -import org.apache.hadoop.yarn.api.protocolrecords.GetDelegationTokenRequest; -import org.apache.hadoop.yarn.api.protocolrecords.GetDelegationTokenResponse; import org.apache.hadoop.yarn.api.protocolrecords.GetNewApplicationRequest; import org.apache.hadoop.yarn.api.protocolrecords.GetNewApplicationResponse; import org.apache.hadoop.yarn.api.protocolrecords.GetQueueInfoRequest; @@ -55,25 +39,18 @@ import org.apache.hadoop.yarn.api.protocolrecords.KillApplicationResponse; import org.apache.hadoop.yarn.api.protocolrecords.MoveApplicationAcrossQueuesRequest; import org.apache.hadoop.yarn.api.protocolrecords.MoveApplicationAcrossQueuesResponse; -import org.apache.hadoop.yarn.api.protocolrecords.RenewDelegationTokenRequest; -import org.apache.hadoop.yarn.api.protocolrecords.RenewDelegationTokenResponse; import org.apache.hadoop.yarn.api.protocolrecords.SubmitApplicationRequest; import org.apache.hadoop.yarn.api.protocolrecords.SubmitApplicationResponse; -import org.apache.hadoop.yarn.api.records.ApplicationAttemptId; -import org.apache.hadoop.yarn.api.records.ApplicationAttemptReport; import org.apache.hadoop.yarn.api.records.ApplicationId; -import org.apache.hadoop.yarn.api.records.ApplicationReport; -import org.apache.hadoop.yarn.api.records.ContainerId; +import org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext; import org.apache.hadoop.yarn.api.records.ContainerLaunchContext; -import org.apache.hadoop.yarn.api.records.ContainerReport; import org.apache.hadoop.yarn.api.records.NodeReport; import org.apache.hadoop.yarn.api.records.Resource; import org.apache.hadoop.yarn.api.records.ResourceRequest; -import org.apache.hadoop.yarn.api.records.Token; import org.apache.hadoop.yarn.api.records.YarnClusterMetrics; -import org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext; -import org.apache.hadoop.yarn.exceptions.YarnException; import org.apache.hadoop.yarn.exceptions.ApplicationNotFoundException; +import org.apache.hadoop.yarn.exceptions.InvalidResourceRequestException; +import org.apache.hadoop.yarn.exceptions.YarnException; /** *

The protocol between clients and the ResourceManager @@ -82,7 +59,7 @@ */ @Public @Stable -public interface ApplicationClientProtocol { +public interface ApplicationClientProtocol extends ApplicationBaseProtocol { /** *

The interface used by clients to obtain a new {@link ApplicationId} for * submitting new applications.

@@ -183,44 +160,6 @@ public SubmitApplicationResponse submitApplication( public KillApplicationResponse forceKillApplication( KillApplicationRequest request) throws YarnException, IOException; - - /** - *

The interface used by clients to get a report of an Application from - * the ResourceManager.

- * - *

The client, via {@link GetApplicationReportRequest} provides the - * {@link ApplicationId} of the application.

- * - *

In secure mode,the ResourceManager verifies access to the - * application, queue etc. before accepting the request.

- * - *

The ResourceManager responds with a - * {@link GetApplicationReportResponse} which includes the - * {@link ApplicationReport} for the application.

- * - *

If the user does not have VIEW_APP access then the - * following fields in the report will be set to stubbed values: - *

- * - * @param request request for an application report - * @return application report - * @throws YarnException - * @throws IOException - */ - @Public - @Stable - @Idempotent - public GetApplicationReportResponse getApplicationReport( - GetApplicationReportRequest request) - throws YarnException, IOException; /** *

The interface used by clients to get metrics about the cluster from @@ -244,34 +183,6 @@ public GetClusterMetricsResponse getClusterMetrics( throws YarnException, IOException; /** - *

The interface used by clients to get a report of Applications - * matching the filters defined by {@link GetApplicationsRequest} - * in the cluster from the ResourceManager.

- * - *

The ResourceManager responds with a - * {@link GetApplicationsResponse} which includes the - * {@link ApplicationReport} for the applications.

- * - *

If the user does not have VIEW_APP access for an - * application then the corresponding report will be filtered as - * described in {@link #getApplicationReport(GetApplicationReportRequest)}. - *

- * - * @param request request for report on applications - * @return report on applications matching the given application types - * defined in the request - * @throws YarnException - * @throws IOException - * @see GetApplicationsRequest - */ - @Public - @Stable - @Idempotent - public GetApplicationsResponse getApplications( - GetApplicationsRequest request) - throws YarnException, IOException; - - /** *

The interface used by clients to get a report of all nodes * in the cluster from the ResourceManager.

* @@ -328,61 +239,12 @@ public GetQueueInfoResponse getQueueInfo( */ @Public @Stable - @Idempotent + @Idempotent public GetQueueUserAclsInfoResponse getQueueUserAcls( GetQueueUserAclsInfoRequest request) throws YarnException, IOException; /** - *

The interface used by clients to get delegation token, enabling the - * containers to be able to talk to the service using those tokens. - * - *

The ResourceManager responds with the delegation - * {@link Token} that can be used by the client to speak to this - * service. - * @param request request to get a delegation token for the client. - * @return delegation token that can be used to talk to this service - * @throws YarnException - * @throws IOException - */ - @Public - @Stable - @Idempotent - public GetDelegationTokenResponse getDelegationToken( - GetDelegationTokenRequest request) - throws YarnException, IOException; - - /** - * Renew an existing delegation {@link Token}. - * - * @param request the delegation token to be renewed. - * @return the new expiry time for the delegation token. - * @throws YarnException - * @throws IOException - */ - @Private - @Unstable - @Idempotent - public RenewDelegationTokenResponse renewDelegationToken( - RenewDelegationTokenRequest request) throws YarnException, - IOException; - - /** - * Cancel an existing delegation {@link Token}. - * - * @param request the delegation token to be cancelled. - * @return an empty response. - * @throws YarnException - * @throws IOException - */ - @Private - @Unstable - @Idempotent - public CancelDelegationTokenResponse cancelDelegationToken( - CancelDelegationTokenRequest request) throws YarnException, - IOException; - - /** * Move an application to a new queue. * * @param request the application ID and the target queue @@ -396,151 +258,4 @@ public CancelDelegationTokenResponse cancelDelegationToken( public MoveApplicationAcrossQueuesResponse moveApplicationAcrossQueues( MoveApplicationAcrossQueuesRequest request) throws YarnException, IOException; - /** - *

- * The interface used by clients to get a report of an Application Attempt - * from the ResourceManager - *

- * - *

- * The client, via {@link GetApplicationAttemptReportRequest} provides the - * {@link ApplicationAttemptId} of the application attempt. - *

- * - *

- * In secure mode,the ResourceManager verifies access to - * the method before accepting the request. - *

- * - *

- * The ResourceManager responds with a - * {@link GetApplicationAttemptReportResponse} which includes the - * {@link ApplicationAttemptReport} for the application attempt. - *

- * - *

- * If the user does not have VIEW_APP access then the following - * fields in the report will be set to stubbed values: - *

- *

- * - * @param request - * request for an application attempt report - * @return application attempt report - * @throws YarnException - * @throws IOException - */ - @Public - @Unstable - @Idempotent - public GetApplicationAttemptReportResponse getApplicationAttemptReport( - GetApplicationAttemptReportRequest request) throws YarnException, - IOException; - - /** - *

- * The interface used by clients to get a report of all Application attempts - * in the cluster from the ResourceManager - *

- * - *

- * The ResourceManager responds with a - * {@link GetApplicationAttemptsRequest} which includes the - * {@link ApplicationAttemptReport} for all the applications attempts of a - * specified application attempt. - *

- * - *

- * If the user does not have VIEW_APP access for an application - * then the corresponding report will be filtered as described in - * {@link #getApplicationAttemptReport(GetApplicationAttemptReportRequest)}. - *

- * - * @param request - * request for reports on all application attempts of an application - * @return reports on all application attempts of an application - * @throws YarnException - * @throws IOException - */ - @Public - @Unstable - @Idempotent - public GetApplicationAttemptsResponse getApplicationAttempts( - GetApplicationAttemptsRequest request) throws YarnException, IOException; - - /** - *

- * The interface used by clients to get a report of an Container from the - * ResourceManager - *

- * - *

- * The client, via {@link GetContainerReportRequest} provides the - * {@link ContainerId} of the container. - *

- * - *

- * In secure mode,the ResourceManager verifies access to the - * method before accepting the request. - *

- * - *

- * The ResourceManager responds with a - * {@link GetContainerReportResponse} which includes the - * {@link ContainerReport} for the container. - *

- * - * @param request - * request for a container report - * @return container report - * @throws YarnException - * @throws IOException - */ - @Public - @Unstable - @Idempotent - public GetContainerReportResponse getContainerReport( - GetContainerReportRequest request) throws YarnException, IOException; - - /** - *

- * The interface used by clients to get a report of Containers for an - * application attempt from the ResourceManager - *

- * - *

- * The client, via {@link GetContainersRequest} provides the - * {@link ApplicationAttemptId} of the application attempt. - *

- * - *

- * In secure mode,the ResourceManager verifies access to the - * method before accepting the request. - *

- * - *

- * The ResourceManager responds with a - * {@link GetContainersResponse} which includes a list of - * {@link ContainerReport} for all the containers of a specific application - * attempt. - *

- * - * @param request - * request for a list of container reports of an application attempt. - * @return reports on all containers of an application attempt - * @throws YarnException - * @throws IOException - */ - @Public - @Unstable - @Idempotent - public GetContainersResponse getContainers(GetContainersRequest request) - throws YarnException, IOException; - } diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/ApplicationHistoryProtocol.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/ApplicationHistoryProtocol.java index 0bfd2ed..fc8e885 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/ApplicationHistoryProtocol.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/ApplicationHistoryProtocol.java @@ -18,37 +18,8 @@ package org.apache.hadoop.yarn.api; -import java.io.IOException; - -import org.apache.hadoop.classification.InterfaceAudience.Private; import org.apache.hadoop.classification.InterfaceAudience.Public; import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.yarn.api.protocolrecords.CancelDelegationTokenRequest; -import org.apache.hadoop.yarn.api.protocolrecords.CancelDelegationTokenResponse; -import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationAttemptReportRequest; -import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationAttemptReportResponse; -import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationAttemptsRequest; -import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationAttemptsResponse; -import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationReportRequest; -import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationReportResponse; -import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationsRequest; -import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationsResponse; -import org.apache.hadoop.yarn.api.protocolrecords.GetContainerReportRequest; -import org.apache.hadoop.yarn.api.protocolrecords.GetContainerReportResponse; -import org.apache.hadoop.yarn.api.protocolrecords.GetContainersRequest; -import org.apache.hadoop.yarn.api.protocolrecords.GetContainersResponse; -import org.apache.hadoop.yarn.api.protocolrecords.GetDelegationTokenRequest; -import org.apache.hadoop.yarn.api.protocolrecords.GetDelegationTokenResponse; -import org.apache.hadoop.yarn.api.protocolrecords.RenewDelegationTokenRequest; -import org.apache.hadoop.yarn.api.protocolrecords.RenewDelegationTokenResponse; -import org.apache.hadoop.yarn.api.records.ApplicationAttemptId; -import org.apache.hadoop.yarn.api.records.ApplicationAttemptReport; -import org.apache.hadoop.yarn.api.records.ApplicationId; -import org.apache.hadoop.yarn.api.records.ApplicationReport; -import org.apache.hadoop.yarn.api.records.ContainerId; -import org.apache.hadoop.yarn.api.records.ContainerReport; -import org.apache.hadoop.yarn.api.records.Token; -import org.apache.hadoop.yarn.exceptions.YarnException; /** *

@@ -58,277 +29,5 @@ */ @Public @Unstable -public interface ApplicationHistoryProtocol { - - /** - *

- * The interface used by clients to get a report of an Application from the - * ResourceManager. - *

- * - *

- * The client, via {@link GetApplicationReportRequest} provides the - * {@link ApplicationId} of the application. - *

- * - *

- * In secure mode,the ApplicationHistoryServer verifies access to - * the application, queue etc. before accepting the request. - *

- * - *

- * The ApplicationHistoryServer responds with a - * {@link GetApplicationReportResponse} which includes the - * {@link ApplicationReport} for the application. - *

- * - *

- * If the user does not have VIEW_APP access then the following - * fields in the report will be set to stubbed values: - *

- *

- * - * @param request - * request for an application report - * @return application report - * @throws YarnException - * @throws IOException - */ - @Public - @Unstable - public GetApplicationReportResponse getApplicationReport( - GetApplicationReportRequest request) throws YarnException, IOException; - - /** - *

- * The interface used by clients to get a report of all Applications in the - * cluster from the ApplicationHistoryServer. - *

- * - *

- * The ApplicationHistoryServer responds with a - * {@link GetApplicationsResponse} which includes a list of - * {@link ApplicationReport} for all the applications. - *

- * - *

- * If the user does not have VIEW_APP access for an application - * then the corresponding report will be filtered as described in - * {@link #getApplicationReport(GetApplicationReportRequest)}. - *

- * - * @param request - * request for reports on all the applications - * @return report on applications matching the given application types defined - * in the request - * @throws YarnException - * @throws IOException - */ - @Public - @Unstable - public GetApplicationsResponse - getApplications(GetApplicationsRequest request) throws YarnException, - IOException; - - /** - *

- * The interface used by clients to get a report of an Application Attempt - * from the ApplicationHistoryServer. - *

- * - *

- * The client, via {@link GetApplicationAttemptReportRequest} provides the - * {@link ApplicationAttemptId} of the application attempt. - *

- * - *

- * In secure mode,the ApplicationHistoryServer verifies access to - * the method before accepting the request. - *

- * - *

- * The ApplicationHistoryServer responds with a - * {@link GetApplicationAttemptReportResponse} which includes the - * {@link ApplicationAttemptReport} for the application attempt. - *

- * - *

- * If the user does not have VIEW_APP access then the following - * fields in the report will be set to stubbed values: - *

- *

- * - * @param request - * request for an application attempt report - * @return application attempt report - * @throws YarnException - * @throws IOException - */ - @Public - @Unstable - public GetApplicationAttemptReportResponse getApplicationAttemptReport( - GetApplicationAttemptReportRequest request) throws YarnException, - IOException; - - /** - *

- * The interface used by clients to get a report of all Application attempts - * in the cluster from the ApplicationHistoryServer. - *

- * - *

- * The ApplicationHistoryServer responds with a - * {@link GetApplicationAttemptsRequest} which includes the - * {@link ApplicationAttemptReport} for all the applications attempts of a - * specified application attempt. - *

- * - *

- * If the user does not have VIEW_APP access for an application - * then the corresponding report will be filtered as described in - * {@link #getApplicationAttemptReport(GetApplicationAttemptReportRequest)}. - *

- * - * @param request - * request for reports on all application attempts of an application - * @return reports on all application attempts of an application - * @throws YarnException - * @throws IOException - */ - @Public - @Unstable - public GetApplicationAttemptsResponse getApplicationAttempts( - GetApplicationAttemptsRequest request) throws YarnException, IOException; - - /** - *

- * The interface used by clients to get a report of an Container from the - * ApplicationHistoryServer. - *

- * - *

- * The client, via {@link GetContainerReportRequest} provides the - * {@link ContainerId} of the container. - *

- * - *

- * In secure mode,the ApplicationHistoryServer verifies access to - * the method before accepting the request. - *

- * - *

- * The ApplicationHistoryServer responds with a - * {@link GetContainerReportResponse} which includes the - * {@link ContainerReport} for the container. - *

- * - * @param request - * request for a container report - * @return container report - * @throws YarnException - * @throws IOException - */ - @Public - @Unstable - public GetContainerReportResponse getContainerReport( - GetContainerReportRequest request) throws YarnException, IOException; - - /** - *

- * The interface used by clients to get a report of Containers for an - * application attempt from the ApplciationHistoryServer. - *

- * - *

- * The client, via {@link GetContainersRequest} provides the - * {@link ApplicationAttemptId} of the application attempt. - *

- * - *

- * In secure mode,the ApplicationHistoryServer verifies access to - * the method before accepting the request. - *

- * - *

- * The ApplicationHistoryServer responds with a - * {@link GetContainersResponse} which includes a list of - * {@link ContainerReport} for all the containers of a specific application - * attempt. - *

- * - * @param request - * request for a list of container reports of an application attempt. - * @return reports on all containers of an application attempt - * @throws YarnException - * @throws IOException - */ - @Public - @Unstable - public GetContainersResponse getContainers(GetContainersRequest request) - throws YarnException, IOException; - - /** - *

- * The interface used by clients to get delegation token, enabling the - * containers to be able to talk to the service using those tokens. - *

- * - *

- * The ApplicationHistoryServer responds with the delegation - * token {@link Token} that can be used by the client to speak to this - * service. - *

- * - * @param request - * request to get a delegation token for the client. - * @return delegation token that can be used to talk to this service - * @throws YarnException - * @throws IOException - */ - @Public - @Unstable - public GetDelegationTokenResponse getDelegationToken( - GetDelegationTokenRequest request) throws YarnException, IOException; - - /** - * Renew an existing delegation token. - * - * @param request - * the delegation token to be renewed. - * @return the new expiry time for the delegation token. - * @throws YarnException - * @throws IOException - */ - @Private - @Unstable - public RenewDelegationTokenResponse renewDelegationToken( - RenewDelegationTokenRequest request) throws YarnException, IOException; - - /** - * Cancel an existing delegation token. - * - * @param request - * the delegation token to be cancelled. - * @return an empty response. - * @throws YarnException - * @throws IOException - */ - @Private - @Unstable - public CancelDelegationTokenResponse cancelDelegationToken( - CancelDelegationTokenRequest request) throws YarnException, IOException; +public interface ApplicationHistoryProtocol extends ApplicationBaseProtocol { } diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/webapp/view/HtmlBlock.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/webapp/view/HtmlBlock.java index 8f885bb..6ee0d1c 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/webapp/view/HtmlBlock.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/webapp/view/HtmlBlock.java @@ -21,6 +21,7 @@ import java.io.PrintWriter; import org.apache.hadoop.classification.InterfaceAudience; +import org.apache.hadoop.security.UserGroupInformation; import org.apache.hadoop.yarn.webapp.MimeType; import org.apache.hadoop.yarn.webapp.SubView; import org.apache.hadoop.yarn.webapp.WebAppException; @@ -81,4 +82,15 @@ public void renderPartial() { * @param html the block to render */ protected abstract void render(Block html); + + protected UserGroupInformation getCallerUGI() { + // Check for the authorization. + String remoteUser = request().getRemoteUser(); + UserGroupInformation callerUGI = null; + if (remoteUser != null) { + callerUGI = UserGroupInformation.createRemoteUser(remoteUser); + } + return callerUGI; + } + } diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/ApplicationHistoryClientService.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/ApplicationHistoryClientService.java index e15198b..d8b6d78 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/ApplicationHistoryClientService.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/ApplicationHistoryClientService.java @@ -58,18 +58,17 @@ import org.apache.hadoop.yarn.exceptions.YarnException; import org.apache.hadoop.yarn.ipc.YarnRPC; -public class ApplicationHistoryClientService extends AbstractService { +public class ApplicationHistoryClientService + extends AbstractService implements ApplicationHistoryProtocol { private static final Log LOG = LogFactory .getLog(ApplicationHistoryClientService.class); private ApplicationHistoryManager history; - private ApplicationHistoryProtocol protocolHandler; private Server server; private InetSocketAddress bindAddress; public ApplicationHistoryClientService(ApplicationHistoryManager history) { super("ApplicationHistoryClientService"); this.history = history; - this.protocolHandler = new ApplicationHSClientProtocolHandler(); } protected void serviceStart() throws Exception { @@ -81,7 +80,7 @@ protected void serviceStart() throws Exception { YarnConfiguration.DEFAULT_TIMELINE_SERVICE_PORT); server = - rpc.getServer(ApplicationHistoryProtocol.class, protocolHandler, + rpc.getServer(ApplicationHistoryProtocol.class, this, address, conf, null, conf.getInt( YarnConfiguration.TIMELINE_SERVICE_HANDLER_THREAD_COUNT, YarnConfiguration.DEFAULT_TIMELINE_SERVICE_CLIENT_THREAD_COUNT)); @@ -105,107 +104,99 @@ protected void serviceStop() throws Exception { } @Private - public ApplicationHistoryProtocol getClientHandler() { - return this.protocolHandler; - } - - @Private public InetSocketAddress getBindAddress() { return this.bindAddress; } - private class ApplicationHSClientProtocolHandler implements - ApplicationHistoryProtocol { - - @Override - public CancelDelegationTokenResponse cancelDelegationToken( - CancelDelegationTokenRequest request) throws YarnException, IOException { - // TODO Auto-generated method stub - return null; - } - - @Override - public GetApplicationAttemptReportResponse getApplicationAttemptReport( - GetApplicationAttemptReportRequest request) throws YarnException, - IOException { - try { - GetApplicationAttemptReportResponse response = - GetApplicationAttemptReportResponse.newInstance(history + @Override + public GetApplicationAttemptReportResponse getApplicationAttemptReport( + GetApplicationAttemptReportRequest request) throws YarnException, + IOException { + try { + GetApplicationAttemptReportResponse response = + GetApplicationAttemptReportResponse.newInstance(history .getApplicationAttempt(request.getApplicationAttemptId())); - return response; - } catch (IOException e) { - throw new ApplicationAttemptNotFoundException(e.getMessage()); - } + return response; + } catch (IOException e) { + throw new ApplicationAttemptNotFoundException(e.getMessage()); } + } - @Override - public GetApplicationAttemptsResponse getApplicationAttempts( - GetApplicationAttemptsRequest request) throws YarnException, - IOException { - GetApplicationAttemptsResponse response = - GetApplicationAttemptsResponse + @Override + public GetApplicationAttemptsResponse getApplicationAttempts( + GetApplicationAttemptsRequest request) throws YarnException, + IOException { + GetApplicationAttemptsResponse response = + GetApplicationAttemptsResponse .newInstance(new ArrayList(history - .getApplicationAttempts(request.getApplicationId()).values())); - return response; - } + .getApplicationAttempts(request.getApplicationId()).values())); + return response; + } - @Override - public GetApplicationReportResponse getApplicationReport( - GetApplicationReportRequest request) throws YarnException, IOException { - try { - ApplicationId applicationId = request.getApplicationId(); - GetApplicationReportResponse response = - GetApplicationReportResponse.newInstance(history + @Override + public GetApplicationReportResponse getApplicationReport( + GetApplicationReportRequest request) throws YarnException, IOException { + try { + ApplicationId applicationId = request.getApplicationId(); + GetApplicationReportResponse response = + GetApplicationReportResponse.newInstance(history .getApplication(applicationId)); - return response; - } catch (IOException e) { - throw new ApplicationNotFoundException(e.getMessage()); - } + return response; + } catch (IOException e) { + throw new ApplicationNotFoundException(e.getMessage()); } + } - @Override - public GetApplicationsResponse getApplications( - GetApplicationsRequest request) throws YarnException, IOException { - GetApplicationsResponse response = - GetApplicationsResponse.newInstance(new ArrayList( + @Override + public GetApplicationsResponse getApplications( + GetApplicationsRequest request) throws YarnException, IOException { + GetApplicationsResponse response = + GetApplicationsResponse.newInstance(new ArrayList( history.getAllApplications().values())); - return response; - } + return response; + } - @Override - public GetContainerReportResponse getContainerReport( - GetContainerReportRequest request) throws YarnException, IOException { - try { - GetContainerReportResponse response = - GetContainerReportResponse.newInstance(history.getContainer(request + @Override + public GetContainerReportResponse getContainerReport( + GetContainerReportRequest request) throws YarnException, IOException { + try { + GetContainerReportResponse response = + GetContainerReportResponse.newInstance(history.getContainer(request .getContainerId())); - return response; - } catch (IOException e) { - throw new ContainerNotFoundException(e.getMessage()); - } + return response; + } catch (IOException e) { + throw new ContainerNotFoundException(e.getMessage()); } + } - @Override - public GetContainersResponse getContainers(GetContainersRequest request) - throws YarnException, IOException { - GetContainersResponse response = - GetContainersResponse.newInstance(new ArrayList( + @Override + public GetContainersResponse getContainers(GetContainersRequest request) + throws YarnException, IOException { + GetContainersResponse response = + GetContainersResponse.newInstance(new ArrayList( history.getContainers(request.getApplicationAttemptId()).values())); - return response; - } + return response; + } - @Override - public GetDelegationTokenResponse getDelegationToken( - GetDelegationTokenRequest request) throws YarnException, IOException { - // TODO Auto-generated method stub - return null; - } + @Override + public CancelDelegationTokenResponse cancelDelegationToken( + CancelDelegationTokenRequest request) throws YarnException, IOException { + // TODO Auto-generated method stub + return null; + } - @Override - public RenewDelegationTokenResponse renewDelegationToken( - RenewDelegationTokenRequest request) throws YarnException, IOException { - // TODO Auto-generated method stub - return null; - } + @Override + public GetDelegationTokenResponse getDelegationToken( + GetDelegationTokenRequest request) throws YarnException, IOException { + // TODO Auto-generated method stub + return null; } + + @Override + public RenewDelegationTokenResponse renewDelegationToken( + RenewDelegationTokenRequest request) throws YarnException, IOException { + // TODO Auto-generated method stub + return null; + } + } diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/ApplicationHistoryManager.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/ApplicationHistoryManager.java index db25d29..8b97023 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/ApplicationHistoryManager.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/ApplicationHistoryManager.java @@ -18,11 +18,114 @@ package org.apache.hadoop.yarn.server.applicationhistoryservice; +import java.io.IOException; +import java.util.Map; + import org.apache.hadoop.classification.InterfaceAudience; +import org.apache.hadoop.classification.InterfaceAudience.Public; import org.apache.hadoop.classification.InterfaceStability; -import org.apache.hadoop.yarn.server.api.ApplicationContext; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.api.records.ApplicationAttemptId; +import org.apache.hadoop.yarn.api.records.ApplicationAttemptReport; +import org.apache.hadoop.yarn.api.records.ApplicationId; +import org.apache.hadoop.yarn.api.records.ApplicationReport; +import org.apache.hadoop.yarn.api.records.ContainerId; +import org.apache.hadoop.yarn.api.records.ContainerReport; @InterfaceAudience.Public @InterfaceStability.Unstable -public interface ApplicationHistoryManager extends ApplicationContext { +public interface ApplicationHistoryManager { + /** + * This method returns Application {@link ApplicationReport} for the specified + * {@link ApplicationId}. + * + * @param appId + * + * @return {@link ApplicationReport} for the ApplicationId. + * @throws IOException + */ + @Public + @Unstable + ApplicationReport getApplication(ApplicationId appId) throws IOException; + + /** + * This method returns all Application {@link ApplicationReport}s + * + * @return map of {@link ApplicationId} to {@link ApplicationReport}s. + * @throws IOException + */ + @Public + @Unstable + Map getAllApplications() throws IOException; + + /** + * Application can have multiple application attempts + * {@link ApplicationAttemptReport}. This method returns the all + * {@link ApplicationAttemptReport}s for the Application. + * + * @param appId + * + * @return all {@link ApplicationAttemptReport}s for the Application. + * @throws IOException + */ + @Public + @Unstable + Map getApplicationAttempts( + ApplicationId appId) throws IOException; + + /** + * This method returns {@link ApplicationAttemptReport} for specified + * {@link ApplicationId}. + * + * @param appAttemptId + * {@link ApplicationAttemptId} + * @return {@link ApplicationAttemptReport} for ApplicationAttemptId + * @throws IOException + */ + @Public + @Unstable + ApplicationAttemptReport getApplicationAttempt( + ApplicationAttemptId appAttemptId) throws IOException; + + /** + * This method returns {@link ContainerReport} for specified + * {@link ContainerId}. + * + * @param containerId + * {@link ContainerId} + * @return {@link ContainerReport} for ContainerId + * @throws IOException + */ + @Public + @Unstable + ContainerReport getContainer(ContainerId containerId) throws IOException; + + /** + * This method returns {@link ContainerReport} for specified + * {@link ApplicationAttemptId}. + * + * @param appAttemptId + * {@link ApplicationAttemptId} + * @return {@link ContainerReport} for ApplicationAttemptId + * @throws IOException + */ + @Public + @Unstable + ContainerReport getAMContainer(ApplicationAttemptId appAttemptId) + throws IOException; + + /** + * This method returns Map of {@link ContainerId} to {@link ContainerReport} + * for specified {@link ApplicationAttemptId}. + * + * @param appAttemptId + * {@link ApplicationAttemptId} + * @return Map of {@link ContainerId} to {@link ContainerReport} for + * ApplicationAttemptId + * @throws IOException + */ + @Public + @Unstable + Map getContainers( + ApplicationAttemptId appAttemptId) throws IOException; } diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/ApplicationHistoryManagerImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/ApplicationHistoryManagerImpl.java index b56a595..5cb3a78 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/ApplicationHistoryManagerImpl.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/ApplicationHistoryManagerImpl.java @@ -138,7 +138,7 @@ private ApplicationReport convertToApplicationReport( appHistory.getApplicationName(), host, rpcPort, null, appHistory.getYarnApplicationState(), appHistory.getDiagnosticsInfo(), trackingUrl, appHistory.getStartTime(), appHistory.getFinishTime(), - appHistory.getFinalApplicationStatus(), null, "", 100, + appHistory.getFinalApplicationStatus(), null, "", 1.0f, appHistory.getApplicationType(), null); } diff --git 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 index 731ae14..555b981 100644 --- 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 @@ -162,7 +162,7 @@ protected void startWebApp() { .withHttpSpnegoKeytabKey( YarnConfiguration.TIMELINE_SERVICE_WEBAPP_SPNEGO_KEYTAB_FILE_KEY) .at(bindAddress) - .start(new AHSWebApp(historyManager, timelineStore)); + .start(new AHSWebApp(ahsClientService, timelineStore)); } catch (Exception e) { String msg = "AHSWebApp failed to start."; LOG.error(msg, e); diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/AHSView.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/AHSView.java index 4baa75d..56a0e93 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/AHSView.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/AHSView.java @@ -25,9 +25,9 @@ import static org.apache.hadoop.yarn.webapp.view.JQueryUI.DATATABLES; import static org.apache.hadoop.yarn.webapp.view.JQueryUI.DATATABLES_ID; import static org.apache.hadoop.yarn.webapp.view.JQueryUI.initID; -import static org.apache.hadoop.yarn.webapp.view.JQueryUI.tableInit; import org.apache.hadoop.yarn.server.webapp.AppsBlock; +import org.apache.hadoop.yarn.server.webapp.WebPageUtils; import org.apache.hadoop.yarn.webapp.SubView; import org.apache.hadoop.yarn.webapp.view.TwoColumnLayout; @@ -41,7 +41,7 @@ protected void preHead(Page.HTML<_> html) { commonPreHead(html); set(DATATABLES_ID, "apps"); - set(initID(DATATABLES, "apps"), appsTableInit()); + set(initID(DATATABLES, "apps"), WebPageUtils.appsTableInit()); setTableStyles(html, "apps", ".queue {width:6em}", ".ui {width:8em}"); // Set the correct title. @@ -65,26 +65,4 @@ protected void commonPreHead(Page.HTML<_> html) { return AppsBlock.class; } - private String appsTableInit() { - // id, user, name, queue, starttime, finishtime, state, status, progress, ui - return tableInit().append(", 'aaData': appsTableData") - .append(", bDeferRender: true").append(", bProcessing: true") - - .append("\n, aoColumnDefs: ").append(getAppsTableColumnDefs()) - - // Sort by id upon page load - .append(", aaSorting: [[0, 'desc']]}").toString(); - } - - protected String getAppsTableColumnDefs() { - StringBuilder sb = new StringBuilder(); - return sb.append("[\n").append("{'sType':'numeric', 'aTargets': [0]") - .append(", 'mRender': parseHadoopID }") - - .append("\n, {'sType':'numeric', 'aTargets': [5, 6]") - .append(", 'mRender': renderHadoopDate }") - - .append("\n, {'sType':'numeric', bSearchable:false, 'aTargets': [9]") - .append(", 'mRender': parseHadoopProgress }]").toString(); - } } diff --git 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 index 93065b3..6cb7b35 100644 --- 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 @@ -19,8 +19,8 @@ import static org.apache.hadoop.yarn.util.StringHelper.pajoin; -import org.apache.hadoop.yarn.server.api.ApplicationContext; -import org.apache.hadoop.yarn.server.applicationhistoryservice.ApplicationHistoryManager; +import org.apache.hadoop.yarn.api.ApplicationBaseProtocol; +import org.apache.hadoop.yarn.server.applicationhistoryservice.ApplicationHistoryClientService; import org.apache.hadoop.yarn.server.applicationhistoryservice.timeline.TimelineStore; import org.apache.hadoop.yarn.webapp.GenericExceptionHandler; import org.apache.hadoop.yarn.webapp.WebApp; @@ -29,12 +29,12 @@ public class AHSWebApp extends WebApp implements YarnWebParams { - private final ApplicationHistoryManager applicationHistoryManager; + private final ApplicationHistoryClientService historyClientService; private final TimelineStore timelineStore; - public AHSWebApp(ApplicationHistoryManager applicationHistoryManager, + public AHSWebApp(ApplicationHistoryClientService historyClientService, TimelineStore timelineStore) { - this.applicationHistoryManager = applicationHistoryManager; + this.historyClientService = historyClientService; this.timelineStore = timelineStore; } @@ -44,7 +44,7 @@ public void setup() { bind(AHSWebServices.class); bind(TimelineWebServices.class); bind(GenericExceptionHandler.class); - bind(ApplicationContext.class).toInstance(applicationHistoryManager); + bind(ApplicationBaseProtocol.class).toInstance(historyClientService); bind(TimelineStore.class).toInstance(timelineStore); route("/", AHSController.class); route(pajoin("/apps", APP_STATE), AHSController.class); diff --git 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 index 2040f57..3064d2d 100644 --- 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 @@ -31,8 +31,8 @@ import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; +import org.apache.hadoop.yarn.api.ApplicationBaseProtocol; import org.apache.hadoop.yarn.api.records.YarnApplicationState; -import org.apache.hadoop.yarn.server.api.ApplicationContext; import org.apache.hadoop.yarn.server.webapp.WebServices; import org.apache.hadoop.yarn.server.webapp.dao.AppAttemptInfo; import org.apache.hadoop.yarn.server.webapp.dao.AppAttemptsInfo; @@ -50,8 +50,8 @@ public class AHSWebServices extends WebServices { @Inject - public AHSWebServices(ApplicationContext appContext) { - super(appContext); + public AHSWebServices(ApplicationBaseProtocol appBaseProt) { + super(appBaseProt); } @GET diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/AppAttemptPage.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/AppAttemptPage.java index 63b44bd..374a45b 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/AppAttemptPage.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/AppAttemptPage.java @@ -21,9 +21,9 @@ import static org.apache.hadoop.yarn.webapp.view.JQueryUI.DATATABLES; import static org.apache.hadoop.yarn.webapp.view.JQueryUI.DATATABLES_ID; import static org.apache.hadoop.yarn.webapp.view.JQueryUI.initID; -import static org.apache.hadoop.yarn.webapp.view.JQueryUI.tableInit; import org.apache.hadoop.yarn.server.webapp.AppAttemptBlock; +import org.apache.hadoop.yarn.server.webapp.WebPageUtils; import org.apache.hadoop.yarn.webapp.SubView; import org.apache.hadoop.yarn.webapp.YarnWebParams; @@ -41,7 +41,7 @@ protected void preHead(Page.HTML<_> html) { $(YarnWebParams.APPLICATION_ATTEMPT_ID))); set(DATATABLES_ID, "containers"); - set(initID(DATATABLES, "containers"), containersTableInit()); + set(initID(DATATABLES, "containers"), WebPageUtils.containersTableInit()); setTableStyles(html, "containers", ".queue {width:6em}", ".ui {width:8em}"); } @@ -50,20 +50,4 @@ protected void preHead(Page.HTML<_> html) { return AppAttemptBlock.class; } - private String containersTableInit() { - return tableInit().append(", 'aaData': containersTableData") - .append(", bDeferRender: true").append(", bProcessing: true") - - .append("\n, aoColumnDefs: ").append(getContainersTableColumnDefs()) - - // Sort by id upon page load - .append(", aaSorting: [[0, 'desc']]}").toString(); - } - - protected String getContainersTableColumnDefs() { - StringBuilder sb = new StringBuilder(); - return sb.append("[\n").append("{'sType':'numeric', 'aTargets': [0]") - .append(", 'mRender': parseHadoopID }]").toString(); - } - } \ No newline at end of file diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/AppPage.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/AppPage.java index 96ca659..316c72b 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/AppPage.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/AppPage.java @@ -22,9 +22,9 @@ import static org.apache.hadoop.yarn.webapp.view.JQueryUI.DATATABLES; import static org.apache.hadoop.yarn.webapp.view.JQueryUI.DATATABLES_ID; import static org.apache.hadoop.yarn.webapp.view.JQueryUI.initID; -import static org.apache.hadoop.yarn.webapp.view.JQueryUI.tableInit; import org.apache.hadoop.yarn.server.webapp.AppBlock; +import org.apache.hadoop.yarn.server.webapp.WebPageUtils; import org.apache.hadoop.yarn.webapp.SubView; import org.apache.hadoop.yarn.webapp.YarnWebParams; @@ -41,7 +41,7 @@ protected void preHead(Page.HTML<_> html) { "Application ", $(YarnWebParams.APPLICATION_ID))); set(DATATABLES_ID, "attempts"); - set(initID(DATATABLES, "attempts"), attemptsTableInit()); + set(initID(DATATABLES, "attempts"), WebPageUtils.attemptsTableInit()); setTableStyles(html, "attempts", ".queue {width:6em}", ".ui {width:8em}"); } @@ -50,22 +50,4 @@ protected void preHead(Page.HTML<_> html) { return AppBlock.class; } - private String attemptsTableInit() { - return tableInit().append(", 'aaData': attemptsTableData") - .append(", bDeferRender: true").append(", bProcessing: true") - - .append("\n, aoColumnDefs: ").append(getAttemptsTableColumnDefs()) - - // Sort by id upon page load - .append(", aaSorting: [[0, 'desc']]}").toString(); - } - - protected String getAttemptsTableColumnDefs() { - StringBuilder sb = new StringBuilder(); - return sb.append("[\n").append("{'sType':'numeric', 'aTargets': [0]") - .append(", 'mRender': parseHadoopID }") - - .append("\n, {'sType':'numeric', 'aTargets': [1]") - .append(", 'mRender': renderHadoopDate }]").toString(); - } } diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/TestApplicationHistoryClientService.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/TestApplicationHistoryClientService.java index a35fe46..f29b030 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/TestApplicationHistoryClientService.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/TestApplicationHistoryClientService.java @@ -86,8 +86,7 @@ public void testApplicationReport() throws IOException, YarnException { GetApplicationReportRequest request = GetApplicationReportRequest.newInstance(appId); GetApplicationReportResponse response = - historyServer.getClientService().getClientHandler() - .getApplicationReport(request); + historyServer.getClientService().getApplicationReport(request); ApplicationReport appReport = response.getApplicationReport(); Assert.assertNotNull(appReport); Assert.assertEquals("application_0_0001", appReport.getApplicationId() @@ -107,8 +106,7 @@ public void testApplications() throws IOException, YarnException { writeApplicationFinishData(appId1); GetApplicationsRequest request = GetApplicationsRequest.newInstance(); GetApplicationsResponse response = - historyServer.getClientService().getClientHandler() - .getApplications(request); + historyServer.getClientService().getApplications(request); List appReport = response.getApplicationList(); Assert.assertNotNull(appReport); Assert.assertEquals(appId, appReport.get(0).getApplicationId()); @@ -125,8 +123,7 @@ public void testApplicationAttemptReport() throws IOException, YarnException { GetApplicationAttemptReportRequest request = GetApplicationAttemptReportRequest.newInstance(appAttemptId); GetApplicationAttemptReportResponse response = - historyServer.getClientService().getClientHandler() - .getApplicationAttemptReport(request); + historyServer.getClientService().getApplicationAttemptReport(request); ApplicationAttemptReport attemptReport = response.getApplicationAttemptReport(); Assert.assertNotNull(attemptReport); @@ -148,8 +145,7 @@ public void testApplicationAttempts() throws IOException, YarnException { GetApplicationAttemptsRequest request = GetApplicationAttemptsRequest.newInstance(appId); GetApplicationAttemptsResponse response = - historyServer.getClientService().getClientHandler() - .getApplicationAttempts(request); + historyServer.getClientService().getApplicationAttempts(request); List attemptReports = response.getApplicationAttemptList(); Assert.assertNotNull(attemptReports); @@ -172,8 +168,7 @@ public void testContainerReport() throws IOException, YarnException { GetContainerReportRequest request = GetContainerReportRequest.newInstance(containerId); GetContainerReportResponse response = - historyServer.getClientService().getClientHandler() - .getContainerReport(request); + historyServer.getClientService().getContainerReport(request); ContainerReport container = response.getContainerReport(); Assert.assertNotNull(container); Assert.assertEquals(containerId, container.getContainerId()); @@ -196,8 +191,7 @@ public void testContainers() throws IOException, YarnException { GetContainersRequest request = GetContainersRequest.newInstance(appAttemptId); GetContainersResponse response = - historyServer.getClientService().getClientHandler() - .getContainers(request); + historyServer.getClientService().getContainers(request); List containers = response.getContainerList(); Assert.assertNotNull(containers); Assert.assertEquals(containerId, containers.get(1).getContainerId()); diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/TestAHSWebApp.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/TestAHSWebApp.java index 82c4276..0b59cda 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/TestAHSWebApp.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/TestAHSWebApp.java @@ -23,12 +23,13 @@ import org.junit.Assert; import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.yarn.api.ApplicationBaseProtocol; 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.api.records.YarnApplicationState; import org.apache.hadoop.yarn.conf.YarnConfiguration; -import org.apache.hadoop.yarn.server.api.ApplicationContext; +import org.apache.hadoop.yarn.server.applicationhistoryservice.ApplicationHistoryClientService; import org.apache.hadoop.yarn.server.applicationhistoryservice.ApplicationHistoryManager; import org.apache.hadoop.yarn.server.applicationhistoryservice.ApplicationHistoryManagerImpl; import org.apache.hadoop.yarn.server.applicationhistoryservice.ApplicationHistoryStore; @@ -68,8 +69,8 @@ public void testAppControllerIndex() throws Exception { @Test public void testView() throws Exception { Injector injector = - WebAppTests.createMockInjector(ApplicationContext.class, - mockApplicationHistoryManager(5, 1, 1)); + WebAppTests.createMockInjector(ApplicationBaseProtocol.class, + mockApplicationHistoryClientService(5, 1, 1)); AHSView ahsViewInstance = injector.getInstance(AHSView.class); ahsViewInstance.render(); @@ -89,8 +90,8 @@ public void testView() throws Exception { @Test public void testAppPage() throws Exception { Injector injector = - WebAppTests.createMockInjector(ApplicationContext.class, - mockApplicationHistoryManager(1, 5, 1)); + WebAppTests.createMockInjector(ApplicationBaseProtocol.class, + mockApplicationHistoryClientService(1, 5, 1)); AppPage appPageInstance = injector.getInstance(AppPage.class); appPageInstance.render(); @@ -105,8 +106,8 @@ public void testAppPage() throws Exception { @Test public void testAppAttemptPage() throws Exception { Injector injector = - WebAppTests.createMockInjector(ApplicationContext.class, - mockApplicationHistoryManager(1, 1, 5)); + WebAppTests.createMockInjector(ApplicationBaseProtocol.class, + mockApplicationHistoryClientService(1, 1, 5)); AppAttemptPage appAttemptPageInstance = injector.getInstance(AppAttemptPage.class); @@ -123,8 +124,8 @@ public void testAppAttemptPage() throws Exception { @Test public void testContainerPage() throws Exception { Injector injector = - WebAppTests.createMockInjector(ApplicationContext.class, - mockApplicationHistoryManager(1, 1, 1)); + WebAppTests.createMockInjector(ApplicationBaseProtocol.class, + mockApplicationHistoryClientService(1, 1, 1)); ContainerPage containerPageInstance = injector.getInstance(ContainerPage.class); @@ -141,10 +142,12 @@ public void testContainerPage() throws Exception { WebAppTests.flushOutput(injector); } - ApplicationHistoryManager mockApplicationHistoryManager(int numApps, + ApplicationHistoryClientService mockApplicationHistoryClientService(int numApps, int numAppAttempts, int numContainers) throws Exception { ApplicationHistoryManager ahManager = new MockApplicationHistoryManagerImpl(store); + ApplicationHistoryClientService historyClientService = + new ApplicationHistoryClientService(ahManager); for (int i = 1; i <= numApps; ++i) { ApplicationId appId = ApplicationId.newInstance(0, i); writeApplicationStartData(appId); @@ -161,7 +164,7 @@ ApplicationHistoryManager mockApplicationHistoryManager(int numApps, } writeApplicationFinishData(appId); } - return ahManager; + return historyClientService; } class MockApplicationHistoryManagerImpl extends ApplicationHistoryManagerImpl { diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/TestAHSWebServices.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/TestAHSWebServices.java index b348443..3153484 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/TestAHSWebServices.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/TestAHSWebServices.java @@ -23,9 +23,8 @@ import javax.ws.rs.core.MediaType; -import org.junit.Assert; - import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.yarn.api.ApplicationBaseProtocol; import org.apache.hadoop.yarn.api.records.ApplicationAttemptId; import org.apache.hadoop.yarn.api.records.ApplicationId; import org.apache.hadoop.yarn.api.records.ContainerId; @@ -36,8 +35,7 @@ import org.apache.hadoop.yarn.api.records.YarnApplicationAttemptState; import org.apache.hadoop.yarn.api.records.YarnApplicationState; import org.apache.hadoop.yarn.conf.YarnConfiguration; -import org.apache.hadoop.yarn.server.api.ApplicationContext; -import org.apache.hadoop.yarn.server.applicationhistoryservice.ApplicationHistoryManager; +import org.apache.hadoop.yarn.server.applicationhistoryservice.ApplicationHistoryClientService; import org.apache.hadoop.yarn.server.applicationhistoryservice.ApplicationHistoryStore; import org.apache.hadoop.yarn.server.applicationhistoryservice.MemoryApplicationHistoryStore; import org.apache.hadoop.yarn.webapp.GenericExceptionHandler; @@ -46,6 +44,7 @@ import org.codehaus.jettison.json.JSONArray; import org.codehaus.jettison.json.JSONException; import org.codehaus.jettison.json.JSONObject; +import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -63,7 +62,7 @@ public class TestAHSWebServices extends JerseyTest { - private static ApplicationHistoryManager ahManager; + private static ApplicationHistoryClientService historyClientService; private Injector injector = Guice.createInjector(new ServletModule() { @@ -73,11 +72,11 @@ protected void configureServlets() { bind(AHSWebServices.class); bind(GenericExceptionHandler.class); try { - ahManager = mockApplicationHistoryManager(); + historyClientService = mockApplicationHistoryClientService(); } catch (Exception e) { Assert.fail(); } - bind(ApplicationContext.class).toInstance(ahManager); + bind(ApplicationBaseProtocol.class).toInstance(historyClientService); serve("/*").with(GuiceContainer.class); } }); @@ -90,14 +89,14 @@ protected Injector getInjector() { } } - private ApplicationHistoryManager mockApplicationHistoryManager() + private ApplicationHistoryClientService mockApplicationHistoryClientService() throws Exception { ApplicationHistoryStore store = new MemoryApplicationHistoryStore(); TestAHSWebApp testAHSWebApp = new TestAHSWebApp(); testAHSWebApp.setApplicationHistoryStore(store); - ApplicationHistoryManager ahManager = - testAHSWebApp.mockApplicationHistoryManager(5, 5, 5); - return ahManager; + ApplicationHistoryClientService historyClientService = + testAHSWebApp.mockApplicationHistoryClientService(5, 5, 5); + return historyClientService; } public TestAHSWebServices() { diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/api/ApplicationContext.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/api/ApplicationContext.java deleted file mode 100644 index 78ae0dd..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/api/ApplicationContext.java +++ /dev/null @@ -1,129 +0,0 @@ -/** - * 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.api; - -import java.io.IOException; -import java.util.Map; - -import org.apache.hadoop.classification.InterfaceAudience.Public; -import org.apache.hadoop.classification.InterfaceStability.Unstable; -import org.apache.hadoop.yarn.api.records.ApplicationAttemptId; -import org.apache.hadoop.yarn.api.records.ApplicationAttemptReport; -import org.apache.hadoop.yarn.api.records.ApplicationId; -import org.apache.hadoop.yarn.api.records.ApplicationReport; -import org.apache.hadoop.yarn.api.records.ContainerId; -import org.apache.hadoop.yarn.api.records.ContainerReport; - -@Public -@Unstable -public interface ApplicationContext { - /** - * This method returns Application {@link ApplicationReport} for the specified - * {@link ApplicationId}. - * - * @param appId - * - * @return {@link ApplicationReport} for the ApplicationId. - * @throws IOException - */ - @Public - @Unstable - ApplicationReport getApplication(ApplicationId appId) throws IOException; - - /** - * This method returns all Application {@link ApplicationReport}s - * - * @return map of {@link ApplicationId} to {@link ApplicationReport}s. - * @throws IOException - */ - @Public - @Unstable - Map getAllApplications() throws IOException; - - /** - * Application can have multiple application attempts - * {@link ApplicationAttemptReport}. This method returns the all - * {@link ApplicationAttemptReport}s for the Application. - * - * @param appId - * - * @return all {@link ApplicationAttemptReport}s for the Application. - * @throws IOException - */ - @Public - @Unstable - Map getApplicationAttempts( - ApplicationId appId) throws IOException; - - /** - * This method returns {@link ApplicationAttemptReport} for specified - * {@link ApplicationId}. - * - * @param appAttemptId - * {@link ApplicationAttemptId} - * @return {@link ApplicationAttemptReport} for ApplicationAttemptId - * @throws IOException - */ - @Public - @Unstable - ApplicationAttemptReport getApplicationAttempt( - ApplicationAttemptId appAttemptId) throws IOException; - - /** - * This method returns {@link ContainerReport} for specified - * {@link ContainerId}. - * - * @param containerId - * {@link ContainerId} - * @return {@link ContainerReport} for ContainerId - * @throws IOException - */ - @Public - @Unstable - ContainerReport getContainer(ContainerId containerId) throws IOException; - - /** - * This method returns {@link ContainerReport} for specified - * {@link ApplicationAttemptId}. - * - * @param appAttemptId - * {@link ApplicationAttemptId} - * @return {@link ContainerReport} for ApplicationAttemptId - * @throws IOException - */ - @Public - @Unstable - ContainerReport getAMContainer(ApplicationAttemptId appAttemptId) - throws IOException; - - /** - * This method returns Map of {@link ContainerId} to {@link ContainerReport} - * for specified {@link ApplicationAttemptId}. - * - * @param appAttemptId - * {@link ApplicationAttemptId} - * @return Map of {@link ContainerId} to {@link ContainerReport} for - * ApplicationAttemptId - * @throws IOException - */ - @Public - @Unstable - Map getContainers( - ApplicationAttemptId appAttemptId) throws IOException; -} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/webapp/AppAttemptBlock.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/webapp/AppAttemptBlock.java index 1a76eca..dd72af5 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/webapp/AppAttemptBlock.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/webapp/AppAttemptBlock.java @@ -20,16 +20,24 @@ import static org.apache.hadoop.yarn.util.StringHelper.join; import static org.apache.hadoop.yarn.webapp.YarnWebParams.APPLICATION_ATTEMPT_ID; -import java.io.IOException; +import java.lang.reflect.UndeclaredThrowableException; +import java.security.PrivilegedExceptionAction; import java.util.Collection; +import java.util.List; import org.apache.commons.lang.StringEscapeUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.hadoop.security.UserGroupInformation; +import org.apache.hadoop.yarn.api.ApplicationBaseProtocol; +import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationAttemptReportRequest; +import org.apache.hadoop.yarn.api.protocolrecords.GetContainersRequest; import org.apache.hadoop.yarn.api.records.ApplicationAttemptId; import org.apache.hadoop.yarn.api.records.ApplicationAttemptReport; import org.apache.hadoop.yarn.api.records.ContainerReport; -import org.apache.hadoop.yarn.server.api.ApplicationContext; +import org.apache.hadoop.yarn.api.records.YarnApplicationAttemptState; +import org.apache.hadoop.yarn.exceptions.ApplicationAttemptNotFoundException; +import org.apache.hadoop.yarn.exceptions.ApplicationNotFoundException; import org.apache.hadoop.yarn.server.webapp.dao.AppAttemptInfo; import org.apache.hadoop.yarn.server.webapp.dao.ContainerInfo; import org.apache.hadoop.yarn.util.ConverterUtils; @@ -44,11 +52,13 @@ public class AppAttemptBlock extends HtmlBlock { private static final Log LOG = LogFactory.getLog(AppAttemptBlock.class); - private final ApplicationContext appContext; + protected ApplicationBaseProtocol appBaseProt; @Inject - public AppAttemptBlock(ApplicationContext appContext) { - this.appContext = appContext; + public AppAttemptBlock( + ApplicationBaseProtocol appBaseProt, ViewContext ctx) { + super(ctx); + this.appBaseProt = appBaseProt; } @Override @@ -67,20 +77,43 @@ protected void render(Block html) { return; } - ApplicationAttemptReport appAttemptReport; + UserGroupInformation callerUGI = getCallerUGI(); + + ApplicationAttemptReport appAttemptReport = null; try { - appAttemptReport = appContext.getApplicationAttempt(appAttemptId); - } catch (IOException e) { + final GetApplicationAttemptReportRequest request = + GetApplicationAttemptReportRequest.newInstance(appAttemptId); + if (callerUGI == null) { + appAttemptReport = appBaseProt.getApplicationAttemptReport(request) + .getApplicationAttemptReport(); + } else { + try { + appAttemptReport = callerUGI.doAs( + new PrivilegedExceptionAction() { + @Override + public ApplicationAttemptReport run() throws Exception { + return appBaseProt.getApplicationAttemptReport(request) + .getApplicationAttemptReport(); + } + }); + } catch (UndeclaredThrowableException e) { + throw e.getCause(); + } + } + } catch (ApplicationNotFoundException e) { + puts("Application Attempt not found: " + attemptid); + return; + } catch (ApplicationAttemptNotFoundException e) { + puts("Application Attempt not found: " + attemptid); + return; + } catch (Throwable e) { String message = "Failed to read the application attempt " + appAttemptId + "."; LOG.error(message, e); html.p()._(message)._(); return; } - if (appAttemptReport == null) { - puts("Application Attempt not found: " + attemptid); - return; - } + AppAttemptInfo appAttempt = new AppAttemptInfo(appAttemptReport); setTitle(join("Application Attempt ", attemptid)); @@ -91,7 +124,7 @@ protected void render(Block html) { node = appAttempt.getHost() + ":" + appAttempt.getRpcPort(); } info("Application Attempt Overview") - ._("State", appAttempt.getAppAttemptState()) + ._("Application Attempt State", appAttempt.getAppAttemptState()) ._( "Master Container", appAttempt.getAmContainerId() == null ? "#" : root_url("container", @@ -101,20 +134,41 @@ protected void render(Block html) { ._( "Tracking URL:", appAttempt.getTrackingUrl() == null ? "#" : root_url(appAttempt - .getTrackingUrl()), "History") - ._("Diagnostics Info:", appAttempt.getDiagnosticsInfo()); + .getTrackingUrl()), + appAttempt.getTrackingUrl() == null ? "Unassigned" : + appAttempt.getAppAttemptState() == YarnApplicationAttemptState.FINISHED || + appAttempt.getAppAttemptState() == YarnApplicationAttemptState.FAILED || + appAttempt.getAppAttemptState() == YarnApplicationAttemptState.KILLED ? + "History" : "ApplicationMaster") + ._("Diagnostics Info:", appAttempt.getDiagnosticsInfo() == null ? + "" : appAttempt.getDiagnosticsInfo()); html._(InfoBlock.class); - Collection containers; + Collection containers = null; try { - containers = appContext.getContainers(appAttemptId).values(); - } catch (IOException e) { - html - .p() - ._( - "Sorry, Failed to get containers for application attempt" + attemptid - + ".")._(); + final GetContainersRequest request = + GetContainersRequest.newInstance(appAttemptId); + if (callerUGI == null) { + containers = appBaseProt.getContainers(request).getContainerList(); + } else { + try { + containers = callerUGI.doAs( + new PrivilegedExceptionAction>() { + @Override + public List run() throws Exception { + return appBaseProt.getContainers(request).getContainerList(); + } + }); + } catch (UndeclaredThrowableException e) { + throw e.getCause(); + } + } + } catch (Throwable e) { + String message = + "Failed to get containers for application attempt" + attemptid + "."; + LOG.error(message, e); + html.p()._(message)._(); return; } @@ -135,11 +189,12 @@ protected void render(Block html) { .append("'>") .append(container.getContainerId()) .append("\",\"") - .append( - StringEscapeUtils.escapeJavaScript(StringEscapeUtils - .escapeHtml(container.getAssignedNodeId()))).append("\",\"") + .append(container.getAssignedNodeId() == null ? "N/A" : + StringEscapeUtils.escapeJavaScript(StringEscapeUtils + .escapeHtml(container.getAssignedNodeId()))) + .append("\",\"") .append(container.getContainerExitStatus()).append("\",\"") diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/webapp/AppBlock.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/webapp/AppBlock.java index 2ae495b..3a976bf 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/webapp/AppBlock.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/webapp/AppBlock.java @@ -21,16 +21,28 @@ import static org.apache.hadoop.yarn.util.StringHelper.join; import static org.apache.hadoop.yarn.webapp.YarnWebParams.APPLICATION_ID; -import java.io.IOException; +import java.lang.reflect.UndeclaredThrowableException; +import java.security.PrivilegedExceptionAction; import java.util.Collection; +import java.util.List; import org.apache.commons.lang.StringEscapeUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.hadoop.security.UserGroupInformation; import org.apache.hadoop.util.StringUtils; +import org.apache.hadoop.yarn.api.ApplicationBaseProtocol; +import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationAttemptsRequest; +import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationReportRequest; +import org.apache.hadoop.yarn.api.protocolrecords.GetContainerReportRequest; import org.apache.hadoop.yarn.api.records.ApplicationAttemptReport; import org.apache.hadoop.yarn.api.records.ApplicationId; import org.apache.hadoop.yarn.api.records.ApplicationReport; +import org.apache.hadoop.yarn.api.records.ContainerId; import org.apache.hadoop.yarn.api.records.ContainerReport; -import org.apache.hadoop.yarn.server.api.ApplicationContext; +import org.apache.hadoop.yarn.api.records.YarnApplicationState; +import org.apache.hadoop.yarn.exceptions.ApplicationNotFoundException; +import org.apache.hadoop.yarn.exceptions.ContainerNotFoundException; import org.apache.hadoop.yarn.server.webapp.dao.AppAttemptInfo; import org.apache.hadoop.yarn.server.webapp.dao.AppInfo; import org.apache.hadoop.yarn.server.webapp.dao.ContainerInfo; @@ -46,12 +58,14 @@ public class AppBlock extends HtmlBlock { - protected ApplicationContext appContext; + private static final Log LOG = LogFactory.getLog(AppBlock.class); + protected ApplicationBaseProtocol appBaseProt; @Inject - AppBlock(ApplicationContext appContext, ViewContext ctx) { + public AppBlock( + ApplicationBaseProtocol appBaseProt, ViewContext ctx) { super(ctx); - this.appContext = appContext; + this.appBaseProt = appBaseProt; } @Override @@ -70,19 +84,39 @@ protected void render(Block html) { return; } - ApplicationReport appReport; + UserGroupInformation callerUGI = getCallerUGI(); + + ApplicationReport appReport = null; try { - appReport = appContext.getApplication(appID); - } catch (IOException e) { + final GetApplicationReportRequest request = + GetApplicationReportRequest.newInstance(appID); + if (callerUGI == null) { + appReport = + appBaseProt.getApplicationReport(request).getApplicationReport(); + } else { + try { + appReport = callerUGI.doAs( + new PrivilegedExceptionAction() { + @Override + public ApplicationReport run() throws Exception { + return appBaseProt.getApplicationReport(request) + .getApplicationReport(); + } + }); + } catch (UndeclaredThrowableException e) { + throw e.getCause(); + } + } + } catch(ApplicationNotFoundException e) { + puts("Application not found: " + aid); + return; + } catch (Throwable e) { String message = "Failed to read the application " + appID + "."; LOG.error(message, e); html.p()._(message)._(); return; } - if (appReport == null) { - puts("Application not found: " + aid); - return; - } + AppInfo app = new AppInfo(appReport); setTitle(join("Application ", aid)); @@ -91,7 +125,9 @@ protected void render(Block html) { ._("User:", app.getUser()) ._("Name:", app.getName()) ._("Application Type:", app.getType()) - ._("State:", app.getAppState()) + ._("Application State:", app.getAppState()) + ._("Application Tags:", + app.getApplicationTags() == null ? "" : app.getApplicationTags()) ._("FinalStatus:", app.getFinalAppStatus()) ._("Started:", Times.format(app.getStartedTime())) ._( @@ -100,14 +136,38 @@ protected void render(Block html) { app.getFinishedTime()))) ._("Tracking URL:", app.getTrackingUrl() == null ? "#" : root_url(app.getTrackingUrl()), - "History")._("Diagnostics:", app.getDiagnosticsInfo()); + app.getTrackingUrl() == null ? "Unassigned" : + app.getAppState() == YarnApplicationState.FINISHED || + app.getAppState() == YarnApplicationState.FAILED || + app.getAppState() == YarnApplicationState.KILLED ? + "History" : "ApplicationMaster") + ._("Diagnostics:", + app.getDiagnosticsInfo() == null ? "" : app.getDiagnosticsInfo()); html._(InfoBlock.class); Collection attempts; try { - attempts = appContext.getApplicationAttempts(appID).values(); - } catch (IOException e) { + final GetApplicationAttemptsRequest request = + GetApplicationAttemptsRequest.newInstance(appID); + if (callerUGI == null) { + attempts = appBaseProt.getApplicationAttempts(request) + .getApplicationAttemptList(); + } else { + try { + attempts = callerUGI.doAs( + new PrivilegedExceptionAction>() { + @Override + public List run() throws Exception { + return appBaseProt.getApplicationAttempts(request) + .getApplicationAttemptList(); + } + }); + } catch (UndeclaredThrowableException e) { + throw e.getCause(); + } + } + } catch (Throwable e) { String message = "Failed to read the attempts of the application " + appID + "."; LOG.error(message, e); @@ -124,12 +184,33 @@ protected void render(Block html) { StringBuilder attemptsTableData = new StringBuilder("[\n"); for (ApplicationAttemptReport appAttemptReport : attempts) { AppAttemptInfo appAttempt = new AppAttemptInfo(appAttemptReport); - ContainerReport containerReport; + ContainerReport containerReport = null; try { - containerReport = - appContext.getAMContainer(appAttemptReport - .getApplicationAttemptId()); - } catch (IOException e) { + // AM container is always the first container of the attempt + final GetContainerReportRequest request = + GetContainerReportRequest.newInstance( + ContainerId.newInstance( + appAttemptReport.getApplicationAttemptId(), 1)); + if (callerUGI == null) { + containerReport = + appBaseProt.getContainerReport(request).getContainerReport(); + } else { + try { + containerReport = + callerUGI.doAs(new PrivilegedExceptionAction() { + @Override + public ContainerReport run() throws Exception { + return appBaseProt.getContainerReport(request) + .getContainerReport(); + } + }); + } catch (UndeclaredThrowableException e) { + throw e.getCause(); + } + } + } catch (ContainerNotFoundException e) { + // No problem, just move on + } catch (Throwable e) { String message = "Failed to read the AM container of the application attempt " + appAttemptReport.getApplicationAttemptId() + "."; @@ -137,7 +218,7 @@ protected void render(Block html) { html.p()._(message)._(); return; } - long startTime = Long.MAX_VALUE; + long startTime = 0L; String logsLink = null; if (containerReport != null) { ContainerInfo container = new ContainerInfo(containerReport); @@ -159,11 +240,9 @@ protected void render(Block html) { .append("\",\"") .append(startTime) .append("\",\"") - .append( - nodeLink == null ? "N/A" : StringEscapeUtils + .append(nodeLink == null ? "N/A" : StringEscapeUtils .escapeJavaScript(StringEscapeUtils.escapeHtml(nodeLink))) .append("\",\"") @@ -179,4 +258,5 @@ protected void render(Block html) { tbody._()._(); } + } diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/webapp/AppsBlock.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/webapp/AppsBlock.java index d4a77a8..e9380ff 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/webapp/AppsBlock.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/webapp/AppsBlock.java @@ -23,57 +23,93 @@ import static org.apache.hadoop.yarn.webapp.view.JQueryUI.C_PROGRESSBAR; import static org.apache.hadoop.yarn.webapp.view.JQueryUI.C_PROGRESSBAR_VALUE; -import java.io.IOException; +import java.lang.reflect.UndeclaredThrowableException; +import java.security.PrivilegedExceptionAction; import java.util.Collection; -import java.util.HashSet; +import java.util.EnumSet; +import java.util.List; import org.apache.commons.lang.StringEscapeUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.hadoop.security.UserGroupInformation; +import org.apache.hadoop.yarn.api.ApplicationBaseProtocol; +import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationsRequest; +import org.apache.hadoop.yarn.api.records.ApplicationAttemptId; import org.apache.hadoop.yarn.api.records.ApplicationReport; import org.apache.hadoop.yarn.api.records.YarnApplicationState; -import org.apache.hadoop.yarn.server.api.ApplicationContext; import org.apache.hadoop.yarn.server.webapp.dao.AppInfo; +import org.apache.hadoop.yarn.util.ConverterUtils; import org.apache.hadoop.yarn.webapp.hamlet.Hamlet; import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TABLE; import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TBODY; +import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.THEAD; +import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TR; import org.apache.hadoop.yarn.webapp.view.HtmlBlock; import com.google.inject.Inject; public class AppsBlock extends HtmlBlock { - protected ApplicationContext appContext; + private static final Log LOG = LogFactory.getLog(AppsBlock.class); + protected ApplicationBaseProtocol appBaseProt; + protected boolean isFairSchedulerPage = false; @Inject - AppsBlock(ApplicationContext appContext, ViewContext ctx) { + public AppsBlock( + ApplicationBaseProtocol appBaseProt, ViewContext ctx) { super(ctx); - this.appContext = appContext; + this.appBaseProt = appBaseProt; } @Override public void render(Block html) { setTitle("Applications"); - TBODY> tbody = - html.table("#apps").thead().tr().th(".id", "ID").th(".user", "User") - .th(".name", "Name").th(".type", "Application Type") - .th(".queue", "Queue").th(".starttime", "StartTime") - .th(".finishtime", "FinishTime").th(".state", "State") - .th(".finalstatus", "FinalStatus").th(".progress", "Progress") - .th(".ui", "Tracking UI")._()._().tbody(); - Collection reqAppStates = null; + + TR>> tr = html.table("#apps").thead().tr() + .th(".id", "ID").th(".user", "User").th(".name", "Name") + .th(".type", "Application Type").th(".queue", "Queue"); + if (isFairSchedulerPage) { + tr = tr.th(".fairshare", "Fair Share"); + } + TBODY> tbody = tr.th(".starttime", "StartTime") + .th(".finishtime", "FinishTime").th(".state", "State") + .th(".finalstatus", "FinalStatus").th(".progress", "Progress") + .th(".ui", "Tracking UI")._()._().tbody(); + EnumSet reqAppStates = + EnumSet.noneOf(YarnApplicationState.class); String reqStateString = $(APP_STATE); if (reqStateString != null && !reqStateString.isEmpty()) { String[] appStateStrings = reqStateString.split(","); - reqAppStates = new HashSet(appStateStrings.length); for (String stateString : appStateStrings) { - reqAppStates.add(YarnApplicationState.valueOf(stateString)); + reqAppStates.add(YarnApplicationState.valueOf(stateString.trim())); } } - Collection appReports; + UserGroupInformation callerUGI = getCallerUGI(); + + Collection appReports = null; try { - appReports = appContext.getAllApplications().values(); - } catch (IOException e) { + final GetApplicationsRequest request = + GetApplicationsRequest.newInstance(reqAppStates); + if (callerUGI == null) { + appReports = appBaseProt.getApplications(request).getApplicationList(); + } else { + try { + appReports = callerUGI.doAs( + new PrivilegedExceptionAction>() { + @Override + public List run() throws Exception { + return appBaseProt.getApplications(request) + .getApplicationList(); + } + }); + } catch (UndeclaredThrowableException e) { + throw e.getCause(); + } + } + } catch (Throwable e) { String message = "Failed to read the applications."; LOG.error(message, e); html.p()._(message)._(); @@ -81,8 +117,11 @@ public void render(Block html) { } StringBuilder appsTableData = new StringBuilder("[\n"); for (ApplicationReport appReport : appReports) { - if (reqAppStates != null - && !reqAppStates.contains(appReport.getYarnApplicationState())) { + // TODO: remove the following condition. It is still here because + // the history side implementation of ApplicationBaseProtocol + // hasn't filtering capability (YARN-1819). + if (!reqAppStates.isEmpty() && + !reqAppStates.contains(appReport.getYarnApplicationState())) { continue; } AppInfo app = new AppInfo(appReport); @@ -108,7 +147,14 @@ public void render(Block html) { .append("\",\"") .append( StringEscapeUtils.escapeJavaScript(StringEscapeUtils.escapeHtml(app - .getQueue()))).append("\",\"").append(app.getStartedTime()) + .getQueue()))); + if (isFairSchedulerPage) { + appsTableData.append("\",\"").append( + getFairShare(ConverterUtils.toApplicationAttemptId( + app.getCurrentAppAttemptId()))); + } + appsTableData + .append("\",\"").append(app.getStartedTime()) .append("\",\"").append(app.getFinishedTime()) .append("\",\"") .append(app.getAppState()) @@ -124,8 +170,13 @@ public void render(Block html) { String trackingURL = app.getTrackingUrl() == null ? "#" : app.getTrackingUrl(); - - appsTableData.append(trackingURL).append("'>").append("History") + String trackingUI = + app.getTrackingUrl() == null ? "Unassigned" : + app.getAppState() == YarnApplicationState.FINISHED || + app.getAppState() == YarnApplicationState.FAILED || + app.getAppState() == YarnApplicationState.KILLED ? + "History" : "ApplicationMaster"; + appsTableData.append(trackingURL).append("'>").append(trackingUI) .append("\"],\n"); } @@ -139,4 +190,10 @@ public void render(Block html) { tbody._()._(); } + + protected int getFairShare(ApplicationAttemptId attemptId) { + // Let FairSchedulerAppsBlock override + throw new UnsupportedOperationException( + "Fair share metrics is only for FairScheduler's apps page"); + } } diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/webapp/ContainerBlock.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/webapp/ContainerBlock.java index bda80da..318b4b8 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/webapp/ContainerBlock.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/webapp/ContainerBlock.java @@ -20,14 +20,20 @@ import static org.apache.hadoop.yarn.util.StringHelper.join; import static org.apache.hadoop.yarn.webapp.YarnWebParams.CONTAINER_ID; -import java.io.IOException; +import java.lang.reflect.UndeclaredThrowableException; +import java.security.PrivilegedExceptionAction; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.hadoop.security.UserGroupInformation; import org.apache.hadoop.util.StringUtils; +import org.apache.hadoop.yarn.api.ApplicationBaseProtocol; +import org.apache.hadoop.yarn.api.protocolrecords.GetContainerReportRequest; import org.apache.hadoop.yarn.api.records.ContainerId; import org.apache.hadoop.yarn.api.records.ContainerReport; -import org.apache.hadoop.yarn.server.api.ApplicationContext; +import org.apache.hadoop.yarn.exceptions.ApplicationAttemptNotFoundException; +import org.apache.hadoop.yarn.exceptions.ApplicationNotFoundException; +import org.apache.hadoop.yarn.exceptions.ContainerNotFoundException; import org.apache.hadoop.yarn.server.webapp.dao.ContainerInfo; import org.apache.hadoop.yarn.util.ConverterUtils; import org.apache.hadoop.yarn.util.Times; @@ -39,12 +45,13 @@ public class ContainerBlock extends HtmlBlock { private static final Log LOG = LogFactory.getLog(ContainerBlock.class); - private final ApplicationContext appContext; + protected ApplicationBaseProtocol appBaseProt; @Inject - public ContainerBlock(ApplicationContext appContext, ViewContext ctx) { + public ContainerBlock( + ApplicationBaseProtocol appBaseProt, ViewContext ctx) { super(ctx); - this.appContext = appContext; + this.appBaseProt = appBaseProt; } @Override @@ -63,25 +70,50 @@ protected void render(Block html) { return; } - ContainerReport containerReport; + UserGroupInformation callerUGI = getCallerUGI(); + + ContainerReport containerReport = null; try { - containerReport = appContext.getContainer(containerId); - } catch (IOException e) { + final GetContainerReportRequest request = + GetContainerReportRequest.newInstance(containerId); + if (callerUGI == null) { + containerReport = appBaseProt.getContainerReport(request) + .getContainerReport(); + } else { + try { + containerReport = callerUGI.doAs( + new PrivilegedExceptionAction() { + @Override + public ContainerReport run() throws Exception { + return appBaseProt.getContainerReport(request) + .getContainerReport(); + } + }); + } catch (UndeclaredThrowableException e) { + throw e.getCause(); + } + } + } catch(ApplicationNotFoundException e) { + puts("Container not found: " + containerid); + return; + } catch(ApplicationAttemptNotFoundException e) { + puts("Container not found: " + containerid); + return; + } catch(ContainerNotFoundException e) { + puts("Container not found: " + containerid); + return; + } catch (Throwable e) { String message = "Failed to read the container " + containerid + "."; LOG.error(message, e); html.p()._(message)._(); return; } - if (containerReport == null) { - puts("Container not found: " + containerid); - return; - } ContainerInfo container = new ContainerInfo(containerReport); setTitle(join("Container ", containerid)); info("Container Overview") - ._("State:", container.getContainerState()) + ._("Container State:", container.getContainerState()) ._("Exit Status:", container.getContainerExitStatus()) ._("Node:", container.getAssignedNodeId()) ._("Priority:", container.getPriority()) @@ -96,7 +128,8 @@ protected void render(Block html) { + container.getAllocatedVCores() + " VCores") ._("Logs:", container.getLogUrl() == null ? "#" : container.getLogUrl(), container.getLogUrl() == null ? "N/A" : "Logs") - ._("Diagnostics:", container.getDiagnosticsInfo()); + ._("Diagnostics:", container.getDiagnosticsInfo() == null ? + "" : container.getDiagnosticsInfo()); html._(InfoBlock.class); } diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/webapp/WebPageUtils.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/webapp/WebPageUtils.java new file mode 100644 index 0000000..e68a782 --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/webapp/WebPageUtils.java @@ -0,0 +1,86 @@ +/** + * 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.webapp; + +import static org.apache.hadoop.yarn.webapp.view.JQueryUI.tableInit; + + +public class WebPageUtils { + + public static String appsTableInit() { + return appsTableInit(false); + } + + public static String appsTableInit(boolean isFairSchedulerPage) { + // id, user, name, queue, starttime, finishtime, state, status, progress, ui + // FairSchedulerPage's table is a bit different + return tableInit() + .append(", 'aaData': appsTableData") + .append(", bDeferRender: true") + .append(", bProcessing: true") + .append("\n, aoColumnDefs: ") + .append(getAppsTableColumnDefs(isFairSchedulerPage)) + // Sort by id upon page load + .append(", aaSorting: [[0, 'desc']]}").toString(); + } + + private static String getAppsTableColumnDefs(boolean isFairSchedulerPage) { + StringBuilder sb = new StringBuilder(); + return sb + .append("[\n") + .append("{'sType':'numeric', 'aTargets': [0]") + .append(", 'mRender': parseHadoopID }") + .append("\n, {'sType':'numeric', 'aTargets': " + + (isFairSchedulerPage ? "[6, 7]": "[5, 6]")) + .append(", 'mRender': renderHadoopDate }") + .append("\n, {'sType':'numeric', bSearchable:false, 'aTargets': [9]") + .append(", 'mRender': parseHadoopProgress }]").toString(); + } + + public static String attemptsTableInit() { + return tableInit().append(", 'aaData': attemptsTableData") + .append(", bDeferRender: true").append(", bProcessing: true") + .append("\n, aoColumnDefs: ").append(getAttemptsTableColumnDefs()) + // Sort by id upon page load + .append(", aaSorting: [[0, 'desc']]}").toString(); + } + + private static String getAttemptsTableColumnDefs() { + StringBuilder sb = new StringBuilder(); + return sb.append("[\n").append("{'sType':'numeric', 'aTargets': [0]") + .append(", 'mRender': parseHadoopID }") + .append("\n, {'sType':'numeric', 'aTargets': [1]") + .append(", 'mRender': renderHadoopDate }]").toString(); + } + + public static String containersTableInit() { + return tableInit().append(", 'aaData': containersTableData") + .append(", bDeferRender: true").append(", bProcessing: true") + .append("\n, aoColumnDefs: ").append(getContainersTableColumnDefs()) + // Sort by id upon page load + .append(", aaSorting: [[0, 'desc']]}").toString(); + } + + private static String getContainersTableColumnDefs() { + StringBuilder sb = new StringBuilder(); + return sb.append("[\n").append("{'sType':'numeric', 'aTargets': [0]") + .append(", 'mRender': parseHadoopID }]").toString(); + } + +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/webapp/WebServices.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/webapp/WebServices.java index 5a82551..7504f35 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/webapp/WebServices.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/webapp/WebServices.java @@ -18,7 +18,6 @@ package org.apache.hadoop.yarn.server.webapp; -import java.io.IOException; import java.util.Arrays; import java.util.Collection; import java.util.HashSet; @@ -28,6 +27,13 @@ import javax.servlet.http.HttpServletResponse; import javax.ws.rs.WebApplicationException; +import org.apache.hadoop.yarn.api.ApplicationBaseProtocol; +import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationAttemptReportRequest; +import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationAttemptsRequest; +import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationReportRequest; +import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationsRequest; +import org.apache.hadoop.yarn.api.protocolrecords.GetContainerReportRequest; +import org.apache.hadoop.yarn.api.protocolrecords.GetContainersRequest; import org.apache.hadoop.yarn.api.records.ApplicationAttemptId; import org.apache.hadoop.yarn.api.records.ApplicationAttemptReport; import org.apache.hadoop.yarn.api.records.ApplicationId; @@ -36,7 +42,9 @@ import org.apache.hadoop.yarn.api.records.ContainerReport; import org.apache.hadoop.yarn.api.records.FinalApplicationStatus; import org.apache.hadoop.yarn.api.records.YarnApplicationState; -import org.apache.hadoop.yarn.server.api.ApplicationContext; +import org.apache.hadoop.yarn.exceptions.ApplicationAttemptNotFoundException; +import org.apache.hadoop.yarn.exceptions.ApplicationNotFoundException; +import org.apache.hadoop.yarn.exceptions.ContainerNotFoundException; import org.apache.hadoop.yarn.server.webapp.dao.AppAttemptInfo; import org.apache.hadoop.yarn.server.webapp.dao.AppAttemptsInfo; import org.apache.hadoop.yarn.server.webapp.dao.AppInfo; @@ -49,10 +57,10 @@ public class WebServices { - protected ApplicationContext appContext; + protected ApplicationBaseProtocol appBaseProt; - public WebServices(ApplicationContext appContext) { - this.appContext = appContext; + public WebServices(ApplicationBaseProtocol appBaseProt) { + this.appBaseProt = appBaseProt; } public AppsInfo getApps(HttpServletRequest req, HttpServletResponse res, @@ -137,8 +145,11 @@ public AppsInfo getApps(HttpServletRequest req, HttpServletResponse res, AppsInfo allApps = new AppsInfo(); Collection appReports = null; try { - appReports = appContext.getAllApplications().values(); - } catch (IOException e) { + // TODO: the request should take the params like what RMWebServices does + // in YARN-1819. + GetApplicationsRequest request = GetApplicationsRequest.newInstance(); + appReports = appBaseProt.getApplications(request).getApplicationList(); + } catch (Exception e) { throw new WebApplicationException(e); } for (ApplicationReport appReport : appReports) { @@ -196,12 +207,13 @@ public AppInfo getApp(HttpServletRequest req, HttpServletResponse res, ApplicationId id = parseApplicationId(appId); ApplicationReport app = null; try { - app = appContext.getApplication(id); - } catch (IOException e) { - throw new WebApplicationException(e); - } - if (app == null) { + GetApplicationReportRequest request = + GetApplicationReportRequest.newInstance(id); + app = appBaseProt.getApplicationReport(request).getApplicationReport(); + } catch(ApplicationNotFoundException e) { throw new NotFoundException("app with id: " + appId + " not found"); + } catch (Exception e) { + throw new WebApplicationException(e); } return new AppInfo(app); } @@ -211,8 +223,11 @@ public AppAttemptsInfo getAppAttempts(HttpServletRequest req, ApplicationId id = parseApplicationId(appId); Collection appAttemptReports = null; try { - appAttemptReports = appContext.getApplicationAttempts(id).values(); - } catch (IOException e) { + GetApplicationAttemptsRequest request = + GetApplicationAttemptsRequest.newInstance(id); + appAttemptReports = appBaseProt.getApplicationAttempts(request) + .getApplicationAttemptList(); + } catch (Exception e) { throw new WebApplicationException(e); } AppAttemptsInfo appAttemptsInfo = new AppAttemptsInfo(); @@ -220,7 +235,6 @@ public AppAttemptsInfo getAppAttempts(HttpServletRequest req, AppAttemptInfo appAttemptInfo = new AppAttemptInfo(appAttemptReport); appAttemptsInfo.add(appAttemptInfo); } - return appAttemptsInfo; } @@ -231,13 +245,15 @@ public AppAttemptInfo getAppAttempt(HttpServletRequest req, validateIds(aid, aaid, null); ApplicationAttemptReport appAttempt = null; try { - appAttempt = appContext.getApplicationAttempt(aaid); - } catch (IOException e) { - throw new WebApplicationException(e); - } - if (appAttempt == null) { + GetApplicationAttemptReportRequest request = + GetApplicationAttemptReportRequest.newInstance(aaid); + appAttempt = appBaseProt.getApplicationAttemptReport(request) + .getApplicationAttemptReport(); + } catch (ApplicationAttemptNotFoundException e) { throw new NotFoundException("app attempt with id: " + appAttemptId + " not found"); + } catch (Exception e) { + throw new WebApplicationException(e); } return new AppAttemptInfo(appAttempt); } @@ -249,8 +265,9 @@ public ContainersInfo getContainers(HttpServletRequest req, validateIds(aid, aaid, null); Collection containerReports = null; try { - containerReports = appContext.getContainers(aaid).values(); - } catch (IOException e) { + GetContainersRequest request = GetContainersRequest.newInstance(aaid); + containerReports = appBaseProt.getContainers(request).getContainerList(); + } catch (Exception e) { throw new WebApplicationException(e); } ContainersInfo containersInfo = new ContainersInfo(); @@ -270,13 +287,14 @@ public ContainerInfo getContainer(HttpServletRequest req, validateIds(aid, aaid, cid); ContainerReport container = null; try { - container = appContext.getContainer(cid); - } catch (IOException e) { - throw new WebApplicationException(e); - } - if (container == null) { + GetContainerReportRequest request = + GetContainerReportRequest.newInstance(cid); + container = appBaseProt.getContainerReport(request).getContainerReport(); + } catch(ContainerNotFoundException e) { throw new NotFoundException("container with id: " + containerId + " not found"); + } catch (Exception e) { + throw new WebApplicationException(e); } return new ContainerInfo(container); } diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/webapp/dao/AppInfo.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/webapp/dao/AppInfo.java index aedf0d3..287a3d5 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/webapp/dao/AppInfo.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/webapp/dao/AppInfo.java @@ -18,6 +18,8 @@ package org.apache.hadoop.yarn.server.webapp.dao; +import static org.apache.hadoop.yarn.util.StringHelper.CSV_JOINER; + import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlRootElement; @@ -52,6 +54,7 @@ protected long elapsedTime; protected int allocatedMB; protected int allocatedVCores; + protected String applicationTags; public AppInfo() { // JAXB needs this @@ -83,7 +86,10 @@ public AppInfo(ApplicationReport app) { allocatedMB = usage.getUsedResources().getMemory(); allocatedVCores = usage.getUsedResources().getVirtualCores(); } - progress = app.getProgress(); + progress = app.getProgress() * 100; // in percent + if (app.getApplicationTags() != null && !app.getApplicationTags().isEmpty()) { + this.applicationTags = CSV_JOINER.join(app.getApplicationTags()); + } } public String getAppId() { @@ -166,4 +172,8 @@ public int getAllocatedVCores() { return allocatedVCores; } + public String getApplicationTags() { + return applicationTags; + } + } diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/AppAttemptPage.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/AppAttemptPage.java new file mode 100644 index 0000000..44f94a3 --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/AppAttemptPage.java @@ -0,0 +1,55 @@ +/** + * 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.resourcemanager.webapp; + +import static org.apache.hadoop.yarn.util.StringHelper.join; +import static org.apache.hadoop.yarn.webapp.view.JQueryUI.DATATABLES; +import static org.apache.hadoop.yarn.webapp.view.JQueryUI.DATATABLES_ID; +import static org.apache.hadoop.yarn.webapp.view.JQueryUI.initID; + +import org.apache.hadoop.yarn.server.webapp.AppAttemptBlock; +import org.apache.hadoop.yarn.server.webapp.WebPageUtils; +import org.apache.hadoop.yarn.webapp.SubView; +import org.apache.hadoop.yarn.webapp.YarnWebParams; + + +public class AppAttemptPage extends RmView { + + @Override + protected void preHead(Page.HTML<_> html) { + commonPreHead(html); + + String appAttemptId = $(YarnWebParams.APPLICATION_ATTEMPT_ID); + set( + TITLE, + appAttemptId.isEmpty() ? "Bad request: missing application attempt ID" + : join("Application Attempt ", + $(YarnWebParams.APPLICATION_ATTEMPT_ID))); + + set(DATATABLES_ID, "containers"); + set(initID(DATATABLES, "containers"), WebPageUtils.containersTableInit()); + setTableStyles(html, "containers", ".queue {width:6em}", ".ui {width:8em}"); + } + + @Override + protected Class content() { + return AppAttemptBlock.class; + } + +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/AppBlock.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/AppBlock.java deleted file mode 100644 index ac8578e..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/AppBlock.java +++ /dev/null @@ -1,163 +0,0 @@ -/** -* 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.resourcemanager.webapp; - -import static org.apache.hadoop.yarn.util.StringHelper.join; -import static org.apache.hadoop.yarn.webapp.YarnWebParams.APPLICATION_ID; -import static org.apache.hadoop.yarn.webapp.view.JQueryUI._EVEN; -import static org.apache.hadoop.yarn.webapp.view.JQueryUI._INFO_WRAP; -import static org.apache.hadoop.yarn.webapp.view.JQueryUI._ODD; -import static org.apache.hadoop.yarn.webapp.view.JQueryUI._TH; - -import java.util.Collection; - -import org.apache.hadoop.conf.Configuration; -import org.apache.hadoop.security.UserGroupInformation; -import org.apache.hadoop.util.StringUtils; -import org.apache.hadoop.yarn.api.records.ApplicationAccessType; -import org.apache.hadoop.yarn.api.records.ApplicationId; -import org.apache.hadoop.yarn.api.records.QueueACL; -import org.apache.hadoop.yarn.server.resourcemanager.RMContext; -import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager; -import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp; -import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttempt; -import org.apache.hadoop.yarn.server.resourcemanager.security.QueueACLsManager; -import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.AppAttemptInfo; -import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.AppInfo; -import org.apache.hadoop.yarn.server.security.ApplicationACLsManager; -import org.apache.hadoop.yarn.util.Apps; -import org.apache.hadoop.yarn.util.Times; -import org.apache.hadoop.yarn.webapp.hamlet.Hamlet; -import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.DIV; -import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TABLE; -import org.apache.hadoop.yarn.webapp.util.WebAppUtils; -import org.apache.hadoop.yarn.webapp.view.HtmlBlock; -import org.apache.hadoop.yarn.webapp.view.InfoBlock; - -import com.google.inject.Inject; - -public class AppBlock extends HtmlBlock { - - private ApplicationACLsManager aclsManager; - private QueueACLsManager queueACLsManager; - private final Configuration conf; - - @Inject - AppBlock(ResourceManager rm, ViewContext ctx, - ApplicationACLsManager aclsManager, QueueACLsManager queueACLsManager, - Configuration conf) { - super(ctx); - this.aclsManager = aclsManager; - this.queueACLsManager = queueACLsManager; - this.conf = conf; - } - - @Override - protected void render(Block html) { - String aid = $(APPLICATION_ID); - if (aid.isEmpty()) { - puts("Bad request: requires application ID"); - return; - } - - ApplicationId appID = null; - try { - appID = Apps.toAppID(aid); - } catch (Exception e) { - puts("Invalid Application ID: " + aid); - return; - } - - RMContext context = getInstance(RMContext.class); - RMApp rmApp = context.getRMApps().get(appID); - if (rmApp == null) { - puts("Application not found: "+ aid); - return; - } - AppInfo app = new AppInfo(rmApp, true, WebAppUtils.getHttpSchemePrefix(conf)); - - // Check for the authorization. - String remoteUser = request().getRemoteUser(); - UserGroupInformation callerUGI = null; - if (remoteUser != null) { - callerUGI = UserGroupInformation.createRemoteUser(remoteUser); - } - if (callerUGI != null - && !(this.aclsManager.checkAccess(callerUGI, - ApplicationAccessType.VIEW_APP, app.getUser(), appID) || - this.queueACLsManager.checkAccess(callerUGI, - QueueACL.ADMINISTER_QUEUE, app.getQueue()))) { - puts("You (User " + remoteUser - + ") are not authorized to view application " + appID); - return; - } - - setTitle(join("Application ", aid)); - - info("Application Overview"). - _("User:", app.getUser()). - _("Name:", app.getName()). - _("Application Type:", app.getApplicationType()). - _("Application Tags:", app.getApplicationTags()). - _("State:", app.getState()). - _("FinalStatus:", app.getFinalStatus()). - _("Started:", Times.format(app.getStartTime())). - _("Elapsed:", StringUtils.formatTime( - Times.elapsed(app.getStartTime(), app.getFinishTime()))). - _("Tracking URL:", !app.isTrackingUrlReady() ? - "#" : app.getTrackingUrlPretty(), app.getTrackingUI()). - _("Diagnostics:", app.getNote()); - - Collection attempts = rmApp.getAppAttempts().values(); - String amString = - attempts.size() == 1 ? "ApplicationMaster" : "ApplicationMasters"; - - DIV div = html. - _(InfoBlock.class). - div(_INFO_WRAP); - // MRAppMasters Table - TABLE> table = div.table("#app"); - table. - tr(). - th(amString). - _(). - tr(). - th(_TH, "Attempt Number"). - th(_TH, "Start Time"). - th(_TH, "Node"). - th(_TH, "Logs"). - _(); - - boolean odd = false; - for (RMAppAttempt attempt : attempts) { - AppAttemptInfo attemptInfo = new AppAttemptInfo(attempt, app.getUser()); - table.tr((odd = !odd) ? _ODD : _EVEN). - td(String.valueOf(attemptInfo.getAttemptId())). - td(Times.format(attemptInfo.getStartTime())). - td().a(".nodelink", url("//", - attemptInfo.getNodeHttpAddress()), - attemptInfo.getNodeHttpAddress())._(). - td().a(".logslink", url(attemptInfo.getLogsLink()), "logs")._(). - _(); - } - - table._(); - div._(); - } -} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/AppPage.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/AppPage.java index a55c62f..ad870b2 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/AppPage.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/AppPage.java @@ -18,15 +18,36 @@ package org.apache.hadoop.yarn.server.resourcemanager.webapp; +import static org.apache.hadoop.yarn.util.StringHelper.join; +import static org.apache.hadoop.yarn.webapp.view.JQueryUI.DATATABLES; +import static org.apache.hadoop.yarn.webapp.view.JQueryUI.DATATABLES_ID; +import static org.apache.hadoop.yarn.webapp.view.JQueryUI.initID; + +import org.apache.hadoop.yarn.server.webapp.AppBlock; +import org.apache.hadoop.yarn.server.webapp.WebPageUtils; import org.apache.hadoop.yarn.webapp.SubView; +import org.apache.hadoop.yarn.webapp.YarnWebParams; public class AppPage extends RmView { - @Override protected void preHead(Page.HTML<_> html) { + @Override + protected void preHead(Page.HTML<_> html) { commonPreHead(html); + + String appId = $(YarnWebParams.APPLICATION_ID); + set( + TITLE, + appId.isEmpty() ? "Bad request: missing application ID" : join( + "Application ", $(YarnWebParams.APPLICATION_ID))); + + set(DATATABLES_ID, "attempts"); + set(initID(DATATABLES, "attempts"), WebPageUtils.attemptsTableInit()); + setTableStyles(html, "attempts", ".queue {width:6em}", ".ui {width:8em}"); } - @Override protected Class content() { + @Override + protected Class content() { return AppBlock.class; } + } diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/AppsBlock.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/AppsBlock.java deleted file mode 100644 index 4f644d1..0000000 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/AppsBlock.java +++ /dev/null @@ -1,128 +0,0 @@ -/** -* 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.resourcemanager.webapp; - -import static org.apache.hadoop.yarn.util.StringHelper.join; -import static org.apache.hadoop.yarn.webapp.YarnWebParams.APP_STATE; -import static org.apache.hadoop.yarn.webapp.view.JQueryUI.C_PROGRESSBAR; -import static org.apache.hadoop.yarn.webapp.view.JQueryUI.C_PROGRESSBAR_VALUE; - -import java.util.Collection; -import java.util.HashSet; -import java.util.concurrent.ConcurrentMap; - -import org.apache.commons.lang.StringEscapeUtils; -import org.apache.hadoop.conf.Configuration; -import org.apache.hadoop.yarn.api.records.ApplicationId; -import org.apache.hadoop.yarn.api.records.YarnApplicationState; -import org.apache.hadoop.yarn.server.resourcemanager.RMContext; -import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp; -import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.AppInfo; -import org.apache.hadoop.yarn.webapp.hamlet.Hamlet; -import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TABLE; -import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TBODY; -import org.apache.hadoop.yarn.webapp.util.WebAppUtils; -import org.apache.hadoop.yarn.webapp.view.HtmlBlock; - -import com.google.inject.Inject; - -class AppsBlock extends HtmlBlock { - final ConcurrentMap apps; - private final Configuration conf; - -@Inject AppsBlock(RMContext rmContext, ViewContext ctx, Configuration conf) { - super(ctx); - apps = rmContext.getRMApps(); - this.conf = conf; - } - - @Override public void render(Block html) { - TBODY> tbody = html. - table("#apps"). - thead(). - tr(). - th(".id", "ID"). - th(".user", "User"). - th(".name", "Name"). - th(".type", "Application Type"). - th(".queue", "Queue"). - th(".starttime", "StartTime"). - th(".finishtime", "FinishTime"). - th(".state", "State"). - th(".finalstatus", "FinalStatus"). - th(".progress", "Progress"). - th(".ui", "Tracking UI")._()._(). - tbody(); - Collection reqAppStates = null; - String reqStateString = $(APP_STATE); - if (reqStateString != null && !reqStateString.isEmpty()) { - String[] appStateStrings = reqStateString.split(","); - reqAppStates = new HashSet(appStateStrings.length); - for(String stateString : appStateStrings) { - reqAppStates.add(YarnApplicationState.valueOf(stateString)); - } - } - StringBuilder appsTableData = new StringBuilder("[\n"); - for (RMApp app : apps.values()) { - if (reqAppStates != null && !reqAppStates.contains(app.createApplicationState())) { - continue; - } - AppInfo appInfo = new AppInfo(app, true, WebAppUtils.getHttpSchemePrefix(conf)); - String percent = String.format("%.1f", appInfo.getProgress()); - //AppID numerical value parsed by parseHadoopID in yarn.dt.plugins.js - appsTableData.append("[\"") - .append(appInfo.getAppId()).append("\",\"") - .append(StringEscapeUtils.escapeJavaScript(StringEscapeUtils.escapeHtml( - appInfo.getUser()))).append("\",\"") - .append(StringEscapeUtils.escapeJavaScript(StringEscapeUtils.escapeHtml( - appInfo.getName()))).append("\",\"") - .append(StringEscapeUtils.escapeJavaScript(StringEscapeUtils.escapeHtml( - appInfo.getApplicationType()))).append("\",\"") - .append(StringEscapeUtils.escapeJavaScript(StringEscapeUtils.escapeHtml( - appInfo.getQueue()))).append("\",\"") - .append(appInfo.getStartTime()).append("\",\"") - .append(appInfo.getFinishTime()).append("\",\"") - .append(appInfo.getState()).append("\",\"") - .append(appInfo.getFinalStatus()).append("\",\"") - // Progress bar - .append("
").append("
") - .append("\",\"") - .append(appInfo.getTrackingUI()).append("\"],\n"); - - } - if(appsTableData.charAt(appsTableData.length() - 2) == ',') { - appsTableData.delete(appsTableData.length()-2, appsTableData.length()-1); - } - appsTableData.append("]"); - html.script().$type("text/javascript"). - _("var appsTableData=" + appsTableData)._(); - - tbody._()._(); - } -} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/AppsBlockWithMetrics.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/AppsBlockWithMetrics.java index 6d461f6..cb0836a 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/AppsBlockWithMetrics.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/AppsBlockWithMetrics.java @@ -18,6 +18,7 @@ package org.apache.hadoop.yarn.server.resourcemanager.webapp; +import org.apache.hadoop.yarn.server.webapp.AppsBlock; import org.apache.hadoop.yarn.webapp.view.HtmlBlock; /** diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/CapacitySchedulerPage.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/CapacitySchedulerPage.java index a4600d8..867e622 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/CapacitySchedulerPage.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/CapacitySchedulerPage.java @@ -22,8 +22,8 @@ import java.util.ArrayList; -import org.apache.hadoop.util.StringUtils; import org.apache.commons.lang.StringEscapeUtils; +import org.apache.hadoop.util.StringUtils; import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager; import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CSQueue; import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacityScheduler; @@ -32,6 +32,7 @@ import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.CapacitySchedulerLeafQueueInfo; import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.CapacitySchedulerQueueInfo; import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.ResourceInfo; +import org.apache.hadoop.yarn.server.webapp.AppsBlock; import org.apache.hadoop.yarn.webapp.ResponseInfo; import org.apache.hadoop.yarn.webapp.SubView; import org.apache.hadoop.yarn.webapp.hamlet.Hamlet; diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/ContainerPage.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/ContainerPage.java new file mode 100644 index 0000000..cff189e --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/ContainerPage.java @@ -0,0 +1,44 @@ +/** + * 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.resourcemanager.webapp; + +import static org.apache.hadoop.yarn.util.StringHelper.join; + +import org.apache.hadoop.yarn.server.webapp.ContainerBlock; +import org.apache.hadoop.yarn.webapp.SubView; +import org.apache.hadoop.yarn.webapp.YarnWebParams; + + +public class ContainerPage extends RmView { + + @Override + protected void preHead(Page.HTML<_> html) { + commonPreHead(html); + + String containerId = $(YarnWebParams.CONTAINER_ID); + set(TITLE, containerId.isEmpty() ? "Bad request: missing container ID" + : join("Container ", $(YarnWebParams.CONTAINER_ID))); + } + + @Override + protected Class content() { + return ContainerBlock.class; + } + +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/DefaultSchedulerPage.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/DefaultSchedulerPage.java index 1bbb993..78913b7 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/DefaultSchedulerPage.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/DefaultSchedulerPage.java @@ -24,6 +24,7 @@ import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager; import org.apache.hadoop.yarn.server.resourcemanager.scheduler.fifo.FifoScheduler; import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.FifoSchedulerInfo; +import org.apache.hadoop.yarn.server.webapp.AppsBlock; import org.apache.hadoop.yarn.webapp.SubView; import org.apache.hadoop.yarn.webapp.hamlet.Hamlet; import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.DIV; diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/FairSchedulerAppsBlock.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/FairSchedulerAppsBlock.java index c36e311..2319ef0 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/FairSchedulerAppsBlock.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/FairSchedulerAppsBlock.java @@ -18,31 +18,12 @@ package org.apache.hadoop.yarn.server.resourcemanager.webapp; -import static org.apache.hadoop.yarn.util.StringHelper.join; -import static org.apache.hadoop.yarn.webapp.YarnWebParams.APP_STATE; -import static org.apache.hadoop.yarn.webapp.view.JQueryUI.C_PROGRESSBAR; -import static org.apache.hadoop.yarn.webapp.view.JQueryUI.C_PROGRESSBAR_VALUE; - -import java.util.Collection; -import java.util.HashSet; -import java.util.concurrent.ConcurrentMap; - -import org.apache.commons.lang.StringEscapeUtils; -import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.yarn.api.ApplicationBaseProtocol; import org.apache.hadoop.yarn.api.records.ApplicationAttemptId; -import org.apache.hadoop.yarn.api.records.ApplicationId; -import org.apache.hadoop.yarn.api.records.YarnApplicationState; -import org.apache.hadoop.yarn.server.resourcemanager.RMContext; import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager; -import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp; import org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FairScheduler; -import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.AppInfo; import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.FairSchedulerInfo; -import org.apache.hadoop.yarn.webapp.hamlet.Hamlet; -import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TABLE; -import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TBODY; -import org.apache.hadoop.yarn.webapp.util.WebAppUtils; -import org.apache.hadoop.yarn.webapp.view.HtmlBlock; +import org.apache.hadoop.yarn.server.webapp.AppsBlock; import com.google.inject.Inject; @@ -50,95 +31,20 @@ * Shows application information specific to the fair * scheduler as part of the fair scheduler page. */ -public class FairSchedulerAppsBlock extends HtmlBlock { - final ConcurrentMap apps; +public class FairSchedulerAppsBlock extends AppsBlock { final FairSchedulerInfo fsinfo; - final Configuration conf; - @Inject public FairSchedulerAppsBlock(RMContext rmContext, - ResourceManager rm, ViewContext ctx, Configuration conf) { - super(ctx); + @Inject + public FairSchedulerAppsBlock(ResourceManager rm, + ApplicationBaseProtocol appBaseProt, ViewContext ctx) { + super(appBaseProt, ctx); FairScheduler scheduler = (FairScheduler) rm.getResourceScheduler(); fsinfo = new FairSchedulerInfo(scheduler); - apps = rmContext.getRMApps(); - this.conf = conf; + isFairSchedulerPage = true; } - - @Override public void render(Block html) { - TBODY> tbody = html. - table("#apps"). - thead(). - tr(). - th(".id", "ID"). - th(".user", "User"). - th(".name", "Name"). - th(".type", "Application Type"). - th(".queue", "Queue"). - th(".fairshare", "Fair Share"). - th(".starttime", "StartTime"). - th(".finishtime", "FinishTime"). - th(".state", "State"). - th(".finalstatus", "FinalStatus"). - th(".progress", "Progress"). - th(".ui", "Tracking UI")._()._(). - tbody(); - Collection reqAppStates = null; - String reqStateString = $(APP_STATE); - if (reqStateString != null && !reqStateString.isEmpty()) { - String[] appStateStrings = reqStateString.split(","); - reqAppStates = new HashSet(appStateStrings.length); - for(String stateString : appStateStrings) { - reqAppStates.add(YarnApplicationState.valueOf(stateString)); - } - } - StringBuilder appsTableData = new StringBuilder("[\n"); - for (RMApp app : apps.values()) { - if (reqAppStates != null && !reqAppStates.contains(app.createApplicationState())) { - continue; - } - AppInfo appInfo = new AppInfo(app, true, WebAppUtils.getHttpSchemePrefix(conf)); - String percent = String.format("%.1f", appInfo.getProgress()); - ApplicationAttemptId attemptId = app.getCurrentAppAttempt().getAppAttemptId(); - int fairShare = fsinfo.getAppFairShare(attemptId); - //AppID numerical value parsed by parseHadoopID in yarn.dt.plugins.js - appsTableData.append("[\"") - .append(appInfo.getAppId()).append("\",\"") - .append(StringEscapeUtils.escapeJavaScript(StringEscapeUtils.escapeHtml( - appInfo.getUser()))).append("\",\"") - .append(StringEscapeUtils.escapeJavaScript(StringEscapeUtils.escapeHtml( - appInfo.getName()))).append("\",\"") - .append(StringEscapeUtils.escapeJavaScript(StringEscapeUtils.escapeHtml( - appInfo.getApplicationType()))).append("\",\"") - .append(StringEscapeUtils.escapeJavaScript(StringEscapeUtils.escapeHtml( - appInfo.getQueue()))).append("\",\"") - .append(fairShare).append("\",\"") - .append(appInfo.getStartTime()).append("\",\"") - .append(appInfo.getFinishTime()).append("\",\"") - .append(appInfo.getState()).append("\",\"") - .append(appInfo.getFinalStatus()).append("\",\"") - // Progress bar - .append("
").append("
") - .append("\",\"") - .append(appInfo.getTrackingUI()).append("\"],\n"); - - } - if(appsTableData.charAt(appsTableData.length() - 2) == ',') { - appsTableData.delete(appsTableData.length()-2, appsTableData.length()-1); - } - appsTableData.append("]"); - html.script().$type("text/javascript"). - _("var appsTableData=" + appsTableData)._(); - tbody._()._(); + @Override + protected int getFairShare(ApplicationAttemptId attemptId) { + return fsinfo.getAppFairShare(attemptId); } } diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/FairSchedulerPage.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/FairSchedulerPage.java index a4f2e4d..bc04c3f 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/FairSchedulerPage.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/FairSchedulerPage.java @@ -237,19 +237,5 @@ static String width(float f) { static String left(float f) { return String.format("left:%.1f%%", f * 100); } - - @Override - protected String getAppsTableColumnDefs() { - StringBuilder sb = new StringBuilder(); - return sb - .append("[\n") - .append("{'sType':'numeric', 'aTargets': [0]") - .append(", 'mRender': parseHadoopID }") - - .append("\n, {'sType':'numeric', 'aTargets': [6, 7]") - .append(", 'mRender': renderHadoopDate }") - - .append("\n, {'sType':'numeric', bSearchable:false, 'aTargets': [9]") - .append(", 'mRender': parseHadoopProgress }]").toString(); - } + } diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/RMWebApp.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/RMWebApp.java index 98ea209..ec1e34c 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/RMWebApp.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/RMWebApp.java @@ -23,6 +23,7 @@ import java.net.InetSocketAddress; import org.apache.hadoop.ha.HAServiceProtocol.HAServiceState; +import org.apache.hadoop.yarn.api.ApplicationBaseProtocol; import org.apache.hadoop.yarn.conf.YarnConfiguration; import org.apache.hadoop.yarn.server.resourcemanager.RMContext; import org.apache.hadoop.yarn.util.RMHAUtils; @@ -60,6 +61,7 @@ public void setup() { bind(ApplicationACLsManager.class).toInstance( rm.getApplicationACLsManager()); bind(QueueACLsManager.class).toInstance(rm.getQueueACLsManager()); + bind(ApplicationBaseProtocol.class).toInstance(rm.getClientRMService()); } route("/", RmController.class); route(pajoin("/nodes", NODE_STATE), RmController.class, "nodes"); @@ -68,6 +70,9 @@ public void setup() { route(pajoin("/app", APPLICATION_ID), RmController.class, "app"); route("/scheduler", RmController.class, "scheduler"); route(pajoin("/queue", QUEUE_NAME), RmController.class, "queue"); + route(pajoin("/appattempt", APPLICATION_ATTEMPT_ID), RmController.class, + "appattempt"); + route(pajoin("/container", CONTAINER_ID), RmController.class, "container"); } @Override diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/RmController.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/RmController.java index f186bf4..6da43f7 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/RmController.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/RmController.java @@ -28,7 +28,6 @@ import org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FairScheduler; import org.apache.hadoop.yarn.util.StringHelper; import org.apache.hadoop.yarn.webapp.Controller; -import org.apache.hadoop.yarn.webapp.WebAppException; import org.apache.hadoop.yarn.webapp.YarnWebParams; import com.google.inject.Inject; @@ -55,6 +54,14 @@ public void app() { render(AppPage.class); } + public void appattempt() { + render(AppAttemptPage.class); + } + + public void container() { + render(ContainerPage.class); + } + public void nodes() { render(NodesPage.class); } diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/RmView.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/RmView.java index 1f3de36..509f076 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/RmView.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/RmView.java @@ -18,12 +18,17 @@ package org.apache.hadoop.yarn.server.resourcemanager.webapp; -import org.apache.hadoop.yarn.webapp.SubView; -import org.apache.hadoop.yarn.webapp.view.TwoColumnLayout; - import static org.apache.hadoop.yarn.util.StringHelper.sjoin; import static org.apache.hadoop.yarn.webapp.YarnWebParams.APP_STATE; -import static org.apache.hadoop.yarn.webapp.view.JQueryUI.*; +import static org.apache.hadoop.yarn.webapp.view.JQueryUI.ACCORDION; +import static org.apache.hadoop.yarn.webapp.view.JQueryUI.ACCORDION_ID; +import static org.apache.hadoop.yarn.webapp.view.JQueryUI.DATATABLES; +import static org.apache.hadoop.yarn.webapp.view.JQueryUI.DATATABLES_ID; +import static org.apache.hadoop.yarn.webapp.view.JQueryUI.initID; + +import org.apache.hadoop.yarn.server.webapp.WebPageUtils; +import org.apache.hadoop.yarn.webapp.SubView; +import org.apache.hadoop.yarn.webapp.view.TwoColumnLayout; // Do NOT rename/refactor this to RMView as it will wreak havoc // on Mac OS HFS @@ -35,7 +40,8 @@ protected void preHead(Page.HTML<_> html) { commonPreHead(html); set(DATATABLES_ID, "apps"); - set(initID(DATATABLES, "apps"), appsTableInit()); + set(initID(DATATABLES, "apps"), + WebPageUtils.appsTableInit(this.getClass() == FairSchedulerPage.class)); setTableStyles(html, "apps", ".queue {width:6em}", ".ui {width:8em}"); // Set the correct title. @@ -59,31 +65,4 @@ protected void commonPreHead(Page.HTML<_> html) { return AppsBlockWithMetrics.class; } - private String appsTableInit() { - // id, user, name, queue, starttime, finishtime, state, status, progress, ui - return tableInit() - .append(", 'aaData': appsTableData") - .append(", bDeferRender: true") - .append(", bProcessing: true") - - .append("\n, aoColumnDefs: ") - .append(getAppsTableColumnDefs()) - - // Sort by id upon page load - .append(", aaSorting: [[0, 'desc']]}").toString(); - } - - protected String getAppsTableColumnDefs() { - StringBuilder sb = new StringBuilder(); - return sb - .append("[\n") - .append("{'sType':'numeric', 'aTargets': [0]") - .append(", 'mRender': parseHadoopID }") - - .append("\n, {'sType':'numeric', 'aTargets': [5, 6]") - .append(", 'mRender': renderHadoopDate }") - - .append("\n, {'sType':'numeric', bSearchable:false, 'aTargets': [9]") - .append(", 'mRender': parseHadoopProgress }]").toString(); - } } diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebApp.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebApp.java index 2c2aae6..c3a619e 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebApp.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebApp.java @@ -21,19 +21,32 @@ import static org.apache.hadoop.yarn.server.resourcemanager.MockNodes.newResource; import static org.apache.hadoop.yarn.webapp.Params.TITLE; import static org.junit.Assert.assertEquals; +import static org.mockito.Matchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import java.io.IOException; +import java.util.ArrayList; import java.util.List; import java.util.concurrent.ConcurrentMap; +import junit.framework.Assert; + import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.yarn.api.ApplicationBaseProtocol; +import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationsRequest; +import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationsResponse; +import org.apache.hadoop.yarn.api.records.ApplicationAttemptId; import org.apache.hadoop.yarn.api.records.ApplicationId; +import org.apache.hadoop.yarn.api.records.ApplicationReport; +import org.apache.hadoop.yarn.api.records.ApplicationResourceUsageReport; import org.apache.hadoop.yarn.api.records.NodeId; import org.apache.hadoop.yarn.api.records.NodeState; +import org.apache.hadoop.yarn.api.records.Token; import org.apache.hadoop.yarn.api.records.YarnApplicationState; import org.apache.hadoop.yarn.conf.YarnConfiguration; +import org.apache.hadoop.yarn.exceptions.YarnException; +import org.apache.hadoop.yarn.server.resourcemanager.ClientRMService; import org.apache.hadoop.yarn.server.resourcemanager.MockNodes; import org.apache.hadoop.yarn.server.resourcemanager.RMContext; import org.apache.hadoop.yarn.server.resourcemanager.RMContextImpl; @@ -46,8 +59,8 @@ import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration; import org.apache.hadoop.yarn.server.resourcemanager.scheduler.fifo.FifoScheduler; import org.apache.hadoop.yarn.server.resourcemanager.security.ClientToAMTokenSecretManagerInRM; -import org.apache.hadoop.yarn.server.resourcemanager.security.RMContainerTokenSecretManager; import org.apache.hadoop.yarn.server.resourcemanager.security.NMTokenSecretManagerInRM; +import org.apache.hadoop.yarn.server.resourcemanager.security.RMContainerTokenSecretManager; import org.apache.hadoop.yarn.server.security.ApplicationACLsManager; import org.apache.hadoop.yarn.util.StringHelper; import org.apache.hadoop.yarn.webapp.WebApps; @@ -86,7 +99,10 @@ public void configure(Binder binder) { @Override public void configure(Binder binder) { try { - binder.bind(ResourceManager.class).toInstance(mockRm(3, 1, 2, 8*GiB)); + ResourceManager mockRm = mockRm(3, 1, 2, 8*GiB); + binder.bind(ResourceManager.class).toInstance(mockRm); + binder.bind(ApplicationBaseProtocol.class) + .toInstance(mockRm.getClientRMService()); } catch (IOException e) { throw new IllegalStateException(e); } @@ -190,9 +206,11 @@ public static ResourceManager mockRm(RMContext rmContext) throws IOException { ResourceManager rm = mock(ResourceManager.class); ResourceScheduler rs = mockCapacityScheduler(); ApplicationACLsManager aclMgr = mockAppACLsManager(); + ClientRMService clientRMService = mockClientRMService(rmContext); when(rm.getResourceScheduler()).thenReturn(rs); when(rm.getRMContext()).thenReturn(rmContext); when(rm.getApplicationACLsManager()).thenReturn(aclMgr); + when(rm.getClientRMService()).thenReturn(clientRMService); return rm; } @@ -215,6 +233,34 @@ public static ApplicationACLsManager mockAppACLsManager() { return new ApplicationACLsManager(conf); } + public static ClientRMService mockClientRMService(RMContext rmContext) { + ClientRMService clientRMService = mock(ClientRMService.class); + List appReports = new ArrayList(); + for (RMApp app : rmContext.getRMApps().values()) { + ApplicationReport appReport = + ApplicationReport.newInstance( + app.getApplicationId(), (ApplicationAttemptId) null, + app.getUser(), app.getQueue(), + app.getName(), (String) null, 0, (Token) null, + app.createApplicationState(), + app.getDiagnostics().toString(), (String) null, + app.getStartTime(), app.getFinishTime(), + app.getFinalApplicationStatus(), + (ApplicationResourceUsageReport) null, app.getTrackingUrl(), + app.getProgress(), app.getApplicationType(), (Token) null); + appReports.add(appReport); + } + GetApplicationsResponse response = mock(GetApplicationsResponse.class); + when(response.getApplicationList()).thenReturn(appReports); + try { + when(clientRMService.getApplications(any(GetApplicationsRequest.class))) + .thenReturn(response); + } catch (YarnException e) { + Assert.fail("Exception is not expteced."); + } + return clientRMService; + } + static void setupQueueConfiguration(CapacitySchedulerConfiguration conf) { // Define top-level queues conf.setQueues(CapacitySchedulerConfiguration.ROOT, new String[] {"a", "b", "c"});