You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by an...@apache.org on 2013/04/25 20:49:53 UTC

svn commit: r1475901 - in /jena/Scratch/AFS/Jena-Dev/trunk/src: dev/Run.java dev/RunDev.java reports/archive/Jena440_QueryTimeout.java

Author: andy
Date: Thu Apr 25 18:49:52 2013
New Revision: 1475901

URL: http://svn.apache.org/r1475901
Log:
Archive report

Added:
    jena/Scratch/AFS/Jena-Dev/trunk/src/dev/RunDev.java
      - copied, changed from r1469821, jena/Scratch/AFS/Jena-Dev/trunk/src/dev/Run.java
    jena/Scratch/AFS/Jena-Dev/trunk/src/reports/archive/Jena440_QueryTimeout.java
Removed:
    jena/Scratch/AFS/Jena-Dev/trunk/src/dev/Run.java

Copied: jena/Scratch/AFS/Jena-Dev/trunk/src/dev/RunDev.java (from r1469821, jena/Scratch/AFS/Jena-Dev/trunk/src/dev/Run.java)
URL: http://svn.apache.org/viewvc/jena/Scratch/AFS/Jena-Dev/trunk/src/dev/RunDev.java?p2=jena/Scratch/AFS/Jena-Dev/trunk/src/dev/RunDev.java&p1=jena/Scratch/AFS/Jena-Dev/trunk/src/dev/Run.java&r1=1469821&r2=1475901&rev=1475901&view=diff
==============================================================================
--- jena/Scratch/AFS/Jena-Dev/trunk/src/dev/Run.java (original)
+++ jena/Scratch/AFS/Jena-Dev/trunk/src/dev/RunDev.java Thu Apr 25 18:49:52 2013
@@ -18,83 +18,26 @@
 
 package dev;
 
-import static org.apache.jena.atlas.lib.Lib.sleep ;
 import org.apache.jena.atlas.lib.StrUtils ;
 import org.apache.jena.atlas.logging.Log ;
-import org.junit.Assert ;
-import org.junit.Test ;
 
-import com.hp.hpl.jena.graph.Graph ;
-import com.hp.hpl.jena.query.* ;
-import com.hp.hpl.jena.sparql.ARQConstants ;
+import com.hp.hpl.jena.query.Query ;
+import com.hp.hpl.jena.query.QueryFactory ;
 import com.hp.hpl.jena.sparql.algebra.Algebra ;
 import com.hp.hpl.jena.sparql.algebra.Op ;
 import com.hp.hpl.jena.sparql.algebra.optimize.Optimize ;
 import com.hp.hpl.jena.sparql.algebra.optimize.TransformFilterEquality ;
-import com.hp.hpl.jena.sparql.core.DatasetGraph ;
-import com.hp.hpl.jena.sparql.core.DatasetGraphFactory ;
-import com.hp.hpl.jena.sparql.engine.binding.Binding ;
 import com.hp.hpl.jena.sparql.serializer.SerializationContext ;
-import com.hp.hpl.jena.sparql.sse.SSE ;
 import com.hp.hpl.jena.sparql.sse.writers.WriterOp ;
 
-public class Run extends RunBase
+public class RunDev extends RunBase
 {
     static { Log.setCmdLogging() ; }
     
     static String DIR = "DB" ; 
     
-    // JENA-440
-    
-    static private String prefix = 
-        "PREFIX f:       <http://example/ns#>\n"+
-        "PREFIX afn:     <http://jena.hpl.hp.com/ARQ/function#>\n" ;
-    static Graph                g   = SSE.parseGraph("(graph (<s> <p> <o1>) (<s> <p> <o2>) (<s> <p> <o3>))") ;
-    static DatasetGraph         dsg = DatasetGraphFactory.createOneGraph(g) ;
-    static Dataset              ds  = DatasetFactory.create(dsg) ;
-    private static void noException(ResultSet rs)
-    {
-        ResultSetFormatter.consume(rs) ;
-    }
-
-    private static void exceptionExpected(ResultSet rs)
-    {
-        try { ResultSetFormatter.consume(rs) ; Assert.fail("QueryCancelledException expected") ; } catch (QueryCancelledException ex) {}
-    }
-
-
-    // ----------------------
-    // Set via context on the QE is too late.
-    
-    @Test
-    public void timeout_30()
-    {
-        String qs = prefix + "SELECT * { { ?s ?p ?o } UNION { FILTER( afn:wait(50) ) } UNION { ?s ?p ?o } }" ;
-        QueryExecution qExec = QueryExecutionFactory.create(qs, ds) ;
-        try {
-            qExec.setTimeout(10,10) ;
-            // No rewrite optimizations.
-            qExec.getContext().set(ARQConstants.sysOptimizerFactory, Optimize.noOptimizationFactory) ;
-            ResultSet rs = qExec.execSelect() ;
-            
-            // Should be several solutions ... 
-            Binding b = rs.nextBinding() ;
-            System.out.println(b) ;
-            // ... then a timeout.
-            sleep(40) ;
-            exceptionExpected(rs) ;
-        } finally {
-            qExec.close() ;
-        }
-    }
-    // ----------------------
-
-    
     public static void main(String[] argv) throws Exception
     {
-        new Run().timeout_30() ;
-        System.out.println("DONE") ;
-        System.exit(0) ;
         mainExplain() ;
         System.exit(0) ;
     }

Added: jena/Scratch/AFS/Jena-Dev/trunk/src/reports/archive/Jena440_QueryTimeout.java
URL: http://svn.apache.org/viewvc/jena/Scratch/AFS/Jena-Dev/trunk/src/reports/archive/Jena440_QueryTimeout.java?rev=1475901&view=auto
==============================================================================
--- jena/Scratch/AFS/Jena-Dev/trunk/src/reports/archive/Jena440_QueryTimeout.java (added)
+++ jena/Scratch/AFS/Jena-Dev/trunk/src/reports/archive/Jena440_QueryTimeout.java Thu Apr 25 18:49:52 2013
@@ -0,0 +1,124 @@
+/**
+ * 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 reports.archive;
+
+import static org.apache.jena.atlas.lib.Lib.sleep ;
+import org.apache.jena.atlas.logging.Log ;
+import org.junit.Assert ;
+import org.junit.Test ;
+
+import com.hp.hpl.jena.graph.Graph ;
+import com.hp.hpl.jena.query.* ;
+import com.hp.hpl.jena.sparql.core.DatasetGraph ;
+import com.hp.hpl.jena.sparql.core.DatasetGraphFactory ;
+import com.hp.hpl.jena.sparql.engine.binding.Binding ;
+import com.hp.hpl.jena.sparql.sse.SSE ;
+
+public class Jena440_QueryTimeout
+{
+    static { Log.setCmdLogging() ; }
+
+    // JENA-440
+
+    static private String prefix = 
+        "PREFIX f:       <http://example/ns#>\n"+
+            "PREFIX afn:     <http://jena.hpl.hp.com/ARQ/function#>\n" ;
+    static Graph                g   = SSE.parseGraph("(graph " +
+    		"(<s> <p> 1)" +
+    		" (<s> <p> 2)" +
+    		" (<s> <p> 3)" +
+            " (<s> <p> 4)" +
+            " (<s> <p> 5)" +
+            " (<s> <p> 6)" +
+            " (<s> <p> 7)" +
+            " (<s> <p> 8)" +
+            " (<s> <p> 9)" +
+            " (<s> <p> 10)" +
+            " (<s> <p> 11)" +
+            " (<s> <p> 12)" +
+    		")") ;
+    static DatasetGraph         dsg = DatasetGraphFactory.createOneGraph(g) ;
+    static Dataset              ds  = DatasetFactory.create(dsg) ;
+
+    private static void noException(ResultSet rs)
+    {
+        ResultSetFormatter.consume(rs) ;
+    }
+
+    private static void exceptionExpected(ResultSet rs)
+    {
+        try { ResultSetFormatter.consume(rs) ; Assert.fail("QueryCancelledException expected") ; } catch (QueryCancelledException ex) {}
+    }
+
+
+    // TestQueryExecutionTimeout
+    // ----------------------
+    // Setting via context on the QE is too late.
+
+    @Test public void timeout_30()  { test2(200, 20, 50, true) ; }
+    @Test public void timeout_31()  { test2(200, 50, 20, false) ; }
+    
+    // Make sure it isn't timeout1 - delay longer than timeout1
+    @Test public void timeout_32()  { test2(100, 500, 200, false) ; }
+    @Test public void timeout_33()  { test2(150, -1,  200, false) ; }
+
+    @Test public void timeout_34()  { test2(10, 40, 100, true) ; }
+    
+    @Test public void timeout_35()  { test2(-1, 20, 50, true) ; }
+    @Test public void timeout_36()  { test2(-1, 50, 20, false) ; }
+
+    @Test public void timeout_37()  { test2(200, 200, 50, false) ; }
+    @Test public void timeout_38()  { test2(200, -1, 50, false) ; }
+
+    
+    private static void test2(long timeout1, long timeout2, int delay, boolean exceptionExpected)
+    {
+     // Enough rows to keep the iterator pipeline full.
+        QueryExecution qExec = QueryExecutionFactory.create(prefix+"SELECT * { ?s ?p ?o }", ds) ;
+        try {
+            qExec.setTimeout(timeout1, timeout2) ;
+//            // No rewrite optimizations.
+//            qExec.getContext().set(ARQConstants.sysOptimizerFactory, Optimize.noOptimizationFactory) ;
+            ResultSet rs = qExec.execSelect() ;
+            // ... wait for first binding.
+            Binding b1 = rs.nextBinding() ;
+            //System.err.println(b1) ;
+            // ... then a possible timeout.
+            sleep(delay) ;
+            if ( exceptionExpected )
+                exceptionExpected(rs) ;
+            else
+                noException(rs) ;
+        } finally {
+            qExec.close() ;
+        }
+    }
+    
+    // ----------------------
+
+
+    public static void main(String[] argv) throws Exception
+    {
+        new Jena440_QueryTimeout().timeout_30() ;
+        System.out.println("DONE") ;
+        System.exit(0) ;
+    }
+
+}
+