clintropolis commented on a change in pull request #9492: add manual laning 
strategy, integration test
URL: https://github.com/apache/druid/pull/9492#discussion_r392101474
 
 

 ##########
 File path: 
server/src/main/java/org/apache/druid/server/scheduling/ManualQueryLaningStrategy.java
 ##########
 @@ -0,0 +1,77 @@
+/*
+ * 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.druid.server.scheduling;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.google.common.base.Preconditions;
+import it.unimi.dsi.fastutil.objects.Object2IntArrayMap;
+import it.unimi.dsi.fastutil.objects.Object2IntMap;
+import org.apache.druid.client.SegmentServerSelector;
+import org.apache.druid.query.QueryContexts;
+import org.apache.druid.query.QueryPlus;
+import org.apache.druid.server.QueryLaningStrategy;
+
+import javax.annotation.Nullable;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+
+public class ManualQueryLaningStrategy implements QueryLaningStrategy
+{
+  @JsonProperty
+  private Map<String, Integer> lanes;
+
+  @JsonProperty
+  private boolean isLimitPercent;
+
+  @JsonCreator
+  public ManualQueryLaningStrategy(
+      @JsonProperty("lanes") Map<String, Integer> lanes,
+      @JsonProperty("isLimitPercent") @Nullable Boolean isLimitPercent
+  )
+  {
+    this.lanes = Preconditions.checkNotNull(lanes, "lanes must be set");
+    this.isLimitPercent = isLimitPercent != null ? isLimitPercent : false;
+    Preconditions.checkArgument(lanes.size() > 0, "lanes must define at least 
one lane");
+    Preconditions.checkArgument(
+        lanes.values().stream().allMatch(x -> this.isLimitPercent ? 0 < x && x 
<= 100 : x > 0),
 
 Review comment:
   I'm not sure it is necessary to enforce that since lane limits are currently 
an 'at most' guarantee instead of an 'at least'; so it seems possibly 
legitimate to say configure two lanes and allow either of them to use 75% of 
total capacity.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to