jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r1348427 - in /jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb: StoreConnection.java sys/TDBMakerTxn.java transaction/DatasetGraphTransaction.java transaction/TransactionManager.java
Date Sat, 09 Jun 2012 15:27:13 GMT
Author: andy
Date: Sat Jun  9 15:27:12 2012
New Revision: 1348427

URL: http://svn.apache.org/viewvc?rev=1348427&view=rev
Log:
Remove operations that create a dataset from a dataset - they risk StoreConnection cache confusion.

Modified:
    jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/StoreConnection.java
    jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/sys/TDBMakerTxn.java
    jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/transaction/DatasetGraphTransaction.java
    jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/transaction/TransactionManager.java

Modified: jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/StoreConnection.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/StoreConnection.java?rev=1348427&r1=1348426&r2=1348427&view=diff
==============================================================================
--- jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/StoreConnection.java (original)
+++ jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/StoreConnection.java Sat Jun  9
15:27:12 2012
@@ -43,12 +43,13 @@ public class StoreConnection
     private final DatasetGraphTDB    baseDSG ;
     private boolean                  isValid = true ;
 
-    // private StoreConnection(Location location)
-    // {
-    // baseDSG = DatasetBuilderStd.build(location) ;
-    // transactionManager = new TransactionManager(baseDSG) ;
-    // }
-    //
+    // Uncached - very dangerous.
+//    private StoreConnection(Location location)
+//    {
+//        baseDSG = DatasetBuilderStd.build(location) ;
+//        transactionManager = new TransactionManager(baseDSG) ;
+//    }
+
     private StoreConnection(DatasetGraphTDB dsg)
     {
         baseDSG = dsg ;
@@ -146,9 +147,8 @@ public class StoreConnection
     {
         StoreConnection sConn = cache.get(location) ;
         if (sConn == null) return ;
-        if (!force && sConn.transactionManager.activeTransactions()) throw new TDBTransactionException(
-                                                                                        
              "Can't expel: Active transactions for location: "
-                                                                                        
                  + location) ;
+        if (!force && sConn.transactionManager.activeTransactions()) 
+            throw new TDBTransactionException("Can't expel: Active transactions for location:
" + location) ;
 
         // No transactions at this point (or we don't care and are clearing up
         // forcefully.)
@@ -172,24 +172,24 @@ public class StoreConnection
         return sConn ;
     }
 
-    /**
-     * Return a StoreConnection for a particular connection. This is used to
-     * create transactions for the database at the location.
-     */
-    public static synchronized StoreConnection make(DatasetGraphTDB dsg)
-    {
-        if (dsg instanceof DatasetGraphTxn)
-        {
-            // ((DatasetGraphTxn)dsg).getTransaction().getBaseDataset() ;
-            throw new TDBTransactionException(
-                                              "Can't make a StoreConnection from a transaction
instance - need the base storage DatasetGraphTDB") ;
-        }
-        Location location = dsg.getLocation() ;
-
-        StoreConnection sConn = cache.get(location) ;
-        if (sConn == null) sConn = _makeAndCache(dsg) ;
-        return sConn ;
-    }
+//    /**
+//     * Return a StoreConnection for a particular connection. This is used to
+//     * create transactions for the database at the location.
+//     */
+//    public static synchronized StoreConnection make(DatasetGraphTDB dsg)
+//    {
+//        if (dsg instanceof DatasetGraphTxn)
+//        {
+//            // ((DatasetGraphTxn)dsg).getTransaction().getBaseDataset() ;
+//            throw new TDBTransactionException(
+//                                              "Can't make a StoreConnection from a transaction
instance - need the base storage DatasetGraphTDB") ;
+//        }
+//        Location location = dsg.getLocation() ;
+//
+//        StoreConnection sConn = cache.get(location) ;
+//        if (sConn == null) sConn = _makeAndCache(dsg) ;
+//        return sConn ;
+//    }
 
     /**
      * Return the StoreConnection if one already exists for this location, else

Modified: jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/sys/TDBMakerTxn.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/sys/TDBMakerTxn.java?rev=1348427&r1=1348426&r2=1348427&view=diff
==============================================================================
--- jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/sys/TDBMakerTxn.java (original)
+++ jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/sys/TDBMakerTxn.java Sat Jun  9
15:27:12 2012
@@ -20,7 +20,6 @@ package com.hp.hpl.jena.tdb.sys;
 
 import com.hp.hpl.jena.tdb.StoreConnection ;
 import com.hp.hpl.jena.tdb.base.file.Location ;
-import com.hp.hpl.jena.tdb.store.DatasetGraphTDB ;
 import com.hp.hpl.jena.tdb.transaction.DatasetGraphTransaction ;
 
 /** factory for creating objects datasets backed by TDB storage which support transactions
*/
@@ -50,12 +49,6 @@ public class TDBMakerTxn
         return new DatasetGraphTransaction(location) ;
     }
     
-    private static DatasetGraphTransaction _create(DatasetGraphTDB dsg)
-    {
-        // No need to cache StoreConnection does all that.
-        return new DatasetGraphTransaction(dsg) ;
-    }
-
     public static void releaseLocation(Location location)
     {
         StoreConnection.release(location) ;

Modified: jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/transaction/DatasetGraphTransaction.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/transaction/DatasetGraphTransaction.java?rev=1348427&r1=1348426&r2=1348427&view=diff
==============================================================================
--- jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/transaction/DatasetGraphTransaction.java
(original)
+++ jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/transaction/DatasetGraphTransaction.java
Sat Jun  9 15:27:12 2012
@@ -56,11 +56,12 @@ public class DatasetGraphTransaction ext
     @Override
     protected void finalize() throws Throwable
     {
+//        if ( txn.get() != null )
+//            txn.get().abort() ;
         txn.remove() ;
     }
 
     // Transaction per thread.
-    private Object lock = new Object() ;
     private ThreadLocalTxn txn = new ThreadLocalTxn() ;
     private ThreadLocalBoolean inTransaction = new ThreadLocalBoolean() ;
 
@@ -72,11 +73,6 @@ public class DatasetGraphTransaction ext
         sConn = StoreConnection.make(location) ;
     }
 
-    public DatasetGraphTransaction(DatasetGraphTDB dsg)
-    {
-        sConn = StoreConnection.make(dsg) ;
-    }
-
     public Location getLocation()       { return sConn.getLocation() ; }
     
     public DatasetGraphTDB getDatasetGraphToQuery()
@@ -137,7 +133,7 @@ public class DatasetGraphTransaction ext
     @Override
     protected void _begin(ReadWrite readWrite)
     {
-        synchronized(lock)
+        synchronized(sConn)
         {
             syncIfNotTransactional() ;
             haveUsedInTransaction = true ;

Modified: jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/transaction/TransactionManager.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/transaction/TransactionManager.java?rev=1348427&r1=1348426&r2=1348427&view=diff
==============================================================================
--- jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/transaction/TransactionManager.java
(original)
+++ jena/trunk/jena-tdb/src/main/java/com/hp/hpl/jena/tdb/transaction/TransactionManager.java
Sat Jun  9 15:27:12 2012
@@ -323,18 +323,13 @@ public class TransactionManager
     
     public static final boolean DEBUG = false ; 
         
+    // If DatasetGraphTransaction has a sync lock on sConn, this
+    // does not need to be sync'ed. But it's possible to use some
+    // of the low level object directly so we'll play safe.  
+    
     synchronized
     private DatasetGraphTxn begin$(ReadWrite mode, String label)
     {
-//        // Subs transactions are a new view - commit is only commit to parent transaction.
 
-//        if ( dsg instanceof DatasetGraphTxn )
-//        {
-//            throw new TDBException("Already in transactional DatasetGraph") ;
-//            // Either:
-//            //   error -> implies nested
-//            //   create new transaction 
-//        }
-        
         if ( mode == ReadWrite.WRITE && activeWriters.get() > 0 )    // Guard
             throw new TDBTransactionException("Existing active write transaction") ;
 



Mime
View raw message