npawar commented on a change in pull request #8389:
URL: https://github.com/apache/pinot/pull/8389#discussion_r833585264



##########
File path: 
pinot-common/src/main/java/org/apache/pinot/common/tier/FixedTierSegmentSelector.java
##########
@@ -0,0 +1,82 @@
+/**
+ * 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.common.tier;
+
+import com.google.common.base.Preconditions;
+import java.util.List;
+import javax.annotation.Nullable;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.helix.HelixManager;
+import org.apache.pinot.common.metadata.ZKMetadataProvider;
+import org.apache.pinot.common.metadata.segment.SegmentZKMetadata;
+import org.apache.pinot.spi.config.table.TableType;
+import org.apache.pinot.spi.utils.CommonConstants.Segment.Realtime;
+import org.apache.pinot.spi.utils.builder.TableNameBuilder;
+
+
+/**
+ * A {@link TierSegmentSelector} strategy which selects segments for a tier 
based on a fixed list
+ */
+public class FixedTierSegmentSelector implements TierSegmentSelector {
+  private final List<String> _segmentList;
+  private final HelixManager _helixManager;
+
+  public FixedTierSegmentSelector(HelixManager helixManager, @Nullable 
List<String> segmentList) {
+    _segmentList = segmentList;
+    _helixManager = helixManager;
+  }
+
+  @Override
+  public String getType() {
+    return TierFactory.FIXED_SEGMENT_SELECTOR_TYPE;
+  }
+
+  /**
+   * Checks if a segment is eligible for the tier based on fixed list
+   * @param tableNameWithType Name of the table
+   * @param segmentName Name of the segment
+   * @return true if eligible
+   */
+  @Override
+  public boolean selectSegment(String tableNameWithType, String segmentName) {
+    if (CollectionUtils.isNotEmpty(_segmentList) && 
_segmentList.contains(segmentName)) {
+      if (TableType.OFFLINE == 
TableNameBuilder.getTableTypeFromTableName(tableNameWithType)) {
+        return true;
+      }
+
+      SegmentZKMetadata segmentZKMetadata =
+          
ZKMetadataProvider.getSegmentZKMetadata(_helixManager.getHelixPropertyStore(), 
tableNameWithType,
+              segmentName);
+      Preconditions.checkNotNull(segmentZKMetadata, "Could not find zk 
metadata for segment: {} of table: {}",
+          segmentName, tableNameWithType);
+      return segmentZKMetadata.getStatus().equals(Realtime.Status.DONE);

Review comment:
       you're right, changed it to look for !IN_PROGRESS




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