diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ApplicationReportPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ApplicationReportPBImpl.java index 57c334a..de6c41c 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ApplicationReportPBImpl.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ApplicationReportPBImpl.java @@ -223,15 +223,15 @@ public float getProgress() { public void setApplicationId(ApplicationId applicationId) { maybeInitBuilder(); if (applicationId == null) - builder.clearStatus(); + builder.clearApplicationId(); this.applicationId = applicationId; } @Override public void setCurrentApplicationAttemptId(ApplicationAttemptId applicationAttemptId) { maybeInitBuilder(); - if (applicationId == null) - builder.clearStatus(); + if (applicationAttemptId == null) + builder.clearCurrentApplicationAttemptId(); this.currentApplicationAttemptId = applicationAttemptId; } diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/proto/yarn_protos.proto hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/proto/yarn_protos.proto index f69aefb..07cd238 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/proto/yarn_protos.proto +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/proto/yarn_protos.proto @@ -152,18 +152,16 @@ message ApplicationReportProto { optional string host = 5; optional int32 rpc_port = 6; optional hadoop.common.TokenProto client_token = 7; - optional ApplicationStatusProto status = 8; - optional YarnApplicationStateProto yarn_application_state = 9; - optional ContainerProto masterContainer = 10; - optional string trackingUrl = 11; - optional string diagnostics = 12 [default = "N/A"]; - optional int64 startTime = 13; - optional int64 finishTime = 14; - optional FinalApplicationStatusProto final_application_status = 15; - optional ApplicationResourceUsageReportProto app_resource_Usage = 16; - optional string originalTrackingUrl = 17; - optional ApplicationAttemptIdProto currentApplicationAttemptId = 18; - optional float progress = 19; + optional YarnApplicationStateProto yarn_application_state = 8; + optional string trackingUrl = 9; + optional string diagnostics = 10 [default = "N/A"]; + optional int64 startTime = 11; + optional int64 finishTime = 12; + optional FinalApplicationStatusProto final_application_status = 13; + optional ApplicationResourceUsageReportProto app_resource_Usage = 14; + optional string originalTrackingUrl = 15; + optional ApplicationAttemptIdProto currentApplicationAttemptId = 16; + optional float progress = 17; } enum NodeStateProto { diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestApplicationAttemptId.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestApplicationAttemptId.java index 764ab42..492b27d 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestApplicationAttemptId.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestApplicationAttemptId.java @@ -57,8 +57,8 @@ public void testApplicationAttemptId() { Assert.assertEquals("appattempt_" + ts + "_543627_33492611", a6.toString()); } - private ApplicationAttemptId createAppAttemptId(long clusterTimeStamp, - int id, int attemptId) { + protected static ApplicationAttemptId createAppAttemptId( + long clusterTimeStamp, int id, int attemptId) { ApplicationAttemptId appAttemptId = Records.newRecord(ApplicationAttemptId.class); ApplicationId appId = Records.newRecord(ApplicationId.class); diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestApplicationId.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestApplicationId.java index a7d701a..11121ae 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestApplicationId.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestApplicationId.java @@ -51,7 +51,7 @@ public void testApplicationId() { Assert.assertEquals("application_" + ts + "_45436343", a5.toString()); } - private ApplicationId createAppId(long clusterTimeStamp, int id) { + protected static ApplicationId createAppId(long clusterTimeStamp, int id) { ApplicationId appId = Records.newRecord(ApplicationId.class); appId.setClusterTimestamp(clusterTimeStamp); appId.setId(id); diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestApplicatonReport.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestApplicatonReport.java new file mode 100644 index 0000000..69574bc --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestApplicatonReport.java @@ -0,0 +1,63 @@ +/** + * 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 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.util.Records; +import org.junit.Assert; +import org.junit.Test; + +public class TestApplicatonReport { + + @Test + public void testApplicationReport() { + long timestamp = System.currentTimeMillis(); + ApplicationReport appReport1 = + createApplicationReport(1, 1, timestamp); + ApplicationReport appReport2 = + createApplicationReport(1, 1, timestamp); + ApplicationReport appReport3 = + createApplicationReport(1, 1, timestamp); + Assert.assertEquals(appReport1, appReport2); + Assert.assertEquals(appReport2, appReport3); + appReport1.setApplicationId(null); + Assert.assertNull(appReport1.getApplicationId()); + Assert.assertNotSame(appReport1, appReport2); + appReport2.setCurrentApplicationAttemptId(null); + Assert.assertNull(appReport2.getCurrentApplicationAttemptId()); + Assert.assertNotSame(appReport2, appReport3); + } + + protected static ApplicationReport createApplicationReport( + int appIdInt, int appAttemptIdInt, long timestamp) { + ApplicationReport appReport = Records.newRecord(ApplicationReport.class); + ApplicationId appId = + TestApplicationId.createAppId(timestamp, appIdInt); + ApplicationAttemptId appAttemptId = + TestApplicationAttemptId.createAppAttemptId( + appId.getClusterTimestamp(), appId.getId(), appAttemptIdInt); + appReport.setApplicationId(appId); + appReport.setCurrentApplicationAttemptId(appAttemptId); + return appReport; + } + +} +