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


##########
pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/assignment/segment/StrictRealtimeSegmentAssignment.java:
##########
@@ -0,0 +1,108 @@
+/**
+ * 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.controller.helix.core.assignment.segment;
+
+import com.google.common.base.Preconditions;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import org.apache.pinot.common.assignment.InstancePartitions;
+import org.apache.pinot.common.utils.LLCSegmentName;
+import org.apache.pinot.spi.config.table.assignment.InstancePartitionsType;
+
+
+/**
+ * Segment assignment for LLC real-time table using upsert. The 
assignSegment() of RealtimeSegmentAssignment is
+ * overridden to add new segment for a table partition in a way that's 
consistent with the assignment in idealState to
+ * make sure that at any time the segments from the same table partition is 
hosted by the same server.
+ * <ul>
+ *   <li>
+ *     For the CONSUMING segments, in addition to what's done in 
RealtimeSegmentAssignment, the assignment has to be
+ *     checked if it's consistent with the current idealState. If the 
assignment calculated according to the
+ *     InstancePartition and the one in idealState are different, the one in 
idealState must be used so that segments
+ *     from the same table partition are always hosted on the same server as 
set in current idealState. If the
+ *     idealState is not honored, segments from the same table partition may 
be assigned to different servers,
+ *     breaking the key assumption for queries to be correct for the table 
using upsert.
+ *   </li>
+ *   <li>
+ *     There is no need to handle COMPLETED segments for tables using upsert, 
because their completed segments should
+ *     not be relocated to servers tagged to host COMPLETED segments. 
Basically, upsert-enabled tables can only use
+ *     servers tagged for CONSUMING segments to host both consuming and 
completed segments from a table partition.
+ *   </li>
+ * </ul>
+ */
+public class StrictRealtimeSegmentAssignment extends RealtimeSegmentAssignment 
{
+
+  @Override
+  public List<String> assignSegment(String segmentName, Map<String, 
Map<String, String>> currentAssignment,
+      Map<InstancePartitionsType, InstancePartitions> instancePartitionsMap) {
+    Preconditions.checkState(instancePartitionsMap.size() == 1, "One instance 
partition type should be provided");
+    Map.Entry<InstancePartitionsType, InstancePartitions> 
typeToInstancePartitions =
+        instancePartitionsMap.entrySet().iterator().next();
+    InstancePartitionsType instancePartitionsType = 
typeToInstancePartitions.getKey();
+    InstancePartitions instancePartitions = 
typeToInstancePartitions.getValue();
+    Preconditions.checkState(instancePartitionsType == 
InstancePartitionsType.CONSUMING,

Review Comment:
   You mean uploading segments to COMPLETED servers? Then how does consuming 
server update the validDocId bitmaps for the uploaded segments over there



-- 
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: commits-unsubscr...@pinot.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org
For additional commands, e-mail: commits-h...@pinot.apache.org

Reply via email to