You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by GitBox <gi...@apache.org> on 2022/10/14 21:49:00 UTC

[GitHub] [pinot] klsince commented on a diff in pull request #9598: add SegmentTierAssigner and refine restful APIs to get segment tier info

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


##########
pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/relocation/SegmentTierAssigner.java:
##########
@@ -0,0 +1,112 @@
+/**
+ * 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.relocation;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Preconditions;
+import java.util.Collections;
+import java.util.List;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.helix.zookeeper.datamodel.ZNRecord;
+import org.apache.pinot.common.metadata.segment.SegmentZKMetadata;
+import org.apache.pinot.common.metrics.ControllerMetrics;
+import org.apache.pinot.common.tier.Tier;
+import org.apache.pinot.common.tier.TierSegmentSelector;
+import org.apache.pinot.common.utils.config.TierConfigUtils;
+import org.apache.pinot.controller.ControllerConf;
+import org.apache.pinot.controller.LeadControllerManager;
+import org.apache.pinot.controller.helix.core.PinotHelixResourceManager;
+import org.apache.pinot.controller.helix.core.periodictask.ControllerPeriodicTask;
+import org.apache.pinot.spi.config.table.TableConfig;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * Periodic task to calculate the target tier the segment belongs to and set it into segment ZK metadata as goal
+ * state, which can be checked by servers when loading the segment to put it onto the target storage tier.
+ */
+public class SegmentTierAssigner extends ControllerPeriodicTask<Void> {
+  private static final Logger LOGGER = LoggerFactory.getLogger(SegmentTierAssigner.class);
+
+  public SegmentTierAssigner(PinotHelixResourceManager pinotHelixResourceManager,
+      LeadControllerManager leadControllerManager, ControllerConf config, ControllerMetrics controllerMetrics) {
+    super(SegmentTierAssigner.class.getSimpleName(), config.getSegmentTierAssignerFrequencyInSeconds(),
+        config.getSegmentTierAssignerInitialDelayInSeconds(), pinotHelixResourceManager, leadControllerManager,
+        controllerMetrics);
+  }
+
+  @Override
+  protected void processTable(String tableNameWithType) {
+    TableConfig tableConfig = _pinotHelixResourceManager.getTableConfig(tableNameWithType);
+    Preconditions.checkState(tableConfig != null, "Failed to find table config for table: {}", tableNameWithType);
+    List<Tier> sortedTiers;
+    if (CollectionUtils.isEmpty(tableConfig.getTierConfigsList())) {
+      LOGGER.info("No tierConfigs so use default tier for segments of table: {}", tableNameWithType);

Review Comment:
   I thought to continue instead returning, so that one can move all data back to default tier by simply deleting the tierConfigs from the tableConfig. Otherwise, to rollback, one has to explicitly set tierConfigs properly move things back to default tier.
   
   Either this INFO log and or the one at L64 is printed for each table when this task kicks in. It'd be flooding if the cluster has a large number of tables but the task kicks in every 1hr (but I'll make it 24hr).



-- 
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-unsubscribe@pinot.apache.org

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


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