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 2015/12/04 17:35:28 UTC
[1/5] jena git commit: Minor: fix exception message.
Repository: jena
Updated Branches:
refs/heads/master 83cf64d78 -> 10648973b
Minor: fix exception message.
Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/92c3affe
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/92c3affe
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/92c3affe
Branch: refs/heads/master
Commit: 92c3affe19b32726d3e065b84a58a478e4a50ad0
Parents: 83cf64d
Author: Andy Seaborne <an...@apache.org>
Authored: Fri Dec 4 15:35:03 2015 +0000
Committer: Andy Seaborne <an...@apache.org>
Committed: Fri Dec 4 15:35:03 2015 +0000
----------------------------------------------------------------------
jena-tdb/src/main/java/org/apache/jena/tdb/StoreConnection.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jena/blob/92c3affe/jena-tdb/src/main/java/org/apache/jena/tdb/StoreConnection.java
----------------------------------------------------------------------
diff --git a/jena-tdb/src/main/java/org/apache/jena/tdb/StoreConnection.java b/jena-tdb/src/main/java/org/apache/jena/tdb/StoreConnection.java
index 0bae435..1ca65c5 100644
--- a/jena-tdb/src/main/java/org/apache/jena/tdb/StoreConnection.java
+++ b/jena-tdb/src/main/java/org/apache/jena/tdb/StoreConnection.java
@@ -54,7 +54,7 @@ public class StoreConnection
private void checkValid()
{
if (!isValid)
- throw new TDBTransactionException("StoreConnection inValid (issued before a StoreConnection.release?") ;
+ throw new TDBTransactionException("StoreConnection inValid (issued before a StoreConnection.release?)") ;
}
// Ensure that a dataset used non-transactionally has been flushed to disk
[3/5] jena git commit: Adjust long comment.
Posted by an...@apache.org.
Adjust long comment.
Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/ae0a5221
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/ae0a5221
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/ae0a5221
Branch: refs/heads/master
Commit: ae0a52218452e742b26560b43d10df73552d34fe
Parents: 00da46b
Author: Andy Seaborne <an...@apache.org>
Authored: Fri Dec 4 16:27:34 2015 +0000
Committer: Andy Seaborne <an...@apache.org>
Committed: Fri Dec 4 16:27:34 2015 +0000
----------------------------------------------------------------------
jena-tdb/src/main/java/org/apache/jena/tdb/StoreConnection.java | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jena/blob/ae0a5221/jena-tdb/src/main/java/org/apache/jena/tdb/StoreConnection.java
----------------------------------------------------------------------
diff --git a/jena-tdb/src/main/java/org/apache/jena/tdb/StoreConnection.java b/jena-tdb/src/main/java/org/apache/jena/tdb/StoreConnection.java
index 8d21cb3..da30b47 100644
--- a/jena-tdb/src/main/java/org/apache/jena/tdb/StoreConnection.java
+++ b/jena-tdb/src/main/java/org/apache/jena/tdb/StoreConnection.java
@@ -178,8 +178,7 @@ public class StoreConnection
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.)
+ // No transactions at this point (or we don't care and are clearing up forcefully.)
sConn.transactionManager.closedown() ;
sConn.baseDSG.close() ;
sConn.isValid = false ;
[4/5] jena git commit: Clean up while reviewing.
Posted by an...@apache.org.
Clean up while reviewing.
Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/0cfc7569
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/0cfc7569
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/0cfc7569
Branch: refs/heads/master
Commit: 0cfc75691aa0c40064a45bbf4264e74bfa831a2f
Parents: ae0a522
Author: Andy Seaborne <an...@apache.org>
Authored: Fri Dec 4 16:33:14 2015 +0000
Committer: Andy Seaborne <an...@apache.org>
Committed: Fri Dec 4 16:33:14 2015 +0000
----------------------------------------------------------------------
jena-tdb/src/main/java/org/apache/jena/tdb/sys/TDBMaker.java | 2 +-
jena-tdb/src/test/java/org/apache/jena/tdb/TestTDBFactory.java | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jena/blob/0cfc7569/jena-tdb/src/main/java/org/apache/jena/tdb/sys/TDBMaker.java
----------------------------------------------------------------------
diff --git a/jena-tdb/src/main/java/org/apache/jena/tdb/sys/TDBMaker.java b/jena-tdb/src/main/java/org/apache/jena/tdb/sys/TDBMaker.java
index 1e90606..2d4acde 100644
--- a/jena-tdb/src/main/java/org/apache/jena/tdb/sys/TDBMaker.java
+++ b/jena-tdb/src/main/java/org/apache/jena/tdb/sys/TDBMaker.java
@@ -33,7 +33,7 @@ public class TDBMaker
// This hides details from the top level TDB Factory (e.g. for testing)
/** Create a DatasetGraph that supports transactions */
- public static DatasetGraphTransaction createDatasetGraphTransaction(String location) {
+ static DatasetGraphTransaction createDatasetGraphTransaction(String location) {
return createDatasetGraphTransaction(Location.create(location)) ;
}
http://git-wip-us.apache.org/repos/asf/jena/blob/0cfc7569/jena-tdb/src/test/java/org/apache/jena/tdb/TestTDBFactory.java
----------------------------------------------------------------------
diff --git a/jena-tdb/src/test/java/org/apache/jena/tdb/TestTDBFactory.java b/jena-tdb/src/test/java/org/apache/jena/tdb/TestTDBFactory.java
index 1672c5e..35853b7 100644
--- a/jena-tdb/src/test/java/org/apache/jena/tdb/TestTDBFactory.java
+++ b/jena-tdb/src/test/java/org/apache/jena/tdb/TestTDBFactory.java
@@ -71,8 +71,8 @@ public class TestTDBFactory extends BaseTest
@Test public void testTDBMakerTxn1()
{
TDBMaker.reset() ;
- DatasetGraph dg1 = TDBMaker.createDatasetGraphTransaction(DIR) ;
- DatasetGraph dg2 = TDBMaker.createDatasetGraphTransaction(DIR) ;
+ DatasetGraph dg1 = TDBMaker.createDatasetGraphTransaction(Location.create(DIR)) ;
+ DatasetGraph dg2 = TDBMaker.createDatasetGraphTransaction(Location.create(DIR)) ;
DatasetGraph dgBase1 = ((DatasetGraphTransaction)dg1).getBaseDatasetGraph() ;
DatasetGraph dgBase2 = ((DatasetGraphTransaction)dg2).getBaseDatasetGraph() ;
[5/5] jena git commit: Simpify by using in a Java8 style.
Posted by an...@apache.org.
Simpify by using in a Java8 style.
Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/10648973
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/10648973
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/10648973
Branch: refs/heads/master
Commit: 10648973b20d5233b5a6bc199e9806f901510d6b
Parents: 0cfc756
Author: Andy Seaborne <an...@apache.org>
Authored: Fri Dec 4 16:34:27 2015 +0000
Committer: Andy Seaborne <an...@apache.org>
Committed: Fri Dec 4 16:34:27 2015 +0000
----------------------------------------------------------------------
.../transaction/DatasetGraphTransaction.java | 39 ++++++++------------
1 file changed, 15 insertions(+), 24 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jena/blob/10648973/jena-tdb/src/main/java/org/apache/jena/tdb/transaction/DatasetGraphTransaction.java
----------------------------------------------------------------------
diff --git a/jena-tdb/src/main/java/org/apache/jena/tdb/transaction/DatasetGraphTransaction.java b/jena-tdb/src/main/java/org/apache/jena/tdb/transaction/DatasetGraphTransaction.java
index 4845dfe..f4cc4f2 100644
--- a/jena-tdb/src/main/java/org/apache/jena/tdb/transaction/DatasetGraphTransaction.java
+++ b/jena-tdb/src/main/java/org/apache/jena/tdb/transaction/DatasetGraphTransaction.java
@@ -27,14 +27,21 @@ import org.apache.jena.tdb.StoreConnection ;
import org.apache.jena.tdb.TDB ;
import org.apache.jena.tdb.base.file.Location ;
import org.apache.jena.tdb.store.DatasetGraphTDB ;
+import static java.lang.ThreadLocal.withInitial ;
/**
- * Transactional DatasetGraph that allows one active transaction. For multiple
- * read transactions, create multiple DatasetGraphTransaction objects. This is
- * analogous to a "connection" in JDBC.
+ * A transactional {@code DatasetGraph} that allows one active transaction per thread.
+ *
+ * {@link DatasetGraphTxn} holds the {~link Trasnaction} object.
+ *
+ * This is analogous to a "connection" in JDBC.
+ * It is a holder of a {@link StoreConnection} combined with the machinary from
+ * {@link DatasetGraphTrackActive}.
+ *
+ * Not considered to be in the public API.
*/
-public class DatasetGraphTransaction extends DatasetGraphTrackActive implements Sync {
+ public class DatasetGraphTransaction extends DatasetGraphTrackActive implements Sync {
/*
* Initially, the app can use this DatasetGraph non-transactionally. But as
* soon as it starts a transaction, the dataset can only be used inside
@@ -46,28 +53,12 @@ public class DatasetGraphTransaction extends DatasetGraphTrackActive implements
* transactions.
*/
- static class ThreadLocalTxn extends ThreadLocal<DatasetGraphTxn> {
- // This is the default - but nice to give it a name and to set it
- // clearly.
- @Override
- protected DatasetGraphTxn initialValue() {
- return null ;
- }
- }
-
- static class ThreadLocalBoolean extends ThreadLocal<Boolean> {
- @Override
- protected Boolean initialValue() {
- return false ;
- }
- }
-
// Transaction per thread per DatasetGraphTransaction object.
- private ThreadLocalTxn txn = new ThreadLocalTxn() ;
- private ThreadLocalBoolean inTransaction = new ThreadLocalBoolean() ;
+ private ThreadLocal<DatasetGraphTxn> txn = withInitial(() -> null);
+ private ThreadLocal<Boolean> inTransaction = withInitial(() -> false);
- private final StoreConnection sConn ;
- private boolean isClosed = false ;
+ private final StoreConnection sConn;
+ private boolean isClosed = false;
public DatasetGraphTransaction(Location location) {
sConn = StoreConnection.make(location) ;
[2/5] jena git commit: Reformat
Posted by an...@apache.org.
Reformat
Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/00da46b6
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/00da46b6
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/00da46b6
Branch: refs/heads/master
Commit: 00da46b6cb2e7ba1f1f9dd16ad64d1b2a3a38080
Parents: 92c3aff
Author: Andy Seaborne <an...@apache.org>
Authored: Fri Dec 4 15:41:49 2015 +0000
Committer: Andy Seaborne <an...@apache.org>
Committed: Fri Dec 4 15:41:49 2015 +0000
----------------------------------------------------------------------
.../org/apache/jena/tdb/StoreConnection.java | 148 +++++++------------
1 file changed, 56 insertions(+), 92 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jena/blob/00da46b6/jena-tdb/src/main/java/org/apache/jena/tdb/StoreConnection.java
----------------------------------------------------------------------
diff --git a/jena-tdb/src/main/java/org/apache/jena/tdb/StoreConnection.java b/jena-tdb/src/main/java/org/apache/jena/tdb/StoreConnection.java
index 1ca65c5..8d21cb3 100644
--- a/jena-tdb/src/main/java/org/apache/jena/tdb/StoreConnection.java
+++ b/jena-tdb/src/main/java/org/apache/jena/tdb/StoreConnection.java
@@ -45,52 +45,44 @@ public class StoreConnection
private boolean isValid = true ;
private volatile boolean haveUsedInTransaction = false ;
- private StoreConnection(DatasetGraphTDB dsg)
- {
- baseDSG = dsg ;
- transactionManager = new TransactionManager(baseDSG) ;
+ private StoreConnection(DatasetGraphTDB dsg) {
+ baseDSG = dsg;
+ transactionManager = new TransactionManager(baseDSG);
}
- private void checkValid()
- {
+ private void checkValid() {
if (!isValid)
throw new TDBTransactionException("StoreConnection inValid (issued before a StoreConnection.release?)") ;
}
// Ensure that a dataset used non-transactionally has been flushed to disk
- private void checkTransactional()
- {
+ private void checkTransactional() {
// Access to booleans is atomic.
- if ( ! haveUsedInTransaction )
- {
+ if ( !haveUsedInTransaction ) {
// See http://en.wikipedia.org/wiki/Double-checked_locking
// Except we don't have the delayed constructor problem.
- synchronized(this)
- {
- if ( ! haveUsedInTransaction )
- {
+ synchronized (this) {
+ if ( !haveUsedInTransaction ) {
// Sync the underlying database in case used
// non-transactionally by the application.
- baseDSG.sync() ;
+ baseDSG.sync();
}
- haveUsedInTransaction = true ;
+ haveUsedInTransaction = true;
}
}
}
public boolean haveUsedInTransaction() { return haveUsedInTransaction ; }
- public Location getLocation()
- {
- checkValid() ;
- return baseDSG.getLocation() ;
+ public Location getLocation() {
+ checkValid();
+ return baseDSG.getLocation();
}
/** Return a description of the transaction manager state */
- public SysTxnState getTransMgrState()
- {
- checkValid() ;
- return transactionManager.state() ;
+ public SysTxnState getTransMgrState() {
+ checkValid();
+ return transactionManager.state();
}
/**
@@ -98,25 +90,22 @@ public class StoreConnection
* {@link Transaction#commit()} or {@link Transaction#abort()}. Terminate a
* write transaction with {@link Transaction#close()}.
*/
- public DatasetGraphTxn begin(ReadWrite mode)
- {
- checkValid() ;
- checkTransactional() ;
- haveUsedInTransaction = true ;
- return transactionManager.begin(mode) ;
+ public DatasetGraphTxn begin(ReadWrite mode) {
+ checkValid();
+ checkTransactional();
+ haveUsedInTransaction = true;
+ return transactionManager.begin(mode);
}
-
/**
* Begin a transaction, giving it a label. Terminate a write transaction
* with {@link Transaction#commit()} or {@link Transaction#abort()}.
* Terminate a write transaction with {@link Transaction#close()}.
*/
- public DatasetGraphTxn begin(ReadWrite mode, String label)
- {
- checkValid() ;
- checkTransactional() ;
- return transactionManager.begin(mode, label) ;
+ public DatasetGraphTxn begin(ReadWrite mode, String label) {
+ checkValid();
+ checkTransactional();
+ return transactionManager.begin(mode, label);
}
/**
@@ -125,57 +114,50 @@ public class StoreConnection
* if pending commits are queued.
* @see #flush
*/
- public DatasetGraphTDB getBaseDataset()
- {
- checkValid() ;
- return baseDSG ;
+ public DatasetGraphTDB getBaseDataset() {
+ checkValid();
+ return baseDSG;
}
/** Flush the delayed write queue to the base storage.
* This can only be done if there are no active transactions.
* If there are active transactions, nothing is done but this is safe to call.
*/
- public void flush()
- {
- if ( ! haveUsedInTransaction() )
- return ;
- checkValid() ;
- transactionManager.flush() ;
+ public void flush() {
+ if ( !haveUsedInTransaction() )
+ return;
+ checkValid();
+ transactionManager.flush();
}
/** Indicate whether there are any active transactions.
* @see #getTransMgrState
*/
- public boolean activeTransactions()
- {
- checkValid() ;
- return transactionManager.activeTransactions() ;
+ public boolean activeTransactions() {
+ checkValid();
+ return transactionManager.activeTransactions();
}
/** Flush the journal regardless - use with great case - do not use when transactions may be active. */
- public void forceRecoverFromJournal()
- {
- JournalControl.recoverFromJournal(getBaseDataset().getConfig(), transactionManager.getJournal()) ;
+ public void forceRecoverFromJournal() {
+ JournalControl.recoverFromJournal(getBaseDataset().getConfig(), transactionManager.getJournal());
}
/** Highly risky! */
- public void printJournal()
- {
- JournalControl.print(transactionManager.getJournal()) ;
+ public void printJournal() {
+ JournalControl.print(transactionManager.getJournal());
}
private static Map<Location, StoreConnection> cache = new HashMap<>() ;
// ---- statics managing the cache.
/** Obtain a StoreConnection for a particular location */
- public static StoreConnection make(String location)
- {
- return make(Location.create(location)) ;
+ public static StoreConnection make(String location) {
+ return make(Location.create(location));
}
/** Stop managing all locations. Use with great care. */
- public static synchronized void reset()
- {
+ public static synchronized void reset() {
// Copy to avoid potential CME.
Set<Location> x = new HashSet<>(cache.keySet()) ;
for (Location loc : x)
@@ -184,14 +166,12 @@ public class StoreConnection
}
/** Stop managing a location. There should be no transactions running. */
- public static synchronized void release(Location location)
- {
- expel(location, false) ;
+ public static synchronized void release(Location location) {
+ expel(location, false);
}
/** Stop managing a location. Use with great care (testing only). */
- public static synchronized void expel(Location location, boolean force)
- {
+ public static synchronized void expel(Location location, boolean force) {
StoreConnection sConn = cache.get(location) ;
if (sConn == null) return ;
@@ -220,8 +200,7 @@ public class StoreConnection
* Return a StoreConnection for a particular connection. This is used to
* create transactions for the database at the location.
*/
- public static synchronized StoreConnection make(Location location, StoreParams params)
- {
+ public static synchronized StoreConnection make(Location location, StoreParams params) {
StoreConnection sConn = cache.get(location) ;
if (sConn != null)
return sConn ;
@@ -239,21 +218,18 @@ public class StoreConnection
* Return the StoreConnection if one already exists for this location, else
* return null
*/
- public static synchronized StoreConnection getExisting(Location location)
- {
- return cache.get(location) ;
+ public static synchronized StoreConnection getExisting(Location location) {
+ return cache.get(location);
}
- private static StoreConnection _makeAndCache(DatasetGraphTDB dsg)
- {
+ private static StoreConnection _makeAndCache(DatasetGraphTDB dsg) {
Location location = dsg.getLocation() ;
StoreConnection sConn = cache.get(location) ;
if (sConn == null)
{
sConn = new StoreConnection(dsg) ;
- if (SystemTDB.DiskLocationMultiJvmUsagePrevention)
- {
+ if ( SystemTDB.DiskLocationMultiJvmUsagePrevention ) {
// Obtain the lock ASAP
LocationLock lock = location.getLock();
if (lock.canLock()) {
@@ -271,16 +247,6 @@ public class StoreConnection
}
sConn.forceRecoverFromJournal() ;
-// boolean actionTaken = JournalControl.recoverFromJournal(dsg.getConfig(), sConn.transactionManager.getJournal()) ;
-// if ( false && actionTaken )
-// {
-// // This should be unnecessary because we wrote the journal replay
-// // via the DSG storage configuration.
-// sConn.transactionManager.closedown() ;
-// sConn.baseDSG.close() ;
-// dsg = DatasetBuilderStd.build(location) ;
-// sConn = new StoreConnection(dsg) ;
-// }
if (!location.isMemUnique())
// Don't cache use-once in-memory datasets.
@@ -293,13 +259,11 @@ public class StoreConnection
}
/**
- * Return a StoreConnection backed by in-memory datastructures (for
- * testing).
+ * Return a StoreConnection backed by in-memory
+ * datastructures (for testing).
*/
- public static StoreConnection createMemUncached()
- {
- DatasetGraphTDB dsg = DatasetBuilderStd.create(Location.mem(), null) ;
- return new StoreConnection(dsg) ;
+ public static StoreConnection createMemUncached() {
+ DatasetGraphTDB dsg = DatasetBuilderStd.create(Location.mem(), null);
+ return new StoreConnection(dsg);
}
-
}