Search in sources :

Example 21 with SailException

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);
    }
}
Also used : SailException(org.eclipse.rdf4j.sail.SailException) QueryEvaluationException(org.eclipse.rdf4j.query.QueryEvaluationException) SailException(org.eclipse.rdf4j.sail.SailException) RepositoryException(org.eclipse.rdf4j.repository.RepositoryException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) PathPatternException(com.inova8.pathql.processor.PathPatternException) RecognitionException(org.antlr.v4.runtime.RecognitionException)

Example 22 with SailException

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));
    }
}
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.eclipse.rdf4j.repository.RepositoryException) InstanceDoesNotExistException(org.apache.rya.api.client.InstanceDoesNotExistException) SailException(org.eclipse.rdf4j.sail.SailException) QueryEvaluationException(org.eclipse.rdf4j.query.QueryEvaluationException) MalformedQueryException(org.eclipse.rdf4j.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 23 with SailException

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);
    }
}
Also used : Sail(org.eclipse.rdf4j.sail.Sail) RyaSailRepository(org.apache.rya.rdftriplestore.RyaSailRepository) SailException(org.eclipse.rdf4j.sail.SailException) MalformedQueryException(org.eclipse.rdf4j.query.MalformedQueryException) QueryEvaluationException(org.eclipse.rdf4j.query.QueryEvaluationException) RDFParseException(org.eclipse.rdf4j.rio.RDFParseException) TupleQueryResultHandlerException(org.eclipse.rdf4j.query.TupleQueryResultHandlerException) SailException(org.eclipse.rdf4j.sail.SailException) RepositoryException(org.eclipse.rdf4j.repository.RepositoryException) IOException(java.io.IOException)

Example 24 with SailException

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);
    }
}
Also used : Sail(org.eclipse.rdf4j.sail.Sail) RyaSailRepository(org.apache.rya.rdftriplestore.RyaSailRepository) SailException(org.eclipse.rdf4j.sail.SailException) MalformedQueryException(org.eclipse.rdf4j.query.MalformedQueryException) QueryEvaluationException(org.eclipse.rdf4j.query.QueryEvaluationException) RDFParseException(org.eclipse.rdf4j.rio.RDFParseException) TupleQueryResultHandlerException(org.eclipse.rdf4j.query.TupleQueryResultHandlerException) SailException(org.eclipse.rdf4j.sail.SailException) RepositoryException(org.eclipse.rdf4j.repository.RepositoryException) IOException(java.io.IOException)

Example 25 with SailException

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);
            }
        }
    }
}
Also used : AccumuloException(org.apache.accumulo.core.client.AccumuloException) UnsupportedRDFormatException(org.eclipse.rdf4j.rio.UnsupportedRDFormatException) RyaClientException(org.apache.rya.api.client.RyaClientException) SailRepository(org.eclipse.rdf4j.repository.sail.SailRepository) InferenceEngineException(org.apache.rya.rdftriplestore.inference.InferenceEngineException) RepositoryException(org.eclipse.rdf4j.repository.RepositoryException) InstanceDoesNotExistException(org.apache.rya.api.client.InstanceDoesNotExistException) SailException(org.eclipse.rdf4j.sail.SailException) IOException(java.io.IOException) SailRepositoryConnection(org.eclipse.rdf4j.repository.sail.SailRepositoryConnection) AccumuloRdfConfiguration(org.apache.rya.accumulo.AccumuloRdfConfiguration) Sail(org.eclipse.rdf4j.sail.Sail) RyaDAOException(org.apache.rya.api.persist.RyaDAOException) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) RDFParseException(org.eclipse.rdf4j.rio.RDFParseException)

Aggregations

SailException (org.eclipse.rdf4j.sail.SailException)36 RyaDAOException (org.apache.rya.api.persist.RyaDAOException)19 QueryEvaluationException (org.eclipse.rdf4j.query.QueryEvaluationException)17 RepositoryException (org.eclipse.rdf4j.repository.RepositoryException)17 AccumuloException (org.apache.accumulo.core.client.AccumuloException)13 AccumuloSecurityException (org.apache.accumulo.core.client.AccumuloSecurityException)13 RyaClientException (org.apache.rya.api.client.RyaClientException)13 Sail (org.eclipse.rdf4j.sail.Sail)13 InferenceEngineException (org.apache.rya.rdftriplestore.inference.InferenceEngineException)12 MalformedQueryException (org.eclipse.rdf4j.query.MalformedQueryException)11 InstanceDoesNotExistException (org.apache.rya.api.client.InstanceDoesNotExistException)8 SailRepository (org.eclipse.rdf4j.repository.sail.SailRepository)7 IOException (java.io.IOException)6 AccumuloRdfConfiguration (org.apache.rya.accumulo.AccumuloRdfConfiguration)6 PathPatternException (com.inova8.pathql.processor.PathPatternException)5 UnsupportedEncodingException (java.io.UnsupportedEncodingException)5 RecognitionException (org.antlr.v4.runtime.RecognitionException)5 Resource (org.eclipse.rdf4j.model.Resource)5 SailRepositoryConnection (org.eclipse.rdf4j.repository.sail.SailRepositoryConnection)5 SailConnection (org.eclipse.rdf4j.sail.SailConnection)5