Search in sources :

Example 16 with FluoDetails

use of org.apache.rya.api.instance.RyaDetails.PCJIndexDetails.FluoDetails in project incubator-rya by apache.

the class RyaDetailsToConfigurationTest method populateConfigTest.

@Test
public void populateConfigTest() {
    final RyaDetails.Builder builder = RyaDetails.builder();
    builder.setRyaInstanceName("test_instance").setRyaVersion("1.2.3.4").setEntityCentricIndexDetails(new EntityCentricIndexDetails(true)).setTemporalIndexDetails(new TemporalIndexDetails(true)).setFreeTextDetails(new FreeTextIndexDetails(false)).setPCJIndexDetails(PCJIndexDetails.builder().setEnabled(true).setFluoDetails(new FluoDetails("test_instance_rya_pcj_updater")).addPCJDetails(PCJDetails.builder().setId("pcj 1").setUpdateStrategy(PCJUpdateStrategy.BATCH).setLastUpdateTime(new Date())).addPCJDetails(PCJDetails.builder().setId("pcj 2").setUpdateStrategy(PCJUpdateStrategy.INCREMENTAL))).setProspectorDetails(new ProspectorDetails(Optional.of(new Date()))).setJoinSelectivityDetails(new JoinSelectivityDetails(Optional.of(new Date())));
    final Configuration conf = new Configuration();
    RyaDetailsToConfiguration.addRyaDetailsToConfiguration(builder.build(), conf);
    // defaults are set to cause the assert to fail
    assertTrue(conf.getBoolean(USE_ENTITY, false));
    assertFalse(conf.getBoolean(USE_FREETEXT, true));
    // RYA-215assertTrue(conf.getBoolean(USE_GEO, false));
    assertTrue(conf.getBoolean(USE_TEMPORAL, false));
    assertTrue(conf.getBoolean(USE_PCJ_UPDATER, false));
}
Also used : ProspectorDetails(org.apache.rya.api.instance.RyaDetails.ProspectorDetails) EntityCentricIndexDetails(org.apache.rya.api.instance.RyaDetails.EntityCentricIndexDetails) TemporalIndexDetails(org.apache.rya.api.instance.RyaDetails.TemporalIndexDetails) Configuration(org.apache.hadoop.conf.Configuration) FreeTextIndexDetails(org.apache.rya.api.instance.RyaDetails.FreeTextIndexDetails) FluoDetails(org.apache.rya.api.instance.RyaDetails.PCJIndexDetails.FluoDetails) Date(java.util.Date) JoinSelectivityDetails(org.apache.rya.api.instance.RyaDetails.JoinSelectivityDetails) Test(org.junit.Test)

Example 17 with FluoDetails

use of org.apache.rya.api.instance.RyaDetails.PCJIndexDetails.FluoDetails in project incubator-rya by apache.

the class AccumuloCreatePeriodicPCJ method createPeriodicPCJ.

@Override
public String createPeriodicPCJ(String instanceName, String sparql, String periodicTopic, String bootStrapServers) throws RyaClientException {
    requireNonNull(instanceName);
    requireNonNull(sparql);
    final Optional<RyaDetails> ryaDetailsHolder = getInstanceDetails.getDetails(instanceName);
    final boolean ryaInstanceExists = ryaDetailsHolder.isPresent();
    if (!ryaInstanceExists) {
        throw new InstanceDoesNotExistException(String.format("The '%s' instance of Rya does not exist.", instanceName));
    }
    final PCJIndexDetails pcjIndexDetails = ryaDetailsHolder.get().getPCJIndexDetails();
    final boolean pcjIndexingEnabeld = pcjIndexDetails.isEnabled();
    if (!pcjIndexingEnabeld) {
        throw new RyaClientException(String.format("The '%s' instance of Rya does not have PCJ Indexing enabled.", instanceName));
    }
    // If a Fluo application is being used, task it with updating the PCJ.
    final Optional<FluoDetails> fluoDetailsHolder = pcjIndexDetails.getFluoDetails();
    if (fluoDetailsHolder.isPresent()) {
        final String fluoAppName = fluoDetailsHolder.get().getUpdateAppName();
        try {
            return updateFluoAppAndRegisterWithKafka(instanceName, fluoAppName, sparql, periodicTopic, bootStrapServers);
        } catch (RepositoryException | MalformedQueryException | SailException | QueryEvaluationException | PcjException | RyaDAOException | PeriodicQueryCreationException e) {
            throw new RyaClientException("Problem while initializing the Fluo application with the new PCJ.", e);
        } catch (UnsupportedQueryException e) {
            throw new RyaClientException("The new PCJ could not be initialized because it either contains an unsupported query node " + "or an invalid ExportStrategy for the given QueryType.  Projection queries can be exported to either Rya or Kafka," + "unless they contain an aggregation, in which case they can only be exported to Kafka.  Construct queries can be exported" + "to Rya and Kafka, and Periodic queries can only be exported to Rya.");
        }
    } else {
        throw new RyaClientException(String.format("The '%s' instance of Rya does not have PCJ Indexing enabled.", instanceName));
    }
}
Also used : RyaClientException(org.apache.rya.api.client.RyaClientException) PcjException(org.apache.rya.indexing.pcj.storage.PcjException) UnsupportedQueryException(org.apache.rya.indexing.pcj.fluo.app.query.UnsupportedQueryException) RyaDetails(org.apache.rya.api.instance.RyaDetails) RepositoryException(org.openrdf.repository.RepositoryException) InstanceDoesNotExistException(org.apache.rya.api.client.InstanceDoesNotExistException) SailException(org.openrdf.sail.SailException) QueryEvaluationException(org.openrdf.query.QueryEvaluationException) MalformedQueryException(org.openrdf.query.MalformedQueryException) RyaDAOException(org.apache.rya.api.persist.RyaDAOException) PeriodicQueryCreationException(org.apache.rya.indexing.pcj.fluo.api.CreatePeriodicQuery.PeriodicQueryCreationException) FluoDetails(org.apache.rya.api.instance.RyaDetails.PCJIndexDetails.FluoDetails) PCJIndexDetails(org.apache.rya.api.instance.RyaDetails.PCJIndexDetails)

Example 18 with FluoDetails

use of org.apache.rya.api.instance.RyaDetails.PCJIndexDetails.FluoDetails in project incubator-rya by apache.

the class AccumuloDeletePeriodicPCJ method deletePeriodicPCJ.

@Override
public void deletePeriodicPCJ(final String instanceName, final String pcjId, String topic, String brokers) throws InstanceDoesNotExistException, RyaClientException {
    requireNonNull(instanceName);
    requireNonNull(pcjId);
    final Optional<RyaDetails> originalDetails = getInstanceDetails.getDetails(instanceName);
    final boolean ryaInstanceExists = originalDetails.isPresent();
    if (!ryaInstanceExists) {
        throw new InstanceDoesNotExistException(String.format("The '%s' instance of Rya does not exist.", instanceName));
    }
    final boolean pcjIndexingEnabled = originalDetails.get().getPCJIndexDetails().isEnabled();
    if (!pcjIndexingEnabled) {
        throw new RyaClientException(String.format("The '%s' instance of Rya does not have PCJ Indexing enabled.", instanceName));
    }
    // If the PCJ was being maintained by a Fluo application, then stop that process.
    final PCJIndexDetails pcjIndexDetails = originalDetails.get().getPCJIndexDetails();
    final Optional<FluoDetails> fluoDetailsHolder = pcjIndexDetails.getFluoDetails();
    if (fluoDetailsHolder.isPresent()) {
        final String fluoAppName = pcjIndexDetails.getFluoDetails().get().getUpdateAppName();
        try {
            stopUpdatingPCJ(instanceName, fluoAppName, pcjId, topic, brokers);
        } catch (MalformedQueryException | UnsupportedQueryException | QueryDeletionException e) {
            throw new RyaClientException(String.format("Unable to delete Periodic Query with id: %s", pcjId), e);
        }
    } else {
        log.error(String.format("Could not stop the Fluo application from updating the PCJ because the Fluo Details are " + "missing for the Rya instance named '%s'.", instanceName));
    }
}
Also used : RyaClientException(org.apache.rya.api.client.RyaClientException) UnsupportedQueryException(org.apache.rya.indexing.pcj.fluo.app.query.UnsupportedQueryException) RyaDetails(org.apache.rya.api.instance.RyaDetails) InstanceDoesNotExistException(org.apache.rya.api.client.InstanceDoesNotExistException) QueryDeletionException(org.apache.rya.indexing.pcj.fluo.api.DeletePeriodicQuery.QueryDeletionException) MalformedQueryException(org.openrdf.query.MalformedQueryException) FluoDetails(org.apache.rya.api.instance.RyaDetails.PCJIndexDetails.FluoDetails) PCJIndexDetails(org.apache.rya.api.instance.RyaDetails.PCJIndexDetails)

Example 19 with FluoDetails

use of org.apache.rya.api.instance.RyaDetails.PCJIndexDetails.FluoDetails in project incubator-rya by apache.

the class MongoDetailsAdapterTest method absentOptionalToMongoTest.

@Test
public void absentOptionalToMongoTest() {
    // Convert the Details into a Mongo DB OBject.
    final RyaDetails details = RyaDetails.builder().setRyaInstanceName("test").setRyaVersion("1").setEntityCentricIndexDetails(new EntityCentricIndexDetails(true)).setPCJIndexDetails(PCJIndexDetails.builder().setEnabled(true).setFluoDetails(new FluoDetails("fluo"))).setTemporalIndexDetails(new TemporalIndexDetails(false)).setFreeTextDetails(new FreeTextIndexDetails(true)).setProspectorDetails(new ProspectorDetails(Optional.<Date>absent())).setJoinSelectivityDetails(new JoinSelectivityDetails(Optional.<Date>absent())).build();
    final DBObject actual = MongoDetailsAdapter.toDBObject(details);
    // Ensure it matches the expected object.
    final BasicDBObject expected = (BasicDBObject) JSON.parse("{ " + "instanceName : \"test\"," + "version : \"1\"," + "entityCentricDetails : true," + // RYA-215                + "geoDetails : false,"
    "pcjDetails : {" + "enabled : true," + "pcjs : [ ]" + "}," + "temporalDetails : false," + "freeTextDetails : true" + "}");
    assertEquals(expected, actual);
}
Also used : ProspectorDetails(org.apache.rya.api.instance.RyaDetails.ProspectorDetails) EntityCentricIndexDetails(org.apache.rya.api.instance.RyaDetails.EntityCentricIndexDetails) BasicDBObject(com.mongodb.BasicDBObject) TemporalIndexDetails(org.apache.rya.api.instance.RyaDetails.TemporalIndexDetails) FreeTextIndexDetails(org.apache.rya.api.instance.RyaDetails.FreeTextIndexDetails) RyaDetails(org.apache.rya.api.instance.RyaDetails) FluoDetails(org.apache.rya.api.instance.RyaDetails.PCJIndexDetails.FluoDetails) BasicDBObject(com.mongodb.BasicDBObject) DBObject(com.mongodb.DBObject) Date(java.util.Date) JoinSelectivityDetails(org.apache.rya.api.instance.RyaDetails.JoinSelectivityDetails) Test(org.junit.Test)

Example 20 with FluoDetails

use of org.apache.rya.api.instance.RyaDetails.PCJIndexDetails.FluoDetails in project incubator-rya by apache.

the class MongoDetailsAdapterTest method ryaDetailsToMongoTest.

@Test
public void ryaDetailsToMongoTest() {
    // Convert the Details into a Mongo DB OBject.
    final RyaDetails details = RyaDetails.builder().setRyaInstanceName("test").setRyaVersion("1").setEntityCentricIndexDetails(new EntityCentricIndexDetails(true)).setPCJIndexDetails(PCJIndexDetails.builder().setEnabled(true).setFluoDetails(new FluoDetails("fluo")).addPCJDetails(PCJDetails.builder().setId("pcj_0").setUpdateStrategy(PCJUpdateStrategy.BATCH).setLastUpdateTime(new Date(0L))).addPCJDetails(PCJDetails.builder().setId("pcj_1").setUpdateStrategy(PCJUpdateStrategy.BATCH).setLastUpdateTime(new Date(1L)))).setTemporalIndexDetails(new TemporalIndexDetails(true)).setFreeTextDetails(new FreeTextIndexDetails(true)).setProspectorDetails(new ProspectorDetails(Optional.fromNullable(new Date(0L)))).setJoinSelectivityDetails(new JoinSelectivityDetails(Optional.fromNullable(new Date(1L)))).setRyaStreamsDetails(new RyaStreamsDetails("localhost", 6)).build();
    final BasicDBObject actual = MongoDetailsAdapter.toDBObject(details);
    // Ensure it matches the expected object.
    final DBObject expected = (DBObject) JSON.parse("{ " + "instanceName : \"test\"," + "version : \"1\"," + "entityCentricDetails : true," + // RYA-215            + "geoDetails : true,"
    "pcjDetails : {" + "enabled : true ," + "pcjs : [ " + "{" + "id : \"pcj_0\"," + "updateStrategy : \"BATCH\"," + "lastUpdate : { $date : \"1970-01-01T00:00:00.000Z\"}" + "}," + "{" + "id : \"pcj_1\"," + "updateStrategy : \"BATCH\"," + "lastUpdate : { $date : \"1970-01-01T00:00:00.001Z\"}" + "}]" + "}," + "temporalDetails : true," + "freeTextDetails : true," + "prospectorDetails : { $date : \"1970-01-01T00:00:00.000Z\"}," + "joinSelectivitiyDetails : { $date : \"1970-01-01T00:00:00.001Z\"}," + "ryaStreamsDetails : { hostname : \"localhost\" , port : 6}" + "}");
    assertEquals(expected.toString(), actual.toString());
}
Also used : ProspectorDetails(org.apache.rya.api.instance.RyaDetails.ProspectorDetails) EntityCentricIndexDetails(org.apache.rya.api.instance.RyaDetails.EntityCentricIndexDetails) BasicDBObject(com.mongodb.BasicDBObject) RyaStreamsDetails(org.apache.rya.api.instance.RyaDetails.RyaStreamsDetails) TemporalIndexDetails(org.apache.rya.api.instance.RyaDetails.TemporalIndexDetails) FreeTextIndexDetails(org.apache.rya.api.instance.RyaDetails.FreeTextIndexDetails) RyaDetails(org.apache.rya.api.instance.RyaDetails) FluoDetails(org.apache.rya.api.instance.RyaDetails.PCJIndexDetails.FluoDetails) BasicDBObject(com.mongodb.BasicDBObject) DBObject(com.mongodb.DBObject) Date(java.util.Date) JoinSelectivityDetails(org.apache.rya.api.instance.RyaDetails.JoinSelectivityDetails) Test(org.junit.Test)

Aggregations

FluoDetails (org.apache.rya.api.instance.RyaDetails.PCJIndexDetails.FluoDetails)23 RyaDetails (org.apache.rya.api.instance.RyaDetails)18 Date (java.util.Date)17 EntityCentricIndexDetails (org.apache.rya.api.instance.RyaDetails.EntityCentricIndexDetails)17 FreeTextIndexDetails (org.apache.rya.api.instance.RyaDetails.FreeTextIndexDetails)17 JoinSelectivityDetails (org.apache.rya.api.instance.RyaDetails.JoinSelectivityDetails)17 ProspectorDetails (org.apache.rya.api.instance.RyaDetails.ProspectorDetails)17 TemporalIndexDetails (org.apache.rya.api.instance.RyaDetails.TemporalIndexDetails)17 Test (org.junit.Test)16 RyaDetailsRepository (org.apache.rya.api.instance.RyaDetailsRepository)10 PCJIndexDetails (org.apache.rya.api.instance.RyaDetails.PCJIndexDetails)6 Connector (org.apache.accumulo.core.client.Connector)5 InstanceDoesNotExistException (org.apache.rya.api.client.InstanceDoesNotExistException)5 RyaClientException (org.apache.rya.api.client.RyaClientException)5 RyaStreamsDetails (org.apache.rya.api.instance.RyaDetails.RyaStreamsDetails)4 UnsupportedQueryException (org.apache.rya.indexing.pcj.fluo.app.query.UnsupportedQueryException)3 MalformedQueryException (org.openrdf.query.MalformedQueryException)3 BasicDBObject (com.mongodb.BasicDBObject)2 DBObject (com.mongodb.DBObject)2 AccumuloRyaInstanceDetailsRepository (org.apache.rya.accumulo.instance.AccumuloRyaInstanceDetailsRepository)2