vvivekiyer commented on code in PR #15109:
URL: https://github.com/apache/pinot/pull/15109#discussion_r2076797320


##########
pinot-controller/src/main/java/org/apache/pinot/controller/workload/QueryWorkloadManager.java:
##########
@@ -0,0 +1,178 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.controller.workload;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+import java.util.stream.Collectors;
+import org.apache.pinot.common.messages.QueryWorkloadRefreshMessage;
+import org.apache.pinot.controller.helix.core.PinotHelixResourceManager;
+import org.apache.pinot.controller.workload.scheme.DefaultPropagationScheme;
+import org.apache.pinot.controller.workload.scheme.TablePropagationScheme;
+import org.apache.pinot.controller.workload.scheme.TenantPropagationScheme;
+import org.apache.pinot.controller.workload.scheme.WorkloadPropagationUtils;
+import org.apache.pinot.controller.workload.splitter.CostSplitter;
+import org.apache.pinot.controller.workload.splitter.DefaultCostSplitter;
+import org.apache.pinot.controller.workload.splitter.InstancesInfo;
+import org.apache.pinot.spi.config.workload.InstanceCost;
+import org.apache.pinot.spi.config.workload.NodeConfig;
+import org.apache.pinot.spi.config.workload.PropagationScheme;
+import org.apache.pinot.spi.config.workload.QueryWorkloadConfig;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * The PropagationManager class is responsible for propagating the query 
workload
+ * refresh message to the relevant instances based on the node configurations.
+ */
+public class QueryWorkloadManager {
+  public static final Logger LOGGER = 
LoggerFactory.getLogger(QueryWorkloadManager.class);
+
+  private final PinotHelixResourceManager _pinotHelixResourceManager;
+  private final TablePropagationScheme _tablePropagationScheme;

Review Comment:
   Let's have a PropogationProvider to get the scheme. resolveInstances() can 
use the provider to get the right one. It's not scalable to instantiate every 
Propogation scheme here.



##########
pinot-spi/src/main/java/org/apache/pinot/spi/utils/CommonConstants.java:
##########
@@ -1122,6 +1123,10 @@ public static class Dedup {
       public static final String DEFAULT_ALLOW_DEDUP_CONSUMPTION_DURING_COMMIT 
=
           "default.allow.dedup.consumption.during.commit";
     }
+
+    public static final String QUERY_WORKLOAD_ENABLED = 
"pinot.server.queryWorkloadEnabled";

Review Comment:
   I don't think you need a separate server Config here. We can rely on the 
configs I'll be creating. 



##########
pinot-spi/src/main/java/org/apache/pinot/spi/config/workload/InstanceCost.java:
##########
@@ -0,0 +1,70 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.spi.config.workload;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyDescription;
+
+
+public class InstanceCost {
+
+  private static final String CPU_COST = "cpuCost";
+  private static final String MEMORY_COST = "memoryCost";
+  private static final String ENFORCEMENT_PERIOD_MILLIS = 
"enforcementPeriodMillis";
+
+  @JsonPropertyDescription("CPU cost of the instance")
+  private long _cpuCost;
+  @JsonPropertyDescription("Memory cost of the instance")
+  private long _memoryCost;
+  @JsonPropertyDescription("Enforcement period in milliseconds")
+  private long _enforcementPeriodMillis;
+
+  @JsonCreator
+  public InstanceCost(@JsonProperty(CPU_COST) long cpuCost, 
@JsonProperty(MEMORY_COST) long memoryCost,
+      @JsonProperty(ENFORCEMENT_PERIOD_MILLIS) long enforcementPeriodMillis) {
+    _cpuCost = cpuCost;
+    _memoryCost = memoryCost;
+    _enforcementPeriodMillis = enforcementPeriodMillis;
+  }
+
+  public long getCpuCost() {

Review Comment:
   Mention Units (Ns for CPU. Bytes for Memory)



##########
pinot-spi/src/main/java/org/apache/pinot/spi/config/workload/InstanceCost.java:
##########
@@ -0,0 +1,70 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.spi.config.workload;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyDescription;
+
+
+public class InstanceCost {
+
+  private static final String CPU_COST = "cpuCost";
+  private static final String MEMORY_COST = "memoryCost";
+  private static final String ENFORCEMENT_PERIOD_MILLIS = 
"enforcementPeriodMillis";
+
+  @JsonPropertyDescription("CPU cost of the instance")
+  private long _cpuCost;
+  @JsonPropertyDescription("Memory cost of the instance")
+  private long _memoryCost;
+  @JsonPropertyDescription("Enforcement period in milliseconds")
+  private long _enforcementPeriodMillis;
+
+  @JsonCreator
+  public InstanceCost(@JsonProperty(CPU_COST) long cpuCost, 
@JsonProperty(MEMORY_COST) long memoryCost,
+      @JsonProperty(ENFORCEMENT_PERIOD_MILLIS) long enforcementPeriodMillis) {
+    _cpuCost = cpuCost;
+    _memoryCost = memoryCost;
+    _enforcementPeriodMillis = enforcementPeriodMillis;
+  }
+
+  public long getCpuCost() {
+    return _cpuCost;
+  }
+
+  public long getMemoryCost() {
+    return _memoryCost;
+  }
+
+  public long getEnforcementPeriodMillis() {

Review Comment:
   Let's remove enforcementPeriod. We want enforcementPeriod to be consistent 
across all workloads.



##########
pinot-controller/src/main/java/org/apache/pinot/controller/workload/scheme/PropagationScheme.java:
##########
@@ -0,0 +1,37 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.controller.workload.scheme;
+
+import java.util.Set;
+import org.apache.pinot.spi.config.workload.NodeConfig;
+
+/**
+ * PropagationScheme is used to resolve instances based on the {@link 
NodeConfig} and {@link NodeConfig.Type}
+ * 1. It helps to identify which instances to propagate the workload to based 
on the node configuration
+ * 2. It helps among which instances the {@link 
org.apache.pinot.spi.config.workload.EnforcementProfile} should be split
+ */
+public interface PropagationScheme {
+  /**
+   * Resolve the instances based on the node type and node configuration
+   * @param nodeType {@link NodeConfig.Type}
+   * @param nodeConfig The {@link NodeConfig} to resolve the instances
+   * @return The set of instances to propagate the workload to
+   */
+  Set<String> resolveInstances(NodeConfig.Type nodeType, NodeConfig 
nodeConfig);

Review Comment:
   Do we need both nodeConfig.Type and nodeConfig? 



##########
pinot-controller/src/main/java/org/apache/pinot/controller/workload/splitter/InstancesInfo.java:
##########
@@ -0,0 +1,43 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.controller.workload.splitter;
+
+import java.util.Set;
+
+
+public class InstancesInfo {

Review Comment:
   Is this class really needed? Looks like a Set of instances is all this is 
storing.



##########
pinot-controller/src/main/java/org/apache/pinot/controller/workload/splitter/CostSplitter.java:
##########
@@ -0,0 +1,47 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.controller.workload.splitter;
+
+import java.util.Map;
+import org.apache.pinot.spi.config.workload.InstanceCost;
+import org.apache.pinot.spi.config.workload.NodeConfig;
+
+/**
+ * Interface for splitting the cost of a workload between instances.
+ */
+public interface CostSplitter {
+  /**
+   * Computes the cost for each instance in the given set of instances.
+   *
+   * @param nodeConfig the node configuration
+   * @param instancesInfo info about all instances involved
+   * @return a map from instance identifier to the cost for that instance
+   */
+  Map<String, InstanceCost> getInstanceCostMap(NodeConfig nodeConfig, 
InstancesInfo instancesInfo);

Review Comment:
   s/getInstanceCostMap/computeInstanceCostMap/



-- 
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: commits-unsubscr...@pinot.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


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

Reply via email to