[GitHub] [hudi] zhangyue19921010 commented on a change in pull request #4721: [HUDI-3320] Hoodie metadata table validator
zhangyue19921010 commented on a change in pull request #4721: URL: https://github.com/apache/hudi/pull/4721#discussion_r799940766 ## File path: hudi-utilities/src/main/java/org/apache/hudi/utilities/HoodieMetadataTableValidator.java ## @@ -0,0 +1,506 @@ +/* + * 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.hudi.utilities; + +import com.beust.jcommander.JCommander; +import com.beust.jcommander.Parameter; +import org.apache.hadoop.fs.Path; +import org.apache.hudi.async.HoodieAsyncService; +import org.apache.hudi.client.common.HoodieSparkEngineContext; +import org.apache.hudi.common.config.HoodieMetadataConfig; +import org.apache.hudi.common.config.TypedProperties; +import org.apache.hudi.common.fs.FSUtils; +import org.apache.hudi.common.model.FileSlice; +import org.apache.hudi.common.model.HoodieBaseFile; +import org.apache.hudi.common.model.HoodieFileGroup; +import org.apache.hudi.common.table.HoodieTableMetaClient; +import org.apache.hudi.common.table.view.FileSystemViewManager; +import org.apache.hudi.common.table.view.HoodieTableFileSystemView; +import org.apache.hudi.common.util.Option; +import org.apache.hudi.common.util.collection.Pair; +import org.apache.hudi.exception.HoodieException; +import org.apache.hudi.exception.HoodieValidationException; + +import org.apache.log4j.LogManager; +import org.apache.log4j.Logger; +import org.apache.spark.SparkConf; +import org.apache.spark.api.java.JavaSparkContext; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.List; +import java.util.Objects; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.stream.Collectors; + +/** + * A validator with spark-submit to compare list partitions and list files between metadata table and filesystem. + * + * + * - Default : This validator will compare the result of listing partitions/listing files between metadata table and filesystem only once. + * + * Example command: + * ``` + * spark-submit \ + * --class org.apache.hudi.utilities.HoodieMetadataTableValidator \ + * --packages org.apache.spark:spark-avro_2.11:2.4.4 \ + * --master spark://:7077 \ + * --driver-memory 1g \ + * --executor-memory 1g \ + * $HUDI_DIR/hudi/packaging/hudi-utilities-bundle/target/hudi-utilities-bundle_2.11-0.11.0-SNAPSHOT.jar \ + * --base-path basePath \ + * --validate-latest-fileSlices \ + * --validate-latest-baseFiles \ + * --validate-all-file-groups \ + * ``` + * + * + * Also You can set `--continuous` for long running this validator. + * And use `--min-validate-interval-seconds` to control the validation frequency, default is 10 minutes. + * + * Example command: + * ``` + * spark-submit \ + * --class org.apache.hudi.utilities.HoodieMetadataTableValidator \ + * --packages org.apache.spark:spark-avro_2.11:2.4.4 \ + * --master spark://:7077 \ + * --driver-memory 1g \ + * --executor-memory 1g \ + * $HUDI_DIR/hudi/packaging/hudi-utilities-bundle/target/hudi-utilities-bundle_2.11-0.11.0-SNAPSHOT.jar \ + * --base-path basePath \ + * --validate-latest-fileSlices \ + * --validate-latest-baseFiles \ + * --validate-all-file-groups \ + * --continuous \ + * --min-validate-interval-seconds 60 \ + * ``` + * + */ +public class HoodieMetadataTableValidator { + + private static final Logger LOG = LogManager.getLogger(HoodieMetadataTableValidator.class); + + // Spark context + private transient JavaSparkContext jsc; + // config + private Config cfg; + // Properties with source, hoodie client, key generator etc. + private TypedProperties props; + + private HoodieTableMetaClient metaClient; + + protected transient Option asyncMetadataTableValidateService; + + public HoodieMetadataTableValidator(HoodieTableMetaClient metaClient) { +this.metaClient = metaClient; + } + + public HoodieMetadataTableValidator(JavaSparkContext jsc, Config cfg) { +this.jsc = jsc; +this.cfg = cfg; + +this.props = cfg.propsFilePath == null +? UtilHelpers.buildProperties(cfg.configs) +: readConfigFromFileSystem(jsc, cfg); + +this.metaClient = HoodieTa
[GitHub] [hudi] zhangyue19921010 commented on a change in pull request #4721: [HUDI-3320] Hoodie metadata table validator
zhangyue19921010 commented on a change in pull request #4721: URL: https://github.com/apache/hudi/pull/4721#discussion_r799940716 ## File path: hudi-utilities/src/main/java/org/apache/hudi/utilities/HoodieMetadataTableValidator.java ## @@ -0,0 +1,506 @@ +/* + * 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.hudi.utilities; + +import com.beust.jcommander.JCommander; +import com.beust.jcommander.Parameter; +import org.apache.hadoop.fs.Path; +import org.apache.hudi.async.HoodieAsyncService; +import org.apache.hudi.client.common.HoodieSparkEngineContext; +import org.apache.hudi.common.config.HoodieMetadataConfig; +import org.apache.hudi.common.config.TypedProperties; +import org.apache.hudi.common.fs.FSUtils; +import org.apache.hudi.common.model.FileSlice; +import org.apache.hudi.common.model.HoodieBaseFile; +import org.apache.hudi.common.model.HoodieFileGroup; +import org.apache.hudi.common.table.HoodieTableMetaClient; +import org.apache.hudi.common.table.view.FileSystemViewManager; +import org.apache.hudi.common.table.view.HoodieTableFileSystemView; +import org.apache.hudi.common.util.Option; +import org.apache.hudi.common.util.collection.Pair; +import org.apache.hudi.exception.HoodieException; +import org.apache.hudi.exception.HoodieValidationException; + +import org.apache.log4j.LogManager; +import org.apache.log4j.Logger; +import org.apache.spark.SparkConf; +import org.apache.spark.api.java.JavaSparkContext; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.List; +import java.util.Objects; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.stream.Collectors; + +/** + * A validator with spark-submit to compare list partitions and list files between metadata table and filesystem. + * + * + * - Default : This validator will compare the result of listing partitions/listing files between metadata table and filesystem only once. + * + * Example command: + * ``` + * spark-submit \ + * --class org.apache.hudi.utilities.HoodieMetadataTableValidator \ + * --packages org.apache.spark:spark-avro_2.11:2.4.4 \ + * --master spark://:7077 \ + * --driver-memory 1g \ + * --executor-memory 1g \ + * $HUDI_DIR/hudi/packaging/hudi-utilities-bundle/target/hudi-utilities-bundle_2.11-0.11.0-SNAPSHOT.jar \ + * --base-path basePath \ + * --validate-latest-fileSlices \ + * --validate-latest-baseFiles \ + * --validate-all-file-groups \ + * ``` + * + * + * Also You can set `--continuous` for long running this validator. + * And use `--min-validate-interval-seconds` to control the validation frequency, default is 10 minutes. + * + * Example command: + * ``` + * spark-submit \ + * --class org.apache.hudi.utilities.HoodieMetadataTableValidator \ + * --packages org.apache.spark:spark-avro_2.11:2.4.4 \ + * --master spark://:7077 \ + * --driver-memory 1g \ + * --executor-memory 1g \ + * $HUDI_DIR/hudi/packaging/hudi-utilities-bundle/target/hudi-utilities-bundle_2.11-0.11.0-SNAPSHOT.jar \ + * --base-path basePath \ + * --validate-latest-fileSlices \ + * --validate-latest-baseFiles \ + * --validate-all-file-groups \ + * --continuous \ + * --min-validate-interval-seconds 60 \ + * ``` + * + */ +public class HoodieMetadataTableValidator { + + private static final Logger LOG = LogManager.getLogger(HoodieMetadataTableValidator.class); + + // Spark context + private transient JavaSparkContext jsc; + // config + private Config cfg; + // Properties with source, hoodie client, key generator etc. + private TypedProperties props; + + private HoodieTableMetaClient metaClient; + + protected transient Option asyncMetadataTableValidateService; + + public HoodieMetadataTableValidator(HoodieTableMetaClient metaClient) { +this.metaClient = metaClient; + } + + public HoodieMetadataTableValidator(JavaSparkContext jsc, Config cfg) { +this.jsc = jsc; +this.cfg = cfg; + +this.props = cfg.propsFilePath == null +? UtilHelpers.buildProperties(cfg.configs) +: readConfigFromFileSystem(jsc, cfg); + +this.metaClient = HoodieTa
[GitHub] [hudi] zhangyue19921010 commented on a change in pull request #4721: [HUDI-3320] Hoodie metadata table validator
zhangyue19921010 commented on a change in pull request #4721: URL: https://github.com/apache/hudi/pull/4721#discussion_r799940426 ## File path: hudi-utilities/src/main/java/org/apache/hudi/utilities/HoodieMetadataTableValidator.java ## @@ -0,0 +1,506 @@ +/* + * 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.hudi.utilities; + +import com.beust.jcommander.JCommander; +import com.beust.jcommander.Parameter; +import org.apache.hadoop.fs.Path; +import org.apache.hudi.async.HoodieAsyncService; +import org.apache.hudi.client.common.HoodieSparkEngineContext; +import org.apache.hudi.common.config.HoodieMetadataConfig; +import org.apache.hudi.common.config.TypedProperties; +import org.apache.hudi.common.fs.FSUtils; +import org.apache.hudi.common.model.FileSlice; +import org.apache.hudi.common.model.HoodieBaseFile; +import org.apache.hudi.common.model.HoodieFileGroup; +import org.apache.hudi.common.table.HoodieTableMetaClient; +import org.apache.hudi.common.table.view.FileSystemViewManager; +import org.apache.hudi.common.table.view.HoodieTableFileSystemView; +import org.apache.hudi.common.util.Option; +import org.apache.hudi.common.util.collection.Pair; +import org.apache.hudi.exception.HoodieException; +import org.apache.hudi.exception.HoodieValidationException; + +import org.apache.log4j.LogManager; +import org.apache.log4j.Logger; +import org.apache.spark.SparkConf; +import org.apache.spark.api.java.JavaSparkContext; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.List; +import java.util.Objects; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.stream.Collectors; + +/** + * A validator with spark-submit to compare list partitions and list files between metadata table and filesystem. + * + * + * - Default : This validator will compare the result of listing partitions/listing files between metadata table and filesystem only once. + * + * Example command: + * ``` + * spark-submit \ + * --class org.apache.hudi.utilities.HoodieMetadataTableValidator \ + * --packages org.apache.spark:spark-avro_2.11:2.4.4 \ + * --master spark://:7077 \ + * --driver-memory 1g \ + * --executor-memory 1g \ + * $HUDI_DIR/hudi/packaging/hudi-utilities-bundle/target/hudi-utilities-bundle_2.11-0.11.0-SNAPSHOT.jar \ + * --base-path basePath \ + * --validate-latest-fileSlices \ + * --validate-latest-baseFiles \ + * --validate-all-file-groups \ + * ``` + * + * + * Also You can set `--continuous` for long running this validator. + * And use `--min-validate-interval-seconds` to control the validation frequency, default is 10 minutes. + * + * Example command: + * ``` + * spark-submit \ + * --class org.apache.hudi.utilities.HoodieMetadataTableValidator \ + * --packages org.apache.spark:spark-avro_2.11:2.4.4 \ + * --master spark://:7077 \ + * --driver-memory 1g \ + * --executor-memory 1g \ + * $HUDI_DIR/hudi/packaging/hudi-utilities-bundle/target/hudi-utilities-bundle_2.11-0.11.0-SNAPSHOT.jar \ + * --base-path basePath \ + * --validate-latest-fileSlices \ + * --validate-latest-baseFiles \ + * --validate-all-file-groups \ + * --continuous \ + * --min-validate-interval-seconds 60 \ + * ``` + * + */ +public class HoodieMetadataTableValidator { + + private static final Logger LOG = LogManager.getLogger(HoodieMetadataTableValidator.class); + + // Spark context + private transient JavaSparkContext jsc; + // config + private Config cfg; + // Properties with source, hoodie client, key generator etc. + private TypedProperties props; + + private HoodieTableMetaClient metaClient; + + protected transient Option asyncMetadataTableValidateService; + + public HoodieMetadataTableValidator(HoodieTableMetaClient metaClient) { +this.metaClient = metaClient; + } + + public HoodieMetadataTableValidator(JavaSparkContext jsc, Config cfg) { +this.jsc = jsc; +this.cfg = cfg; + +this.props = cfg.propsFilePath == null +? UtilHelpers.buildProperties(cfg.configs) +: readConfigFromFileSystem(jsc, cfg); + +this.metaClient = HoodieTa
[GitHub] [hudi] zhangyue19921010 commented on a change in pull request #4721: [HUDI-3320] Hoodie metadata table validator
zhangyue19921010 commented on a change in pull request #4721: URL: https://github.com/apache/hudi/pull/4721#discussion_r799940151 ## File path: hudi-utilities/src/main/java/org/apache/hudi/utilities/HoodieMetadataTableValidator.java ## @@ -0,0 +1,506 @@ +/* + * 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.hudi.utilities; + +import com.beust.jcommander.JCommander; +import com.beust.jcommander.Parameter; +import org.apache.hadoop.fs.Path; +import org.apache.hudi.async.HoodieAsyncService; +import org.apache.hudi.client.common.HoodieSparkEngineContext; +import org.apache.hudi.common.config.HoodieMetadataConfig; +import org.apache.hudi.common.config.TypedProperties; +import org.apache.hudi.common.fs.FSUtils; +import org.apache.hudi.common.model.FileSlice; +import org.apache.hudi.common.model.HoodieBaseFile; +import org.apache.hudi.common.model.HoodieFileGroup; +import org.apache.hudi.common.table.HoodieTableMetaClient; +import org.apache.hudi.common.table.view.FileSystemViewManager; +import org.apache.hudi.common.table.view.HoodieTableFileSystemView; +import org.apache.hudi.common.util.Option; +import org.apache.hudi.common.util.collection.Pair; +import org.apache.hudi.exception.HoodieException; +import org.apache.hudi.exception.HoodieValidationException; + +import org.apache.log4j.LogManager; +import org.apache.log4j.Logger; +import org.apache.spark.SparkConf; +import org.apache.spark.api.java.JavaSparkContext; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.List; +import java.util.Objects; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.stream.Collectors; + +/** + * A validator with spark-submit to compare list partitions and list files between metadata table and filesystem. + * + * + * - Default : This validator will compare the result of listing partitions/listing files between metadata table and filesystem only once. + * + * Example command: + * ``` + * spark-submit \ + * --class org.apache.hudi.utilities.HoodieMetadataTableValidator \ + * --packages org.apache.spark:spark-avro_2.11:2.4.4 \ + * --master spark://:7077 \ + * --driver-memory 1g \ + * --executor-memory 1g \ + * $HUDI_DIR/hudi/packaging/hudi-utilities-bundle/target/hudi-utilities-bundle_2.11-0.11.0-SNAPSHOT.jar \ + * --base-path basePath \ + * --validate-latest-fileSlices \ + * --validate-latest-baseFiles \ + * --validate-all-file-groups \ Review comment: Done. ## File path: hudi-utilities/src/main/java/org/apache/hudi/utilities/HoodieMetadataTableValidator.java ## @@ -0,0 +1,506 @@ +/* + * 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.hudi.utilities; + +import com.beust.jcommander.JCommander; +import com.beust.jcommander.Parameter; +import org.apache.hadoop.fs.Path; +import org.apache.hudi.async.HoodieAsyncService; +import org.apache.hudi.client.common.HoodieSparkEngineContext; +import org.apache.hudi.common.config.HoodieMetadataConfig; +import org.apache.hudi.common.config.TypedProperties; +import org.apache.hudi.common.fs.FSUtils; +import org.apache.hudi.common.model.FileSlice; +import org.apache.hudi.common.model.HoodieBaseFile; +import org.apache.hudi.common.model.HoodieFileGroup; +import org.apache.hudi.common.table.HoodieTableMetaClient; +import org.apach
[GitHub] [hudi] zhangyue19921010 commented on a change in pull request #4721: [HUDI-3320] Hoodie metadata table validator
zhangyue19921010 commented on a change in pull request #4721: URL: https://github.com/apache/hudi/pull/4721#discussion_r799940054 ## File path: hudi-utilities/src/main/java/org/apache/hudi/utilities/HoodieMetadataTableValidator.java ## @@ -0,0 +1,506 @@ +/* + * 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.hudi.utilities; + +import com.beust.jcommander.JCommander; +import com.beust.jcommander.Parameter; +import org.apache.hadoop.fs.Path; +import org.apache.hudi.async.HoodieAsyncService; +import org.apache.hudi.client.common.HoodieSparkEngineContext; +import org.apache.hudi.common.config.HoodieMetadataConfig; +import org.apache.hudi.common.config.TypedProperties; +import org.apache.hudi.common.fs.FSUtils; +import org.apache.hudi.common.model.FileSlice; +import org.apache.hudi.common.model.HoodieBaseFile; +import org.apache.hudi.common.model.HoodieFileGroup; +import org.apache.hudi.common.table.HoodieTableMetaClient; +import org.apache.hudi.common.table.view.FileSystemViewManager; +import org.apache.hudi.common.table.view.HoodieTableFileSystemView; +import org.apache.hudi.common.util.Option; +import org.apache.hudi.common.util.collection.Pair; +import org.apache.hudi.exception.HoodieException; +import org.apache.hudi.exception.HoodieValidationException; + +import org.apache.log4j.LogManager; +import org.apache.log4j.Logger; +import org.apache.spark.SparkConf; +import org.apache.spark.api.java.JavaSparkContext; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.List; +import java.util.Objects; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.stream.Collectors; + +/** + * A validator with spark-submit to compare list partitions and list files between metadata table and filesystem. + * + * + * - Default : This validator will compare the result of listing partitions/listing files between metadata table and filesystem only once. + * + * Example command: + * ``` + * spark-submit \ + * --class org.apache.hudi.utilities.HoodieMetadataTableValidator \ + * --packages org.apache.spark:spark-avro_2.11:2.4.4 \ + * --master spark://:7077 \ + * --driver-memory 1g \ + * --executor-memory 1g \ + * $HUDI_DIR/hudi/packaging/hudi-utilities-bundle/target/hudi-utilities-bundle_2.11-0.11.0-SNAPSHOT.jar \ + * --base-path basePath \ + * --validate-latest-fileSlices \ + * --validate-latest-baseFiles \ + * --validate-all-file-groups \ + * ``` + * + * + * Also You can set `--continuous` for long running this validator. + * And use `--min-validate-interval-seconds` to control the validation frequency, default is 10 minutes. + * + * Example command: + * ``` + * spark-submit \ + * --class org.apache.hudi.utilities.HoodieMetadataTableValidator \ + * --packages org.apache.spark:spark-avro_2.11:2.4.4 \ + * --master spark://:7077 \ + * --driver-memory 1g \ + * --executor-memory 1g \ + * $HUDI_DIR/hudi/packaging/hudi-utilities-bundle/target/hudi-utilities-bundle_2.11-0.11.0-SNAPSHOT.jar \ + * --base-path basePath \ + * --validate-latest-fileSlices \ + * --validate-latest-baseFiles \ + * --validate-all-file-groups \ + * --continuous \ + * --min-validate-interval-seconds 60 \ Review comment: Done. -- 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...@hudi.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [hudi] zhangyue19921010 commented on a change in pull request #4721: [HUDI-3320] Hoodie metadata table validator
zhangyue19921010 commented on a change in pull request #4721: URL: https://github.com/apache/hudi/pull/4721#discussion_r798336089 ## File path: hudi-utilities/src/main/java/org/apache/hudi/utilities/HoodieMetadataTableValidator.java ## @@ -0,0 +1,458 @@ +/* + * 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.hudi.utilities; + +import com.beust.jcommander.JCommander; +import com.beust.jcommander.Parameter; +import org.apache.hadoop.fs.Path; +import org.apache.hudi.async.HoodieAsyncService; +import org.apache.hudi.client.common.HoodieSparkEngineContext; +import org.apache.hudi.common.config.HoodieMetadataConfig; +import org.apache.hudi.common.config.TypedProperties; +import org.apache.hudi.common.fs.FSUtils; +import org.apache.hudi.common.model.FileSlice; +import org.apache.hudi.common.model.HoodieBaseFile; +import org.apache.hudi.common.table.HoodieTableMetaClient; +import org.apache.hudi.common.table.view.FileSystemViewManager; +import org.apache.hudi.common.table.view.HoodieTableFileSystemView; +import org.apache.hudi.common.util.Option; +import org.apache.hudi.common.util.collection.Pair; +import org.apache.hudi.exception.HoodieException; +import org.apache.hudi.exception.HoodieValidationException; + +import org.apache.log4j.LogManager; +import org.apache.log4j.Logger; +import org.apache.spark.SparkConf; +import org.apache.spark.api.java.JavaSparkContext; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Comparator; +import java.util.List; +import java.util.Objects; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.stream.Collectors; + +/** + * A validator with spark-submit to compare list partitions and list files between metadata table and filesystem + * + * You can specify the running mode of the validator through `--mode`. + * There are 2 modes of the {@link HoodieMetadataTableValidator}: + * - CONTINUOUS : This validator will compare the result of listing partitions/listing files between metadata table and filesystem every 10 minutes(default). + * + * Example command: + * ``` + * spark-submit \ + * --class org.apache.hudi.utilities.HoodieMetadataTableValidator \ + * --packages org.apache.spark:spark-avro_2.11:2.4.4 \ + * --master spark://:7077 \ + * --driver-memory 1g \ + * --executor-memory 1g \ + * $HUDI_DIR/hudi/packaging/hudi-utilities-bundle/target/hudi-utilities-bundle_2.11-0.11.0-SNAPSHOT.jar \ + * --base-path basePath \ + * --min-validate-interval-seconds 60 \ + * --mode CONTINUOUS + * ``` + * + * + * You can specify the running mode of the validator through `--mode`. + * There are 2 modes of the {@link HoodieMetadataTableValidator}: + * - ONCE : This validator will compare the result of listing partitions/listing files between metadata table and filesystem only once. + * + * Example command: + * ``` + * spark-submit \ + * --class org.apache.hudi.utilities.HoodieMetadataTableValidator \ + * --packages org.apache.spark:spark-avro_2.11:2.4.4 \ + * --master spark://:7077 \ + * --driver-memory 1g \ + * --executor-memory 1g \ + * $HUDI_DIR/hudi/packaging/hudi-utilities-bundle/target/hudi-utilities-bundle_2.11-0.11.0-SNAPSHOT.jar \ + * --base-path basePath \ + * --min-validate-interval-seconds 60 \ + * --mode ONCE + * ``` + * + */ +public class HoodieMetadataTableValidator { + + private static final Logger LOG = LogManager.getLogger(HoodieMetadataTableValidator.class); + + // Spark context + private transient JavaSparkContext jsc; + // config + private Config cfg; + // Properties with source, hoodie client, key generator etc. + private TypedProperties props; + + private HoodieTableMetaClient metaClient; + + protected transient Option asyncMetadataTableValidateService; + + public HoodieMetadataTableValidator(HoodieTableMetaClient metaClient) { +this.metaClient = metaClient; + } + + public HoodieMetadataTableValidator(JavaSparkContext jsc, Config cfg) { +this.jsc = jsc; +this.cfg = cfg; + +this.props = cfg.propsFilePath == null +? UtilHelpers.buildProperties(cfg.config
[GitHub] [hudi] zhangyue19921010 commented on a change in pull request #4721: [HUDI-3320] Hoodie metadata table validator
zhangyue19921010 commented on a change in pull request #4721: URL: https://github.com/apache/hudi/pull/4721#discussion_r798177169 ## File path: hudi-utilities/src/main/java/org/apache/hudi/utilities/HoodieMetadataTableValidator.java ## @@ -0,0 +1,458 @@ +/* + * 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.hudi.utilities; + +import com.beust.jcommander.JCommander; +import com.beust.jcommander.Parameter; +import org.apache.hadoop.fs.Path; +import org.apache.hudi.async.HoodieAsyncService; +import org.apache.hudi.client.common.HoodieSparkEngineContext; +import org.apache.hudi.common.config.HoodieMetadataConfig; +import org.apache.hudi.common.config.TypedProperties; +import org.apache.hudi.common.fs.FSUtils; +import org.apache.hudi.common.model.FileSlice; +import org.apache.hudi.common.model.HoodieBaseFile; +import org.apache.hudi.common.table.HoodieTableMetaClient; +import org.apache.hudi.common.table.view.FileSystemViewManager; +import org.apache.hudi.common.table.view.HoodieTableFileSystemView; +import org.apache.hudi.common.util.Option; +import org.apache.hudi.common.util.collection.Pair; +import org.apache.hudi.exception.HoodieException; +import org.apache.hudi.exception.HoodieValidationException; + +import org.apache.log4j.LogManager; +import org.apache.log4j.Logger; +import org.apache.spark.SparkConf; +import org.apache.spark.api.java.JavaSparkContext; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Comparator; +import java.util.List; +import java.util.Objects; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.stream.Collectors; + +/** + * A validator with spark-submit to compare list partitions and list files between metadata table and filesystem + * + * You can specify the running mode of the validator through `--mode`. + * There are 2 modes of the {@link HoodieMetadataTableValidator}: + * - CONTINUOUS : This validator will compare the result of listing partitions/listing files between metadata table and filesystem every 10 minutes(default). + * + * Example command: + * ``` + * spark-submit \ + * --class org.apache.hudi.utilities.HoodieMetadataTableValidator \ + * --packages org.apache.spark:spark-avro_2.11:2.4.4 \ + * --master spark://:7077 \ + * --driver-memory 1g \ + * --executor-memory 1g \ + * $HUDI_DIR/hudi/packaging/hudi-utilities-bundle/target/hudi-utilities-bundle_2.11-0.11.0-SNAPSHOT.jar \ + * --base-path basePath \ + * --min-validate-interval-seconds 60 \ + * --mode CONTINUOUS + * ``` + * + * + * You can specify the running mode of the validator through `--mode`. + * There are 2 modes of the {@link HoodieMetadataTableValidator}: + * - ONCE : This validator will compare the result of listing partitions/listing files between metadata table and filesystem only once. + * + * Example command: + * ``` + * spark-submit \ + * --class org.apache.hudi.utilities.HoodieMetadataTableValidator \ + * --packages org.apache.spark:spark-avro_2.11:2.4.4 \ + * --master spark://:7077 \ + * --driver-memory 1g \ + * --executor-memory 1g \ + * $HUDI_DIR/hudi/packaging/hudi-utilities-bundle/target/hudi-utilities-bundle_2.11-0.11.0-SNAPSHOT.jar \ + * --base-path basePath \ + * --min-validate-interval-seconds 60 \ + * --mode ONCE + * ``` + * + */ +public class HoodieMetadataTableValidator { + + private static final Logger LOG = LogManager.getLogger(HoodieMetadataTableValidator.class); + + // Spark context + private transient JavaSparkContext jsc; + // config + private Config cfg; + // Properties with source, hoodie client, key generator etc. + private TypedProperties props; + + private HoodieTableMetaClient metaClient; + + protected transient Option asyncMetadataTableValidateService; + + public HoodieMetadataTableValidator(HoodieTableMetaClient metaClient) { +this.metaClient = metaClient; + } + + public HoodieMetadataTableValidator(JavaSparkContext jsc, Config cfg) { +this.jsc = jsc; +this.cfg = cfg; + +this.props = cfg.propsFilePath == null +? UtilHelpers.buildProperties(cfg.config
[GitHub] [hudi] zhangyue19921010 commented on a change in pull request #4721: [HUDI-3320] Hoodie metadata table validator
zhangyue19921010 commented on a change in pull request #4721: URL: https://github.com/apache/hudi/pull/4721#discussion_r798176659 ## File path: hudi-utilities/src/main/java/org/apache/hudi/utilities/HoodieMetadataTableValidator.java ## @@ -0,0 +1,458 @@ +/* + * 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.hudi.utilities; + +import com.beust.jcommander.JCommander; +import com.beust.jcommander.Parameter; +import org.apache.hadoop.fs.Path; +import org.apache.hudi.async.HoodieAsyncService; +import org.apache.hudi.client.common.HoodieSparkEngineContext; +import org.apache.hudi.common.config.HoodieMetadataConfig; +import org.apache.hudi.common.config.TypedProperties; +import org.apache.hudi.common.fs.FSUtils; +import org.apache.hudi.common.model.FileSlice; +import org.apache.hudi.common.model.HoodieBaseFile; +import org.apache.hudi.common.table.HoodieTableMetaClient; +import org.apache.hudi.common.table.view.FileSystemViewManager; +import org.apache.hudi.common.table.view.HoodieTableFileSystemView; +import org.apache.hudi.common.util.Option; +import org.apache.hudi.common.util.collection.Pair; +import org.apache.hudi.exception.HoodieException; +import org.apache.hudi.exception.HoodieValidationException; + +import org.apache.log4j.LogManager; +import org.apache.log4j.Logger; +import org.apache.spark.SparkConf; +import org.apache.spark.api.java.JavaSparkContext; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Comparator; +import java.util.List; +import java.util.Objects; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.stream.Collectors; + +/** + * A validator with spark-submit to compare list partitions and list files between metadata table and filesystem + * + * You can specify the running mode of the validator through `--mode`. + * There are 2 modes of the {@link HoodieMetadataTableValidator}: + * - CONTINUOUS : This validator will compare the result of listing partitions/listing files between metadata table and filesystem every 10 minutes(default). + * + * Example command: + * ``` + * spark-submit \ + * --class org.apache.hudi.utilities.HoodieMetadataTableValidator \ + * --packages org.apache.spark:spark-avro_2.11:2.4.4 \ + * --master spark://:7077 \ + * --driver-memory 1g \ + * --executor-memory 1g \ + * $HUDI_DIR/hudi/packaging/hudi-utilities-bundle/target/hudi-utilities-bundle_2.11-0.11.0-SNAPSHOT.jar \ + * --base-path basePath \ + * --min-validate-interval-seconds 60 \ + * --mode CONTINUOUS + * ``` + * + * + * You can specify the running mode of the validator through `--mode`. + * There are 2 modes of the {@link HoodieMetadataTableValidator}: + * - ONCE : This validator will compare the result of listing partitions/listing files between metadata table and filesystem only once. + * + * Example command: + * ``` + * spark-submit \ + * --class org.apache.hudi.utilities.HoodieMetadataTableValidator \ + * --packages org.apache.spark:spark-avro_2.11:2.4.4 \ + * --master spark://:7077 \ + * --driver-memory 1g \ + * --executor-memory 1g \ + * $HUDI_DIR/hudi/packaging/hudi-utilities-bundle/target/hudi-utilities-bundle_2.11-0.11.0-SNAPSHOT.jar \ + * --base-path basePath \ + * --min-validate-interval-seconds 60 \ + * --mode ONCE + * ``` + * + */ +public class HoodieMetadataTableValidator { + + private static final Logger LOG = LogManager.getLogger(HoodieMetadataTableValidator.class); + + // Spark context + private transient JavaSparkContext jsc; + // config + private Config cfg; + // Properties with source, hoodie client, key generator etc. + private TypedProperties props; + + private HoodieTableMetaClient metaClient; + + protected transient Option asyncMetadataTableValidateService; + + public HoodieMetadataTableValidator(HoodieTableMetaClient metaClient) { +this.metaClient = metaClient; + } + + public HoodieMetadataTableValidator(JavaSparkContext jsc, Config cfg) { +this.jsc = jsc; +this.cfg = cfg; + +this.props = cfg.propsFilePath == null +? UtilHelpers.buildProperties(cfg.config
[GitHub] [hudi] zhangyue19921010 commented on a change in pull request #4721: [HUDI-3320] Hoodie metadata table validator
zhangyue19921010 commented on a change in pull request #4721: URL: https://github.com/apache/hudi/pull/4721#discussion_r798176560 ## File path: hudi-utilities/src/main/java/org/apache/hudi/utilities/HoodieMetadataTableValidator.java ## @@ -0,0 +1,458 @@ +/* + * 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.hudi.utilities; + +import com.beust.jcommander.JCommander; +import com.beust.jcommander.Parameter; +import org.apache.hadoop.fs.Path; +import org.apache.hudi.async.HoodieAsyncService; +import org.apache.hudi.client.common.HoodieSparkEngineContext; +import org.apache.hudi.common.config.HoodieMetadataConfig; +import org.apache.hudi.common.config.TypedProperties; +import org.apache.hudi.common.fs.FSUtils; +import org.apache.hudi.common.model.FileSlice; +import org.apache.hudi.common.model.HoodieBaseFile; +import org.apache.hudi.common.table.HoodieTableMetaClient; +import org.apache.hudi.common.table.view.FileSystemViewManager; +import org.apache.hudi.common.table.view.HoodieTableFileSystemView; +import org.apache.hudi.common.util.Option; +import org.apache.hudi.common.util.collection.Pair; +import org.apache.hudi.exception.HoodieException; +import org.apache.hudi.exception.HoodieValidationException; + +import org.apache.log4j.LogManager; +import org.apache.log4j.Logger; +import org.apache.spark.SparkConf; +import org.apache.spark.api.java.JavaSparkContext; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Comparator; +import java.util.List; +import java.util.Objects; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.stream.Collectors; + +/** + * A validator with spark-submit to compare list partitions and list files between metadata table and filesystem + * + * You can specify the running mode of the validator through `--mode`. + * There are 2 modes of the {@link HoodieMetadataTableValidator}: + * - CONTINUOUS : This validator will compare the result of listing partitions/listing files between metadata table and filesystem every 10 minutes(default). + * + * Example command: + * ``` + * spark-submit \ + * --class org.apache.hudi.utilities.HoodieMetadataTableValidator \ + * --packages org.apache.spark:spark-avro_2.11:2.4.4 \ + * --master spark://:7077 \ + * --driver-memory 1g \ + * --executor-memory 1g \ + * $HUDI_DIR/hudi/packaging/hudi-utilities-bundle/target/hudi-utilities-bundle_2.11-0.11.0-SNAPSHOT.jar \ + * --base-path basePath \ + * --min-validate-interval-seconds 60 \ + * --mode CONTINUOUS Review comment: Sure, changed. -- 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...@hudi.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [hudi] zhangyue19921010 commented on a change in pull request #4721: [HUDI-3320] Hoodie metadata table validator
zhangyue19921010 commented on a change in pull request #4721: URL: https://github.com/apache/hudi/pull/4721#discussion_r798176463 ## File path: hudi-utilities/src/main/java/org/apache/hudi/utilities/HoodieMetadataTableValidator.java ## @@ -0,0 +1,458 @@ +/* + * 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.hudi.utilities; + +import com.beust.jcommander.JCommander; +import com.beust.jcommander.Parameter; +import org.apache.hadoop.fs.Path; +import org.apache.hudi.async.HoodieAsyncService; +import org.apache.hudi.client.common.HoodieSparkEngineContext; +import org.apache.hudi.common.config.HoodieMetadataConfig; +import org.apache.hudi.common.config.TypedProperties; +import org.apache.hudi.common.fs.FSUtils; +import org.apache.hudi.common.model.FileSlice; +import org.apache.hudi.common.model.HoodieBaseFile; +import org.apache.hudi.common.table.HoodieTableMetaClient; +import org.apache.hudi.common.table.view.FileSystemViewManager; +import org.apache.hudi.common.table.view.HoodieTableFileSystemView; +import org.apache.hudi.common.util.Option; +import org.apache.hudi.common.util.collection.Pair; +import org.apache.hudi.exception.HoodieException; +import org.apache.hudi.exception.HoodieValidationException; + +import org.apache.log4j.LogManager; +import org.apache.log4j.Logger; +import org.apache.spark.SparkConf; +import org.apache.spark.api.java.JavaSparkContext; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Comparator; +import java.util.List; +import java.util.Objects; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.stream.Collectors; + +/** + * A validator with spark-submit to compare list partitions and list files between metadata table and filesystem + * + * You can specify the running mode of the validator through `--mode`. + * There are 2 modes of the {@link HoodieMetadataTableValidator}: + * - CONTINUOUS : This validator will compare the result of listing partitions/listing files between metadata table and filesystem every 10 minutes(default). + * + * Example command: + * ``` + * spark-submit \ + * --class org.apache.hudi.utilities.HoodieMetadataTableValidator \ + * --packages org.apache.spark:spark-avro_2.11:2.4.4 \ + * --master spark://:7077 \ + * --driver-memory 1g \ + * --executor-memory 1g \ + * $HUDI_DIR/hudi/packaging/hudi-utilities-bundle/target/hudi-utilities-bundle_2.11-0.11.0-SNAPSHOT.jar \ + * --base-path basePath \ + * --min-validate-interval-seconds 60 \ + * --mode CONTINUOUS + * ``` + * + * + * You can specify the running mode of the validator through `--mode`. + * There are 2 modes of the {@link HoodieMetadataTableValidator}: Review comment: Changed. Just two kinds of example now: 1. --continuous + --min-validate-interval-seconds. 2. default which will validate once. -- 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...@hudi.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [hudi] zhangyue19921010 commented on a change in pull request #4721: [HUDI-3320] Hoodie metadata table validator
zhangyue19921010 commented on a change in pull request #4721: URL: https://github.com/apache/hudi/pull/4721#discussion_r797353641 ## File path: hudi-utilities/src/main/java/org/apache/hudi/utilities/HoodieMetadataTableValidator.java ## @@ -0,0 +1,439 @@ +/* + * 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.hudi.utilities; + +import com.beust.jcommander.JCommander; +import com.beust.jcommander.Parameter; +import org.apache.hadoop.fs.Path; +import org.apache.hudi.async.HoodieAsyncService; +import org.apache.hudi.client.common.HoodieSparkEngineContext; +import org.apache.hudi.common.config.HoodieMetadataConfig; +import org.apache.hudi.common.config.TypedProperties; +import org.apache.hudi.common.fs.FSUtils; +import org.apache.hudi.common.model.FileSlice; +import org.apache.hudi.common.model.HoodieBaseFile; +import org.apache.hudi.common.table.HoodieTableMetaClient; +import org.apache.hudi.common.table.view.FileSystemViewManager; +import org.apache.hudi.common.table.view.HoodieTableFileSystemView; +import org.apache.hudi.common.util.Option; +import org.apache.hudi.common.util.collection.Pair; +import org.apache.hudi.exception.HoodieException; +import org.apache.hudi.exception.HoodieValidationException; +import org.apache.log4j.LogManager; +import org.apache.log4j.Logger; +import org.apache.spark.SparkConf; +import org.apache.spark.api.java.JavaSparkContext; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Objects; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.stream.Collectors; + +/** + * A validator with spark-submit to compare list partitions and list files between metadata table and filesystem + * + * You can run this validator with the following command and have a try: + * ``` + * spark-submit \ + * --class org.apache.hudi.utilities.HoodieMetadataTableValidator \ + * --packages org.apache.spark:spark-avro_2.11:2.4.4 \ + * --master spark://:7077 \ + * --driver-memory 1g \ + * --executor-memory 1g \ + * $HUDI_DIR/hudi/packaging/hudi-utilities-bundle/target/hudi-utilities-bundle_2.11-0.11.0-SNAPSHOT.jar \ + * --base-path basePath \ + * --mode CONTINUOUS + * ``` + * + * + * You can specify the running mode of the validator through `--mode`. + * There are 2 modes of the {@link HoodieMetadataTableValidator}: + * - CONTINUOUS : This validator will compare the result of listing partitions/listing files between metadata table and filesystem every 10 minutes(default). + * + * Example command: + * ``` + * spark-submit \ + * --class org.apache.hudi.utilities.HoodieMetadataTableValidator \ + * --packages org.apache.spark:spark-avro_2.11:2.4.4 \ + * --master spark://:7077 \ + * --driver-memory 1g \ + * --executor-memory 1g \ + * $HUDI_DIR/hudi/packaging/hudi-utilities-bundle/target/hudi-utilities-bundle_2.11-0.11.0-SNAPSHOT.jar \ + * --base-path basePath \ + * --mode CONTINUOUS Review comment: Sure thing. Added. PTAL :) -- 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...@hudi.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [hudi] zhangyue19921010 commented on a change in pull request #4721: [HUDI-3320] Hoodie metadata table validator
zhangyue19921010 commented on a change in pull request #4721: URL: https://github.com/apache/hudi/pull/4721#discussion_r796251580 ## File path: hudi-utilities/src/main/java/org/apache/hudi/utilities/HoodieMetadataTableValidator.java ## @@ -0,0 +1,337 @@ +/* + * 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.hudi.utilities; + +import com.beust.jcommander.JCommander; +import com.beust.jcommander.Parameter; +import org.apache.hadoop.fs.Path; +import org.apache.hudi.async.HoodieAsyncService; +import org.apache.hudi.client.common.HoodieSparkEngineContext; +import org.apache.hudi.common.config.HoodieMetadataConfig; +import org.apache.hudi.common.config.TypedProperties; +import org.apache.hudi.common.fs.FSUtils; +import org.apache.hudi.common.model.FileSlice; +import org.apache.hudi.common.model.HoodieBaseFile; +import org.apache.hudi.common.table.HoodieTableMetaClient; +import org.apache.hudi.common.table.view.FileSystemViewManager; +import org.apache.hudi.common.table.view.HoodieTableFileSystemView; +import org.apache.hudi.common.util.Option; +import org.apache.hudi.common.util.collection.Pair; +import org.apache.hudi.exception.HoodieException; +import org.apache.log4j.LogManager; +import org.apache.log4j.Logger; +import org.apache.spark.SparkConf; +import org.apache.spark.api.java.JavaSparkContext; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Objects; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.stream.Collectors; + +public class HoodieMetadataTableValidator { + + private static final Logger LOG = LogManager.getLogger(HoodieMetadataTableValidator.class); + + // Spark context + private transient JavaSparkContext jsc; + // config + private Config cfg; + // Properties with source, hoodie client, key generator etc. + private TypedProperties props; + + private HoodieTableMetaClient metaClient; + + protected transient Option asyncMetadataTableValidateService; + + public HoodieMetadataTableValidator(HoodieTableMetaClient metaClient) { +this.metaClient = metaClient; + } + + public HoodieMetadataTableValidator(JavaSparkContext jsc, Config cfg) { +this.jsc = jsc; +this.cfg = cfg; + +this.props = cfg.propsFilePath == null +? UtilHelpers.buildProperties(cfg.configs) +: readConfigFromFileSystem(jsc, cfg); + +this.metaClient = HoodieTableMetaClient.builder() +.setConf(jsc.hadoopConfiguration()).setBasePath(cfg.basePath) +.setLoadActiveTimelineOnLoad(true) +.build(); + +this.asyncMetadataTableValidateService = cfg.runningMode.equalsIgnoreCase(Mode.CONTINUOUS.name()) +? Option.of(new AsyncMetadataTableValidateService()) : Option.empty(); + } + + /** + * Reads config from the file system. + * + * @param jsc {@link JavaSparkContext} instance. + * @param cfg {@link Config} instance. + * @return the {@link TypedProperties} instance. + */ + private TypedProperties readConfigFromFileSystem(JavaSparkContext jsc, Config cfg) { +return UtilHelpers.readConfig(jsc.hadoopConfiguration(), new Path(cfg.propsFilePath), cfg.configs) +.getProps(true); + } + + public enum Mode { +// Running MetadataTableValidator in continuous +CONTINUOUS, +// Running MetadataTableValidator once +ONCE + } + + public static class Config implements Serializable { +@Parameter(names = {"--base-path", "-sp"}, description = "Base path for the table", required = true) +public String basePath = null; + +@Parameter(names = {"--mode", "-m"}, description = "Set job mode: " ++ "Set \"CONTINUOUS\" Running MetadataTableValidator in continuous" ++ "Set \"ONCE\" Running MetadataTableValidator once", required = false) +public String runningMode = "once"; + +@Parameter(names = {"--min-validate-interval-seconds"}, +description = "the min validate interval of each validate in continuous mode") +public Integer minValidateIntervalSeconds = 10; + +@Parameter(names = {"--ignore-failed", "-ig"}, description
[GitHub] [hudi] zhangyue19921010 commented on a change in pull request #4721: [HUDI-3320] Hoodie metadata table validator
zhangyue19921010 commented on a change in pull request #4721: URL: https://github.com/apache/hudi/pull/4721#discussion_r796251289 ## File path: hudi-utilities/src/main/java/org/apache/hudi/utilities/HoodieMetadataTableValidator.java ## @@ -0,0 +1,337 @@ +/* + * 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.hudi.utilities; + +import com.beust.jcommander.JCommander; +import com.beust.jcommander.Parameter; +import org.apache.hadoop.fs.Path; +import org.apache.hudi.async.HoodieAsyncService; +import org.apache.hudi.client.common.HoodieSparkEngineContext; +import org.apache.hudi.common.config.HoodieMetadataConfig; +import org.apache.hudi.common.config.TypedProperties; +import org.apache.hudi.common.fs.FSUtils; +import org.apache.hudi.common.model.FileSlice; +import org.apache.hudi.common.model.HoodieBaseFile; +import org.apache.hudi.common.table.HoodieTableMetaClient; +import org.apache.hudi.common.table.view.FileSystemViewManager; +import org.apache.hudi.common.table.view.HoodieTableFileSystemView; +import org.apache.hudi.common.util.Option; +import org.apache.hudi.common.util.collection.Pair; +import org.apache.hudi.exception.HoodieException; +import org.apache.log4j.LogManager; +import org.apache.log4j.Logger; +import org.apache.spark.SparkConf; +import org.apache.spark.api.java.JavaSparkContext; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Objects; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.stream.Collectors; + +public class HoodieMetadataTableValidator { + + private static final Logger LOG = LogManager.getLogger(HoodieMetadataTableValidator.class); + + // Spark context + private transient JavaSparkContext jsc; + // config + private Config cfg; + // Properties with source, hoodie client, key generator etc. + private TypedProperties props; + + private HoodieTableMetaClient metaClient; + + protected transient Option asyncMetadataTableValidateService; + + public HoodieMetadataTableValidator(HoodieTableMetaClient metaClient) { +this.metaClient = metaClient; + } + + public HoodieMetadataTableValidator(JavaSparkContext jsc, Config cfg) { +this.jsc = jsc; +this.cfg = cfg; + +this.props = cfg.propsFilePath == null +? UtilHelpers.buildProperties(cfg.configs) +: readConfigFromFileSystem(jsc, cfg); + +this.metaClient = HoodieTableMetaClient.builder() +.setConf(jsc.hadoopConfiguration()).setBasePath(cfg.basePath) +.setLoadActiveTimelineOnLoad(true) +.build(); + +this.asyncMetadataTableValidateService = cfg.runningMode.equalsIgnoreCase(Mode.CONTINUOUS.name()) +? Option.of(new AsyncMetadataTableValidateService()) : Option.empty(); + } + + /** + * Reads config from the file system. + * + * @param jsc {@link JavaSparkContext} instance. + * @param cfg {@link Config} instance. + * @return the {@link TypedProperties} instance. + */ + private TypedProperties readConfigFromFileSystem(JavaSparkContext jsc, Config cfg) { +return UtilHelpers.readConfig(jsc.hadoopConfiguration(), new Path(cfg.propsFilePath), cfg.configs) +.getProps(true); + } + + public enum Mode { +// Running MetadataTableValidator in continuous +CONTINUOUS, +// Running MetadataTableValidator once +ONCE + } + + public static class Config implements Serializable { +@Parameter(names = {"--base-path", "-sp"}, description = "Base path for the table", required = true) +public String basePath = null; + +@Parameter(names = {"--mode", "-m"}, description = "Set job mode: " ++ "Set \"CONTINUOUS\" Running MetadataTableValidator in continuous" ++ "Set \"ONCE\" Running MetadataTableValidator once", required = false) +public String runningMode = "once"; + +@Parameter(names = {"--min-validate-interval-seconds"}, +description = "the min validate interval of each validate in continuous mode") +public Integer minValidateIntervalSeconds = 10; + +@Parameter(names = {"--ignore-failed", "-ig"}, description
[GitHub] [hudi] zhangyue19921010 commented on a change in pull request #4721: [HUDI-3320] Hoodie metadata table validator
zhangyue19921010 commented on a change in pull request #4721: URL: https://github.com/apache/hudi/pull/4721#discussion_r796251222 ## File path: hudi-utilities/src/main/java/org/apache/hudi/utilities/HoodieMetadataTableValidator.java ## @@ -0,0 +1,337 @@ +/* + * 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.hudi.utilities; + +import com.beust.jcommander.JCommander; +import com.beust.jcommander.Parameter; +import org.apache.hadoop.fs.Path; +import org.apache.hudi.async.HoodieAsyncService; +import org.apache.hudi.client.common.HoodieSparkEngineContext; +import org.apache.hudi.common.config.HoodieMetadataConfig; +import org.apache.hudi.common.config.TypedProperties; +import org.apache.hudi.common.fs.FSUtils; +import org.apache.hudi.common.model.FileSlice; +import org.apache.hudi.common.model.HoodieBaseFile; +import org.apache.hudi.common.table.HoodieTableMetaClient; +import org.apache.hudi.common.table.view.FileSystemViewManager; +import org.apache.hudi.common.table.view.HoodieTableFileSystemView; +import org.apache.hudi.common.util.Option; +import org.apache.hudi.common.util.collection.Pair; +import org.apache.hudi.exception.HoodieException; +import org.apache.log4j.LogManager; +import org.apache.log4j.Logger; +import org.apache.spark.SparkConf; +import org.apache.spark.api.java.JavaSparkContext; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Objects; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.stream.Collectors; + +public class HoodieMetadataTableValidator { + + private static final Logger LOG = LogManager.getLogger(HoodieMetadataTableValidator.class); + + // Spark context + private transient JavaSparkContext jsc; + // config + private Config cfg; + // Properties with source, hoodie client, key generator etc. + private TypedProperties props; + + private HoodieTableMetaClient metaClient; + + protected transient Option asyncMetadataTableValidateService; + + public HoodieMetadataTableValidator(HoodieTableMetaClient metaClient) { +this.metaClient = metaClient; + } + + public HoodieMetadataTableValidator(JavaSparkContext jsc, Config cfg) { +this.jsc = jsc; +this.cfg = cfg; + +this.props = cfg.propsFilePath == null +? UtilHelpers.buildProperties(cfg.configs) +: readConfigFromFileSystem(jsc, cfg); + +this.metaClient = HoodieTableMetaClient.builder() +.setConf(jsc.hadoopConfiguration()).setBasePath(cfg.basePath) +.setLoadActiveTimelineOnLoad(true) +.build(); + +this.asyncMetadataTableValidateService = cfg.runningMode.equalsIgnoreCase(Mode.CONTINUOUS.name()) +? Option.of(new AsyncMetadataTableValidateService()) : Option.empty(); + } + + /** + * Reads config from the file system. + * + * @param jsc {@link JavaSparkContext} instance. + * @param cfg {@link Config} instance. + * @return the {@link TypedProperties} instance. + */ + private TypedProperties readConfigFromFileSystem(JavaSparkContext jsc, Config cfg) { +return UtilHelpers.readConfig(jsc.hadoopConfiguration(), new Path(cfg.propsFilePath), cfg.configs) +.getProps(true); + } + + public enum Mode { +// Running MetadataTableValidator in continuous +CONTINUOUS, +// Running MetadataTableValidator once +ONCE + } + + public static class Config implements Serializable { +@Parameter(names = {"--base-path", "-sp"}, description = "Base path for the table", required = true) +public String basePath = null; + +@Parameter(names = {"--mode", "-m"}, description = "Set job mode: " ++ "Set \"CONTINUOUS\" Running MetadataTableValidator in continuous" ++ "Set \"ONCE\" Running MetadataTableValidator once", required = false) +public String runningMode = "once"; Review comment: Yeap, use ` Mode mode = Mode.valueOf(cfg.runningMode.toUpperCase());` -- 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 uns
[GitHub] [hudi] zhangyue19921010 commented on a change in pull request #4721: [HUDI-3320] Hoodie metadata table validator
zhangyue19921010 commented on a change in pull request #4721: URL: https://github.com/apache/hudi/pull/4721#discussion_r796251049 ## File path: hudi-utilities/src/main/java/org/apache/hudi/utilities/HoodieMetadataTableValidator.java ## @@ -0,0 +1,337 @@ +/* + * 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.hudi.utilities; + +import com.beust.jcommander.JCommander; +import com.beust.jcommander.Parameter; +import org.apache.hadoop.fs.Path; +import org.apache.hudi.async.HoodieAsyncService; +import org.apache.hudi.client.common.HoodieSparkEngineContext; +import org.apache.hudi.common.config.HoodieMetadataConfig; +import org.apache.hudi.common.config.TypedProperties; +import org.apache.hudi.common.fs.FSUtils; +import org.apache.hudi.common.model.FileSlice; +import org.apache.hudi.common.model.HoodieBaseFile; +import org.apache.hudi.common.table.HoodieTableMetaClient; +import org.apache.hudi.common.table.view.FileSystemViewManager; +import org.apache.hudi.common.table.view.HoodieTableFileSystemView; +import org.apache.hudi.common.util.Option; +import org.apache.hudi.common.util.collection.Pair; +import org.apache.hudi.exception.HoodieException; +import org.apache.log4j.LogManager; +import org.apache.log4j.Logger; +import org.apache.spark.SparkConf; +import org.apache.spark.api.java.JavaSparkContext; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Objects; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.stream.Collectors; + +public class HoodieMetadataTableValidator { + + private static final Logger LOG = LogManager.getLogger(HoodieMetadataTableValidator.class); + + // Spark context + private transient JavaSparkContext jsc; + // config + private Config cfg; + // Properties with source, hoodie client, key generator etc. + private TypedProperties props; + + private HoodieTableMetaClient metaClient; + + protected transient Option asyncMetadataTableValidateService; + + public HoodieMetadataTableValidator(HoodieTableMetaClient metaClient) { +this.metaClient = metaClient; + } + + public HoodieMetadataTableValidator(JavaSparkContext jsc, Config cfg) { +this.jsc = jsc; +this.cfg = cfg; + +this.props = cfg.propsFilePath == null +? UtilHelpers.buildProperties(cfg.configs) +: readConfigFromFileSystem(jsc, cfg); + +this.metaClient = HoodieTableMetaClient.builder() +.setConf(jsc.hadoopConfiguration()).setBasePath(cfg.basePath) +.setLoadActiveTimelineOnLoad(true) +.build(); + +this.asyncMetadataTableValidateService = cfg.runningMode.equalsIgnoreCase(Mode.CONTINUOUS.name()) +? Option.of(new AsyncMetadataTableValidateService()) : Option.empty(); + } + + /** + * Reads config from the file system. + * + * @param jsc {@link JavaSparkContext} instance. + * @param cfg {@link Config} instance. + * @return the {@link TypedProperties} instance. + */ + private TypedProperties readConfigFromFileSystem(JavaSparkContext jsc, Config cfg) { +return UtilHelpers.readConfig(jsc.hadoopConfiguration(), new Path(cfg.propsFilePath), cfg.configs) +.getProps(true); + } + + public enum Mode { +// Running MetadataTableValidator in continuous +CONTINUOUS, +// Running MetadataTableValidator once +ONCE + } + + public static class Config implements Serializable { +@Parameter(names = {"--base-path", "-sp"}, description = "Base path for the table", required = true) +public String basePath = null; + +@Parameter(names = {"--mode", "-m"}, description = "Set job mode: " ++ "Set \"CONTINUOUS\" Running MetadataTableValidator in continuous" ++ "Set \"ONCE\" Running MetadataTableValidator once", required = false) +public String runningMode = "once"; + +@Parameter(names = {"--min-validate-interval-seconds"}, +description = "the min validate interval of each validate in continuous mode") +public Integer minValidateIntervalSeconds = 10; Review comment: Okay, change it to 10 minutes for continuo