You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hbase.apache.org by GitBox <gi...@apache.org> on 2022/11/25 06:32:09 UTC

[GitHub] [hbase] vaijosh commented on a diff in pull request #4889: HBASE-27498: Added logic in ConnectionImplementation.getKeepAliveMasterService to avoid expensive rpc calls in synchronized block

vaijosh commented on code in PR #4889:
URL: https://github.com/apache/hbase/pull/4889#discussion_r1032043733


##########
hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionImplementation.java:
##########
@@ -382,6 +390,24 @@ public void newDead(ServerName sn) {
       default:
         // Doing nothing
     }
+
+    this.cachedMasterStateSupplier = Suppliers.memoizeWithExpiration(() -> {
+      if (this.masterServiceState.getStub() == null) {
+        return false;
+      }
+      try {
+        LOG.info("Getting master state using rpc call");
+        return this.masterServiceState.isMasterRunning();
+      } catch (UndeclaredThrowableException e) {
+        // It's somehow messy, but we can receive exceptions such as
+        // java.net.ConnectException but they're not declared. So we catch it...
+        LOG.info("Master connection is not running anymore", e.getUndeclaredThrowable());
+        return false;
+      } catch (IOException se) {
+        LOG.warn("Checking master connection", se);
+        return false;
+      }
+    }, conf.getLong(MASTER_STATE_CACHE_TIMEOUT_SEC, 30), TimeUnit.SECONDS);

Review Comment:
   Hi @taklwu I have implemented the review comments in recent commit



-- 
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: issues-unsubscribe@hbase.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org