Search in sources :

Example 1 with RyaStatementStore

use of org.apache.rya.export.api.store.RyaStatementStore in project incubator-rya by apache.

the class StatementStoreFactory method getBaseStatementStore.

/**
 * @param isParent
 * @param config
 *          These parameters are hacks until the Accumulo DAO only accepts a connector.
 *          Once that happens this will be much, much cleaner, and make the {@link AccumuloInstanceDriver}
 *          obsolete.
 * @throws Exception
 */
private RyaStatementStore getBaseStatementStore(final DBType dbType, final String hostname, final int port, final String ryaInstancename, final String tablePrefix, final MergeConfiguration config, final boolean isParent) throws Exception {
    RyaStatementStore store;
    if (dbType == DBType.MONGO) {
        store = getBaseMongoStore(hostname, port, ryaInstancename);
    } else {
        final AccumuloMergeConfiguration aConfig = (AccumuloMergeConfiguration) config;
        final InstanceType type = isParent ? aConfig.getParentInstanceType() : aConfig.getChildInstanceType();
        store = getBaseAccumuloStore(ryaInstancename, type, isParent, ryaInstancename, tablePrefix, tablePrefix, tablePrefix, tablePrefix);
    }
    return store;
}
Also used : AccumuloMergeConfiguration(org.apache.rya.export.api.conf.AccumuloMergeConfiguration) InstanceType(org.apache.rya.export.InstanceType) MongoRyaStatementStore(org.apache.rya.export.mongo.MongoRyaStatementStore) AccumuloRyaStatementStore(org.apache.rya.export.accumulo.AccumuloRyaStatementStore) TimestampPolicyAccumuloRyaStatementStore(org.apache.rya.export.accumulo.policy.TimestampPolicyAccumuloRyaStatementStore) RyaStatementStore(org.apache.rya.export.api.store.RyaStatementStore) TimestampPolicyMongoRyaStatementStore(org.apache.rya.export.mongo.policy.TimestampPolicyMongoRyaStatementStore)

Example 2 with RyaStatementStore

use of org.apache.rya.export.api.store.RyaStatementStore in project incubator-rya by apache.

the class StatementStoreFactory method getParentStatementStore.

/**
 * Builds and retrieves the Parent {@link RyaStatementStore}.
 * @return The created {@link RyaStatementStore} that connects to the Parent rya.
 * @throws Exception - Something went wrong creating the {@link RyaStatementStore}.
 */
public RyaStatementStore getParentStatementStore() throws Exception {
    final DBType dbType = configuration.getParentDBType();
    final String ryaInstanceName = configuration.getParentRyaInstanceName();
    RyaStatementStore store = getBaseStatementStore(dbType, configuration.getParentHostname(), configuration.getParentPort(), ryaInstanceName, configuration.getParentTablePrefix(), configuration, true);
    store = getMergePolicyStatementStore(store, configuration.getMergePolicy(), ryaInstanceName, dbType);
    return store;
}
Also used : DBType(org.apache.rya.export.DBType) MongoRyaStatementStore(org.apache.rya.export.mongo.MongoRyaStatementStore) AccumuloRyaStatementStore(org.apache.rya.export.accumulo.AccumuloRyaStatementStore) TimestampPolicyAccumuloRyaStatementStore(org.apache.rya.export.accumulo.policy.TimestampPolicyAccumuloRyaStatementStore) RyaStatementStore(org.apache.rya.export.api.store.RyaStatementStore) TimestampPolicyMongoRyaStatementStore(org.apache.rya.export.mongo.policy.TimestampPolicyMongoRyaStatementStore)

Example 3 with RyaStatementStore

use of org.apache.rya.export.api.store.RyaStatementStore in project incubator-rya by apache.

the class StatementStoreFactory method getMergePolicyStatementStore.

private RyaStatementStore getMergePolicyStatementStore(final RyaStatementStore store, final MergePolicy policy, final String ryaInstanceName, final DBType dbType) {
    RyaStatementStore policyStore = null;
    if (policy == MergePolicy.TIMESTAMP) {
        final TimestampPolicyMergeConfiguration timeConfig = (TimestampPolicyMergeConfiguration) configuration;
        final Date timestamp = timeConfig.getToolStartTime();
        if (dbType == DBType.MONGO) {
            policyStore = new TimestampPolicyMongoRyaStatementStore((MongoRyaStatementStore) store, timestamp, ryaInstanceName);
        } else {
            policyStore = new TimestampPolicyAccumuloRyaStatementStore((AccumuloRyaStatementStore) store, timestamp);
        }
    }
    return policyStore == null ? store : policyStore;
}
Also used : TimestampPolicyMergeConfiguration(org.apache.rya.export.api.conf.policy.TimestampPolicyMergeConfiguration) TimestampPolicyAccumuloRyaStatementStore(org.apache.rya.export.accumulo.policy.TimestampPolicyAccumuloRyaStatementStore) AccumuloRyaStatementStore(org.apache.rya.export.accumulo.AccumuloRyaStatementStore) TimestampPolicyAccumuloRyaStatementStore(org.apache.rya.export.accumulo.policy.TimestampPolicyAccumuloRyaStatementStore) MongoRyaStatementStore(org.apache.rya.export.mongo.MongoRyaStatementStore) AccumuloRyaStatementStore(org.apache.rya.export.accumulo.AccumuloRyaStatementStore) TimestampPolicyAccumuloRyaStatementStore(org.apache.rya.export.accumulo.policy.TimestampPolicyAccumuloRyaStatementStore) RyaStatementStore(org.apache.rya.export.api.store.RyaStatementStore) TimestampPolicyMongoRyaStatementStore(org.apache.rya.export.mongo.policy.TimestampPolicyMongoRyaStatementStore) TimestampPolicyMongoRyaStatementStore(org.apache.rya.export.mongo.policy.TimestampPolicyMongoRyaStatementStore) MongoRyaStatementStore(org.apache.rya.export.mongo.MongoRyaStatementStore) TimestampPolicyMongoRyaStatementStore(org.apache.rya.export.mongo.policy.TimestampPolicyMongoRyaStatementStore) Date(java.util.Date)

Example 4 with RyaStatementStore

use of org.apache.rya.export.api.store.RyaStatementStore in project incubator-rya by apache.

the class MergeDriverClient method main.

public static void main(final String[] args) throws ParseException, MergeConfigurationException, UnknownHostException, MergerException, java.text.ParseException, SailException, AccumuloException, AccumuloSecurityException, InferenceEngineException, RepositoryException, MalformedQueryException, UpdateExecutionException {
    final String log4jConfiguration = System.getProperties().getProperty("log4j.configuration");
    if (StringUtils.isNotBlank(log4jConfiguration)) {
        final String parsedConfiguration = PathUtils.clean(StringUtils.removeStart(log4jConfiguration, "file:"));
        final File configFile = new File(parsedConfiguration);
        if (configFile.exists()) {
            DOMConfigurator.configure(parsedConfiguration);
        } else {
            BasicConfigurator.configure();
        }
    }
    final MergeConfigurationCLI config = new MergeConfigurationCLI(args);
    try {
        configuration = config.createConfiguration();
    } catch (final MergeConfigurationException e) {
        LOG.error("Configuration failed.", e);
    }
    final boolean useTimeSync = configuration.getUseNtpServer();
    Optional<Long> offset = Optional.absent();
    if (useTimeSync) {
        final String tomcat = configuration.getChildTomcatUrl();
        final String ntpHost = configuration.getNtpServerHost();
        try {
            offset = Optional.<Long>fromNullable(TimeUtils.getNtpServerAndMachineTimeDifference(ntpHost, tomcat));
        } catch (final IOException e) {
            LOG.error("Unable to get time difference between time server: " + ntpHost + " and the server: " + tomcat, e);
        }
    }
    final StatementStoreFactory storeFactory = new StatementStoreFactory(configuration);
    try {
        final RyaStatementStore parentStore = storeFactory.getParentStatementStore();
        final RyaStatementStore childStore = storeFactory.getChildStatementStore();
        LOG.info("Starting Merge Tool");
        if (configuration.getParentDBType() == ACCUMULO && configuration.getChildDBType() == ACCUMULO) {
            final AccumuloRyaStatementStore childAStore = (AccumuloRyaStatementStore) childStore;
            final AccumuloRyaStatementStore parentAStore = (AccumuloRyaStatementStore) parentStore;
        // do map reduce merging.
        // TODO: Run Merger
        } else {
            if (configuration.getMergePolicy() == TIMESTAMP) {
                final TimestampPolicyMergeConfiguration timeConfig = (TimestampPolicyMergeConfiguration) configuration;
                final Long timeOffset;
                if (offset.isPresent()) {
                    timeOffset = offset.get();
                } else {
                    timeOffset = 0L;
                }
                final MemoryTimeMerger merger = new MemoryTimeMerger(parentStore, childStore, new VisibilityStatementMerger(), timeConfig.getToolStartTime(), configuration.getParentRyaInstanceName(), timeOffset);
                merger.runJob();
            }
        }
    } catch (final Exception e) {
        LOG.error("Something went wrong creating a Rya Statement Store connection.", e);
    }
    Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {

        @Override
        public void uncaughtException(final Thread thread, final Throwable throwable) {
            LOG.error("Uncaught exception in " + thread.getName(), throwable);
        }
    });
    LOG.info("Finished running Merge Tool");
    System.exit(1);
}
Also used : StatementStoreFactory(org.apache.rya.export.client.merge.StatementStoreFactory) TimestampPolicyMergeConfiguration(org.apache.rya.export.api.conf.policy.TimestampPolicyMergeConfiguration) VisibilityStatementMerger(org.apache.rya.export.client.merge.VisibilityStatementMerger) MemoryTimeMerger(org.apache.rya.export.client.merge.MemoryTimeMerger) IOException(java.io.IOException) MergeConfigurationCLI(org.apache.rya.export.client.conf.MergeConfigurationCLI) InferenceEngineException(org.apache.rya.rdftriplestore.inference.InferenceEngineException) SailException(org.openrdf.sail.SailException) RepositoryException(org.openrdf.repository.RepositoryException) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) UpdateExecutionException(org.openrdf.query.UpdateExecutionException) MalformedQueryException(org.openrdf.query.MalformedQueryException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException) AccumuloException(org.apache.accumulo.core.client.AccumuloException) MergerException(org.apache.rya.export.api.MergerException) ParseException(org.apache.commons.cli.ParseException) MergeConfigurationException(org.apache.rya.export.api.conf.MergeConfigurationException) MergeConfigurationException(org.apache.rya.export.api.conf.MergeConfigurationException) AccumuloRyaStatementStore(org.apache.rya.export.accumulo.AccumuloRyaStatementStore) File(java.io.File) AccumuloRyaStatementStore(org.apache.rya.export.accumulo.AccumuloRyaStatementStore) RyaStatementStore(org.apache.rya.export.api.store.RyaStatementStore)

Aggregations

AccumuloRyaStatementStore (org.apache.rya.export.accumulo.AccumuloRyaStatementStore)4 RyaStatementStore (org.apache.rya.export.api.store.RyaStatementStore)4 TimestampPolicyAccumuloRyaStatementStore (org.apache.rya.export.accumulo.policy.TimestampPolicyAccumuloRyaStatementStore)3 MongoRyaStatementStore (org.apache.rya.export.mongo.MongoRyaStatementStore)3 TimestampPolicyMongoRyaStatementStore (org.apache.rya.export.mongo.policy.TimestampPolicyMongoRyaStatementStore)3 TimestampPolicyMergeConfiguration (org.apache.rya.export.api.conf.policy.TimestampPolicyMergeConfiguration)2 File (java.io.File)1 IOException (java.io.IOException)1 UnknownHostException (java.net.UnknownHostException)1 Date (java.util.Date)1 AccumuloException (org.apache.accumulo.core.client.AccumuloException)1 AccumuloSecurityException (org.apache.accumulo.core.client.AccumuloSecurityException)1 ParseException (org.apache.commons.cli.ParseException)1 DBType (org.apache.rya.export.DBType)1 InstanceType (org.apache.rya.export.InstanceType)1 MergerException (org.apache.rya.export.api.MergerException)1 AccumuloMergeConfiguration (org.apache.rya.export.api.conf.AccumuloMergeConfiguration)1 MergeConfigurationException (org.apache.rya.export.api.conf.MergeConfigurationException)1 MergeConfigurationCLI (org.apache.rya.export.client.conf.MergeConfigurationCLI)1 MemoryTimeMerger (org.apache.rya.export.client.merge.MemoryTimeMerger)1