diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/impl/MemoryFederationStateStore.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/impl/MemoryFederationStateStore.java index fe02afcd83..98ddb93730 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/impl/MemoryFederationStateStore.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/impl/MemoryFederationStateStore.java @@ -33,7 +33,6 @@ import org.apache.hadoop.classification.VisibleForTesting; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.security.token.delegation.DelegationKey; -import org.apache.hadoop.util.Time; import org.apache.hadoop.yarn.api.records.ApplicationId; import org.apache.hadoop.yarn.api.records.ReservationId; import org.apache.hadoop.yarn.conf.YarnConfiguration; @@ -295,7 +294,7 @@ public GetApplicationsHomeSubClusterResponse getApplicationsHomeSubCluster( private ApplicationHomeSubCluster generateAppHomeSC(ApplicationId applicationId) { SubClusterId subClusterId = applications.get(applicationId); - return ApplicationHomeSubCluster.newInstance(applicationId, Time.now(), subClusterId); + return ApplicationHomeSubCluster.newInstance(applicationId, subClusterId); } @Override diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/impl/ZookeeperFederationStateStore.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/impl/ZookeeperFederationStateStore.java index affd4ced4f..3215333cbb 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/impl/ZookeeperFederationStateStore.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/impl/ZookeeperFederationStateStore.java @@ -30,7 +30,6 @@ import org.apache.commons.lang3.NotImplementedException; import org.apache.hadoop.classification.VisibleForTesting; import org.apache.hadoop.conf.Configuration; -import org.apache.hadoop.util.Time; import org.apache.hadoop.util.curator.ZKCuratorManager; import org.apache.hadoop.yarn.api.records.ApplicationId; import org.apache.hadoop.yarn.conf.YarnConfiguration; @@ -300,7 +299,7 @@ private ApplicationHomeSubCluster generateAppHomeSC(String appId) { ApplicationId applicationId = ApplicationId.fromString(appId); SubClusterId homeSubCluster = getApp(applicationId); ApplicationHomeSubCluster app = - ApplicationHomeSubCluster.newInstance(applicationId, Time.now(), homeSubCluster); + ApplicationHomeSubCluster.newInstance(applicationId, homeSubCluster); return app; } catch (Exception ex) { LOG.error("get homeSubCluster by appId = {}.", appId); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/ApplicationHomeSubClusterPBImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/ApplicationHomeSubClusterPBImpl.java index a72a431430..41d557ae3a 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/ApplicationHomeSubClusterPBImpl.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/ApplicationHomeSubClusterPBImpl.java @@ -44,6 +44,7 @@ public class ApplicationHomeSubClusterPBImpl extends ApplicationHomeSubCluster { private ApplicationId applicationId = null; private SubClusterId homeSubCluster = null; + private long createTime = 0L; public ApplicationHomeSubClusterPBImpl() { builder = ApplicationHomeSubClusterProto.newBuilder(); @@ -110,6 +111,9 @@ public String toString() { @Override public ApplicationId getApplicationId() { ApplicationHomeSubClusterProtoOrBuilder p = viaProto ? proto : builder; + if (this.applicationId != null) { + return this.applicationId; + } if (!p.hasApplicationId()) { return null; } @@ -125,6 +129,7 @@ public void setApplicationId(ApplicationId applicationId) { return; } this.applicationId = applicationId; + builder.setApplicationId(convertToProtoFormat(applicationId)); } @Override @@ -141,22 +146,34 @@ public SubClusterId getHomeSubCluster() { } @Override - public void setHomeSubCluster(SubClusterId homeSubCluster) { + public void setHomeSubCluster(SubClusterId paramHomeSubCluster) { maybeInitBuilder(); - if (homeSubCluster == null) { + if (paramHomeSubCluster == null) { builder.clearHomeSubCluster(); + return; } - this.homeSubCluster = homeSubCluster; + this.homeSubCluster = paramHomeSubCluster; + builder.setHomeSubCluster(convertToProtoFormat(paramHomeSubCluster)); } @Override public long getCreateTime() { - return 0; + ApplicationHomeSubClusterProtoOrBuilder p = viaProto ? proto : builder; + if (this.createTime != 0) { + return this.createTime; + } + if (!p.hasCreateTime()) { + return 0; + } + this.createTime = p.getCreateTime(); + return this.createTime; } @Override public void setCreateTime(long time) { - + maybeInitBuilder(); + this.createTime = time; + builder.setCreateTime(time); } private SubClusterId convertFromProtoFormat(SubClusterIdProto subClusterId) { diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/GetApplicationHomeSubClusterRequestPBImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/GetApplicationHomeSubClusterRequestPBImpl.java index 44c8ca8cc5..857aeef0f3 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/GetApplicationHomeSubClusterRequestPBImpl.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/GetApplicationHomeSubClusterRequestPBImpl.java @@ -127,6 +127,7 @@ public void setApplicationId(ApplicationId applicationId) { return; } this.applicationId = applicationId; + builder.setApplicationId(convertToProtoFormat(applicationId)); } private ApplicationId convertFromProtoFormat(ApplicationIdProto appId) { diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/GetApplicationsHomeSubClusterResponsePBImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/GetApplicationsHomeSubClusterResponsePBImpl.java index a53b381ae4..9a58a6d57a 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/GetApplicationsHomeSubClusterResponsePBImpl.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/GetApplicationsHomeSubClusterResponsePBImpl.java @@ -122,6 +122,7 @@ public void setAppsHomeSubClusters( return; } this.appsHomeSubCluster = appsHomeSubClusters; + addSubClustersInfoToProto(); } private void initSubClustersInfoList() { @@ -132,7 +133,7 @@ private void initSubClustersInfoList() { viaProto ? proto : builder; List subClusterInfosList = p.getAppSubclusterMapList(); - appsHomeSubCluster = new ArrayList(); + appsHomeSubCluster = new ArrayList<>(); for (ApplicationHomeSubClusterProto r : subClusterInfosList) { appsHomeSubCluster.add(convertFromProtoFormat(r)); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/GetReservationHomeSubClusterRequestPBImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/GetReservationHomeSubClusterRequestPBImpl.java index d3011d84a6..02351fff85 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/GetReservationHomeSubClusterRequestPBImpl.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/GetReservationHomeSubClusterRequestPBImpl.java @@ -119,13 +119,14 @@ public ReservationId getReservationId() { } @Override - public void setReservationId(ReservationId reservationId) { + public void setReservationId(ReservationId paramReservationId) { maybeInitBuilder(); - if (reservationId == null) { + if (paramReservationId == null) { builder.clearReservationId(); return; } - this.reservationId = reservationId; + this.reservationId = paramReservationId; + builder.setReservationId(convertToProtoFormat(paramReservationId)); } private ReservationId convertFromProtoFormat(ReservationIdProto appId) { diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/GetReservationsHomeSubClusterResponsePBImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/GetReservationsHomeSubClusterResponsePBImpl.java index c380997fa1..e424c03f05 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/GetReservationsHomeSubClusterResponsePBImpl.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/GetReservationsHomeSubClusterResponsePBImpl.java @@ -122,6 +122,7 @@ public void setAppsHomeSubClusters( return; } this.appsHomeSubCluster = appsHomeSubClusters; + addSubClustersInfoToProto(); } private void initSubClustersInfoList() { diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/GetSubClusterInfoResponsePBImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/GetSubClusterInfoResponsePBImpl.java index 1647d06aaa..bedd295dc6 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/GetSubClusterInfoResponsePBImpl.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/GetSubClusterInfoResponsePBImpl.java @@ -114,12 +114,14 @@ public SubClusterInfo getSubClusterInfo() { } @Override - public void setSubClusterInfo(SubClusterInfo subClusterInfo) { + public void setSubClusterInfo(SubClusterInfo paramSubClusterInfo) { maybeInitBuilder(); - if (subClusterInfo == null) { + if (paramSubClusterInfo == null) { builder.clearSubClusterInfo(); + return; } - this.subClusterInfo = subClusterInfo; + this.subClusterInfo = paramSubClusterInfo; + builder.setSubClusterInfo(convertToProtoFormat(paramSubClusterInfo)); } private SubClusterInfo convertFromProtoFormat( diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/GetSubClusterPoliciesConfigurationsResponsePBImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/GetSubClusterPoliciesConfigurationsResponsePBImpl.java index 67d5995bba..458a165632 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/GetSubClusterPoliciesConfigurationsResponsePBImpl.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/GetSubClusterPoliciesConfigurationsResponsePBImpl.java @@ -123,6 +123,7 @@ public void setPoliciesConfigs( builder.clearPoliciesConfigurations(); } this.subClusterPolicies = policyConfigurations; + addSubClusterPoliciesConfigurationsToProto(); } private void initSubClusterPoliciesConfigurationsList() { diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/GetSubClusterPolicyConfigurationResponsePBImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/GetSubClusterPolicyConfigurationResponsePBImpl.java index 5b54f262cd..6ccd4d9d70 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/GetSubClusterPolicyConfigurationResponsePBImpl.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/GetSubClusterPolicyConfigurationResponsePBImpl.java @@ -126,8 +126,10 @@ public void setPolicyConfiguration( maybeInitBuilder(); if (policyConfiguration == null) { builder.clearPolicyConfiguration(); + return; } this.subClusterPolicy = policyConfiguration; + this.builder.setPolicyConfiguration(convertToProtoFormat(policyConfiguration)); } private SubClusterPolicyConfiguration convertFromProtoFormat( diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/GetSubClustersInfoResponsePBImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/GetSubClustersInfoResponsePBImpl.java index 271570882f..b6029315bf 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/GetSubClustersInfoResponsePBImpl.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/GetSubClustersInfoResponsePBImpl.java @@ -101,6 +101,7 @@ public void setSubClusters(Collection subClusters) { return; } this.subClusterInfos = subClusters.stream().collect(Collectors.toList()); + addSubClusterInfosToProto(); } private void initSubClustersInfoList() { diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/ReservationHomeSubClusterPBImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/ReservationHomeSubClusterPBImpl.java index ba7f9d185f..5a04e73f87 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/ReservationHomeSubClusterPBImpl.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/ReservationHomeSubClusterPBImpl.java @@ -124,6 +124,7 @@ public void setReservationId(ReservationId resId) { builder.clearReservationId(); return; } + builder.setReservationId(convertToProtoFormat(resId)); this.reservationId = resId; } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/RouterMasterKeyRequestPBImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/RouterMasterKeyRequestPBImpl.java index 2d457e2f85..44d1e4ecb9 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/RouterMasterKeyRequestPBImpl.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/RouterMasterKeyRequestPBImpl.java @@ -93,8 +93,10 @@ public void setRouterMasterKey(RouterMasterKey masterKey) { maybeInitBuilder(); if (masterKey == null) { builder.clearRouterMasterKey(); + return; } this.routerMasterKey = masterKey; + builder.setRouterMasterKey(convertToProtoFormat(masterKey)); } @Override diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/RouterMasterKeyResponsePBImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/RouterMasterKeyResponsePBImpl.java index 1fbe1cce2d..26ca8a0f8b 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/RouterMasterKeyResponsePBImpl.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/RouterMasterKeyResponsePBImpl.java @@ -93,8 +93,10 @@ public void setRouterMasterKey(RouterMasterKey masterKey) { maybeInitBuilder(); if (masterKey == null) { builder.clearRouterMasterKey(); + return; } this.routerMasterKey = masterKey; + builder.setRouterMasterKey(convertToProtoFormat(masterKey)); } @Override diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/SetSubClusterPolicyConfigurationRequestPBImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/SetSubClusterPolicyConfigurationRequestPBImpl.java index 84fb0d6720..3bdf12449d 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/SetSubClusterPolicyConfigurationRequestPBImpl.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/SetSubClusterPolicyConfigurationRequestPBImpl.java @@ -126,8 +126,10 @@ public void setPolicyConfiguration( maybeInitBuilder(); if (policyConfiguration == null) { builder.clearPolicyConfiguration(); + return; } this.subClusterPolicy = policyConfiguration; + builder.setPolicyConfiguration(convertToProtoFormat(policyConfiguration)); } private SubClusterPolicyConfiguration convertFromProtoFormat( diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/SubClusterHeartbeatRequestPBImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/SubClusterHeartbeatRequestPBImpl.java index 3725652bdf..573ee0297d 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/SubClusterHeartbeatRequestPBImpl.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/SubClusterHeartbeatRequestPBImpl.java @@ -122,8 +122,10 @@ public void setSubClusterId(SubClusterId subClusterId) { maybeInitBuilder(); if (subClusterId == null) { builder.clearSubClusterId(); + return; } this.subClusterId = subClusterId; + builder.setSubClusterId(convertToProtoFormat(subClusterId)); } @Override diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/SubClusterInfoPBImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/SubClusterInfoPBImpl.java index ab365d8687..cc16097f62 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/SubClusterInfoPBImpl.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/SubClusterInfoPBImpl.java @@ -104,8 +104,10 @@ public void setSubClusterId(SubClusterId subClusterId) { maybeInitBuilder(); if (subClusterId == null) { builder.clearSubClusterId(); + return; } this.subClusterId = subClusterId; + builder.setSubClusterId(convertToProtoFormat(subClusterId)); } @Override diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/SubClusterRegisterRequestPBImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/SubClusterRegisterRequestPBImpl.java index 306ad6599c..2295947d9a 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/SubClusterRegisterRequestPBImpl.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/store/records/impl/pb/SubClusterRegisterRequestPBImpl.java @@ -118,8 +118,10 @@ public void setSubClusterInfo(SubClusterInfo subClusterInfo) { maybeInitBuilder(); if (subClusterInfo == null) { builder.clearSubClusterInfo(); + return; } this.subClusterInfo = subClusterInfo; + builder.setSubClusterInfo(convertToProtoFormat(subClusterInfo)); } private SubClusterInfo convertFromProtoFormat( diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/federation/policies/amrmproxy/TestBroadcastAMRMProxyFederationPolicy.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/federation/policies/amrmproxy/TestBroadcastAMRMProxyFederationPolicy.java index 52f36a40ba..64e6068c1c 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/federation/policies/amrmproxy/TestBroadcastAMRMProxyFederationPolicy.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/federation/policies/amrmproxy/TestBroadcastAMRMProxyFederationPolicy.java @@ -19,7 +19,6 @@ package org.apache.hadoop.yarn.server.federation.policies.amrmproxy; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; import java.util.HashSet; import java.util.List; @@ -52,9 +51,9 @@ public void setUp() throws Exception { for (int i = 1; i <= 2; i++) { SubClusterIdInfo sc = new SubClusterIdInfo("sc" + i); - SubClusterInfo sci = mock(SubClusterInfo.class); - when(sci.getState()).thenReturn(SubClusterState.SC_RUNNING); - when(sci.getSubClusterId()).thenReturn(sc.toId()); + SubClusterInfo sci = SubClusterInfo.newInstance( + sc.toId(), "dns1:80", "dns1:81", "dns1:82", "dns1:83", SubClusterState.SC_RUNNING, + System.currentTimeMillis(), "something"); getActiveSubclusters().put(sc.toId(), sci); } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/federation/policies/amrmproxy/TestHomeAMRMProxyPolicy.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/federation/policies/amrmproxy/TestHomeAMRMProxyPolicy.java index 1f57c1fe5d..a4998e6871 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/federation/policies/amrmproxy/TestHomeAMRMProxyPolicy.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/federation/policies/amrmproxy/TestHomeAMRMProxyPolicy.java @@ -24,7 +24,6 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.fail; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; import java.util.HashSet; import java.util.List; @@ -62,9 +61,9 @@ public void setUp() throws Exception { for (int i = 0; i < NUM_SUBCLUSTERS; i++) { SubClusterIdInfo sc = new SubClusterIdInfo("sc" + i); - SubClusterInfo sci = mock(SubClusterInfo.class); - when(sci.getState()).thenReturn(SubClusterState.SC_RUNNING); - when(sci.getSubClusterId()).thenReturn(sc.toId()); + SubClusterInfo sci = SubClusterInfo.newInstance( + sc.toId(), "dns1:80", "dns1:81", "dns1:82", "dns1:83", SubClusterState.SC_RUNNING, + System.currentTimeMillis(), "something"); getActiveSubclusters().put(sc.toId(), sci); } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/federation/policies/amrmproxy/TestLocalityMulticastAMRMProxyPolicy.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/federation/policies/amrmproxy/TestLocalityMulticastAMRMProxyPolicy.java index 10359e4445..b12614066f 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/federation/policies/amrmproxy/TestLocalityMulticastAMRMProxyPolicy.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/federation/policies/amrmproxy/TestLocalityMulticastAMRMProxyPolicy.java @@ -19,8 +19,6 @@ package org.apache.hadoop.yarn.server.federation.policies.amrmproxy; import static org.junit.Assert.fail; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; import java.nio.ByteBuffer; import java.util.ArrayList; @@ -79,9 +77,9 @@ public void setUp() throws Exception { SubClusterIdInfo sc = new SubClusterIdInfo("subcluster" + i); // sub-cluster 3 is not active if (i != 3) { - SubClusterInfo sci = mock(SubClusterInfo.class); - when(sci.getState()).thenReturn(SubClusterState.SC_RUNNING); - when(sci.getSubClusterId()).thenReturn(sc.toId()); + SubClusterInfo sci = SubClusterInfo.newInstance( + sc.toId(), "dns1:80", "dns1:81", "dns1:82", "dns1:83", SubClusterState.SC_RUNNING, + System.currentTimeMillis(), "something"); getActiveSubclusters().put(sc.toId(), sci); } @@ -330,11 +328,14 @@ Collections. emptyList(), * use as the default for when nodes or racks are unknown. */ private void addHomeSubClusterAsActive() { - SubClusterInfo sci = mock(SubClusterInfo.class); - when(sci.getState()).thenReturn(SubClusterState.SC_RUNNING); - when(sci.getSubClusterId()).thenReturn(getHomeSubCluster()); - getActiveSubclusters().put(getHomeSubCluster(), sci); - SubClusterIdInfo sc = new SubClusterIdInfo(getHomeSubCluster().getId()); + + SubClusterId homeSubCluster = getHomeSubCluster(); + SubClusterInfo sci = SubClusterInfo.newInstance( + homeSubCluster, "dns1:80", "dns1:81", "dns1:82", "dns1:83", SubClusterState.SC_RUNNING, + System.currentTimeMillis(), "something"); + + getActiveSubclusters().put(homeSubCluster, sci); + SubClusterIdInfo sc = new SubClusterIdInfo(homeSubCluster.getId()); getPolicyInfo().getRouterPolicyWeights().put(sc, 0.1f); getPolicyInfo().getAMRMPolicyWeights().put(sc, 0.1f); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/federation/policies/amrmproxy/TestRejectAMRMProxyPolicy.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/federation/policies/amrmproxy/TestRejectAMRMProxyPolicy.java index 655582941f..8bea41ca31 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/federation/policies/amrmproxy/TestRejectAMRMProxyPolicy.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/federation/policies/amrmproxy/TestRejectAMRMProxyPolicy.java @@ -19,7 +19,6 @@ package org.apache.hadoop.yarn.server.federation.policies.amrmproxy; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; import java.util.HashSet; import java.util.List; @@ -51,9 +50,9 @@ public void setUp() throws Exception { for (int i = 1; i <= 2; i++) { SubClusterIdInfo sc = new SubClusterIdInfo("sc" + i); - SubClusterInfo sci = mock(SubClusterInfo.class); - when(sci.getState()).thenReturn(SubClusterState.SC_RUNNING); - when(sci.getSubClusterId()).thenReturn(sc.toId()); + SubClusterInfo sci = SubClusterInfo.newInstance( + sc.toId(), "dns1:80", "dns1:81", "dns1:82", "dns1:83", SubClusterState.SC_RUNNING, + System.currentTimeMillis(), "something"); getActiveSubclusters().put(sc.toId(), sci); } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/federation/policies/router/TestPriorityRouterPolicy.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/federation/policies/router/TestPriorityRouterPolicy.java index 0b78a10c0a..cf2df6d560 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/federation/policies/router/TestPriorityRouterPolicy.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/federation/policies/router/TestPriorityRouterPolicy.java @@ -17,8 +17,6 @@ package org.apache.hadoop.yarn.server.federation.policies.router; import static org.apache.hadoop.test.LambdaTestUtils.intercept; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; import java.util.HashMap; import java.util.Map; @@ -93,9 +91,9 @@ public void testZeroSubClustersWithPositiveWeight() throws Exception { for (int i = 0; i < 5; i++) { SubClusterIdInfo sc = new SubClusterIdInfo("sc" + i); - SubClusterInfo sci = mock(SubClusterInfo.class); - when(sci.getState()).thenReturn(SubClusterState.SC_RUNNING); - when(sci.getSubClusterId()).thenReturn(sc.toId()); + SubClusterInfo sci = SubClusterInfo.newInstance( + sc.toId(), "dns1:80", "dns1:81", "dns1:82", "dns1:83", SubClusterState.SC_RUNNING, + System.currentTimeMillis(), "something"); getActiveSubclusters().put(sc.toId(), sci); routerWeights.put(sc, 0.0f); amrmWeights.put(sc, -1.0f); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/federation/store/records/TestFederationProtocolRecords.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/federation/store/records/TestFederationProtocolRecords.java index 13a98a9993..174b428852 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/federation/store/records/TestFederationProtocolRecords.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/federation/store/records/TestFederationProtocolRecords.java @@ -19,6 +19,7 @@ import org.apache.hadoop.yarn.api.BasePBImplRecordsTest; import org.apache.hadoop.yarn.api.records.ApplicationId; +import org.apache.hadoop.yarn.api.records.ReservationId; import org.apache.hadoop.yarn.federation.proto.YarnServerFederationProtos.AddApplicationHomeSubClusterRequestProto; import org.apache.hadoop.yarn.federation.proto.YarnServerFederationProtos.AddApplicationHomeSubClusterResponseProto; import org.apache.hadoop.yarn.federation.proto.YarnServerFederationProtos.DeleteApplicationHomeSubClusterRequestProto; @@ -47,9 +48,11 @@ import org.apache.hadoop.yarn.federation.proto.YarnServerFederationProtos.SubClusterRegisterResponseProto; import org.apache.hadoop.yarn.federation.proto.YarnServerFederationProtos.UpdateApplicationHomeSubClusterRequestProto; import org.apache.hadoop.yarn.federation.proto.YarnServerFederationProtos.UpdateApplicationHomeSubClusterResponseProto; +import org.apache.hadoop.yarn.federation.proto.YarnServerFederationProtos.GetReservationHomeSubClusterRequestProto; import org.apache.hadoop.yarn.federation.proto.YarnServerFederationProtos.RouterMasterKeyProto; import org.apache.hadoop.yarn.federation.proto.YarnServerFederationProtos.RouterMasterKeyRequestProto; import org.apache.hadoop.yarn.federation.proto.YarnServerFederationProtos.RouterMasterKeyResponseProto; +import org.apache.hadoop.yarn.federation.proto.YarnServerFederationProtos.ApplicationHomeSubClusterProto; import org.apache.hadoop.yarn.server.federation.store.records.impl.pb.AddApplicationHomeSubClusterRequestPBImpl; import org.apache.hadoop.yarn.server.federation.store.records.impl.pb.AddApplicationHomeSubClusterResponsePBImpl; import org.apache.hadoop.yarn.server.federation.store.records.impl.pb.DeleteApplicationHomeSubClusterRequestPBImpl; @@ -81,6 +84,8 @@ import org.apache.hadoop.yarn.server.federation.store.records.impl.pb.RouterMasterKeyPBImpl; import org.apache.hadoop.yarn.server.federation.store.records.impl.pb.RouterMasterKeyRequestPBImpl; import org.apache.hadoop.yarn.server.federation.store.records.impl.pb.RouterMasterKeyResponsePBImpl; +import org.apache.hadoop.yarn.server.federation.store.records.impl.pb.ApplicationHomeSubClusterPBImpl; +import org.apache.hadoop.yarn.server.federation.store.records.impl.pb.GetReservationHomeSubClusterRequestPBImpl; import org.apache.hadoop.yarn.server.records.Version; import org.junit.BeforeClass; import org.junit.Test; @@ -99,6 +104,7 @@ public static void setup() throws Exception { generateByNewInstance(ApplicationHomeSubCluster.class); generateByNewInstance(SubClusterPolicyConfiguration.class); generateByNewInstance(RouterMasterKey.class); + generateByNewInstance(ReservationId.class); } @Test @@ -284,4 +290,16 @@ public void testRouterMasterKeyRequest() throws Exception { public void testRouterMasterKeyResponse() throws Exception { validatePBImplRecord(RouterMasterKeyResponsePBImpl.class, RouterMasterKeyResponseProto.class); } + + @Test + public void testApplicationHomeSubCluster() throws Exception { + validatePBImplRecord(ApplicationHomeSubClusterPBImpl.class, + ApplicationHomeSubClusterProto.class); + } + + @Test + public void testGetReservationHomeSubClusterRequest() throws Exception { + validatePBImplRecord(GetReservationHomeSubClusterRequestPBImpl.class, + GetReservationHomeSubClusterRequestProto.class); + } } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/federation/utils/FederationPoliciesTestUtil.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/federation/utils/FederationPoliciesTestUtil.java index 6ae64d555b..ad4daf945f 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/federation/utils/FederationPoliciesTestUtil.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/federation/utils/FederationPoliciesTestUtil.java @@ -276,8 +276,8 @@ public static FederationStateStoreFacade initFacade( * @throws YarnException in case the initialization is not successful. */ public static FederationStateStoreFacade initFacade() throws YarnException { - return initFacade(new ArrayList<>(), mock(SubClusterPolicyConfiguration - .class)); + SubClusterPolicyConfiguration policyConfiguration = + SubClusterPolicyConfiguration.newInstance(null, null, null); + return initFacade(new ArrayList<>(), policyConfiguration); } - }