krishan1390 commented on code in PR #17125:
URL: https://github.com/apache/pinot/pull/17125#discussion_r2486290700


##########
pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/minion/ClusterInfoAccessor.java:
##########
@@ -186,6 +195,79 @@ public String getVipUrl() {
     return _controllerConf.generateVipUrl();
   }
 
+  /**
+   * Get the VIP URL of the lead controller for the given table.
+   * Falls back to the current controller's VIP URL if lead controller cannot 
be determined for some reason
+   *
+   * @param tableNameWithType table name with type
+   * @return VIP URL of the lead controller of the table
+   */
+  public String getVipUrlForLeadController(String tableNameWithType) {
+    String rawTableName = 
TableNameBuilder.extractRawTableName(tableNameWithType);
+    if (_leadControllerManager.isLeaderForTable(rawTableName)) {
+      return getVipUrl();
+    }
+
+    String leadControllerInstanceId = 
getLeadControllerForTable(tableNameWithType);
+    if (leadControllerInstanceId == null) {
+      return getVipUrl();
+    }
+
+    // Fetch the instance config for the given controller and obtain the 
hostname and port
+    HelixDataAccessor dataAccessor = 
_pinotHelixResourceManager.getHelixZkManager().getHelixDataAccessor();
+    PropertyKey.Builder keyBuilder = dataAccessor.keyBuilder();
+    InstanceConfig instanceConfig = 
dataAccessor.getProperty(keyBuilder.instanceConfig(leadControllerInstanceId));
+    if (instanceConfig == null) {
+      return getVipUrl();

Review Comment:
   lets log this case ? 



##########
pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/minion/ClusterInfoAccessor.java:
##########
@@ -186,6 +195,79 @@ public String getVipUrl() {
     return _controllerConf.generateVipUrl();
   }
 
+  /**
+   * Get the VIP URL of the lead controller for the given table.
+   * Falls back to the current controller's VIP URL if lead controller cannot 
be determined for some reason
+   *
+   * @param tableNameWithType table name with type
+   * @return VIP URL of the lead controller of the table
+   */
+  public String getVipUrlForLeadController(String tableNameWithType) {
+    String rawTableName = 
TableNameBuilder.extractRawTableName(tableNameWithType);
+    if (_leadControllerManager.isLeaderForTable(rawTableName)) {
+      return getVipUrl();
+    }
+
+    String leadControllerInstanceId = 
getLeadControllerForTable(tableNameWithType);
+    if (leadControllerInstanceId == null) {
+      return getVipUrl();
+    }
+
+    // Fetch the instance config for the given controller and obtain the 
hostname and port
+    HelixDataAccessor dataAccessor = 
_pinotHelixResourceManager.getHelixZkManager().getHelixDataAccessor();
+    PropertyKey.Builder keyBuilder = dataAccessor.keyBuilder();
+    InstanceConfig instanceConfig = 
dataAccessor.getProperty(keyBuilder.instanceConfig(leadControllerInstanceId));
+    if (instanceConfig == null) {
+      return getVipUrl();
+    }
+
+    String host = instanceConfig.getHostName();
+    String port = instanceConfig.getPort();
+    return _controllerConf.generateVipUrl(host, port);
+  }
+
+  private String getLeadControllerForTable(String tableNameWithType) {

Review Comment:
   lets log cases where we're returning null from this method ? 



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