StephanErb commented on a change in pull request #37: Staggered (Variable 
batch) Updates
URL: https://github.com/apache/aurora/pull/37#discussion_r217963287
 
 

 ##########
 File path: 
src/main/java/org/apache/aurora/scheduler/updater/strategy/VariableBatchStrategy.java
 ##########
 @@ -0,0 +1,135 @@
+/**
+ * Licensed 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.aurora.scheduler.updater.strategy;
+
+import java.util.List;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Ordering;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * A strategy that limits the number of instances selected by the subclass 
using variable steps.
+ *
+ * @param <T> Instance type.
+ */
+public class VariableBatchStrategy<T extends Comparable<T>> implements 
UpdateStrategy<T> {
+  private final Ordering<T> ordering;
+  protected final ImmutableList<Integer> maxActiveGroups;
+  private final boolean rollingForward;
+  private Optional<Integer> instanceModificationCount;
+
+  private static final Logger LOG = 
LoggerFactory.getLogger(VariableBatchStrategy.class);
+
+  /**
+   * Creates a variable active-limited strategy that applies an upper bound to 
all results.
+   *
+   * @param maxActiveGroups  List of Maximum group sizes. Each group size 
represents a step.
+   * {@link #getNextGroup(Set, Set)}.
+   */
+  public VariableBatchStrategy(Ordering<T> ordering,
+      List<Integer> maxActiveGroups,
+      boolean rollingForward) {
+
+    this.ordering = Objects.requireNonNull(ordering);
+    this.rollingForward = rollingForward;
+
+    maxActiveGroups.forEach(x -> Preconditions.checkArgument(x > 0));
+
+    this.maxActiveGroups = ImmutableList.copyOf(maxActiveGroups);
+    this.instanceModificationCount = Optional.empty();
+  }
+
+  private int determineStep(int idle) {
 
 Review comment:
   Please add one short comment that explains what this function does. For a 
casual reader it can be confusing what you mean with step.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to