Skip to content

Commit

Permalink
simplifying the hadoop conf instantiation
Browse files Browse the repository at this point in the history
  • Loading branch information
nsivabalan committed Nov 22, 2023
1 parent 64838b8 commit 2aa12a6
Showing 1 changed file with 3 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
import java.util.Set;
import java.util.stream.Collectors;

import static org.apache.hudi.common.util.StringUtils.isNullOrEmpty;
import static org.apache.hudi.common.util.StringUtils.nonEmpty;
import static org.apache.hudi.hadoop.utils.HoodieInputFormatUtils.getInputFormatClassName;
import static org.apache.hudi.hadoop.utils.HoodieInputFormatUtils.getOutputFormatClassName;
Expand Down Expand Up @@ -104,22 +103,12 @@ public class HiveSyncTool extends HoodieSyncTool implements AutoCloseable {
public HiveSyncTool(Properties props, Configuration hadoopConf) {
super(props, hadoopConf);
String configuredMetastoreUris = props.getProperty(METASTORE_URIS.key());
String existingHadoopConfMetastoreUris = hadoopConf.get(HiveConf.ConfVars.METASTOREURIS.varname);

final Configuration hadoopConfForSync; // the configuration to use for this instance of the sync tool
if (nonEmpty(configuredMetastoreUris)) {
// if the metastore uris from the provided hadoop configuration exist and are equal to the user provided URIs, then we can use the provided configuration
if (configuredMetastoreUris.equals(existingHadoopConfMetastoreUris)) {
hadoopConfForSync = hadoopConf;
} else if (isNullOrEmpty(existingHadoopConfMetastoreUris)) {
// if there is no value already set in the provided configuration, update the existing configuration to avoid making copies of the configuration per instance of this tool
hadoopConf.set(HiveConf.ConfVars.METASTOREURIS.varname, configuredMetastoreUris);
hadoopConfForSync = hadoopConf;
} else {
// if the metastore uris exist in the provided hadoop configuration but differ from the user provided URIs, then we need to create a new configuration with the value set
hadoopConfForSync = new Configuration(hadoopConf);
hadoopConfForSync.set(HiveConf.ConfVars.METASTOREURIS.varname, configuredMetastoreUris);
}
// if metastore uri is configured, we need to create a new configuration with the value set
hadoopConfForSync = new Configuration(hadoopConf);
hadoopConfForSync.set(HiveConf.ConfVars.METASTOREURIS.varname, configuredMetastoreUris);
} else {
// if the user did not provide any URIs, then we can use the provided configuration
hadoopConfForSync = hadoopConf;
Expand Down

0 comments on commit 2aa12a6

Please sign in to comment.