You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@marmotta.apache.org by ss...@apache.org on 2013/09/09 14:49:28 UTC
git commit: fixed a number of further tests,
better handling of aborted reasoning processes
Updated Branches:
refs/heads/develop 906a7f4fc -> c9adb4d2a
fixed a number of further tests, better handling of aborted reasoning processes
Project: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/commit/c9adb4d2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/tree/c9adb4d2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/diff/c9adb4d2
Branch: refs/heads/develop
Commit: c9adb4d2a92fe218ce3f7d7d6a4d54e98796c071
Parents: 906a7f4
Author: Sebastian Schaffert <ss...@apache.org>
Authored: Mon Sep 9 14:49:21 2013 +0200
Committer: Sebastian Schaffert <ss...@apache.org>
Committed: Mon Sep 9 14:49:21 2013 +0200
----------------------------------------------------------------------
.../kiwi/reasoner/engine/ReasoningEngine.java | 386 +++++++++----------
.../model/exception/ReasoningException.java | 100 +++++
.../exception/UnjustifiedTripleException.java | 44 +++
.../engine/JustificationResolutionTest.java | 3 +-
.../persistence/KWRLProgramPersistenceTest.java | 1 +
.../KiWiRDFSchemaRepositoryConnectionTest.java | 6 +
.../kiwi/persistence/KiWiConnection.java | 5 +-
.../ldcache/services/test/LDCacheKiWiTest.java | 5 +
.../ldclient/test/TestLDClientTest.java | 4 +-
9 files changed, 341 insertions(+), 213 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/c9adb4d2/libraries/kiwi/kiwi-reasoner/src/main/java/org/apache/marmotta/kiwi/reasoner/engine/ReasoningEngine.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-reasoner/src/main/java/org/apache/marmotta/kiwi/reasoner/engine/ReasoningEngine.java b/libraries/kiwi/kiwi-reasoner/src/main/java/org/apache/marmotta/kiwi/reasoner/engine/ReasoningEngine.java
index c60451e..18e0607 100644
--- a/libraries/kiwi/kiwi-reasoner/src/main/java/org/apache/marmotta/kiwi/reasoner/engine/ReasoningEngine.java
+++ b/libraries/kiwi/kiwi-reasoner/src/main/java/org/apache/marmotta/kiwi/reasoner/engine/ReasoningEngine.java
@@ -30,6 +30,8 @@ import org.apache.marmotta.kiwi.model.rdf.KiWiNode;
import org.apache.marmotta.kiwi.model.rdf.KiWiResource;
import org.apache.marmotta.kiwi.model.rdf.KiWiTriple;
import org.apache.marmotta.kiwi.model.rdf.KiWiUriResource;
+import org.apache.marmotta.kiwi.reasoner.model.exception.ReasoningException;
+import org.apache.marmotta.kiwi.reasoner.model.exception.UnjustifiedTripleException;
import org.apache.marmotta.kiwi.reasoner.model.program.*;
import org.apache.marmotta.kiwi.reasoner.model.query.QueryResult;
import org.apache.marmotta.kiwi.reasoner.persistence.KiWiReasoningConnection;
@@ -341,58 +343,59 @@ public class ReasoningEngine implements TransactionListener {
}
private void executeReasoner(TransactionData data) {
- updateTaskStatus("fetching worklist");
- Set<KiWiTriple> newTriples = StatementCommons.newQuadrupleSet();
- for(Statement stmt : data.getAddedTriples()) {
- KiWiTriple t = (KiWiTriple)stmt;
- if(t.isMarkedForReasoning()) {
- newTriples.add(t);
- t.setMarkedForReasoning(false);
+ try {
+ updateTaskStatus("fetching worklist");
+ Set<KiWiTriple> newTriples = StatementCommons.newQuadrupleSet();
+ for(Statement stmt : data.getAddedTriples()) {
+ KiWiTriple t = (KiWiTriple)stmt;
+ if(t.isMarkedForReasoning()) {
+ newTriples.add(t);
+ t.setMarkedForReasoning(false);
+ }
}
- }
- //taskManagerService.setTaskSteps(newTriples.size() + data.getRemovedTriples().size());
- // evaluate the rules for all added triples
- if(newTriples.size() > 0) {
- long start2 = System.currentTimeMillis();
- updateTaskStatus("reasoning over " + newTriples.size() + " new triples");
- processRules(newTriples);
- log.debug("REASONER: reasoning for {} new triples took {} ms overall", newTriples.size(), System.currentTimeMillis() - start2);
- }
+ //taskManagerService.setTaskSteps(newTriples.size() + data.getRemovedTriples().size());
+ // evaluate the rules for all added triples
+ if(newTriples.size() > 0) {
+ long start2 = System.currentTimeMillis();
+ updateTaskStatus("reasoning over " + newTriples.size() + " new triples");
+ processRules(newTriples);
+ log.debug("REASONER: reasoning for {} new triples took {} ms overall", newTriples.size(), System.currentTimeMillis() - start2);
+ }
- if(data.getRemovedTriples().size() > 0) {
- log.debug("cleaning up justifications and inferences for {} triples",data.getRemovedTriples().size());
- try {
- KiWiReasoningConnection connection = persistence.getConnection();
+ if(data.getRemovedTriples().size() > 0) {
+ log.debug("cleaning up justifications and inferences for {} triples",data.getRemovedTriples().size());
try {
- // first clean up justifications that are no longer supported
- cleanupJustifications(connection, data.getRemovedTriples());
-
-
- // then remove all inferred triples that are no longer supported
- cleanupUnsupported(connection);
-
- // and finally garbage collect those triples that are inferred and deleted
- // garbage collection is now carried out by a thread in the triple store
- //garbageCollectTriples();
- connection.commit();
- } catch (SQLException ex) {
- connection.rollback();
+ KiWiReasoningConnection connection = persistence.getConnection();
+ try {
+ // first clean up justifications that are no longer supported
+ cleanupJustifications(connection, data.getRemovedTriples());
+
+
+ // then remove all inferred triples that are no longer supported
+ cleanupUnsupported(connection);
+
+ // and finally garbage collect those triples that are inferred and deleted
+ // garbage collection is now carried out by a thread in the triple store
+ //garbageCollectTriples();
+ connection.commit();
+ } catch (SQLException ex) {
+ connection.rollback();
+ throw ex;
+ } finally {
+ connection.close();
+ }
+ } catch (SailException | SQLException ex) {
+ log.error("REASONING ERROR: could not clean up unsupported triples, database state will be inconsistent! Message: {}", ex.getMessage());
+ log.debug("Exception details:", ex);
throw ex;
- } finally {
- connection.close();
}
- } catch (SailException ex) {
- log.error("REPOSITORY ERROR: could not clean up unsupported triples, database state will be inconsistent! Message: {}", ex.getMessage());
- log.debug("Exception details:", ex);
- } catch (SQLException ex) {
- log.error("DATABASE ERROR: could not clean up justifications for triples, database state will be inconsistent! Message: {}", ex.getMessage());
- log.debug("Exception details:", ex);
- }
+ }
+ } catch (SQLException | SailException | ReasoningException ex) {
+ log.error("REASONER: processing of transaction data with ID {} aborted; reason: {}", data.getTransactionId(), ex.getMessage());
}
-
}
/**
@@ -542,45 +545,20 @@ public class ReasoningEngine implements TransactionListener {
*
* @param addedTriples
*/
- private void processRules(final Set<KiWiTriple> addedTriples) {
- try {
- updateTaskStatus("processing rules ...");
- // select the rules that have at least one matching pattern; the match method will
- // return a set of variable bindings that we will be used to prepopulate the bindings
-// Set<Callable<Boolean>> tasks = new HashSet<Callable<Boolean>>();
- for(final Pattern pattern : patternRuleMap.keySet()) {
- for(KiWiTriple triple : addedTriples) {
- QueryResult match = matches(pattern,triple);
- if(match != null) {
- for(Rule rule : patternRuleMap.get(pattern)) {
- log.debug("REASONER(rule '{}'): pattern {} matched with triple {}", rule.getName(), pattern.toString(), triple.toString());
- processRule(rule, match, pattern);
- }
+ private void processRules(final Set<KiWiTriple> addedTriples) throws SQLException, SailException, ReasoningException {
+ updateTaskStatus("processing rules ...");
+ // select the rules that have at least one matching pattern; the match method will
+ // return a set of variable bindings that we will be used to prepopulate the bindings
+ for(final Pattern pattern : patternRuleMap.keySet()) {
+ for(KiWiTriple triple : addedTriples) {
+ QueryResult match = matches(pattern,triple);
+ if(match != null) {
+ for(Rule rule : patternRuleMap.get(pattern)) {
+ log.debug("REASONER(rule '{}'): pattern {} matched with triple {}", rule.getName(), pattern.toString(), triple.toString());
+ processRule(rule, match, pattern);
}
}
- // TODO: for parallel reasoning, the problem is that we should only create one thread per rule and not
- // one per pattern, otherwise we can get duplicates because the same rule is evaluated twice
-/*
- tasks.add(new Callable<Boolean>() {
- @Override
- public Boolean call() throws Exception {
- for(KiWiTriple triple : addedTriples) {
- QueryResult match = matches(pattern,triple);
- if(match != null) {
- log.debug("pattern {} matched with triple {}", pattern.toString(), triple.toString());
- processRule(patternRuleMap.get(pattern), match, pattern);
- }
- }
-
- return Boolean.TRUE;
- }
- });
-*/
}
- //workers.invokeAll(tasks);
-
- } catch(Exception ex) {
- log.error("error while processing rules",ex);
}
}
@@ -592,7 +570,7 @@ public class ReasoningEngine implements TransactionListener {
* @param rule
* @param match
*/
- private void processRule(Rule rule, QueryResult match, Pattern p) {
+ private void processRule(Rule rule, QueryResult match, Pattern p) throws SQLException, SailException, ReasoningException {
// get the variable bindings for the rule evaluation
log.debug("REASONER(rule '{}'): evaluating rule body {} ...", rule.getName() != null ? rule.getName() : rule.getId(), rule);
@@ -606,153 +584,143 @@ public class ReasoningEngine implements TransactionListener {
CloseableIteration<QueryResult, SQLException> bodyResult;
+ KiWiReasoningConnection connection = persistence.getConnection();
+ SailConnection sail = store.getConnection();
+ KiWiSailConnection isail = getWrappedConnection(sail);
try {
- KiWiReasoningConnection connection = persistence.getConnection();
- SailConnection sail = store.getConnection();
- KiWiSailConnection isail = getWrappedConnection(sail);
- try {
- // if there are further patterns, evaluate them; if the matched pattern was the only pattern, then
- // simply take the match as binding
- if(body.size() > 0) {
- bodyResult = connection.query(body,match,null,null,true);
- } else if(match != null) {
- bodyResult = new SingletonIteration<QueryResult, SQLException>(match);
- } else {
- bodyResult = new EmptyIteration<QueryResult, SQLException>();
- }
+ // if there are further patterns, evaluate them; if the matched pattern was the only pattern, then
+ // simply take the match as binding
+ if(body.size() > 0) {
+ bodyResult = connection.query(body,match,null,null,true);
+ } else if(match != null) {
+ bodyResult = new SingletonIteration<QueryResult, SQLException>(match);
+ } else {
+ bodyResult = new EmptyIteration<QueryResult, SQLException>();
+ }
- // construct triples out of the bindings and the rule heads
- long counter = 0;
+ // construct triples out of the bindings and the rule heads
+ long counter = 0;
- // initialise a new set of justifications
- Set<Justification> justifications = new HashSet<Justification>();
+ // initialise a new set of justifications
+ Set<Justification> justifications = new HashSet<Justification>();
- sail.begin();
- while(bodyResult.hasNext()) {
- QueryResult row = bodyResult.next();
- Map<VariableField,KiWiNode> binding = row.getBindings();
+ sail.begin();
+ while(bodyResult.hasNext()) {
+ QueryResult row = bodyResult.next();
+ Map<VariableField,KiWiNode> binding = row.getBindings();
- Resource subject = null;
- URI property = null;
- Value object;
+ Resource subject = null;
+ URI property = null;
+ Value object;
- if(rule.getHead().getSubject() != null && rule.getHead().getSubject().isVariableField()) {
- if(!binding.get(rule.getHead().getSubject()).isUriResource() && !binding.get(rule.getHead().getSubject()).isAnonymousResource()) {
- log.info("cannot use value {} as subject, because it is not a resource",binding.get(rule.getHead().getSubject()));
- continue;
- }
- subject = (KiWiResource)binding.get(rule.getHead().getSubject());
- } else if(rule.getHead().getSubject() != null && rule.getHead().getSubject().isResourceField()) {
- subject = ((ResourceField)rule.getHead().getSubject()).getResource();
- } else
- throw new IllegalArgumentException("Subject of rule head may only be a variable or a resource; rule: "+rule);
-
- if(rule.getHead().getProperty() != null && rule.getHead().getProperty().isVariableField()) {
- if(!binding.get(rule.getHead().getProperty()).isUriResource()) {
- log.info("cannot use value {} as property, because it is not a URI resource",binding.get(rule.getHead().getProperty()));
- continue;
+ if(rule.getHead().getSubject() != null && rule.getHead().getSubject().isVariableField()) {
+ if(!binding.get(rule.getHead().getSubject()).isUriResource() && !binding.get(rule.getHead().getSubject()).isAnonymousResource()) {
+ log.info("cannot use value {} as subject, because it is not a resource",binding.get(rule.getHead().getSubject()));
+ continue;
+ }
+ subject = (KiWiResource)binding.get(rule.getHead().getSubject());
+ } else if(rule.getHead().getSubject() != null && rule.getHead().getSubject().isResourceField()) {
+ subject = ((ResourceField)rule.getHead().getSubject()).getResource();
+ } else
+ throw new IllegalArgumentException("Subject of rule head may only be a variable or a resource; rule: "+rule);
+
+ if(rule.getHead().getProperty() != null && rule.getHead().getProperty().isVariableField()) {
+ if(!binding.get(rule.getHead().getProperty()).isUriResource()) {
+ log.info("cannot use value {} as property, because it is not a URI resource",binding.get(rule.getHead().getProperty()));
+ continue;
+ }
+ property = (KiWiUriResource)binding.get(rule.getHead().getProperty());
+ } else if(rule.getHead().getProperty() != null && rule.getHead().getProperty().isResourceField()) {
+ property = (KiWiUriResource)((ResourceField)rule.getHead().getProperty()).getResource();
+ } else
+ throw new IllegalArgumentException("Property of rule head may only be a variable or a resource; rule: "+rule);
+
+ if(rule.getHead().getObject() != null && rule.getHead().getObject().isVariableField()) {
+ object = binding.get(rule.getHead().getObject());
+ } else if(rule.getHead().getObject() != null && rule.getHead().getObject().isResourceField()) {
+ object = ((ResourceField)rule.getHead().getObject()).getResource();
+ } else if(rule.getHead().getObject() != null && rule.getHead().getObject().isLiteralField()) {
+ object = ((LiteralField)rule.getHead().getObject()).getLiteral();
+ } else
+ throw new IllegalArgumentException("Object of rule head may only be a variable, a literal, or a resource; rule: "+rule);
+
+
+ KiWiTriple triple = isail.addInferredStatement(subject, property, object);
+
+ Justification justification = new Justification();
+ justification.setTriple(triple);
+ justification.getSupportingRules().add(rule);
+ justification.getSupportingTriples().addAll(row.getJustifications());
+ justifications.add(justification);
+
+ // when the batch size is reached, commit the transaction, save the justifications, and start a new
+ // transaction and new justification set
+ if(++counter % config.getBatchSize() == 0) {
+ persistenceLock.lock();
+
+ try {
+
+ sail.commit();
+
+ log.debug("adding {} justifications",justifications.size());
+
+ updateTaskStatus("storing justifications ...");
+ Set<Justification> baseJustifications = getBaseJustifications(connection,justifications);
+
+ if(config.isRemoveDuplicateJustifications()) {
+ removeDuplicateJustifications(connection,baseJustifications);
}
- property = (KiWiUriResource)binding.get(rule.getHead().getProperty());
- } else if(rule.getHead().getProperty() != null && rule.getHead().getProperty().isResourceField()) {
- property = (KiWiUriResource)((ResourceField)rule.getHead().getProperty()).getResource();
- } else
- throw new IllegalArgumentException("Property of rule head may only be a variable or a resource; rule: "+rule);
-
- if(rule.getHead().getObject() != null && rule.getHead().getObject().isVariableField()) {
- object = binding.get(rule.getHead().getObject());
- } else if(rule.getHead().getObject() != null && rule.getHead().getObject().isResourceField()) {
- object = ((ResourceField)rule.getHead().getObject()).getResource();
- } else if(rule.getHead().getObject() != null && rule.getHead().getObject().isLiteralField()) {
- object = ((LiteralField)rule.getHead().getObject()).getLiteral();
- } else
- throw new IllegalArgumentException("Object of rule head may only be a variable, a literal, or a resource; rule: "+rule);
-
-
- KiWiTriple triple = isail.addInferredStatement(subject, property, object);
-
- Justification justification = new Justification();
- justification.setTriple(triple);
- justification.getSupportingRules().add(rule);
- justification.getSupportingTriples().addAll(row.getJustifications());
- justifications.add(justification);
-
- // when the batch size is reached, commit the transaction, save the justifications, and start a new
- // transaction and new justification set
- if(++counter % config.getBatchSize() == 0) {
- persistenceLock.lock();
-
- try {
-
- sail.commit();
-
- log.debug("adding {} justifications",justifications.size());
-
- updateTaskStatus("storing justifications ...");
- Set<Justification> baseJustifications = getBaseJustifications(connection,justifications);
-
- if(config.isRemoveDuplicateJustifications()) {
- removeDuplicateJustifications(connection,baseJustifications);
- }
-
- log.debug("{} justifications added after resolving inferred triples", baseJustifications.size());
-
- // persist the justifications that have been created in the rule processing
- if(baseJustifications.size() > 0) {
- connection.storeJustifications(baseJustifications);
- }
- connection.commit();
- sail.begin();
- } finally {
- persistenceLock.unlock();
+
+ log.debug("{} justifications added after resolving inferred triples", baseJustifications.size());
+
+ // persist the justifications that have been created in the rule processing
+ if(baseJustifications.size() > 0) {
+ connection.storeJustifications(baseJustifications);
}
- justifications.clear();
+ connection.commit();
+ sail.begin();
+ } finally {
+ persistenceLock.unlock();
}
+ justifications.clear();
}
+ }
- persistenceLock.lock();
- try {
- sail.commit();
+ persistenceLock.lock();
+ try {
+ sail.commit();
- log.debug("adding {} justifications",justifications.size());
- updateTaskStatus("storing justifications ...");
- Set<Justification> baseJustifications = getBaseJustifications(connection,justifications);
+ log.debug("adding {} justifications",justifications.size());
+ updateTaskStatus("storing justifications ...");
+ Set<Justification> baseJustifications = getBaseJustifications(connection,justifications);
- if(config.isRemoveDuplicateJustifications()) {
- removeDuplicateJustifications(connection,baseJustifications);
- }
+ if(config.isRemoveDuplicateJustifications()) {
+ removeDuplicateJustifications(connection,baseJustifications);
+ }
- // persist the justifications that have been created in the rule processing
- if(baseJustifications.size() > 0) {
- connection.storeJustifications(baseJustifications);
- }
+ // persist the justifications that have been created in the rule processing
+ if(baseJustifications.size() > 0) {
+ connection.storeJustifications(baseJustifications);
+ }
- log.debug("{} justifications added after resolving inferred triples", baseJustifications.size());
+ log.debug("{} justifications added after resolving inferred triples", baseJustifications.size());
- Iterations.closeCloseable(bodyResult);
- connection.commit();
- } finally {
- persistenceLock.unlock();
- }
- } catch(SailException ex) {
- connection.rollback();
- sail.rollback();
- throw ex;
- } catch(SQLException ex) {
- sail.rollback();
- connection.rollback();
- throw ex;
+ Iterations.closeCloseable(bodyResult);
+ connection.commit();
} finally {
- connection.close();
- sail.close();
+ persistenceLock.unlock();
}
-
- } catch(SQLException ex) {
- log.error("DATABASE ERROR: could not process rule, database state will be inconsistent! Message: {}",ex.getMessage());
+ } catch(SailException | SQLException | ReasoningException ex) {
+ log.error("REASONING ERROR: could not process rule, database state will be inconsistent! Message: {}",ex.getMessage());
log.debug("Exception details:",ex);
- } catch (SailException ex) {
- log.error("REPOSITORY ERROR: could not process rule, database state will be inconsistent! Message: {}",ex.getMessage());
- log.debug("Exception details:", ex);
+
+ connection.rollback();
+ sail.rollback();
+ throw ex;
+ } finally {
+ connection.close();
+ sail.close();
}
}
@@ -780,7 +748,7 @@ public class ReasoningEngine implements TransactionListener {
* @param justifications
* @return
*/
- protected Set<Justification> getBaseJustifications(KiWiReasoningConnection connection, Set<Justification> justifications) throws SQLException {
+ protected Set<Justification> getBaseJustifications(KiWiReasoningConnection connection, Set<Justification> justifications) throws SQLException, ReasoningException {
Set<Justification> baseJustifications = new HashSet<Justification>();
Map<KiWiTriple,Collection<Justification>> justificationCache = StatementCommons.newQuadrupleMap();
@@ -804,7 +772,7 @@ public class ReasoningEngine implements TransactionListener {
}
if(supportJustifications.size() == 0) {
- log.error("error: inferred triple {} is not justified!",support);
+ throw new UnjustifiedTripleException("error: inferred triple is not justified!", support);
}
// mix the two sets
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/c9adb4d2/libraries/kiwi/kiwi-reasoner/src/main/java/org/apache/marmotta/kiwi/reasoner/model/exception/ReasoningException.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-reasoner/src/main/java/org/apache/marmotta/kiwi/reasoner/model/exception/ReasoningException.java b/libraries/kiwi/kiwi-reasoner/src/main/java/org/apache/marmotta/kiwi/reasoner/model/exception/ReasoningException.java
new file mode 100644
index 0000000..bc25d22
--- /dev/null
+++ b/libraries/kiwi/kiwi-reasoner/src/main/java/org/apache/marmotta/kiwi/reasoner/model/exception/ReasoningException.java
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.marmotta.kiwi.reasoner.model.exception;
+
+/**
+ * Add file description here!
+ *
+ * @author Sebastian Schaffert (sschaffert@apache.org)
+ */
+public class ReasoningException extends Exception {
+
+ /**
+ * Constructs a new exception with {@code null} as its detail message.
+ * The cause is not initialized, and may subsequently be initialized by a
+ * call to {@link #initCause}.
+ */
+ public ReasoningException() {
+ }
+
+ /**
+ * Constructs a new exception with the specified cause and a detail
+ * message of <tt>(cause==null ? null : cause.toString())</tt> (which
+ * typically contains the class and detail message of <tt>cause</tt>).
+ * This constructor is useful for exceptions that are little more than
+ * wrappers for other throwables (for example, {@link
+ * java.security.PrivilegedActionException}).
+ *
+ * @param cause the cause (which is saved for later retrieval by the
+ * {@link #getCause()} method). (A <tt>null</tt> value is
+ * permitted, and indicates that the cause is nonexistent or
+ * unknown.)
+ * @since 1.4
+ */
+ public ReasoningException(Throwable cause) {
+ super(cause);
+ }
+
+ /**
+ * Constructs a new exception with the specified detail message. The
+ * cause is not initialized, and may subsequently be initialized by
+ * a call to {@link #initCause}.
+ *
+ * @param message the detail message. The detail message is saved for
+ * later retrieval by the {@link #getMessage()} method.
+ */
+ public ReasoningException(String message) {
+ super(message);
+ }
+
+ /**
+ * Constructs a new exception with the specified detail message and
+ * cause. <p>Note that the detail message associated with
+ * {@code cause} is <i>not</i> automatically incorporated in
+ * this exception's detail message.
+ *
+ * @param message the detail message (which is saved for later retrieval
+ * by the {@link #getMessage()} method).
+ * @param cause the cause (which is saved for later retrieval by the
+ * {@link #getCause()} method). (A <tt>null</tt> value is
+ * permitted, and indicates that the cause is nonexistent or
+ * unknown.)
+ * @since 1.4
+ */
+ public ReasoningException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ /**
+ * Constructs a new exception with the specified detail message,
+ * cause, suppression enabled or disabled, and writable stack
+ * trace enabled or disabled.
+ *
+ * @param message the detail message.
+ * @param cause the cause. (A {@code null} value is permitted,
+ * and indicates that the cause is nonexistent or unknown.)
+ * @param enableSuppression whether or not suppression is enabled
+ * or disabled
+ * @param writableStackTrace whether or not the stack trace should
+ * be writable
+ * @since 1.7
+ */
+ public ReasoningException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
+ super(message, cause, enableSuppression, writableStackTrace);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/c9adb4d2/libraries/kiwi/kiwi-reasoner/src/main/java/org/apache/marmotta/kiwi/reasoner/model/exception/UnjustifiedTripleException.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-reasoner/src/main/java/org/apache/marmotta/kiwi/reasoner/model/exception/UnjustifiedTripleException.java b/libraries/kiwi/kiwi-reasoner/src/main/java/org/apache/marmotta/kiwi/reasoner/model/exception/UnjustifiedTripleException.java
new file mode 100644
index 0000000..853db1c
--- /dev/null
+++ b/libraries/kiwi/kiwi-reasoner/src/main/java/org/apache/marmotta/kiwi/reasoner/model/exception/UnjustifiedTripleException.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.marmotta.kiwi.reasoner.model.exception;
+
+import org.apache.marmotta.kiwi.model.rdf.KiWiTriple;
+
+/**
+ * Add file description here!
+ *
+ * @author Sebastian Schaffert (sschaffert@apache.org)
+ */
+public class UnjustifiedTripleException extends ReasoningException {
+
+ private KiWiTriple triple;
+
+ /**
+ * Constructs a new exception with the specified detail message. The
+ * cause is not initialized, and may subsequently be initialized by
+ * a call to {@link #initCause}.
+ *
+ * @param message the detail message. The detail message is saved for
+ * later retrieval by the {@link #getMessage()} method.
+ */
+ public UnjustifiedTripleException(String message, KiWiTriple triple) {
+ super(message);
+
+ this.triple = triple;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/c9adb4d2/libraries/kiwi/kiwi-reasoner/src/test/java/org/apache/marmotta/kiwi/reasoner/test/engine/JustificationResolutionTest.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-reasoner/src/test/java/org/apache/marmotta/kiwi/reasoner/test/engine/JustificationResolutionTest.java b/libraries/kiwi/kiwi-reasoner/src/test/java/org/apache/marmotta/kiwi/reasoner/test/engine/JustificationResolutionTest.java
index 9e9713b..3f1aa48 100644
--- a/libraries/kiwi/kiwi-reasoner/src/test/java/org/apache/marmotta/kiwi/reasoner/test/engine/JustificationResolutionTest.java
+++ b/libraries/kiwi/kiwi-reasoner/src/test/java/org/apache/marmotta/kiwi/reasoner/test/engine/JustificationResolutionTest.java
@@ -24,6 +24,7 @@ import org.apache.marmotta.commons.sesame.model.Namespaces;
import org.apache.marmotta.commons.sesame.model.StatementCommons;
import org.apache.marmotta.kiwi.model.rdf.*;
import org.apache.marmotta.kiwi.reasoner.engine.ReasoningEngine;
+import org.apache.marmotta.kiwi.reasoner.model.exception.ReasoningException;
import org.apache.marmotta.kiwi.reasoner.model.program.Justification;
import org.apache.marmotta.kiwi.reasoner.model.program.Rule;
import org.apache.marmotta.kiwi.reasoner.persistence.KiWiReasoningConnection;
@@ -308,7 +309,7 @@ public class JustificationResolutionTest {
* @return
*/
@Override
- public Set<Justification> getBaseJustifications(KiWiReasoningConnection connection, Set<Justification> justifications) throws SQLException {
+ public Set<Justification> getBaseJustifications(KiWiReasoningConnection connection, Set<Justification> justifications) throws SQLException, ReasoningException {
return super.getBaseJustifications(connection, justifications);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/c9adb4d2/libraries/kiwi/kiwi-reasoner/src/test/java/org/apache/marmotta/kiwi/reasoner/test/persistence/KWRLProgramPersistenceTest.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-reasoner/src/test/java/org/apache/marmotta/kiwi/reasoner/test/persistence/KWRLProgramPersistenceTest.java b/libraries/kiwi/kiwi-reasoner/src/test/java/org/apache/marmotta/kiwi/reasoner/test/persistence/KWRLProgramPersistenceTest.java
index 72524f5..b945334 100644
--- a/libraries/kiwi/kiwi-reasoner/src/test/java/org/apache/marmotta/kiwi/reasoner/test/persistence/KWRLProgramPersistenceTest.java
+++ b/libraries/kiwi/kiwi-reasoner/src/test/java/org/apache/marmotta/kiwi/reasoner/test/persistence/KWRLProgramPersistenceTest.java
@@ -78,6 +78,7 @@ public class KWRLProgramPersistenceTest {
repository.initialize();
persistence = new KiWiPersistence(config);
+ persistence.initialise();
persistence.initDatabase();
rpersistence = new KiWiReasoningPersistence(persistence, repository.getValueFactory());
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/c9adb4d2/libraries/kiwi/kiwi-reasoner/src/test/java/org/apache/marmotta/kiwi/reasoner/test/sesame/KiWiRDFSchemaRepositoryConnectionTest.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-reasoner/src/test/java/org/apache/marmotta/kiwi/reasoner/test/sesame/KiWiRDFSchemaRepositoryConnectionTest.java b/libraries/kiwi/kiwi-reasoner/src/test/java/org/apache/marmotta/kiwi/reasoner/test/sesame/KiWiRDFSchemaRepositoryConnectionTest.java
index 5eab69d..8d959ec 100644
--- a/libraries/kiwi/kiwi-reasoner/src/test/java/org/apache/marmotta/kiwi/reasoner/test/sesame/KiWiRDFSchemaRepositoryConnectionTest.java
+++ b/libraries/kiwi/kiwi-reasoner/src/test/java/org/apache/marmotta/kiwi/reasoner/test/sesame/KiWiRDFSchemaRepositoryConnectionTest.java
@@ -170,4 +170,10 @@ public class KiWiRDFSchemaRepositoryConnectionTest extends RDFSchemaRepositoryCo
public void testOrderByQueriesAreInterruptable() throws Exception {
}
+ @Override
+ @Test
+ @Ignore("KiWi creates a separate context for inferred statements")
+ public void testGetContextIDs() throws Exception {
+ }
+
}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/c9adb4d2/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/KiWiConnection.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/KiWiConnection.java b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/KiWiConnection.java
index 63a8352..3467525 100644
--- a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/KiWiConnection.java
+++ b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/KiWiConnection.java
@@ -1181,6 +1181,8 @@ public class KiWiConnection {
* @param triple
*/
public void deleteTriple(final KiWiTriple triple) throws SQLException {
+ requireJDBCConnection();
+
RetryExecution execution = new RetryExecution("DELETE");
execution.setUseSavepoint(true);
execution.execute(connection, new RetryCommand() {
@@ -1202,7 +1204,6 @@ public class KiWiConnection {
commitLock.lock();
try {
if(tripleBatch == null || !tripleBatch.remove(triple)) {
- requireJDBCConnection();
PreparedStatement deleteTriple = getPreparedStatement("delete.triple");
synchronized (deleteTriple) {
@@ -1959,7 +1960,7 @@ public class KiWiConnection {
* <code>Connection</code> object is in auto-commit mode
* @see #setAutoCommit
*/
- public void commit() throws SQLException {
+ public synchronized void commit() throws SQLException {
numberOfCommits++;
RetryExecution execution = new RetryExecution("COMMIT");
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/c9adb4d2/libraries/ldcache/ldcache-core/src/test/java/org/apache/marmotta/ldcache/services/test/LDCacheKiWiTest.java
----------------------------------------------------------------------
diff --git a/libraries/ldcache/ldcache-core/src/test/java/org/apache/marmotta/ldcache/services/test/LDCacheKiWiTest.java b/libraries/ldcache/ldcache-core/src/test/java/org/apache/marmotta/ldcache/services/test/LDCacheKiWiTest.java
index be5d789..b22b600 100644
--- a/libraries/ldcache/ldcache-core/src/test/java/org/apache/marmotta/ldcache/services/test/LDCacheKiWiTest.java
+++ b/libraries/ldcache/ldcache-core/src/test/java/org/apache/marmotta/ldcache/services/test/LDCacheKiWiTest.java
@@ -274,6 +274,11 @@ public class LDCacheKiWiTest {
Thread.sleep(1000);
} catch (InterruptedException e) {
}
+ } else {
+ try {
+ Thread.sleep(100);
+ } catch (InterruptedException e) {
+ }
}
}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/c9adb4d2/libraries/ldclient/ldclient-core/src/test/java/org/apache/marmotta/ldclient/test/TestLDClientTest.java
----------------------------------------------------------------------
diff --git a/libraries/ldclient/ldclient-core/src/test/java/org/apache/marmotta/ldclient/test/TestLDClientTest.java b/libraries/ldclient/ldclient-core/src/test/java/org/apache/marmotta/ldclient/test/TestLDClientTest.java
index 2cf0a4f..4570c08 100644
--- a/libraries/ldclient/ldclient-core/src/test/java/org/apache/marmotta/ldclient/test/TestLDClientTest.java
+++ b/libraries/ldclient/ldclient-core/src/test/java/org/apache/marmotta/ldclient/test/TestLDClientTest.java
@@ -30,6 +30,8 @@ import org.junit.runner.Description;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.net.URI;
+
public class TestLDClientTest {
private TestLDClient client;
@@ -67,7 +69,7 @@ public class TestLDClientTest {
@Test(expected = DataRetrievalException.class)
public void testLocalhostInvalidPort() throws Exception {
- client.retrieveResource("http://127.1.2.3:-1/");
+ client.retrieveResource("http://127.1.2.3:66000/");
Assert.fail();
}