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 2011/11/22 16:58:31 UTC

svn commit: r1205051 - /incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/dev/Jena163_TDBDifferentIds.java

Author: andy
Date: Tue Nov 22 15:58:30 2011
New Revision: 1205051

URL: http://svn.apache.org/viewvc?rev=1205051&view=rev
Log: (empty)

Modified:
    incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/dev/Jena163_TDBDifferentIds.java

Modified: incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/dev/Jena163_TDBDifferentIds.java
URL: http://svn.apache.org/viewvc/incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/dev/Jena163_TDBDifferentIds.java?rev=1205051&r1=1205050&r2=1205051&view=diff
==============================================================================
--- incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/dev/Jena163_TDBDifferentIds.java (original)
+++ incubator/jena/Scratch/AFS/Jena-Dev/trunk/src/dev/Jena163_TDBDifferentIds.java Tue Nov 22 15:58:30 2011
@@ -22,10 +22,7 @@ import static com.hp.hpl.jena.tdb.transa
 import static java.lang.String.format ;
 
 import java.util.Iterator ;
-import java.util.concurrent.Callable ;
-import java.util.concurrent.ExecutorService ;
-import java.util.concurrent.Executors ;
-import java.util.concurrent.TimeUnit ;
+import java.util.concurrent.* ;
 import java.util.concurrent.atomic.AtomicInteger ;
 
 import org.junit.AfterClass ;
@@ -85,7 +82,7 @@ public class Jena163_TDBDifferentIds
     static boolean logging                  = ! inlineProgress ; // (! log.isDebugEnabled()) && Iterations > 20 ;
     
     static final int numReaderTasks         = 5 ;
-    static final int numWriterTasksA        = 2 ; 
+    static final int numWriterTasksA        = 3 ; 
     static final int numWriterTasksC        = 5 ;
 
     static final int readerSeqRepeats       = 8 ;
@@ -95,38 +92,44 @@ public class Jena163_TDBDifferentIds
     static final int writerCommitSeqRepeats = 4 ;
     static final int writerMaxPause         = 10 ;
 
-    static final int numTreadsInPool        = 4 ;           // If <= 0 then use an unbounded thread pool.   
+    static final int numThreadsInPool        = 4 ;           // If <= 0 then use an unbounded thread pool.   
     private static ExecutorService execService = null ;
     
     
     private static int iteration = 0 ;
-    private static int numIterationsPerBlock = 100 ;        // Interacts with colMax : make colMax >= numIterationsPerBlock in detailEveryTransaction = false mode
+    private static int numIterationsPerBlock = 100 ;
     private static int colCount = 0 ;
     private static int colMax = 200 ;
     private static boolean detailEveryTransaction = true ; // Set true so that every transaction print a letter for what it does. 
+    private static Semaphore startPoint ; 
+
+    /** TODO
+     * Ideally: better mixes of R, C and A.
+     * One thread, processes a list of RCA choices.
+     * Different mixes to different threads.
+     * 
+     * Random data
+     */
     
     public static void main(String...args) throws InterruptedException
     {
         String x = (MEM?"memory":"disk["+SystemTDB.fileMode()+"]") ;
         
+        // Make colMax >= numIterationsPerBlock in detailEveryTransaction = false mode
         if ( !detailEveryTransaction )
             colMax = numIterationsPerBlock ;
         
-        
         if ( logging )
             log.info("START ({}, {} iterations)", x, Iterations) ;
         else
             printf("START (%s, %d iterations)\n", x, Iterations) ;
         
-//        int numIterations = (Iterations < 10) ? 1 : Iterations / 10 ;
-//        numIterations = Math.min(numIterations, 100) ;
-        
         for ( iteration = 0 ; iteration < Iterations ; iteration++ )
         {
             clean() ;
 
-            execService = ( numTreadsInPool > 0 ) 
-                ? Executors.newFixedThreadPool(numTreadsInPool)
+            execService = ( numThreadsInPool > 0 ) 
+                ? Executors.newFixedThreadPool(numThreadsInPool)
                 : Executors.newCachedThreadPool() ;
             
             startTestIteration() ;                
@@ -169,6 +172,7 @@ public class Jena163_TDBDifferentIds
         @Override
         public Object call()
         {
+            start() ;
             DatasetGraphTxn dsg = null ;
             try
             {
@@ -276,6 +280,8 @@ public class Jena163_TDBDifferentIds
         @Override
         public Object call()
         {
+            start() ;
+
             DatasetGraphTxn dsg = null ;
             try { 
                 int id = gen.incrementAndGet() ;
@@ -335,6 +341,13 @@ public class Jena163_TDBDifferentIds
         // return the delta.
         protected abstract int change(DatasetGraphTxn dsg, int id, int i) ;
     }
+    
+    public static void start()
+    {
+        try { startPoint.acquire() ; }
+        catch (InterruptedException e) { e.printStackTrace(); }
+        pause(10) ;
+    }
 
     @BeforeClass 
     public static void beforeClass()
@@ -405,10 +418,29 @@ public class Jena163_TDBDifferentIds
                 return changeProc(dsg, id, i) ;
             }
         } ;
+        
+        startPoint = new Semaphore(0) ;
 
-        submit(execService, procR,   numReaderTasks, "READ-") ;
-        submit(execService, procW_c, numWriterTasksC, "COMMIT-") ;
-        submit(execService, procW_a, numWriterTasksA, "ABORT-") ;
+        int RN1 = numReaderTasks/2 ;
+        int RN2 = 1 ;
+        int RN3 = numReaderTasks - RN1 - RN2;
+
+        int WC1 =  numWriterTasksC - 2 ;
+        int WC2 =  numWriterTasksC - WC1 ;
+        
+        int WA1 =  numWriterTasksA - 1 ;
+        int WA2 =  numWriterTasksA - WA1 ;
+        
+        // Define the query mix.
+        submit(execService, procR,   RN1, "READ-") ;
+        submit(execService, procW_c, WC1, "COMMIT-") ;
+        submit(execService, procR,   RN2, "READ-") ;
+        submit(execService, procW_a, WA1, "ABORT-") ;
+        submit(execService, procW_c, WC2, "COMMIT-") ;
+        submit(execService, procW_c, WA2, "ABORT-") ;
+        submit(execService, procR,   RN3, "READ-") ;
+        
+        startPoint.release(4000) ;
         
         try
         {