Re: [PR] Add `strict` and `pooled` Broker tier selector strategies (druid)
abhishekrb19 merged PR #19094: URL: https://github.com/apache/druid/pull/19094 -- 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]
Re: [PR] Add `strict` and `pooled` Broker tier selector strategies (druid)
abhishekrb19 commented on PR #19094: URL: https://github.com/apache/druid/pull/19094#issuecomment-403962 Thanks for the review @aho135! The Docker test failures `test_runIndexTask_andKillData ` and `test_runIndexParallelTask_andCompactData` are unrelated to this patch (the first one is a usual suspect) -- 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]
Re: [PR] Add `strict` and `pooled` Broker tier selector strategies (druid)
abhishekrb19 commented on code in PR #19094: URL: https://github.com/apache/druid/pull/19094#discussion_r2909167971 ## server/src/test/java/org/apache/druid/client/selector/TierSelectorStrategyTest.java: ## @@ -568,4 +594,326 @@ public void testPreferredTierSelectorStrategyDefaultPriority() preferredTierHighPriority, preferredTierLowPriority, nonPreferredTierHighestPriority ); } + Review Comment: Thanks, good call! Added a case for these mixed priorities. -- 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]
Re: [PR] Add `strict` and `pooled` Broker tier selector strategies (druid)
abhishekrb19 commented on code in PR #19094:
URL: https://github.com/apache/druid/pull/19094#discussion_r2909166474
##
server/src/main/java/org/apache/druid/client/selector/StrictTierSelectorStrategy.java:
##
@@ -0,0 +1,183 @@
+/*
+ * 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.client.selector;
+
+import com.fasterxml.jackson.annotation.JacksonInject;
+import com.fasterxml.jackson.annotation.JsonCreator;
+import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
+import it.unimi.dsi.fastutil.ints.Int2ObjectRBTreeMap;
+import org.apache.druid.client.QueryableDruidServer;
+import org.apache.druid.java.util.emitter.EmittingLogger;
+import org.apache.druid.java.util.emitter.service.ServiceEmitter;
+import org.apache.druid.java.util.emitter.service.ServiceMetricEvent;
+import org.apache.druid.query.Query;
+import org.apache.druid.query.metadata.metadata.SegmentMetadataQuery;
+import org.apache.druid.timeline.DataSegment;
+
+import javax.annotation.Nullable;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * A {@link TierSelectorStrategy} that only considers servers whose priorities
+ * are explicitly listed in {@link
StrictTierSelectorStrategyConfig#getPriorities()}.
+ *
+ * Unlike other strategies like {@link CustomTierSelectorStrategy} that falls
back to servers with different priorities,
+ * this strategy strictly filters the available servers to the configured
priorities.
+ * If no servers match the configured priorities, an empty server list is
returned from {@link #pick(Query, Int2ObjectRBTreeMap, DataSegment, int)},
+ * which may cause queries to return partial or no data.
+ *
+ * When multiple priorities are configured, they are evaluated in the order
specified, with earlier priorities
+ * preferred over later ones.
+ *
+ * Example configuration:
+ * druid.broker.select.tier=strict
+ * druid.broker.select.tier.strict.priorities=[2,1]
+ *
+ * With this configuration, servers with priority 2 are preferred over servers
with priority 1.
+ * Servers with any other tier priority are not considered.
+ *
+ * This strategy is useful when query isolation is required between different
server priority tiers. Brokers may still
+ * be configured to watch all server tiers, allowing them to retain visibility
into the overall cluster state
+ * while enforcing isolation at query time.
+ */
+public class StrictTierSelectorStrategy extends AbstractTierSelectorStrategy
+{
+ private static final EmittingLogger log = new
EmittingLogger(StrictTierSelectorStrategy.class);
+ public static final String TYPE = "strict";
+
+ private final StrictTierSelectorStrategyConfig config;
+ private final ServiceEmitter emitter;
+ private final Map configuredPriorities;
+ private final Comparator comparator;
+
+ @JsonCreator
+ public StrictTierSelectorStrategy(
+ @JacksonInject final ServerSelectorStrategy serverSelectorStrategy,
+ @JacksonInject final StrictTierSelectorStrategyConfig config,
+ @JacksonInject final ServiceEmitter emitter
+ )
+ {
+super(serverSelectorStrategy);
+this.config = config;
+this.emitter = emitter;
+
+configuredPriorities = new HashMap<>();
+for (int i = 0; i < config.getPriorities().size(); i++) {
+ configuredPriorities.put(config.getPriorities().get(i), i);
+}
+
+this.comparator = (p1, p2) -> {
+ final Integer rank1 = configuredPriorities.get(p1);
+ final Integer rank2 = configuredPriorities.get(p2);
+
+ if (rank1 != null && rank2 != null) {
+return Integer.compare(rank1, rank2);
+ }
+ if (rank1 != null) {
+return -1;
+ }
+ if (rank2 != null) {
+return 1;
+ }
+
+ // Priorities outside configuredPriorities don't matter and won't be
selected in pick() for this strategy.
+ // This fallback ordering can be anything and is needed because the
comparator may be used by ServerSelector/ServerView
+ // which maintains views of all servers, including those with
unconfigured priorities.
+ return Integer.compare(p2, p1);
+};
+ }
+
+ @Override
+ public List pick(
+ @Nul
Re: [PR] Add `strict` and `pooled` Broker tier selector strategies (druid)
aho135 commented on code in PR #19094: URL: https://github.com/apache/druid/pull/19094#discussion_r2908799961 ## server/src/test/java/org/apache/druid/client/selector/TierSelectorStrategyTest.java: ## @@ -568,4 +594,326 @@ public void testPreferredTierSelectorStrategyDefaultPriority() preferredTierHighPriority, preferredTierLowPriority, nonPreferredTierHighestPriority ); } + Review Comment: Maybe one test case where we have partial priority match. e.g. Servers with priority [-1, 0, 2] but StrictTierSelectorStrategy configured with [0,1] -- 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]
Re: [PR] Add `strict` and `pooled` Broker tier selector strategies (druid)
aho135 commented on code in PR #19094:
URL: https://github.com/apache/druid/pull/19094#discussion_r2908783421
##
server/src/main/java/org/apache/druid/client/selector/StrictTierSelectorStrategy.java:
##
@@ -0,0 +1,183 @@
+/*
+ * 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.client.selector;
+
+import com.fasterxml.jackson.annotation.JacksonInject;
+import com.fasterxml.jackson.annotation.JsonCreator;
+import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
+import it.unimi.dsi.fastutil.ints.Int2ObjectRBTreeMap;
+import org.apache.druid.client.QueryableDruidServer;
+import org.apache.druid.java.util.emitter.EmittingLogger;
+import org.apache.druid.java.util.emitter.service.ServiceEmitter;
+import org.apache.druid.java.util.emitter.service.ServiceMetricEvent;
+import org.apache.druid.query.Query;
+import org.apache.druid.query.metadata.metadata.SegmentMetadataQuery;
+import org.apache.druid.timeline.DataSegment;
+
+import javax.annotation.Nullable;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * A {@link TierSelectorStrategy} that only considers servers whose priorities
+ * are explicitly listed in {@link
StrictTierSelectorStrategyConfig#getPriorities()}.
+ *
+ * Unlike other strategies like {@link CustomTierSelectorStrategy} that falls
back to servers with different priorities,
+ * this strategy strictly filters the available servers to the configured
priorities.
+ * If no servers match the configured priorities, an empty server list is
returned from {@link #pick(Query, Int2ObjectRBTreeMap, DataSegment, int)},
+ * which may cause queries to return partial or no data.
+ *
+ * When multiple priorities are configured, they are evaluated in the order
specified, with earlier priorities
+ * preferred over later ones.
+ *
+ * Example configuration:
+ * druid.broker.select.tier=strict
+ * druid.broker.select.tier.strict.priorities=[2,1]
+ *
+ * With this configuration, servers with priority 2 are preferred over servers
with priority 1.
+ * Servers with any other tier priority are not considered.
+ *
+ * This strategy is useful when query isolation is required between different
server priority tiers. Brokers may still
+ * be configured to watch all server tiers, allowing them to retain visibility
into the overall cluster state
+ * while enforcing isolation at query time.
+ */
+public class StrictTierSelectorStrategy extends AbstractTierSelectorStrategy
+{
+ private static final EmittingLogger log = new
EmittingLogger(StrictTierSelectorStrategy.class);
+ public static final String TYPE = "strict";
+
+ private final StrictTierSelectorStrategyConfig config;
+ private final ServiceEmitter emitter;
+ private final Map configuredPriorities;
+ private final Comparator comparator;
+
+ @JsonCreator
+ public StrictTierSelectorStrategy(
+ @JacksonInject final ServerSelectorStrategy serverSelectorStrategy,
+ @JacksonInject final StrictTierSelectorStrategyConfig config,
+ @JacksonInject final ServiceEmitter emitter
+ )
+ {
+super(serverSelectorStrategy);
+this.config = config;
+this.emitter = emitter;
+
+configuredPriorities = new HashMap<>();
+for (int i = 0; i < config.getPriorities().size(); i++) {
+ configuredPriorities.put(config.getPriorities().get(i), i);
+}
+
+this.comparator = (p1, p2) -> {
+ final Integer rank1 = configuredPriorities.get(p1);
+ final Integer rank2 = configuredPriorities.get(p2);
+
+ if (rank1 != null && rank2 != null) {
+return Integer.compare(rank1, rank2);
+ }
+ if (rank1 != null) {
+return -1;
+ }
+ if (rank2 != null) {
+return 1;
+ }
+
+ // Priorities outside configuredPriorities don't matter and won't be
selected in pick() for this strategy.
+ // This fallback ordering can be anything and is needed because the
comparator may be used by ServerSelector/ServerView
+ // which maintains views of all servers, including those with
unconfigured priorities.
+ return Integer.compare(p2, p1);
+};
+ }
+
+ @Override
+ public List pick(
+ @Nullable
Re: [PR] Add `strict` and `pooled` Broker tier selector strategies (druid)
aho135 commented on code in PR #19094:
URL: https://github.com/apache/druid/pull/19094#discussion_r2908728911
##
server/src/main/java/org/apache/druid/client/selector/StrictTierSelectorStrategy.java:
##
@@ -0,0 +1,183 @@
+/*
+ * 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.client.selector;
+
+import com.fasterxml.jackson.annotation.JacksonInject;
+import com.fasterxml.jackson.annotation.JsonCreator;
+import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
+import it.unimi.dsi.fastutil.ints.Int2ObjectRBTreeMap;
+import org.apache.druid.client.QueryableDruidServer;
+import org.apache.druid.java.util.emitter.EmittingLogger;
+import org.apache.druid.java.util.emitter.service.ServiceEmitter;
+import org.apache.druid.java.util.emitter.service.ServiceMetricEvent;
+import org.apache.druid.query.Query;
+import org.apache.druid.query.metadata.metadata.SegmentMetadataQuery;
+import org.apache.druid.timeline.DataSegment;
+
+import javax.annotation.Nullable;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * A {@link TierSelectorStrategy} that only considers servers whose priorities
+ * are explicitly listed in {@link
StrictTierSelectorStrategyConfig#getPriorities()}.
+ *
+ * Unlike other strategies like {@link CustomTierSelectorStrategy} that falls
back to servers with different priorities,
Review Comment:
```suggestion
* Unlike other strategies like {@link CustomTierSelectorStrategy} that fall
back to servers with different priorities,
```
--
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]
Re: [PR] Add `strict` and `pooled` Broker tier selector strategies (druid)
aho135 commented on code in PR #19094:
URL: https://github.com/apache/druid/pull/19094#discussion_r2908713839
##
server/src/main/java/org/apache/druid/client/selector/PooledTierSelectorStrategy.java:
##
@@ -0,0 +1,158 @@
+/*
+ * 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.client.selector;
+
+import com.fasterxml.jackson.annotation.JacksonInject;
+import com.fasterxml.jackson.annotation.JsonCreator;
+import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
+import it.unimi.dsi.fastutil.ints.Int2ObjectRBTreeMap;
+import org.apache.druid.client.QueryableDruidServer;
+import org.apache.druid.java.util.emitter.EmittingLogger;
+import org.apache.druid.java.util.emitter.service.ServiceEmitter;
+import org.apache.druid.java.util.emitter.service.ServiceMetricEvent;
+import org.apache.druid.query.Query;
+import org.apache.druid.query.metadata.metadata.SegmentMetadataQuery;
+import org.apache.druid.timeline.DataSegment;
+
+import javax.annotation.Nullable;
+import java.util.Comparator;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * A {@link TierSelectorStrategy} that pools servers with the configured set
of priorities from {@link PooledTierSelectorStrategyConfig#getPriorities()}
+ * and delegates server selection to the configured {@link
ServerSelectorStrategy}.
+ *
+ * Unlike other {@link TierSelectorStrategy} like {@link
CustomTierSelectorStrategy}
+ * which has a preference for priority order, this strategy treats all
configured priorities equally
+ * by combining their servers into a single selection pool and delegates to
{@link ServerSelectorStrategy} to do
+ * the server selection. If no servers match the configured priorities in the
pool, an empty server list is returned,
+ * which may cause queries to return partial or no data.
+ *
+ * Example configuration:
+ * druid.broker.select.tier=pooled
+ * druid.broker.select.tier.pooled.priorities=[2,1]
+ *
+ * With this configuration, servers with priority 2 and 1 are pooled together
and
+ * selection is delegated to the {@link ServerSelectorStrategy}. Servers with
other
+ * priorities are ignored.
+ */
+public class PooledTierSelectorStrategy extends AbstractTierSelectorStrategy
+{
+ private static final EmittingLogger log = new
EmittingLogger(PooledTierSelectorStrategy.class);
+ public static final String TYPE = "pooled";
+
+ private final ServerSelectorStrategy serverSelectorStrategy;
+ private final PooledTierSelectorStrategyConfig config;
+ private final ServiceEmitter emitter;
+ private final Set configuredPriorities;
+
+ @JsonCreator
+ public PooledTierSelectorStrategy(
+ @JacksonInject final ServerSelectorStrategy serverSelectorStrategy,
Review Comment:
nit: We could make ServerSelectorStrategy in AbstractTierSelectorStrategy
`protected`
--
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]
Re: [PR] Add `strict` and `pooled` Broker tier selector strategies (druid)
aho135 commented on code in PR #19094:
URL: https://github.com/apache/druid/pull/19094#discussion_r2908695095
##
server/src/main/java/org/apache/druid/client/selector/PooledTierSelectorStrategy.java:
##
@@ -0,0 +1,158 @@
+/*
+ * 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.client.selector;
+
+import com.fasterxml.jackson.annotation.JacksonInject;
+import com.fasterxml.jackson.annotation.JsonCreator;
+import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
+import it.unimi.dsi.fastutil.ints.Int2ObjectRBTreeMap;
+import org.apache.druid.client.QueryableDruidServer;
+import org.apache.druid.java.util.emitter.EmittingLogger;
+import org.apache.druid.java.util.emitter.service.ServiceEmitter;
+import org.apache.druid.java.util.emitter.service.ServiceMetricEvent;
+import org.apache.druid.query.Query;
+import org.apache.druid.query.metadata.metadata.SegmentMetadataQuery;
+import org.apache.druid.timeline.DataSegment;
+
+import javax.annotation.Nullable;
+import java.util.Comparator;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * A {@link TierSelectorStrategy} that pools servers with the configured set
of priorities from {@link PooledTierSelectorStrategyConfig#getPriorities()}
+ * and delegates server selection to the configured {@link
ServerSelectorStrategy}.
+ *
+ * Unlike other {@link TierSelectorStrategy} like {@link
CustomTierSelectorStrategy}
+ * which has a preference for priority order, this strategy treats all
configured priorities equally
+ * by combining their servers into a single selection pool and delegates to
{@link ServerSelectorStrategy} to do
+ * the server selection. If no servers match the configured priorities in the
pool, an empty server list is returned,
+ * which may cause queries to return partial or no data.
+ *
+ * Example configuration:
+ * druid.broker.select.tier=pooled
+ * druid.broker.select.tier.pooled.priorities=[2,1]
+ *
+ * With this configuration, servers with priority 2 and 1 are pooled together
and
+ * selection is delegated to the {@link ServerSelectorStrategy}. Servers with
other
+ * priorities are ignored.
+ */
+public class PooledTierSelectorStrategy extends AbstractTierSelectorStrategy
+{
+ private static final EmittingLogger log = new
EmittingLogger(PooledTierSelectorStrategy.class);
+ public static final String TYPE = "pooled";
+
+ private final ServerSelectorStrategy serverSelectorStrategy;
+ private final PooledTierSelectorStrategyConfig config;
+ private final ServiceEmitter emitter;
+ private final Set configuredPriorities;
+
+ @JsonCreator
+ public PooledTierSelectorStrategy(
+ @JacksonInject final ServerSelectorStrategy serverSelectorStrategy,
+ @JacksonInject final PooledTierSelectorStrategyConfig config,
+ @JacksonInject final ServiceEmitter emitter
+ )
+ {
+super(serverSelectorStrategy);
+this.serverSelectorStrategy = serverSelectorStrategy;
+this.config = config;
+this.emitter = emitter;
+this.configuredPriorities = config.getPriorities();
+ }
+
+ @Override
+ public List pick(
+ @Nullable final Query query,
+ final Int2ObjectRBTreeMap> prioritizedServers,
+ final DataSegment segment,
+ final int numServersToPick
+ )
+ {
+final Set candidateServerPool = new
LinkedHashSet<>();
+
+for (Int2ObjectMap.Entry> entry :
prioritizedServers.int2ObjectEntrySet()) {
+ final int priority = entry.getIntKey();
+ final Set servers = entry.getValue();
+
+ if (configuredPriorities.contains(priority)) {
+candidateServerPool.addAll(servers);
+ } else {
+log.debug(
+"Server priority[%d] not in the configured list of priorities[%s]
so ignore servers[%s] for query[%s]",
+priority, config.getPriorities(), servers, query
+);
+ }
+}
+
+if (candidateServerPool.isEmpty()) {
+ if (query == null || query instanceof SegmentMetadataQuery) {
+// Debug logging to reduce logging spam as these are typically
system-generated segment metadata queries
+log.debug(
+"No server found for query[%s] from server priorities[%s].
Configured priorities[
Re: [PR] Add `strict` and `pooled` Broker tier selector strategies (druid)
github-advanced-security[bot] commented on code in PR #19094:
URL: https://github.com/apache/druid/pull/19094#discussion_r2891595932
##
server/src/test/java/org/apache/druid/client/selector/TierSelectorStrategyTest.java:
##
@@ -568,4 +586,366 @@
preferredTierHighPriority, preferredTierLowPriority,
nonPreferredTierHighestPriority
);
}
+
+ @Test
+ public void testStrictTierSelectorStrategyAllConfigured()
+ {
+DirectDruidClient client = EasyMock.createMock(DirectDruidClient.class);
+QueryableDruidServer pNeg1 = new QueryableDruidServer(
+new DruidServer("test1", "localhost", null, 0, null,
ServerType.HISTORICAL, DruidServer.DEFAULT_TIER, -1),
+client
+);
+QueryableDruidServer p0 = new QueryableDruidServer(
+new DruidServer("test2", "localhost", null, 0, null,
ServerType.HISTORICAL, DruidServer.DEFAULT_TIER, 0),
+client
+);
+QueryableDruidServer p2 = new QueryableDruidServer(
+new DruidServer("test3", "localhost", null, 0, null,
ServerType.HISTORICAL, DruidServer.DEFAULT_TIER, 2),
+client
+);
+
+testTierSelectorStrategy(
+new StrictTierSelectorStrategy(
+new ConnectionCountServerSelectorStrategy(),
+new StrictTierSelectorStrategyConfig(List.of(2, 0, -1)),
+serviceEmitter
+),
+p2, p0, pNeg1
+);
+ }
+
+ @Test
+ public void testStrictTierSelectorStrategyNoMatchingPriorities()
+ {
+DirectDruidClient client = EasyMock.createMock(DirectDruidClient.class);
+QueryableDruidServer p0 = new QueryableDruidServer(
+new DruidServer("test1", "localhost", null, 0, null,
ServerType.INDEXER_EXECUTOR, DruidServer.DEFAULT_TIER, 0),
+client
+);
+QueryableDruidServer p1 = new QueryableDruidServer(
+new DruidServer("test2", "localhost", null, 0, null,
ServerType.INDEXER_EXECUTOR, DruidServer.DEFAULT_TIER, 1),
+client
+);
+QueryableDruidServer p2 = new QueryableDruidServer(
+new DruidServer("test3", "localhost", null, 0, null,
ServerType.INDEXER_EXECUTOR, DruidServer.DEFAULT_TIER, 2),
+client
+);
+
+final ServerSelector serverSelector = new ServerSelector(
+new DataSegment(
+"test",
+Intervals.of("2013-01-01/2013-01-02"),
+DateTimes.of("2013-01-01").toString(),
+new HashMap<>(),
+new ArrayList<>(),
+new ArrayList<>(),
+NoneShardSpec.instance(),
+0,
+0L
+),
Review Comment:
## Deprecated method or constructor invocation
Invoking [DataSegment.DataSegment](1) should be avoided because it has been
deprecated.
[Show more
details](https://github.com/apache/druid/security/code-scanning/10856)
##
server/src/test/java/org/apache/druid/client/selector/TierSelectorStrategyTest.java:
##
@@ -568,4 +586,366 @@
preferredTierHighPriority, preferredTierLowPriority,
nonPreferredTierHighestPriority
);
}
+
+ @Test
+ public void testStrictTierSelectorStrategyAllConfigured()
+ {
+DirectDruidClient client = EasyMock.createMock(DirectDruidClient.class);
+QueryableDruidServer pNeg1 = new QueryableDruidServer(
+new DruidServer("test1", "localhost", null, 0, null,
ServerType.HISTORICAL, DruidServer.DEFAULT_TIER, -1),
+client
+);
+QueryableDruidServer p0 = new QueryableDruidServer(
+new DruidServer("test2", "localhost", null, 0, null,
ServerType.HISTORICAL, DruidServer.DEFAULT_TIER, 0),
+client
+);
+QueryableDruidServer p2 = new QueryableDruidServer(
+new DruidServer("test3", "localhost", null, 0, null,
ServerType.HISTORICAL, DruidServer.DEFAULT_TIER, 2),
+client
+);
+
+testTierSelectorStrategy(
+new StrictTierSelectorStrategy(
+new ConnectionCountServerSelectorStrategy(),
+new StrictTierSelectorStrategyConfig(List.of(2, 0, -1)),
+serviceEmitter
+),
+p2, p0, pNeg1
+);
+ }
+
+ @Test
+ public void testStrictTierSelectorStrategyNoMatchingPriorities()
+ {
+DirectDruidClient client = EasyMock.createMock(DirectDruidClient.class);
+QueryableDruidServer p0 = new QueryableDruidServer(
+new DruidServer("test1", "localhost", null, 0, null,
ServerType.INDEXER_EXECUTOR, DruidServer.DEFAULT_TIER, 0),
+client
+);
+QueryableDruidServer p1 = new QueryableDruidServer(
+new DruidServer("test2", "localhost", null, 0, null,
ServerType.INDEXER_EXECUTOR, DruidServer.DEFAULT_TIER, 1),
+client
+);
+QueryableDruidServer p2 = new QueryableDruidServer(
+new DruidServer("test3", "localhost", null, 0, null,
ServerType.INDEXER_EXECUTOR, DruidServer.DEFAULT_TIER, 2),
+client
+);
+
+final ServerSelector serverSelector = new ServerSelector(
+new DataSegment(
+"test",
+Intervals.of("20
