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 2019/11/12 00:47:37 UTC

[GitHub] [hbase] ndimiduk commented on a change in pull request #812: HBASE-23275: Track active master's address in ActiveMasterManager

ndimiduk commented on a change in pull request #812: HBASE-23275: Track active master's address in ActiveMasterManager
URL: https://github.com/apache/hbase/pull/812#discussion_r344970350
 
 

 ##########
 File path: hbase-server/src/main/java/org/apache/hadoop/hbase/master/ActiveMasterManager.java
 ##########
 @@ -106,6 +112,33 @@ void handle(final String path) {
     }
   }
 
+  /*
+   * Fetches the active master's ServerName from zookeeper.
+   */
+  private void fetchAndSetActiveMasterServerName() {
+    LOG.debug("Attempting to fetch active master sn from zk");
+    try {
+      activeMasterServerName.set(MasterAddressTracker.getMasterAddress(watcher));
+    } catch (IOException | KeeperException e) {
+      // Log and ignore for now and re-fetch later if needed.
+      LOG.error("Error fetching active master information", e);
+    }
+  }
+
+  public ServerName getActiveMasterServerName() {
+    if (!clusterHasActiveMaster.get()) {
+      return null;
+    }
+    ServerName sname = activeMasterServerName.get();
+    if (sname != null) {
+      return sname;
+    }
+    // This happens if the data was not fetched earlier for some reason.
+    fetchAndSetActiveMasterServerName();
+    // It could still be null, but return whatever we have.
 
 Review comment:
   This seems reason enough to return an `Optional`, yes?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services