You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@helix.apache.org by "desaikomal (via GitHub)" <gi...@apache.org> on 2023/05/18 19:44:42 UTC

[GitHub] [helix] desaikomal commented on a diff in pull request #2493: Waged - Hard constraint - Fix for n - n+1 issue.

desaikomal commented on code in PR #2493:
URL: https://github.com/apache/helix/pull/2493#discussion_r1198236833


##########
helix-core/src/main/java/org/apache/helix/controller/dataproviders/InstanceCapacityDataProvider.java:
##########
@@ -0,0 +1,59 @@
+package org.apache.helix.controller.dataproviders;
+
+/*
+ * 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.
+ */
+
+import java.util.Map;
+
+/**
+ * An interface to provide capacity data for instance.
+ * It will consider the pending state transition and assigned partitions capacity.
+ * It will be dynamic and will always provide the available "headroom".
+ *
+ * The actual implementation will be stateful.
+ */
+public interface InstanceCapacityDataProvider {
+
+ /**
+   * Get the instance remaining capacity. 
+   * Capacity and weight both are represented as Key-Value.
+   * Returns the capacity map of available head room for the instance.
+   * @param instanceName - instance name to query
+   * @return Map<String, Integer> - capacity pair for all defined attributes for the instance.
+   */
+  public Map<String, Integer> getInstanceAvailableCapacity(String instanceName);
+
+  /**
+   * Check if partition can be placed on the instance.
+   *
+   * @param instanceName - instance name 
+   * @param partitionCapacity - Partition capacity expresed in capacity map.
+   * @return boolean - True if the partition can be placed, False otherwise
+   */
+  public boolean isInstanceCapacityAvailable(String instanceName, Map<String, Integer> partitionCapacity);
+
+  /**
+   * Reduce the available capacity by specified Partition Capacity Map.
+   *
+   * @param instanceName - instance name 
+   * @param partitionCapacity - Partition capacity expresed in capacity map.
+   * @returns boolean - True if successfully updated partition capacity, false otherwise.
+   */
+  public boolean reduceAvailableInstanceCapacity(String instanceName, Map<String, Integer> partitionCapacity);

Review Comment:
   I like the suggestion of having a "manager" class. But that pattern is not followed by all the existing DataProviders. Current DataProviders are not pure interface and are all stateful too. I am sure, you must have seen: https://github.com/apache/helix/blob/master/helix-core/src/main/java/org/apache/helix/controller/dataproviders/ResourceControllerDataProvider.java
   
   Let me know if the above makes sense. One is code organization and another is method scopes and purpose. Please do review the existing data provider and let me know. thanks,
   komal



-- 
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: reviews-unsubscribe@helix.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org