Search in sources :

Example 1 with MergeConfiguration

use of org.apache.rya.export.api.conf.MergeConfiguration 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;
}
Also used : ConfigurationAdapter(org.apache.rya.export.api.conf.ConfigurationAdapter) MergePolicy(org.apache.rya.export.MergePolicy) DBType(org.apache.rya.export.DBType) MergeConfiguration(org.apache.rya.export.api.conf.MergeConfiguration) TimestampPolicyMergeConfiguration(org.apache.rya.export.api.conf.policy.TimestampPolicyMergeConfiguration) AccumuloMergeConfiguration(org.apache.rya.export.api.conf.AccumuloMergeConfiguration) File(java.io.File)

Example 2 with MergeConfiguration

use of org.apache.rya.export.api.conf.MergeConfiguration in project incubator-rya by apache.

the class TimestampPolicyConfigurationAdapter method createConfig.

/**
 * @param jConfig - The JAXB generated configuration.
 * @return The {@link MergeConfiguration} used in the application
 * @throws MergeConfigurationException
 */
@Override
public MergeConfiguration createConfig(final MergeToolConfiguration jConfig) throws MergeConfigurationException {
    final TimestampMergePolicyConfiguration timeConfig = (TimestampMergePolicyConfiguration) jConfig;
    final MergeConfiguration.Builder configBuilder = super.getBuilder(jConfig);
    final TimestampPolicyBuilder builder = new TimestampPolicyBuilder(configBuilder);
    builder.setToolStartTime(timeConfig.getToolStartTime());
    return builder.build();
}
Also used : TimestampMergePolicyConfiguration(org.apache.rya.export.TimestampMergePolicyConfiguration) MergeConfiguration(org.apache.rya.export.api.conf.MergeConfiguration) TimestampPolicyBuilder(org.apache.rya.export.api.conf.policy.TimestampPolicyMergeConfiguration.TimestampPolicyBuilder)

Aggregations

MergeConfiguration (org.apache.rya.export.api.conf.MergeConfiguration)2 File (java.io.File)1 DBType (org.apache.rya.export.DBType)1 MergePolicy (org.apache.rya.export.MergePolicy)1 TimestampMergePolicyConfiguration (org.apache.rya.export.TimestampMergePolicyConfiguration)1 AccumuloMergeConfiguration (org.apache.rya.export.api.conf.AccumuloMergeConfiguration)1 ConfigurationAdapter (org.apache.rya.export.api.conf.ConfigurationAdapter)1 TimestampPolicyMergeConfiguration (org.apache.rya.export.api.conf.policy.TimestampPolicyMergeConfiguration)1 TimestampPolicyBuilder (org.apache.rya.export.api.conf.policy.TimestampPolicyMergeConfiguration.TimestampPolicyBuilder)1