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/11/22 13:50:19 UTC

git commit: - minor bug fixes to make tests more reliable

Updated Branches:
  refs/heads/develop c3d897a95 -> cd94dc118


- minor bug fixes to make tests more reliable


Project: http://git-wip-us.apache.org/repos/asf/marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/marmotta/commit/cd94dc11
Tree: http://git-wip-us.apache.org/repos/asf/marmotta/tree/cd94dc11
Diff: http://git-wip-us.apache.org/repos/asf/marmotta/diff/cd94dc11

Branch: refs/heads/develop
Commit: cd94dc1186b558437b79ee9d5adceb1b5c4a789d
Parents: c3d897a
Author: Sebastian Schaffert <ss...@apache.org>
Authored: Fri Nov 22 13:50:12 2013 +0100
Committer: Sebastian Schaffert <ss...@apache.org>
Committed: Fri Nov 22 13:50:12 2013 +0100

----------------------------------------------------------------------
 .../src/test/resources/logback-test.xml         |  3 ++
 .../persistence/mysql/create_fulltext_index.sql |  2 +-
 .../exception/ResultInterruptedException.java   | 45 ++++++++++++++++++++
 .../kiwi/persistence/KiWiConnection.java        |  5 +++
 .../marmotta/kiwi/sail/KiWiSailConnection.java  | 30 +++++++++++--
 5 files changed, 81 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/marmotta/blob/cd94dc11/libraries/kiwi/kiwi-loader/src/test/resources/logback-test.xml
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-loader/src/test/resources/logback-test.xml b/libraries/kiwi/kiwi-loader/src/test/resources/logback-test.xml
index 63d73e8..fce18e6 100644
--- a/libraries/kiwi/kiwi-loader/src/test/resources/logback-test.xml
+++ b/libraries/kiwi/kiwi-loader/src/test/resources/logback-test.xml
@@ -22,6 +22,9 @@
             <pattern>%m%n</pattern>
         </encoder>
     </appender>
+
+    <logger name="net.sf.ehcache.pool.impl" level="WARN" />
+
     <root level="${root-level:-INFO}">
         <appender-ref ref="CONSOLE"/>
     </root>

http://git-wip-us.apache.org/repos/asf/marmotta/blob/cd94dc11/libraries/kiwi/kiwi-sparql/src/main/resources/org/apache/marmotta/kiwi/persistence/mysql/create_fulltext_index.sql
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-sparql/src/main/resources/org/apache/marmotta/kiwi/persistence/mysql/create_fulltext_index.sql b/libraries/kiwi/kiwi-sparql/src/main/resources/org/apache/marmotta/kiwi/persistence/mysql/create_fulltext_index.sql
index 09b1788..c764c08 100644
--- a/libraries/kiwi/kiwi-sparql/src/main/resources/org/apache/marmotta/kiwi/persistence/mysql/create_fulltext_index.sql
+++ b/libraries/kiwi/kiwi-sparql/src/main/resources/org/apache/marmotta/kiwi/persistence/mysql/create_fulltext_index.sql
@@ -13,7 +13,7 @@
 -- See the License for the specific language governing permissions and
 -- limitations under the License.
 
-DROP INDEX IF EXISTS kiwi_ft_idx;
+DROP INDEX kiwi_ft_idx ON nodes;
 CREATE FULLTEXT INDEX kiwi_ft_idx ON nodes(svalue);
 
 INSERT INTO metadata(mkey,mvalue) VALUES ('ft.idx','true');

http://git-wip-us.apache.org/repos/asf/marmotta/blob/cd94dc11/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/exception/ResultInterruptedException.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/exception/ResultInterruptedException.java b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/exception/ResultInterruptedException.java
new file mode 100644
index 0000000..ef03f8b
--- /dev/null
+++ b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/exception/ResultInterruptedException.java
@@ -0,0 +1,45 @@
+/*
+ * 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.exception;
+
+import java.sql.SQLException;
+
+/**
+ * Used to signal that retrieving the results has been interrupted in one or the other way. Necessary to
+ * throw the proper interrupted exceptions when interrupting SPARQL queries.
+ *
+ * @author Sebastian Schaffert (sschaffert@apache.org)
+ */
+public class ResultInterruptedException extends SQLException {
+
+    /**
+     * Constructs a <code>SQLException</code> object with a given
+     * <code>reason</code>. The  <code>SQLState</code>  is initialized to
+     * <code>null</code> and the vender code is initialized to 0.
+     * <p/>
+     * The <code>cause</code> is not initialized, and may subsequently be
+     * initialized by a call to the
+     * {@link Throwable#initCause(Throwable)} method.
+     * <p/>
+     *
+     * @param reason a description of the exception
+     */
+    public ResultInterruptedException(String reason) {
+        super(reason,"57014");
+    }
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/cd94dc11/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 69fff03..c4661a7 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
@@ -34,6 +34,7 @@ import org.apache.marmotta.commons.sesame.model.Namespaces;
 import org.apache.marmotta.commons.util.DateUtils;
 import org.apache.marmotta.kiwi.caching.KiWiCacheManager;
 import org.apache.marmotta.kiwi.config.KiWiConfiguration;
+import org.apache.marmotta.kiwi.exception.ResultInterruptedException;
 import org.apache.marmotta.kiwi.model.caching.TripleTable;
 import org.apache.marmotta.kiwi.model.rdf.*;
 import org.apache.marmotta.kiwi.persistence.util.ResultSetIteration;
@@ -1654,6 +1655,10 @@ public class KiWiConnection {
      * @return a KiWiTriple representation of the database result
      */
     protected KiWiTriple constructTripleFromDatabase(ResultSet row) throws SQLException {
+        if(row.isClosed()) {
+            throw new ResultInterruptedException("retrieving results has been interrupted");
+        }
+
         Long id = row.getLong("id");
 
         Element cached = tripleCache.get(id);

http://git-wip-us.apache.org/repos/asf/marmotta/blob/cd94dc11/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/sail/KiWiSailConnection.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/sail/KiWiSailConnection.java b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/sail/KiWiSailConnection.java
index a46bee1..a9d1a8f 100644
--- a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/sail/KiWiSailConnection.java
+++ b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/sail/KiWiSailConnection.java
@@ -20,15 +20,28 @@ package org.apache.marmotta.kiwi.sail;
 import com.google.common.base.Function;
 import com.google.common.collect.Iterables;
 import com.google.common.collect.Lists;
-import info.aduna.iteration.*;
+import info.aduna.iteration.CloseableIteration;
+import info.aduna.iteration.DelayedIteration;
+import info.aduna.iteration.ExceptionConvertingIteration;
+import info.aduna.iteration.FilterIteration;
+import info.aduna.iteration.Iteration;
+import info.aduna.iteration.Iterations;
+import info.aduna.iteration.UnionIteration;
 import org.apache.marmotta.commons.sesame.repository.ResourceConnection;
+import org.apache.marmotta.kiwi.exception.ResultInterruptedException;
 import org.apache.marmotta.kiwi.model.rdf.KiWiNamespace;
 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.persistence.KiWiConnection;
-import org.openrdf.model.*;
+import org.openrdf.model.BNode;
+import org.openrdf.model.Namespace;
+import org.openrdf.model.Resource;
+import org.openrdf.model.Statement;
+import org.openrdf.model.URI;
+import org.openrdf.model.Value;
+import org.openrdf.model.ValueFactory;
 import org.openrdf.query.BindingSet;
 import org.openrdf.query.Dataset;
 import org.openrdf.query.QueryEvaluationException;
@@ -286,6 +299,8 @@ public class KiWiSailConnection extends NotifyingSailConnectionBase implements I
                     protected Iteration<? extends Statement, ? extends RepositoryException> createIteration() throws RepositoryException {
                         try {
                             return databaseConnection.listTriples(rsubj, rpred, robj, context, includeInferred, false);
+                        } catch (ResultInterruptedException e) {
+                            throw new RepositoryException("listing triples interrupted",e);
                         } catch (SQLException e) {
                             throw new RepositoryException("database error while listing triples",e);
                         }
@@ -298,6 +313,8 @@ public class KiWiSailConnection extends NotifyingSailConnectionBase implements I
                 protected Iteration<? extends Statement, ? extends RepositoryException> createIteration() throws RepositoryException {
                     try {
                         return databaseConnection.listTriples(rsubj, rpred, robj, null, includeInferred, true);
+                    } catch (ResultInterruptedException e) {
+                        throw new RepositoryException("listing triples interrupted",e);
                     } catch (SQLException e) {
                         throw new RepositoryException("database error while listing triples",e);
                     }
@@ -317,7 +334,7 @@ public class KiWiSailConnection extends NotifyingSailConnectionBase implements I
                              */
                             @Override
                             protected SailException convert(Exception e) {
-                                return new SailException("database error while iterating over result set",e);
+                                return new SailException("database error while iterating over result set",e.getCause());
                             }
                         };
                     }
@@ -597,6 +614,13 @@ public class KiWiSailConnection extends NotifyingSailConnectionBase implements I
                         else if (e instanceof IOException) {
                             return new QueryEvaluationException(e);
                         }
+                        else if (e instanceof SailException) {
+                            if(e.getCause() instanceof ResultInterruptedException) {
+                                return new QueryInterruptedException(e);
+                            } else {
+                                return new QueryEvaluationException(e);
+                            }
+                        }
                         else if (e instanceof RuntimeException) {
                             throw (RuntimeException)e;
                         }