use of org.apache.rya.export.MergePolicy in project incubator-rya by apache.
the class MergeConfigurationCLI method createConfiguration.
/**
* Attempts to create the {@link MergeConfiguration} based on the provided
* configuration file.
* @return The {@link MergeConfiguration} created.
* @throws MergeConfigurationException - Thrown when the provided file is
* not formatted properly for a {@link MergeConfiguration}.
*/
public MergeConfiguration createConfiguration() throws MergeConfigurationException {
if (configuration == null) {
// If the config option is present, ignore all other options.
if (cmd.hasOption(CONFIG_OPTION.getOpt())) {
final File xml = new File(cmd.getOptionValue(CONFIG_OPTION.getOpt()));
final ConfigurationAdapter adapter = new ConfigurationAdapter();
configuration = adapter.createConfig(createConfigurationFromFile(xml));
} else {
final DBType parentType = DBType.fromValue(cmd.getOptionValue(PARENT_DB_OPTION.getLongOpt()));
final DBType childType = DBType.fromValue(cmd.getOptionValue(CHILD_DB_OPTION.getLongOpt()));
final MergePolicy mergePolicy = MergePolicy.fromValue(cmd.getOptionValue(MERGE_OPTION.getLongOpt()));
MergeConfiguration.Builder builder = new MergeConfiguration.Builder().setParentHostname(cmd.getOptionValue(PARENT_HOST_OPTION.getLongOpt())).setParentUsername(cmd.getOptionValue(PARENT_USER_OPTION.getLongOpt())).setParentPassword(cmd.getOptionValue(PARENT_PSWD_OPTION.getLongOpt())).setParentRyaInstanceName(cmd.getOptionValue(PARENT_RYA_OPTION.getLongOpt())).setParentTablePrefix(cmd.getOptionValue(PARENT_PREFIX_OPTION.getLongOpt())).setParentTomcatUrl(cmd.getOptionValue(PARENT_TOMCAT_OPTION.getLongOpt())).setParentDBType(parentType).setParentPort(Integer.parseInt(cmd.getOptionValue(PARENT_PORT_OPTION.getLongOpt()))).setChildHostname(cmd.getOptionValue(CHILD_HOST_OPTION.getLongOpt())).setChildUsername(cmd.getOptionValue(CHILD_USER_OPTION.getLongOpt())).setChildPassword(cmd.getOptionValue(CHILD_PSWD_OPTION.getLongOpt())).setChildRyaInstanceName(cmd.getOptionValue(CHILD_RYA_OPTION.getLongOpt())).setChildTablePrefix(cmd.getOptionValue(CHILD_PREFIX_OPTION.getLongOpt())).setChildTomcatUrl(cmd.getOptionValue(CHILD_TOMCAT_OPTION.getLongOpt())).setChildDBType(childType).setChildPort(Integer.parseInt(cmd.getOptionValue(CHILD_PORT_OPTION.getLongOpt()))).setMergePolicy(mergePolicy);
if (mergePolicy == TIMESTAMP) {
builder = new TimestampPolicyMergeConfiguration.TimestampPolicyBuilder(builder).setToolStartTime(cmd.getOptionValue(TIME_OPTION.getLongOpt()));
}
if (parentType == DBType.ACCUMULO) {
builder = new AccumuloMergeConfiguration.AccumuloBuilder(builder).setParentZookeepers(cmd.getOptionValue(PARENT_ACCUMULO_ZOOKEEPERS_OPTION.getLongOpt())).setParentAuths(cmd.getOptionValue(PARENT_ACCUMULO_AUTHS_OPTION.getLongOpt())).setParentInstanceType(InstanceType.fromValue(cmd.getOptionValue(PARENT_ACCUMULO_TYPE_OPTION.getLongOpt())));
}
if (childType == DBType.ACCUMULO) {
builder = new AccumuloMergeConfiguration.AccumuloBuilder(builder).setChildZookeepers(cmd.getOptionValue(CHILD_ACCUMULO_ZOOKEEPERS_OPTION.getLongOpt())).setChildAuths(cmd.getOptionValue(CHILD_ACCUMULO_AUTHS_OPTION.getLongOpt())).setChildInstanceType(InstanceType.fromValue(cmd.getOptionValue(CHILD_ACCUMULO_TYPE_OPTION.getLongOpt())));
}
configuration = builder.build();
}
}
return configuration;
}
Aggregations