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


##########
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,23 @@ public void updateApplicationHomeSubCluster(
    */
   public SubClusterId getApplicationHomeSubCluster(ApplicationId appId)
       throws YarnException {
-    GetApplicationHomeSubClusterResponse response =
-        stateStore.getApplicationHomeSubCluster(
+    try {
+      if (isCachingEnabled()) {
+        Object value =
+            cache.get(buildGetApplicationHomeSubClusterRequest(appId));
+        if (value instanceof SubClusterId) {
+          return (SubClusterId) value;
+        } else {
+          throw new YarnException("Cannot be converted to SubClusterId.");

Review Comment:
   This part of the code does need cast, I simplified the code.
   The main reasons are as follows:
   
   The key and value used by the Cache defined here are both Object types.
   
   ```
   private Cache<Object, Object> 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,23 @@ public void updateApplicationHomeSubCluster(
    */
   public SubClusterId getApplicationHomeSubCluster(ApplicationId appId)
       throws YarnException {
-    GetApplicationHomeSubClusterResponse response =
-        stateStore.getApplicationHomeSubCluster(
+    try {
+      if (isCachingEnabled()) {
+        Object value =
+            cache.get(buildGetApplicationHomeSubClusterRequest(appId));
+        if (value instanceof SubClusterId) {
+          return (SubClusterId) value;
+        } else {
+          throw new YarnException("Cannot be converted to SubClusterId.");

Review Comment:
   This part of the code does need cast, I simplified the code.
   
   The main reasons are as follows:
   
   The key and value used by the Cache defined here are both Object types.
   
   ```
   private Cache<Object, Object> cache;
   ```



-- 
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