shounakmk219 commented on code in PR #11077:
URL: https://github.com/apache/pinot/pull/11077#discussion_r1265250074
##########
pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/PinotHelixResourceManager.java:
##########
@@ -4128,6 +4138,33 @@ public PeriodicTaskInvocationResponse
invokeControllerPeriodicTask(String tableN
return new PeriodicTaskInvocationResponse(periodicTaskRequestId,
messageCount > 0);
}
+ /**
+ * Construct a map of all the tags and their respective minimum instance
requirements.
+ * The minimum instance requirement is computed by
+ * - for BROKER tenant tag set it to 1.
+ * - for SERVER tenant tag iterate over all the tables of that tenant and
find the maximum table replication.
+ * - for rest of the tags just set it to 0
+ * @return map of tags and their minimum instance requirements
+ */
+ public Map<String, Integer> minimumInstancesRequiredForTags() {
+ Map<String, Integer> tagMinServerMap = new HashMap<>();
+ for (InstanceConfig instanceConfig : getAllHelixInstanceConfigs()) {
+ for (String tag : instanceConfig.getTags()) {
+ tagMinServerMap.put(tag, TagNameUtils.isBrokerTag(tag) ? 1 : 0);
+ }
Review Comment:
Now that you point out I guess there's no harm to have 0 brokers as long as
it hosts no tables. Fixed it.
##########
pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/PinotHelixResourceManager.java:
##########
@@ -4128,6 +4138,33 @@ public PeriodicTaskInvocationResponse
invokeControllerPeriodicTask(String tableN
return new PeriodicTaskInvocationResponse(periodicTaskRequestId,
messageCount > 0);
}
+ /**
+ * Construct a map of all the tags and their respective minimum instance
requirements.
+ * The minimum instance requirement is computed by
+ * - for BROKER tenant tag set it to 1.
+ * - for SERVER tenant tag iterate over all the tables of that tenant and
find the maximum table replication.
+ * - for rest of the tags just set it to 0
+ * @return map of tags and their minimum instance requirements
+ */
+ public Map<String, Integer> minimumInstancesRequiredForTags() {
+ Map<String, Integer> tagMinServerMap = new HashMap<>();
+ for (InstanceConfig instanceConfig : getAllHelixInstanceConfigs()) {
+ for (String tag : instanceConfig.getTags()) {
+ tagMinServerMap.put(tag, TagNameUtils.isBrokerTag(tag) ? 1 : 0);
+ }
+ }
+ for (TableConfig tableConfig : getAllTableConfigs()) {
+ String serverTag =
TagNameUtils.getServerTagForTenant(tableConfig.getTenantConfig().getServer(),
+ tableConfig.getTableType());
+ int maxReplication =
Math.max(Objects.requireNonNullElse(tagMinServerMap.get(serverTag), 0),
+ tableConfig.getReplication());
+ tagMinServerMap.put(serverTag, maxReplication);
Review Comment:
Done
--
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]