marmotta-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sschaff...@apache.org
Subject git commit: fixed reference to ehcache started implementing SPARQL timeout support (MARMOTTA-267)
Date Tue, 09 Jul 2013 15:45:08 GMT
Updated Branches:
  refs/heads/develop f31ed040e -> d12f782ce


fixed reference to ehcache
started implementing SPARQL timeout support (MARMOTTA-267)


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

Branch: refs/heads/develop
Commit: d12f782ce68f1ad6cf1818ce44a537c635fdfe2c
Parents: f31ed04
Author: Sebastian Schaffert <sschaffert@apache.org>
Authored: Tue Jul 9 17:45:02 2013 +0200
Committer: Sebastian Schaffert <sschaffert@apache.org>
Committed: Tue Jul 9 17:45:02 2013 +0200

----------------------------------------------------------------------
 .../evaluation/KiWiEvaluationStrategyImpl.java  |  4 ++
 .../persistence/KiWiSparqlConnection.java       | 63 ++++++++++++++------
 libraries/kiwi/kiwi-transactions/pom.xml        |  2 +-
 libraries/kiwi/kiwi-triplestore/pom.xml         |  2 +-
 .../ldcache/ldcache-backend-ehcache/pom.xml     |  2 +-
 parent/pom.xml                                  |  2 +-
 platform/marmotta-core/pom.xml                  |  2 +-
 7 files changed, 54 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/d12f782c/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/evaluation/KiWiEvaluationStrategyImpl.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/evaluation/KiWiEvaluationStrategyImpl.java
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/evaluation/KiWiEvaluationStrategyImpl.java
index 1f667eb..054cca0 100644
--- a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/evaluation/KiWiEvaluationStrategyImpl.java
+++ b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/evaluation/KiWiEvaluationStrategyImpl.java
@@ -80,6 +80,8 @@ public class KiWiEvaluationStrategyImpl extends EvaluationStrategyImpl{
                 throw new QueryEvaluationException(e);
             } catch (IllegalArgumentException e) {
                 throw new QueryEvaluationException(e);
+            } catch (InterruptedException e) {
+                throw new QueryEvaluationException(e);
             }
         } else {
             return super.evaluate(join, bindings);
@@ -102,6 +104,8 @@ public class KiWiEvaluationStrategyImpl extends EvaluationStrategyImpl{
                 throw new QueryEvaluationException(e);
             } catch (IllegalArgumentException e) {
                 throw new QueryEvaluationException(e);
+            } catch (InterruptedException e) {
+                throw new QueryEvaluationException(e);
             }
         } else {
             return super.evaluate(join, bindings);

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/d12f782c/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/persistence/KiWiSparqlConnection.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/persistence/KiWiSparqlConnection.java
b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/persistence/KiWiSparqlConnection.java
index 777d3a8..0daf476 100644
--- a/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/persistence/KiWiSparqlConnection.java
+++ b/libraries/kiwi/kiwi-sparql/src/main/java/org/apache/marmotta/kiwi/sparql/persistence/KiWiSparqlConnection.java
@@ -46,6 +46,7 @@ import java.sql.SQLException;
 import java.text.DateFormat;
 import java.text.SimpleDateFormat;
 import java.util.*;
+import java.util.concurrent.*;
 import java.util.regex.Pattern;
 
 /**
@@ -65,9 +66,14 @@ public class KiWiSparqlConnection {
     private KiWiConnection parent;
     private KiWiValueFactory valueFactory;
 
+    private ExecutorService executorService;
+
     public KiWiSparqlConnection(KiWiConnection parent, KiWiValueFactory valueFactory) throws
SQLException {
         this.parent = parent;
         this.valueFactory = valueFactory;
+
+        // interruptible queries run in a separate thread
+        this.executorService = Executors.newCachedThreadPool();
     }
 
     /**
@@ -76,7 +82,7 @@ public class KiWiSparqlConnection {
      * @param join
      * @return
      */
-    public CloseableIteration<BindingSet, SQLException> evaluateJoin(TupleExpr join,
final BindingSet bindings) throws SQLException {
+    public CloseableIteration<BindingSet, SQLException> evaluateJoin(TupleExpr join,
final BindingSet bindings) throws SQLException, InterruptedException {
         Preconditions.checkArgument(join instanceof Join || join instanceof Filter || join
instanceof StatementPattern);
 
         // some definitions
@@ -289,30 +295,51 @@ public class KiWiSparqlConnection {
         log.debug("constructed SQL query string:\n {}",queryString);
         log.debug("SPARQL -> SQL variable mappings:\n {}", queryVariables);
 
-        PreparedStatement queryStatement = parent.getJDBCConnection().prepareStatement(queryString);
-        ResultSet result = queryStatement.executeQuery();
+        final PreparedStatement queryStatement = parent.getJDBCConnection().prepareStatement(queryString);
 
-        ResultSetIteration<BindingSet> it = new ResultSetIteration<BindingSet>(result,
true, new ResultTransformerFunction<BindingSet>() {
-            @Override
-            public BindingSet apply(ResultSet row) throws SQLException {
-                MapBindingSet resultRow = new MapBindingSet();
 
-                for(Var v : selectVariables) {
-                    resultRow.addBinding(v.getName(), parent.loadNodeById(row.getLong(variableNames.get(v))));
+        Future<ResultSet> queryFuture =
+                executorService.submit(new Callable<ResultSet>() {
+                    @Override
+                    public ResultSet call() throws Exception {
+                        return queryStatement.executeQuery();
+                    }
                 }
+                );
 
 
-                if(bindings != null) {
-                    for(Binding binding : bindings) {
-                        resultRow.addBinding(binding);
+        try {
+            ResultSet result = queryFuture.get();
+
+            ResultSetIteration<BindingSet> it = new ResultSetIteration<BindingSet>(result,
true, new ResultTransformerFunction<BindingSet>() {
+                @Override
+                public BindingSet apply(ResultSet row) throws SQLException {
+                    MapBindingSet resultRow = new MapBindingSet();
+
+                    for(Var v : selectVariables) {
+                        resultRow.addBinding(v.getName(), parent.loadNodeById(row.getLong(variableNames.get(v))));
                     }
-                }
-                return resultRow;
-            }
-        });
 
-        // materialize result to avoid having more than one result set open at the same time
-        return new CloseableIteratorIteration<BindingSet, SQLException>(Iterations.asList(it).iterator());
+
+                    if(bindings != null) {
+                        for(Binding binding : bindings) {
+                            resultRow.addBinding(binding);
+                        }
+                    }
+                    return resultRow;
+                }
+            });
+
+            // materialize result to avoid having more than one result set open at the same
time
+            return new CloseableIteratorIteration<BindingSet, SQLException>(Iterations.asList(it).iterator());
+        } catch (InterruptedException e) {
+            log.info("SPARQL query execution cancelled");
+            queryStatement.cancel();
+            throw e;
+        } catch (ExecutionException e) {
+            log.error("error executing SPARQL query",e);
+            throw new SQLException("error executing SPARQL query",e);
+        }
     }
 
     private String evaluateExpression(ValueExpr expr, Map<Var, List<String>>
queryVariables, OPTypes optype) {

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/d12f782c/libraries/kiwi/kiwi-transactions/pom.xml
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-transactions/pom.xml b/libraries/kiwi/kiwi-transactions/pom.xml
index c76886e..d696682 100644
--- a/libraries/kiwi/kiwi-transactions/pom.xml
+++ b/libraries/kiwi/kiwi-transactions/pom.xml
@@ -94,7 +94,7 @@
         	<scope>test</scope>
         </dependency>
         <dependency>
-            <groupId>net.sf.ehcache</groupId>
+            <groupId>net.sf.ehcache.internal</groupId>
             <artifactId>ehcache-core</artifactId>
             <scope>test</scope>
         </dependency>

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/d12f782c/libraries/kiwi/kiwi-triplestore/pom.xml
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-triplestore/pom.xml b/libraries/kiwi/kiwi-triplestore/pom.xml
index cfa62d2..dc45996 100644
--- a/libraries/kiwi/kiwi-triplestore/pom.xml
+++ b/libraries/kiwi/kiwi-triplestore/pom.xml
@@ -62,7 +62,7 @@
 
         <!-- Caching (transactional) -->
         <dependency>
-            <groupId>net.sf.ehcache</groupId>
+            <groupId>net.sf.ehcache.internal</groupId>
             <artifactId>ehcache-core</artifactId>
         </dependency>
 

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/d12f782c/libraries/ldcache/ldcache-backend-ehcache/pom.xml
----------------------------------------------------------------------
diff --git a/libraries/ldcache/ldcache-backend-ehcache/pom.xml b/libraries/ldcache/ldcache-backend-ehcache/pom.xml
index f4db276..f63e1ab 100644
--- a/libraries/ldcache/ldcache-backend-ehcache/pom.xml
+++ b/libraries/ldcache/ldcache-backend-ehcache/pom.xml
@@ -70,7 +70,7 @@
             <artifactId>kiwi-tripletable</artifactId>
         </dependency>
         <dependency>
-            <groupId>net.sf.ehcache</groupId>
+            <groupId>net.sf.ehcache.internal</groupId>
             <artifactId>ehcache-core</artifactId>
         </dependency>
     </dependencies>

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/d12f782c/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index ba69fe0..fd7cb04 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -942,7 +942,7 @@
             </dependency>
 
             <dependency>
-                <groupId>net.sf.ehcache</groupId>
+                <groupId>net.sf.ehcache.internal</groupId>
                 <artifactId>ehcache-core</artifactId>
                 <version>2.7.2</version>
             </dependency>

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/d12f782c/platform/marmotta-core/pom.xml
----------------------------------------------------------------------
diff --git a/platform/marmotta-core/pom.xml b/platform/marmotta-core/pom.xml
index 654c052..515b26b 100644
--- a/platform/marmotta-core/pom.xml
+++ b/platform/marmotta-core/pom.xml
@@ -325,7 +325,7 @@
         
         <!-- Persistence -->
         <dependency>
-            <groupId>net.sf.ehcache</groupId>
+            <groupId>net.sf.ehcache.internal</groupId>
             <artifactId>ehcache-core</artifactId>
         </dependency>
         <dependency>


Mime
View raw message