use of org.apache.rya.api.instance.RyaDetails in project incubator-rya by apache.
the class AccumuloPcjStorage method listPcjs.
@Override
public List<String> listPcjs() throws PCJStorageException {
try {
final RyaDetails details = ryaDetailsRepo.getRyaInstanceDetails();
final PCJIndexDetails pcjIndexDetails = details.getPCJIndexDetails();
final List<String> pcjIds = new ArrayList<>(pcjIndexDetails.getPCJDetails().keySet());
return pcjIds;
} catch (final RyaDetailsRepositoryException e) {
throw new PCJStorageException("Could not check to see if RyaDetails exist for the instance.", e);
}
}
use of org.apache.rya.api.instance.RyaDetails in project incubator-rya by apache.
the class RyaTestInstanceRule method before.
@Override
protected void before() throws Throwable {
// Get the next Rya instance name.
ryaInstanceName = "testInstance_" + ryaInstanceNameCounter.getAndIncrement();
if (install) {
// Create Rya Details for the instance name.
final RyaDetailsRepository detailsRepo = new AccumuloRyaInstanceDetailsRepository(cluster.getConnector(), ryaInstanceName);
final RyaDetails details = RyaDetails.builder().setRyaInstanceName(ryaInstanceName).setRyaVersion("0.0.0.0").setFreeTextDetails(new FreeTextIndexDetails(true)).setEntityCentricIndexDetails(new EntityCentricIndexDetails(true)).setTemporalIndexDetails(new TemporalIndexDetails(true)).setPCJIndexDetails(PCJIndexDetails.builder().setEnabled(true)).setJoinSelectivityDetails(new JoinSelectivityDetails(Optional.absent())).setProspectorDetails(new ProspectorDetails(Optional.absent())).build();
detailsRepo.initialize(details);
}
}
use of org.apache.rya.api.instance.RyaDetails 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));
}
}
use of org.apache.rya.api.instance.RyaDetails 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));
}
}
use of org.apache.rya.api.instance.RyaDetails 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);
}
Aggregations