Search in sources :

Example 1 with IncrementalBindingSetExporter

use of org.apache.rya.indexing.pcj.fluo.app.export.IncrementalBindingSetExporter in project incubator-rya by apache.

the class KafkaBindingSetExporterFactory method build.

@Override
public Optional<IncrementalResultExporter> build(final Context context) throws IncrementalExporterFactoryException, ConfigurationException {
    final KafkaBindingSetExporterParameters exportParams = new KafkaBindingSetExporterParameters(context.getObserverConfiguration().toMap());
    if (exportParams.getUseKafkaBindingSetExporter()) {
        log.info("Exporter is enabled.");
        // Setup Kafka connection
        final KafkaProducer<String, VisibilityBindingSet> producer = new KafkaProducer<>(exportParams.listAllConfig());
        // Create the exporter
        final IncrementalBindingSetExporter exporter = new KafkaBindingSetExporter(producer);
        return Optional.of(exporter);
    } else {
        return Optional.absent();
    }
}
Also used : KafkaProducer(org.apache.kafka.clients.producer.KafkaProducer) VisibilityBindingSet(org.apache.rya.api.model.VisibilityBindingSet) IncrementalBindingSetExporter(org.apache.rya.indexing.pcj.fluo.app.export.IncrementalBindingSetExporter)

Example 2 with IncrementalBindingSetExporter

use of org.apache.rya.indexing.pcj.fluo.app.export.IncrementalBindingSetExporter in project incubator-rya by apache.

the class PeriodicBindingSetExporterFactory method build.

@Override
public Optional<IncrementalResultExporter> build(Context context) throws IncrementalExporterFactoryException, ConfigurationException {
    checkNotNull(context);
    // Wrap the context's parameters for parsing.
    final RyaExportParameters params = new RyaExportParameters(context.getObserverConfiguration().toMap());
    if (params.getUsePeriodicBindingSetExporter()) {
        // Setup Zookeeper connection info.
        final String accumuloInstance = params.getAccumuloInstanceName().get();
        final String zookeeperServers = params.getZookeeperServers().get().replaceAll(";", ",");
        final Instance inst = new ZooKeeperInstance(accumuloInstance, zookeeperServers);
        try {
            // Setup Accumulo connection info.
            final String exporterUsername = params.getExporterUsername().get();
            final String exporterPassword = params.getExporterPassword().get();
            final Connector accumuloConn = inst.getConnector(exporterUsername, new PasswordToken(exporterPassword));
            // Setup Rya PCJ Storage.
            final String ryaInstanceName = params.getRyaInstanceName().get();
            final PeriodicQueryResultStorage periodicStorage = new AccumuloPeriodicQueryResultStorage(accumuloConn, ryaInstanceName);
            // Make the exporter.
            final IncrementalBindingSetExporter exporter = new PeriodicBindingSetExporter(periodicStorage);
            return Optional.of(exporter);
        } catch (final AccumuloException | AccumuloSecurityException e) {
            throw new IncrementalExporterFactoryException("Could not initialize the Accumulo connector using the provided configuration.", e);
        }
    } else {
        return Optional.absent();
    }
}
Also used : Connector(org.apache.accumulo.core.client.Connector) AccumuloException(org.apache.accumulo.core.client.AccumuloException) Instance(org.apache.accumulo.core.client.Instance) ZooKeeperInstance(org.apache.accumulo.core.client.ZooKeeperInstance) AccumuloPeriodicQueryResultStorage(org.apache.rya.indexing.pcj.storage.accumulo.AccumuloPeriodicQueryResultStorage) IncrementalBindingSetExporter(org.apache.rya.indexing.pcj.fluo.app.export.IncrementalBindingSetExporter) ZooKeeperInstance(org.apache.accumulo.core.client.ZooKeeperInstance) PasswordToken(org.apache.accumulo.core.client.security.tokens.PasswordToken) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) AccumuloPeriodicQueryResultStorage(org.apache.rya.indexing.pcj.storage.accumulo.AccumuloPeriodicQueryResultStorage) PeriodicQueryResultStorage(org.apache.rya.indexing.pcj.storage.PeriodicQueryResultStorage)

Example 3 with IncrementalBindingSetExporter

use of org.apache.rya.indexing.pcj.fluo.app.export.IncrementalBindingSetExporter in project incubator-rya by apache.

the class RyaBindingSetExporterFactory method build.

@Override
public Optional<IncrementalResultExporter> build(final Context context) throws IncrementalExporterFactoryException, ConfigurationException {
    checkNotNull(context);
    // Wrap the context's parameters for parsing.
    final RyaExportParameters params = new RyaExportParameters(context.getObserverConfiguration().toMap());
    if (params.getUseRyaBindingSetExporter()) {
        // Setup Zookeeper connection info.
        final String accumuloInstance = params.getAccumuloInstanceName().get();
        final String zookeeperServers = params.getZookeeperServers().get().replaceAll(";", ",");
        final Instance inst = new ZooKeeperInstance(accumuloInstance, zookeeperServers);
        try {
            // Setup Accumulo connection info.
            final String exporterUsername = params.getExporterUsername().get();
            final String exporterPassword = params.getExporterPassword().get();
            final Connector accumuloConn = inst.getConnector(exporterUsername, new PasswordToken(exporterPassword));
            // Setup Rya PCJ Storage.
            final String ryaInstanceName = params.getRyaInstanceName().get();
            final PrecomputedJoinStorage pcjStorage = new AccumuloPcjStorage(accumuloConn, ryaInstanceName);
            // Make the exporter.
            final IncrementalBindingSetExporter exporter = new RyaBindingSetExporter(pcjStorage);
            return Optional.of(exporter);
        } catch (final AccumuloException | AccumuloSecurityException e) {
            throw new IncrementalExporterFactoryException("Could not initialize the Accumulo connector using the provided configuration.", e);
        }
    } else {
        return Optional.absent();
    }
}
Also used : Connector(org.apache.accumulo.core.client.Connector) AccumuloException(org.apache.accumulo.core.client.AccumuloException) AccumuloPcjStorage(org.apache.rya.indexing.pcj.storage.accumulo.AccumuloPcjStorage) Instance(org.apache.accumulo.core.client.Instance) ZooKeeperInstance(org.apache.accumulo.core.client.ZooKeeperInstance) IncrementalBindingSetExporter(org.apache.rya.indexing.pcj.fluo.app.export.IncrementalBindingSetExporter) ZooKeeperInstance(org.apache.accumulo.core.client.ZooKeeperInstance) PasswordToken(org.apache.accumulo.core.client.security.tokens.PasswordToken) PrecomputedJoinStorage(org.apache.rya.indexing.pcj.storage.PrecomputedJoinStorage) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException)

Aggregations

IncrementalBindingSetExporter (org.apache.rya.indexing.pcj.fluo.app.export.IncrementalBindingSetExporter)3 AccumuloException (org.apache.accumulo.core.client.AccumuloException)2 AccumuloSecurityException (org.apache.accumulo.core.client.AccumuloSecurityException)2 Connector (org.apache.accumulo.core.client.Connector)2 Instance (org.apache.accumulo.core.client.Instance)2 ZooKeeperInstance (org.apache.accumulo.core.client.ZooKeeperInstance)2 PasswordToken (org.apache.accumulo.core.client.security.tokens.PasswordToken)2 KafkaProducer (org.apache.kafka.clients.producer.KafkaProducer)1 VisibilityBindingSet (org.apache.rya.api.model.VisibilityBindingSet)1 PeriodicQueryResultStorage (org.apache.rya.indexing.pcj.storage.PeriodicQueryResultStorage)1 PrecomputedJoinStorage (org.apache.rya.indexing.pcj.storage.PrecomputedJoinStorage)1 AccumuloPcjStorage (org.apache.rya.indexing.pcj.storage.accumulo.AccumuloPcjStorage)1 AccumuloPeriodicQueryResultStorage (org.apache.rya.indexing.pcj.storage.accumulo.AccumuloPeriodicQueryResultStorage)1