goiri commented on code in PR #4701:
URL: https://github.com/apache/hadoop/pull/4701#discussion_r938339570


##########
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/utils/FederationStateStoreFacade.java:
##########
@@ -513,6 +525,32 @@ public Map<String, SubClusterPolicyConfiguration> invoke(
     return cacheRequest;
   }
 
+  @SuppressWarnings("unchecked")
+  private Object buildGetApplicationHomeSubClusterRequest(String appId) {

Review Comment:
   Can we cast it here?



##########
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/utils/FederationStateStoreFacade.java:
##########
@@ -513,6 +525,32 @@ public Map<String, SubClusterPolicyConfiguration> invoke(
     return cacheRequest;
   }
 
+  @SuppressWarnings("unchecked")
+  private Object buildGetApplicationHomeSubClusterRequest(String appId) {
+    final String cacheKey = buildCacheKey(getClass().getSimpleName(),
+        GET_APPLICATION_HOME_SUBCLUSTER_CACHEID, appId);
+    CacheRequest<String, Map<String, SubClusterId>> cacheRequest =
+        new CacheRequest<>(
+            cacheKey,
+            input -> {
+              ApplicationId applicationId = ApplicationId.fromString(appId);
+
+              GetApplicationHomeSubClusterResponse response =
+                  stateStore.getApplicationHomeSubCluster(
+                      
GetApplicationHomeSubClusterRequest.newInstance(applicationId));
+
+              ApplicationHomeSubCluster applicationHomeSubCluster =
+                  response.getApplicationHomeSubCluster();
+              SubClusterId subClusterId = 
applicationHomeSubCluster.getHomeSubCluster();
+
+              Map<String, SubClusterId> appSubCluster = new HashMap<>();

Review Comment:
   Can you return a singleton map?



##########
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/federation/utils/TestFederationStateStoreFacade.java:
##########
@@ -206,4 +206,19 @@ public void testAddApplicationHomeSubCluster() throws 
YarnException {
     Assert.assertEquals(subClusterId1, result);
   }
 
+  @Test
+  public void testGetApplicationHomeSubClusterCache() throws YarnException {
+    ApplicationId appId = ApplicationId.newInstance(clusterTs, numApps + 1);
+    SubClusterId subClusterId1 = SubClusterId.newInstance("Home1");
+
+    ApplicationHomeSubCluster appHomeSubCluster =
+        ApplicationHomeSubCluster.newInstance(appId, subClusterId1);
+    SubClusterId subClusterIdAdd =
+        facade.addApplicationHomeSubCluster(appHomeSubCluster);
+
+    SubClusterId subClusterIdCache = 
facade.getApplicationHomeSubCluster(appId);
+    Assert.assertEquals(subClusterIdCache, subClusterIdAdd);

Review Comment:
   How do we make sure we went through the cache?



##########
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/federation/utils/FederationStateStoreFacade.java:
##########
@@ -376,10 +378,20 @@ public void updateApplicationHomeSubCluster(
    */
   public SubClusterId getApplicationHomeSubCluster(ApplicationId appId)
       throws YarnException {
-    GetApplicationHomeSubClusterResponse response =
-        stateStore.getApplicationHomeSubCluster(
+    try {
+      if (isCachingEnabled()) {
+        Map<ApplicationId, SubClusterId> cacheAppSubCluster =
+            (Map<ApplicationId, SubClusterId>)
+                
cache.get(buildGetApplicationHomeSubClusterRequest(appId.toString()));

Review Comment:
   Still left.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to