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 2018/02/01 17:35:14 UTC

[2/5] jena git commit: Cleanup comments and code around txn

Cleanup comments and code around txn


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

Branch: refs/heads/master
Commit: 90698b24de18060c291a66267c509a16e90a33ac
Parents: 6228bbc
Author: Andy Seaborne <an...@apache.org>
Authored: Tue Jan 30 11:53:29 2018 +0000
Committer: Andy Seaborne <an...@apache.org>
Committed: Tue Jan 30 11:53:29 2018 +0000

----------------------------------------------------------------------
 .../sparql/graph/TransactionHandlerNull.java    |  2 +-
 .../jena/tdb2/store/GraphViewSwitchable.java    |  5 --
 .../jena/tdb/graph/TransactionHandlerTDB.java   | 62 --------------------
 .../apache/jena/tdb/store/GraphNonTxnTDB.java   | 57 ++++++++++++++----
 4 files changed, 47 insertions(+), 79 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/90698b24/jena-arq/src/main/java/org/apache/jena/sparql/graph/TransactionHandlerNull.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/graph/TransactionHandlerNull.java b/jena-arq/src/main/java/org/apache/jena/sparql/graph/TransactionHandlerNull.java
index 8245695..5a6fd88 100644
--- a/jena-arq/src/main/java/org/apache/jena/sparql/graph/TransactionHandlerNull.java
+++ b/jena-arq/src/main/java/org/apache/jena/sparql/graph/TransactionHandlerNull.java
@@ -22,7 +22,7 @@ import org.apache.jena.graph.TransactionHandler;
 import org.apache.jena.graph.impl.TransactionHandlerBase;
 import org.apache.jena.sparql.JenaTransactionException;
 
-/** Implementation of {@link TransactionHandler} that does nothing but track the transction state. */
+/** Implementation of {@link TransactionHandler} that does nothing but track the transaction state. */
 public class TransactionHandlerNull extends TransactionHandlerBase {
  
     private ThreadLocal<Boolean> inTransaction = ThreadLocal.withInitial(()->Boolean.FALSE);

http://git-wip-us.apache.org/repos/asf/jena/blob/90698b24/jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/store/GraphViewSwitchable.java
----------------------------------------------------------------------
diff --git a/jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/store/GraphViewSwitchable.java b/jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/store/GraphViewSwitchable.java
index deeb788..c82af4f 100644
--- a/jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/store/GraphViewSwitchable.java
+++ b/jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/store/GraphViewSwitchable.java
@@ -33,11 +33,6 @@ import org.apache.jena.sparql.expr.nodevalue.NodeFunctions;
  * A GraphView that is sensitive to {@link DatasetGraphSwitchable} switching.
  */
 public class GraphViewSwitchable extends GraphView {
-    // Fixups for GraphView
-    //   Prefixes.
-    //   Transaction handler.
-    // Long term - ensure that GraphView uses get() always, inc prefixes, transaction handlers
-    
     // Factory style.
     public static GraphViewSwitchable createDefaultGraph(DatasetGraphSwitchable dsg)
     { return new GraphViewSwitchable(dsg, Quad.defaultGraphNodeGenerated) ; }

http://git-wip-us.apache.org/repos/asf/jena/blob/90698b24/jena-tdb/src/main/java/org/apache/jena/tdb/graph/TransactionHandlerTDB.java
----------------------------------------------------------------------
diff --git a/jena-tdb/src/main/java/org/apache/jena/tdb/graph/TransactionHandlerTDB.java b/jena-tdb/src/main/java/org/apache/jena/tdb/graph/TransactionHandlerTDB.java
deleted file mode 100644
index 1af7c3f..0000000
--- a/jena-tdb/src/main/java/org/apache/jena/tdb/graph/TransactionHandlerTDB.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * 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.jena.tdb.graph;
-
-import org.apache.jena.graph.Graph ;
-import org.apache.jena.graph.impl.TransactionHandlerBase ;
-import org.apache.jena.tdb.TDB ;
-import org.apache.jena.tdb.store.GraphTDB ;
-
-/** Support for when TDB is used non-transactionally. Does not support ACID transactions.  
- *  Flushes if commit is called although it denies supporting transactions
- */
-
-public class TransactionHandlerTDB extends TransactionHandlerBase //implements TransactionHandler 
-{
-    private final Graph graph ;
-
-    public TransactionHandlerTDB(GraphTDB graph)
-    {
-        this.graph = graph ;
-    }
-    
-    @Override
-    public void abort()
-    {
-        // Not the Jena old-style transaction interface
-        throw new UnsupportedOperationException("TDB: 'abort' of a transaction not supported") ;
-        //log.warn("'Abort' of a transaction not supported - ignored") ;
-    }
-
-    @Override
-    public void begin()
-    {}
-
-    @Override
-    public void commit()
-    {
-        TDB.sync(graph) ;
-    }
-
-    @Override
-    public boolean transactionsSupported()
-    {
-        return false ;
-    }
-}

http://git-wip-us.apache.org/repos/asf/jena/blob/90698b24/jena-tdb/src/main/java/org/apache/jena/tdb/store/GraphNonTxnTDB.java
----------------------------------------------------------------------
diff --git a/jena-tdb/src/main/java/org/apache/jena/tdb/store/GraphNonTxnTDB.java b/jena-tdb/src/main/java/org/apache/jena/tdb/store/GraphNonTxnTDB.java
index 55d0677..3cc35dc 100644
--- a/jena-tdb/src/main/java/org/apache/jena/tdb/store/GraphNonTxnTDB.java
+++ b/jena-tdb/src/main/java/org/apache/jena/tdb/store/GraphNonTxnTDB.java
@@ -16,13 +16,15 @@
  * limitations under the License.
  */
 
-package org.apache.jena.tdb.store ;
+package org.apache.jena.tdb.store;
 
-import org.apache.jena.atlas.lib.Closeable ;
-import org.apache.jena.atlas.lib.Sync ;
-import org.apache.jena.graph.Node ;
+import org.apache.jena.atlas.lib.Closeable;
+import org.apache.jena.atlas.lib.Sync;
+import org.apache.jena.graph.Graph;
+import org.apache.jena.graph.Node;
 import org.apache.jena.graph.TransactionHandler;
-import org.apache.jena.tdb.graph.TransactionHandlerTDB;
+import org.apache.jena.graph.impl.TransactionHandlerBase;
+import org.apache.jena.tdb.TDB;
 
 /**
  * Non-transactional version of {@link GraphTDB}. Handed out by DatasetGraphTDB when used
@@ -32,25 +34,58 @@ import org.apache.jena.tdb.graph.TransactionHandlerTDB;
  * @see GraphTxnTDB
  */
 public class GraphNonTxnTDB extends GraphTDB implements Closeable, Sync {
-    private final DatasetGraphTDB    dataset ;
+    private final DatasetGraphTDB    dataset;
 
     public GraphNonTxnTDB(DatasetGraphTDB dataset, Node graphName) {
-        super(dataset, graphName) ;
-        this.dataset = dataset ;
+        super(dataset, graphName);
+        this.dataset = dataset;
     }
 
     @Override
     public DatasetGraphTDB getDatasetGraphTDB() {
-        return dataset ;
+        return dataset;
     }
 
     @Override
     protected DatasetGraphTDB getBaseDatasetGraphTDB() {
-        return dataset ;
+        return dataset;
     }
     
     @Override
     public TransactionHandler getTransactionHandler() {
-        return new TransactionHandlerTDB(this) ;
+        return new TransactionHandlerTDB(this);
+    }
+    
+    // Transaction handler for non-transactional use.
+    // Does not support transactions, but syncs on commit which is the best it
+    // can do without being transactional, which is striongly preferrerd.
+    // For backwards compatibility only.
+    private static class TransactionHandlerTDB extends TransactionHandlerBase //implements TransactionHandler 
+    {
+        private final Graph graph;
+
+        public TransactionHandlerTDB(GraphTDB graph) {
+            this.graph = graph ;
+        }
+
+        @Override
+        public void abort() {
+            // Not the Jena old-style transaction interface
+            throw new UnsupportedOperationException("TDB: 'abort' of a transaction not supported") ;
+            // log.warn("'Abort' of a transaction not supported - ignored");
+        }
+
+        @Override
+        public void begin() {}
+
+        @Override
+        public void commit() {
+            TDB.sync(graph) ;
+        }
+
+        @Override
+        public boolean transactionsSupported() {
+            return false ;
+        }
     }
 }