[HUDI-2883] Refactor hive sync tool / config to use reflection and standardize configs (#4175)
- Refactor hive sync tool / config to use reflection and standardize configs Co-authored-by: sivabalan <n.siva.b@gmail.com> Co-authored-by: Rajesh Mahindra <rmahindra@Rajeshs-MacBook-Pro.local> Co-authored-by: Raymond Xu <2701446+xushiyan@users.noreply.github.com>
This commit is contained in:
@@ -82,6 +82,8 @@ public class HoodieTableConfig extends HoodieConfig {
|
||||
|
||||
public static final String HOODIE_PROPERTIES_FILE = "hoodie.properties";
|
||||
public static final String HOODIE_PROPERTIES_FILE_BACKUP = "hoodie.properties.backup";
|
||||
public static final String HOODIE_WRITE_TABLE_NAME_KEY = "hoodie.datasource.write.table.name";
|
||||
public static final String HOODIE_TABLE_NAME_KEY = "hoodie.table.name";
|
||||
|
||||
public static final ConfigProperty<String> DATABASE_NAME = ConfigProperty
|
||||
.key("hoodie.database.name")
|
||||
@@ -90,7 +92,7 @@ public class HoodieTableConfig extends HoodieConfig {
|
||||
+ "we can set it to limit the table name under a specific database");
|
||||
|
||||
public static final ConfigProperty<String> NAME = ConfigProperty
|
||||
.key("hoodie.table.name")
|
||||
.key(HOODIE_TABLE_NAME_KEY)
|
||||
.noDefaultValue()
|
||||
.withDocumentation("Table name that will be used for registering with Hive. Needs to be same across runs.");
|
||||
|
||||
|
||||
@@ -92,6 +92,24 @@ public class ReflectionUtils {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the clazz has the target constructor or not.
|
||||
*
|
||||
* When catch {@link HoodieException} from {@link #loadClass}, it's inconvenient to say if the exception was thrown
|
||||
* due to the instantiation's own logic or missing constructor.
|
||||
*
|
||||
* TODO: ReflectionUtils should throw a specific exception to indicate Reflection problem.
|
||||
*/
|
||||
public static boolean hasConstructor(String clazz, Class<?>[] constructorArgTypes) {
|
||||
try {
|
||||
getClass(clazz).getConstructor(constructorArgTypes);
|
||||
return true;
|
||||
} catch (NoSuchMethodException e) {
|
||||
LOG.warn("Unable to instantiate class " + clazz, e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an instance of the given class. Constructor arg types are inferred.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user