This is an automated email from the ASF dual-hosted git repository.

jackie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pinot.git


The following commit(s) were added to refs/heads/master by this push:
     new 4a26fba3c3 minor: changes as a follow up PR (#14000)
4a26fba3c3 is described below

commit 4a26fba3c3ce3163b9d625a1898da31260993c7e
Author: Anand Kr Shaw <anandkrshawherit...@gmail.com>
AuthorDate: Sun Sep 15 20:20:15 2024 +0530

    minor: changes as a follow up PR (#14000)
---
 .../pinot/common/utils/helix/HelixHelper.java      | 34 ++++++++++++++++++----
 1 file changed, 28 insertions(+), 6 deletions(-)

diff --git 
a/pinot-common/src/main/java/org/apache/pinot/common/utils/helix/HelixHelper.java
 
b/pinot-common/src/main/java/org/apache/pinot/common/utils/helix/HelixHelper.java
index 43e6210e18..37c36cd567 100644
--- 
a/pinot-common/src/main/java/org/apache/pinot/common/utils/helix/HelixHelper.java
+++ 
b/pinot-common/src/main/java/org/apache/pinot/common/utils/helix/HelixHelper.java
@@ -397,8 +397,8 @@ public class HelixHelper {
   /**
    *  Returns the instances in the cluster without any tag.
    */
-  public static List<String> getInstancesWithoutTag(HelixManager helixManager, 
String tag) {
-    return getInstancesWithoutTag(getInstanceConfigs(helixManager), tag);
+  public static List<String> getInstancesWithoutTag(HelixManager helixManager, 
String defaultTag) {
+    return getInstancesWithoutTag(getInstanceConfigs(helixManager), 
defaultTag);
   }
 
   /**
@@ -412,8 +412,17 @@ public class HelixHelper {
     return 
instancesWithTag.stream().map(InstanceConfig::getInstanceName).collect(Collectors.toList());
   }
 
-  public static List<String> getInstancesWithoutTag(List<InstanceConfig> 
instanceConfigs, String tag) {
-    List<InstanceConfig> instancesWithoutTag = 
getInstancesConfigsWithoutTag(instanceConfigs, tag);
+  /**
+   * Retrieves the list of instance names for instances that do not have a 
specific tag associated with them.
+   * This method filters through the provided list of {@link InstanceConfig} 
objects and identifies those
+   * that are associated with the provided {@code defaultTag}, which indicates 
the absence of a specific tag.
+   *
+   * @param instanceConfigs the list of {@link InstanceConfig} objects to be 
checked for instances without tags.
+   * @param defaultTag the default tag that represents instances without an 
associated tag.
+   * @return a list of instance names for instances that do not have a 
specific tag.
+   */
+  public static List<String> getInstancesWithoutTag(List<InstanceConfig> 
instanceConfigs, String defaultTag) {
+    List<InstanceConfig> instancesWithoutTag = 
getInstancesConfigsWithoutTag(instanceConfigs, defaultTag);
     return 
instancesWithoutTag.stream().map(InstanceConfig::getInstanceName).collect(Collectors.toList());
   }
 
@@ -427,11 +436,24 @@ public class HelixHelper {
     return instancesWithTag;
   }
 
-  public static List<InstanceConfig> 
getInstancesConfigsWithoutTag(List<InstanceConfig> instanceConfigs, String tag) 
{
+
+  /**
+   * Retrieves a list of {@link InstanceConfig} objects that either do not 
have any tags
+   * or are associated with the provided tag, which represents the absence of 
a specific tag.
+   * This method iterates through the provided list of {@link InstanceConfig} 
objects, checks
+   * whether their tag list is empty or if they contain the specified tag, and 
collects those
+   * instances that match the criteria.
+   *
+   * @param instanceConfigs the list of {@link InstanceConfig} objects to be 
checked.
+   * @param defaultTag the tag used to identify instances that are either 
untagged or have the specified tag.
+   * @return a list of {@link InstanceConfig} objects that are untagged or 
have the specified tag.
+   */
+  public static List<InstanceConfig> getInstancesConfigsWithoutTag(
+      List<InstanceConfig> instanceConfigs, String defaultTag) {
     List<InstanceConfig> instancesWithoutTag = new ArrayList<>();
     for (InstanceConfig instanceConfig : instanceConfigs) {
       // instanceConfig.getTags() never returns null
-      if (instanceConfig.getTags().isEmpty() || 
instanceConfig.containsTag(tag)) {
+      if (instanceConfig.getTags().isEmpty() || 
instanceConfig.containsTag(defaultTag)) {
         instancesWithoutTag.add(instanceConfig);
       }
     }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org
For additional commands, e-mail: commits-h...@pinot.apache.org

Reply via email to