Provide a constructor for CombineSelectionPolicy with only the selection config as argument[]
Closes from sv2000/gobblin-401
@@ -71,13 +71,17 @@ public class CombineSelectionPolicy implements VersionSelectionPolicy<DatasetVer
public static final String VERSION_SELECTION_COMBINE_OPERATION = "selection.combine.operation";
public enum CombineOperation {
- INTERSECT,
- UNION
+ INTERSECT, UNION
}
private final List<VersionSelectionPolicy<DatasetVersion>> selectionPolicies;
private final CombineOperation combineOperation;
+ public CombineSelectionPolicy(Config config)
+ throws IOException {
+ this(config, new Properties());
+ }
+
public CombineSelectionPolicy(List<VersionSelectionPolicy<DatasetVersion>> selectionPolicies,
CombineOperation combineOperation) {
this.combineOperation = combineOperation;
@@ -85,17 +89,18 @@ public class CombineSelectionPolicy implements VersionSelectionPolicy<DatasetVer
}
@SuppressWarnings("unchecked")
- public CombineSelectionPolicy(Config config, Properties jobProps) throws IOException {
+ public CombineSelectionPolicy(Config config, Properties jobProps)
+ throws IOException {
Preconditions.checkArgument(config.hasPath(VERSION_SELECTION_POLICIES_PREFIX), "Combine operation not specified.");
ImmutableList.Builder<VersionSelectionPolicy<DatasetVersion>> builder = ImmutableList.builder();
for (String combineClassName : config.getStringList(VERSION_SELECTION_POLICIES_PREFIX)) {
try {
- builder.add((VersionSelectionPolicy<DatasetVersion>) GobblinConstructorUtils.invokeFirstConstructor(
- Class.forName(combineClassName), ImmutableList.<Object> of(config), ImmutableList.<Object> of(jobProps)));
- } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException | InstantiationException
- | ClassNotFoundException e) {
+ builder.add((VersionSelectionPolicy<DatasetVersion>) GobblinConstructorUtils
+ .invokeFirstConstructor(Class.forName(combineClassName), ImmutableList.<Object>of(config),
+ ImmutableList.<Object>of(jobProps)));
+ } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException | InstantiationException | ClassNotFoundException e) {
throw new IllegalArgumentException(e);
}
}
@@ -109,9 +114,9 @@ public class CombineSelectionPolicy implements VersionSelectionPolicy<DatasetVer
CombineOperation.valueOf(config.getString(VERSION_SELECTION_COMBINE_OPERATION).toUpperCase());
}
- public CombineSelectionPolicy(Properties props) throws IOException {
+ public CombineSelectionPolicy(Properties props)
+ throws IOException {
this(ConfigFactory.parseProperties(props), props);
-
}
/**
@@ -150,7 +155,6 @@ public class CombineSelectionPolicy implements VersionSelectionPolicy<DatasetVer
default:
throw new RuntimeException("Combine operation " + this.combineOperation + " not recognized.");
}
-
}
@VisibleForTesting
