klsince commented on code in PR #11847:
URL: https://github.com/apache/pinot/pull/11847#discussion_r1367558654


##########
pinot-broker/src/main/java/org/apache/pinot/broker/routing/instanceselector/FallbackReplicaGroupInstanceSelector.java:
##########
@@ -0,0 +1,428 @@
+/**
+ * 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.broker.routing.instanceselector;
+
+import java.time.Clock;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeSet;
+import java.util.stream.Collectors;
+import javax.annotation.Nullable;
+import org.apache.commons.lang3.tuple.Pair;
+import org.apache.helix.model.ExternalView;
+import org.apache.helix.model.IdealState;
+import org.apache.helix.store.zk.ZkHelixPropertyStore;
+import org.apache.helix.zookeeper.datamodel.ZNRecord;
+import 
org.apache.pinot.broker.routing.adaptiveserverselector.AdaptiveServerSelector;
+import org.apache.pinot.common.metrics.BrokerMetrics;
+import org.apache.pinot.common.request.BrokerRequest;
+import org.apache.pinot.common.utils.HashUtil;
+import org.apache.pinot.common.utils.config.QueryOptionsUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * This extends the default strictReplicaGroup policy to allow fallback. When 
using default strictReplicaGroup policy,
+ * if none of replica groups have all segments available in it, all segments 
are marked as unavailable, which is very
+ * strict and makes queries less available. In this new policy, we allow to 
fall back to a replica group in that
+ * case, even though the selected replica group might have some segments 
unavailable. As strictReplicaGroup, all the
+ * remaining available segments are processed in the same replica group.
+ */
+public class FallbackReplicaGroupInstanceSelector extends BaseInstanceSelector 
{
+  private static final Logger LOGGER = 
LoggerFactory.getLogger(FallbackReplicaGroupInstanceSelector.class);
+  private final Map<Set<String>, InstanceGroup> _instanceGroups = new 
HashMap<>();

Review Comment:
   InstanceGroup is a key concept here. It is a set of the replica instances 
hosting a group of segments, e.g. segment[0-10] are kept on instance[0-2] (i.e. 
3 replicas for those segments), then the InstanceGroup is (instance0/1/2) with 
each instance hosting all segment[0-10].
   
   The major change is to keep available/unavailable segments for every 
instance in a InstanceGroup, to allow us to dynamically select an instance from 
the InstanceGroup for its available segments, and report the unavailable 
segments from the selected instance.



-- 
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]

Reply via email to