xushiyan commented on code in PR #5854: URL: https://github.com/apache/hudi/pull/5854#discussion_r912380985
########## hudi-sync/hudi-datahub-sync/src/main/java/org/apache/hudi/sync/datahub/config/DataHubSyncConfig.java: ########## @@ -49,45 +52,52 @@ public class DataHubSyncConfig extends HoodieSyncConfig { .noDefaultValue() .withDocumentation("Pluggable class to supply a DataHub REST emitter to connect to the DataHub instance. This overwrites other emitter configs."); - @Parameter(names = {"--identifier-class"}, description = "Pluggable class to help provide info to identify a DataHub Dataset.") - public String identifierClass; + public final HoodieDataHubDatasetIdentifier datasetIdentifier; + + public DataHubSyncConfig(Properties props) { + super(props); + String identifierClass = getStringOrDefault(META_SYNC_DATAHUB_DATASET_IDENTIFIER_CLASS); + datasetIdentifier = (HoodieDataHubDatasetIdentifier) ReflectionUtils.loadClass(identifierClass, new Class<?>[] {Properties.class}, props); + } - @Parameter(names = {"--emitter-server"}, description = "Server URL of the DataHub instance.") - public String emitterServer; + public RestEmitter getRestEmitter() { + if (contains(META_SYNC_DATAHUB_EMITTER_SUPPLIER_CLASS)) { + return ((DataHubEmitterSupplier) ReflectionUtils.loadClass(getString(META_SYNC_DATAHUB_EMITTER_SUPPLIER_CLASS))).get(); + } else if (contains(META_SYNC_DATAHUB_EMITTER_SERVER)) { + return RestEmitter.create(b -> b.server(getString(META_SYNC_DATAHUB_EMITTER_SERVER)).token(getStringOrDefault(META_SYNC_DATAHUB_EMITTER_TOKEN, null))); + } else { + return RestEmitter.createWithDefaults(); + } + } - @Parameter(names = {"--emitter-token"}, description = "Auth token to connect to the DataHub instance.") - public String emitterToken; + public static class DataHubSyncConfigParams { - @Parameter(names = {"--emitter-supplier-class"}, description = "Pluggable class to supply a DataHub REST emitter to connect to the DataHub instance. This overwrites other emitter configs.") - public String emitterSupplierClass; + @ParametersDelegate() + public final HoodieSyncConfigParams hoodieSyncConfigParams = new HoodieSyncConfigParams(); - @Parameter(names = {"--help", "-h"}, help = true) - public Boolean help = false; + @Parameter(names = {"--identifier-class"}, description = "Pluggable class to help provide info to identify a DataHub Dataset.") + public String identifierClass; - public final HoodieDataHubDatasetIdentifier datasetIdentifier; + @Parameter(names = {"--emitter-server"}, description = "Server URL of the DataHub instance.") + public String emitterServer; - public DataHubSyncConfig() { - this(new TypedProperties()); - } + @Parameter(names = {"--emitter-token"}, description = "Auth token to connect to the DataHub instance.") + public String emitterToken; - public DataHubSyncConfig(TypedProperties props) { - super(props); - identifierClass = getStringOrDefault(META_SYNC_DATAHUB_DATASET_IDENTIFIER_CLASS); - emitterServer = getStringOrDefault(META_SYNC_DATAHUB_EMITTER_SERVER, null); - emitterToken = getStringOrDefault(META_SYNC_DATAHUB_EMITTER_TOKEN, null); - emitterSupplierClass = getStringOrDefault(META_SYNC_DATAHUB_EMITTER_SUPPLIER_CLASS, null); + @Parameter(names = {"--emitter-supplier-class"}, description = "Pluggable class to supply a DataHub REST emitter to connect to the DataHub instance. This overwrites other emitter configs.") + public String emitterSupplierClass; - datasetIdentifier = (HoodieDataHubDatasetIdentifier) ReflectionUtils - .loadClass(identifierClass, new Class<?>[] {TypedProperties.class}, props); - } + public boolean isHelp() { Review Comment: the tricky thing is, for org.apache.hudi.sync.common.HoodieSyncConfig.HoodieSyncConfigParams, we are not subclassing it. Subclassing could cause problems with taking cmd args. Don't have an optimal solution for this help feature. I felt not too much bothered about it due to its triviality. -- 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