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 2021/06/14 07:11:25 UTC

[GitHub] [incubator-pinot] Jackie-Jiang commented on a change in pull request #7046: Add utility to convert configs from IndexingConfig to the new IngestionConfig.

Jackie-Jiang commented on a change in pull request #7046:
URL: https://github.com/apache/incubator-pinot/pull/7046#discussion_r649624131



##########
File path: pinot-common/src/main/java/org/apache/pinot/common/utils/config/TableConfigUtils.java
##########
@@ -212,4 +215,54 @@ public static ZNRecord toZNRecord(TableConfig tableConfig)
     znRecord.setSimpleFields(simpleFields);
     return znRecord;
   }
+
+  /**
+   * Helper method to convert from indexingConfig (that is deprecated) to ingestionConfig.

Review comment:
       `indexingConfig` is not deprecated, only the ingestion related configs.

##########
File path: pinot-common/src/main/java/org/apache/pinot/common/utils/config/TableConfigUtils.java
##########
@@ -212,4 +215,54 @@ public static ZNRecord toZNRecord(TableConfig tableConfig)
     znRecord.setSimpleFields(simpleFields);
     return znRecord;
   }
+
+  /**
+   * Helper method to convert from indexingConfig (that is deprecated) to ingestionConfig.
+   * Since we are moving from indexingConfig to ingestionConfig for ingestion related configs,
+   * this utility helps with that migration. It also handles corner cases where both these
+   * configs might exist, in which case ingestionConfig takes precedence, and only required
+   * fields absent there are carried over from indexingConfig.
+   *
+   * The conversion happens in-place, the specified tableConfig is mutated in-place.
+   *
+   * @param tableConfig Input table config.
+   */
+  public static void convertFromIndexToIngestionConfig(TableConfig tableConfig) {
+    IndexingConfig indexingConfig = tableConfig.getIndexingConfig();

Review comment:
       (nit) Inline this into line 256

##########
File path: pinot-common/src/main/java/org/apache/pinot/common/utils/config/TableConfigUtils.java
##########
@@ -212,4 +215,54 @@ public static ZNRecord toZNRecord(TableConfig tableConfig)
     znRecord.setSimpleFields(simpleFields);
     return znRecord;
   }
+
+  /**
+   * Helper method to convert from indexingConfig (that is deprecated) to ingestionConfig.

Review comment:
       It also collects ingestion related configs from the validation config

##########
File path: pinot-common/src/main/java/org/apache/pinot/common/utils/config/TableConfigUtils.java
##########
@@ -212,4 +215,54 @@ public static ZNRecord toZNRecord(TableConfig tableConfig)
     znRecord.setSimpleFields(simpleFields);
     return znRecord;
   }
+
+  /**
+   * Helper method to convert from indexingConfig (that is deprecated) to ingestionConfig.
+   * Since we are moving from indexingConfig to ingestionConfig for ingestion related configs,
+   * this utility helps with that migration. It also handles corner cases where both these
+   * configs might exist, in which case ingestionConfig takes precedence, and only required
+   * fields absent there are carried over from indexingConfig.
+   *
+   * The conversion happens in-place, the specified tableConfig is mutated in-place.
+   *
+   * @param tableConfig Input table config.
+   */
+  public static void convertFromIndexToIngestionConfig(TableConfig tableConfig) {

Review comment:
       Shall we rename it to `convertFromLegacyTableConfig`? We can keep updating this method when we need to deprecate certain configs

##########
File path: pinot-common/src/main/java/org/apache/pinot/common/utils/config/TableConfigUtils.java
##########
@@ -212,4 +215,54 @@ public static ZNRecord toZNRecord(TableConfig tableConfig)
     znRecord.setSimpleFields(simpleFields);
     return znRecord;
   }
+
+  /**
+   * Helper method to convert from indexingConfig (that is deprecated) to ingestionConfig.
+   * Since we are moving from indexingConfig to ingestionConfig for ingestion related configs,
+   * this utility helps with that migration. It also handles corner cases where both these
+   * configs might exist, in which case ingestionConfig takes precedence, and only required
+   * fields absent there are carried over from indexingConfig.
+   *
+   * The conversion happens in-place, the specified tableConfig is mutated in-place.
+   *
+   * @param tableConfig Input table config.
+   */
+  public static void convertFromIndexToIngestionConfig(TableConfig tableConfig) {
+    IndexingConfig indexingConfig = tableConfig.getIndexingConfig();
+
+    // It is possible that indexing as well as ingestion configs exist, in which case we always honor ingestion config.
+    IngestionConfig ingestionConfig = tableConfig.getIngestionConfig();
+    BatchIngestionConfig batchIngestionConfig =
+        (ingestionConfig != null) ? ingestionConfig.getBatchIngestionConfig() : null;
+
+    SegmentsValidationAndRetentionConfig validationConfig = tableConfig.getValidationConfig();
+    if (batchIngestionConfig == null) {
+      batchIngestionConfig = new BatchIngestionConfig(null, validationConfig.getSegmentPushType(),
+          validationConfig.getSegmentPushFrequency());
+    } else {
+      // This should not happen typically, but since we are in repair mode, might as well cover this corner case.
+      if (batchIngestionConfig.getSegmentIngestionType() == null) {
+        batchIngestionConfig.setSegmentIngestionType(validationConfig.getSegmentPushType());
+      }
+
+      if (batchIngestionConfig.getSegmentIngestionFrequency() == null) {
+        batchIngestionConfig.setSegmentIngestionFrequency(validationConfig.getSegmentPushFrequency());
+      }
+    }
+
+    StreamIngestionConfig streamIngestionConfig =
+        (ingestionConfig != null) ? ingestionConfig.getStreamIngestionConfig() : null;
+    if (streamIngestionConfig == null) {
+      streamIngestionConfig = new StreamIngestionConfig(Collections.singletonList(indexingConfig.getStreamConfigs()));
+    }
+
+    if (ingestionConfig == null) {
+      ingestionConfig = new IngestionConfig(batchIngestionConfig, streamIngestionConfig, null, null, null);
+    } else {
+      ingestionConfig.setBatchIngestionConfig(batchIngestionConfig);
+      ingestionConfig.setStreamIngestionConfig(streamIngestionConfig);
+    }
+
+    tableConfig.setIngestionConfig(ingestionConfig);

Review comment:
       We should also remove the deprecated configs if exist

##########
File path: pinot-common/src/test/java/org/apache/pinot/common/utils/config/TableConfigUtilsTest.java
##########
@@ -0,0 +1,150 @@
+/**
+ * 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.utils.config;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+import org.apache.pinot.spi.config.table.TableConfig;
+import org.apache.pinot.spi.config.table.TableType;
+import org.apache.pinot.spi.config.table.ingestion.BatchIngestionConfig;
+import org.apache.pinot.spi.data.readers.GenericRow;
+import org.apache.pinot.spi.stream.PartitionLevelConsumer;
+import org.apache.pinot.spi.stream.StreamConfig;
+import org.apache.pinot.spi.stream.StreamConfigProperties;
+import org.apache.pinot.spi.stream.StreamConsumerFactory;
+import org.apache.pinot.spi.stream.StreamLevelConsumer;
+import org.apache.pinot.spi.stream.StreamMessageDecoder;
+import org.apache.pinot.spi.stream.StreamMetadataProvider;
+import org.apache.pinot.spi.utils.builder.TableConfigBuilder;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+
+/**
+ * Unit test for {@link TableConfigUtils} class.
+ */
+public class TableConfigUtilsTest {
+
+  private static final String TABLE_NAME = "testTable";
+
+  /**
+   * Test the {@link TableConfigUtils#convertFromLegacyTableConfig(TableConfig)} utility.
+   * <ul>
+   *   <li>Creates a Table Config setting deprecated fields in Indexing Config.</li>
+   *   <li>Asserts that the utility can convert these fields into Ingestion Config.</li>
+   * </ul>
+   */
+  @Test
+  public void testIndexToIngestionConfigConversion() {

Review comment:
       Change the test name

##########
File path: pinot-common/src/main/java/org/apache/pinot/common/utils/config/TableConfigUtils.java
##########
@@ -212,4 +215,54 @@ public static ZNRecord toZNRecord(TableConfig tableConfig)
     znRecord.setSimpleFields(simpleFields);
     return znRecord;
   }
+
+  /**
+   * Helper method to convert from indexingConfig (that is deprecated) to ingestionConfig.
+   * Since we are moving from indexingConfig to ingestionConfig for ingestion related configs,
+   * this utility helps with that migration. It also handles corner cases where both these
+   * configs might exist, in which case ingestionConfig takes precedence, and only required
+   * fields absent there are carried over from indexingConfig.
+   *
+   * The conversion happens in-place, the specified tableConfig is mutated in-place.
+   *
+   * @param tableConfig Input table config.
+   */
+  public static void convertFromIndexToIngestionConfig(TableConfig tableConfig) {
+    IndexingConfig indexingConfig = tableConfig.getIndexingConfig();
+
+    // It is possible that indexing as well as ingestion configs exist, in which case we always honor ingestion config.
+    IngestionConfig ingestionConfig = tableConfig.getIngestionConfig();
+    BatchIngestionConfig batchIngestionConfig =
+        (ingestionConfig != null) ? ingestionConfig.getBatchIngestionConfig() : null;
+
+    SegmentsValidationAndRetentionConfig validationConfig = tableConfig.getValidationConfig();
+    if (batchIngestionConfig == null) {
+      batchIngestionConfig = new BatchIngestionConfig(null, validationConfig.getSegmentPushType(),
+          validationConfig.getSegmentPushFrequency());
+    } else {
+      // This should not happen typically, but since we are in repair mode, might as well cover this corner case.
+      if (batchIngestionConfig.getSegmentIngestionType() == null) {
+        batchIngestionConfig.setSegmentIngestionType(validationConfig.getSegmentPushType());
+      }
+
+      if (batchIngestionConfig.getSegmentIngestionFrequency() == null) {
+        batchIngestionConfig.setSegmentIngestionFrequency(validationConfig.getSegmentPushFrequency());
+      }
+    }
+
+    StreamIngestionConfig streamIngestionConfig =
+        (ingestionConfig != null) ? ingestionConfig.getStreamIngestionConfig() : null;
+    if (streamIngestionConfig == null) {
+      streamIngestionConfig = new StreamIngestionConfig(Collections.singletonList(indexingConfig.getStreamConfigs()));
+    }
+
+    if (ingestionConfig == null) {
+      ingestionConfig = new IngestionConfig(batchIngestionConfig, streamIngestionConfig, null, null, null);
+    } else {
+      ingestionConfig.setBatchIngestionConfig(batchIngestionConfig);
+      ingestionConfig.setStreamIngestionConfig(streamIngestionConfig);
+    }
+
+    tableConfig.setIngestionConfig(ingestionConfig);

Review comment:
       The callers should use `IngestionConfigUtils` to read the config. Let's at least add a TODO here to do the cleanup.
   We should clean up the old configs because I believe this PR is for the auto-tuning feature which will modify certain configs. If we don't clean up the old configs, there will be inconsistency between old and new config, which will cause confusion.




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

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