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

 ##########
 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:
   Sure.

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to