Search in sources :

Example 6 with CreatePeriodicQuery

use of org.apache.rya.indexing.pcj.fluo.api.CreatePeriodicQuery in project incubator-rya by apache.

the class AccumuloCreatePeriodicPCJ method updateFluoAppAndRegisterWithKafka.

private String updateFluoAppAndRegisterWithKafka(final String ryaInstance, final String fluoAppName, String sparql, String periodicTopic, String bootStrapServers) throws RepositoryException, MalformedQueryException, SailException, QueryEvaluationException, PcjException, RyaDAOException, UnsupportedQueryException, PeriodicQueryCreationException {
    requireNonNull(sparql);
    requireNonNull(periodicTopic);
    requireNonNull(bootStrapServers);
    final PeriodicQueryResultStorage periodicStorage = new AccumuloPeriodicQueryResultStorage(getConnector(), ryaInstance);
    // Connect to the Fluo application that is updating this instance's PCJs.
    final AccumuloConnectionDetails cd = super.getAccumuloConnectionDetails();
    try (final FluoClient fluoClient = new FluoClientFactory().connect(cd.getUsername(), new String(cd.getUserPass()), cd.getInstanceName(), cd.getZookeepers(), fluoAppName)) {
        // Initialize the PCJ within the Fluo application.
        final CreatePeriodicQuery periodicPcj = new CreatePeriodicQuery(fluoClient, periodicStorage);
        PeriodicNotificationClient periodicClient = new KafkaNotificationRegistrationClient(periodicTopic, createProducer(bootStrapServers));
        return periodicPcj.withRyaIntegration(sparql, periodicClient, getConnector(), ryaInstance).getQueryId();
    }
}
Also used : FluoClient(org.apache.fluo.api.client.FluoClient) AccumuloPeriodicQueryResultStorage(org.apache.rya.indexing.pcj.storage.accumulo.AccumuloPeriodicQueryResultStorage) PeriodicNotificationClient(org.apache.rya.periodic.notification.api.PeriodicNotificationClient) CreatePeriodicQuery(org.apache.rya.indexing.pcj.fluo.api.CreatePeriodicQuery) AccumuloPeriodicQueryResultStorage(org.apache.rya.indexing.pcj.storage.accumulo.AccumuloPeriodicQueryResultStorage) PeriodicQueryResultStorage(org.apache.rya.indexing.pcj.storage.PeriodicQueryResultStorage) KafkaNotificationRegistrationClient(org.apache.rya.periodic.notification.registration.KafkaNotificationRegistrationClient)

Aggregations

FluoClient (org.apache.fluo.api.client.FluoClient)6 CreatePeriodicQuery (org.apache.rya.indexing.pcj.fluo.api.CreatePeriodicQuery)6 PeriodicQueryResultStorage (org.apache.rya.indexing.pcj.storage.PeriodicQueryResultStorage)6 AccumuloPeriodicQueryResultStorage (org.apache.rya.indexing.pcj.storage.accumulo.AccumuloPeriodicQueryResultStorage)6 ZonedDateTime (java.time.ZonedDateTime)4 HashSet (java.util.HashSet)4 DatatypeFactory (javax.xml.datatype.DatatypeFactory)4 Test (org.junit.Test)4 Statement (org.openrdf.model.Statement)4 ValueFactory (org.openrdf.model.ValueFactory)4 ValueFactoryImpl (org.openrdf.model.impl.ValueFactoryImpl)4 BindingSet (org.openrdf.query.BindingSet)4 QueryBindingSet (org.openrdf.query.algebra.evaluation.QueryBindingSet)4 ArrayList (java.util.ArrayList)3 Connector (org.apache.accumulo.core.client.Connector)3 KafkaConsumer (org.apache.kafka.clients.consumer.KafkaConsumer)3 StringDeserializer (org.apache.kafka.common.serialization.StringDeserializer)3 BindingSetSerDe (org.apache.rya.periodic.notification.serialization.BindingSetSerDe)3 PeriodicNotificationClient (org.apache.rya.periodic.notification.api.PeriodicNotificationClient)2 KafkaNotificationRegistrationClient (org.apache.rya.periodic.notification.registration.KafkaNotificationRegistrationClient)2