use of org.eclipse.rdf4j.sail.SailException in project com.inova8.intelligentgraph by peterjohnlawrence.
the class IntelligentGraphConnection method addStatement.
/**
* Adds the statement.
*
* @param modify the modify
* @param subj the subj
* @param pred the pred
* @param obj the obj
* @param contexts the contexts
* @throws SailException the sail exception
*/
@Override
public void addStatement(UpdateContext modify, Resource subj, IRI pred, Value obj, Resource... contexts) throws SailException {
try {
String[] predicateParts;
if (pred != null) {
// predicateParts= pred.stringValue().split(IntelligentGraphConstants.PATH_QL_REGEX);
predicateParts = decodePredicate(pred);
switch(predicateParts[0]) {
case PATHQL.addFact:
addFact(modify, subj, predicateParts[1], obj, contexts);
break;
default:
super.addStatement(modify, subj, pred, obj, contexts);
checkReificationsChanged(pred);
}
} else
super.addStatement(modify, subj, pred, obj, contexts);
this.intelligentGraphSail.clearCache();
} catch (Exception e) {
throw new SailException(e);
}
}
use of org.eclipse.rdf4j.sail.SailException 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.eclipse.rdf4j.sail.SailException in project incubator-rya by apache.
the class AccumuloRyaSailFactoryLoadFilesIT method createRyaSailRepository.
private static RyaSailRepository createRyaSailRepository(final RdfCloudTripleStoreConfiguration config) throws SailException {
log.info("Connecting to Sail Repository.");
try {
final Sail extSail = RyaSailFactory.getInstance(config);
final RyaSailRepository repository = new RyaSailRepository(extSail);
return repository;
} catch (final Exception e) {
throw new SailException("Failed to create Rya Sail Repository", e);
}
}
use of org.eclipse.rdf4j.sail.SailException in project incubator-rya by apache.
the class MongoDbRyaSailFactoryLoadFilesIT method createRyaSailRepository.
private static RyaSailRepository createRyaSailRepository(final RdfCloudTripleStoreConfiguration config) throws SailException {
log.info("Connecting to Sail Repository.");
try {
final Sail extSail = RyaSailFactory.getInstance(config);
final RyaSailRepository repository = new RyaSailRepository(extSail);
return repository;
} catch (final Exception e) {
throw new SailException("Failed to create Rya Sail Repository", e);
}
}
use of org.eclipse.rdf4j.sail.SailException in project incubator-rya by apache.
the class AccumuloLoadStatementsFile method loadStatements.
@Override
public void loadStatements(final String ryaInstanceName, final Path statementsFile, final RDFFormat format) throws InstanceDoesNotExistException, RyaClientException {
requireNonNull(ryaInstanceName);
requireNonNull(statementsFile);
requireNonNull(format);
// Ensure the Rya Instance exists.
if (!instanceExists.exists(ryaInstanceName)) {
throw new InstanceDoesNotExistException(String.format("There is no Rya instance named '%s'.", ryaInstanceName));
}
Sail sail = null;
SailRepository sailRepo = null;
SailRepositoryConnection sailRepoConn = null;
try {
// Get a Sail object that is connected to the Rya instance.
final AccumuloRdfConfiguration ryaConf = getAccumuloConnectionDetails().buildAccumuloRdfConfiguration(ryaInstanceName);
// RYA-327 should address this hardcoded value.
ryaConf.setFlush(false);
sail = RyaSailFactory.getInstance(ryaConf);
// Load the file.
sailRepo = new SailRepository(sail);
sailRepoConn = sailRepo.getConnection();
sailRepoConn.add(statementsFile.toFile(), null, format);
} catch (final SailException | AccumuloException | AccumuloSecurityException | RyaDAOException | InferenceEngineException e) {
log.warn("Exception while loading:", e);
throw new RyaClientException("A problem connecting to the Rya instance named '" + ryaInstanceName + "' has caused the load to fail.", e);
} catch (final RepositoryException | RDFParseException | UnsupportedRDFormatException | IOException e) {
log.warn("Exception while loading:", e);
throw new RyaClientException("A problem processing the RDF file has caused the load into Rya instance named " + ryaInstanceName + "to fail.", e);
} finally {
// Shut it all down.
if (sailRepoConn != null) {
try {
sailRepoConn.close();
} catch (final RepositoryException e) {
log.warn("Couldn't close the SailRepoConnection that is attached to the Rya instance.", e);
}
}
if (sailRepo != null) {
try {
sailRepo.shutDown();
} catch (final RepositoryException e) {
log.warn("Couldn't shut down the SailRepository that is attached to the Rya instance.", e);
}
}
if (sail != null) {
try {
sail.shutDown();
} catch (final SailException e) {
log.warn("Couldn't shut down the Sail that is attached to the Rya instance.", e);
}
}
}
}
Aggregations