From: <tho...@us...> - 2011-06-02 12:53:05
|
Revision: 4600 http://bigdata.svn.sourceforge.net/bigdata/?rev=4600&view=rev Author: thompsonbry Date: 2011-06-02 12:52:57 +0000 (Thu, 02 Jun 2011) Log Message: ----------- Working to resolve [1]. I've added versions of this test with truth maintenance enabled (for triples and sids modes). I've modified TestSids?, which runs before this test in the TestBigdataSailWithSids? test suite, to improve its finally clauses handling the open connection and the open sail. I've also checked TestTxCreate?, which runs before this test in the TestBigdataSailWithSids? and the TestBigdataSailWithQuads? test suites. There were ambiguous invocations of BigdataSailConnection#isOpen?() in two derived classes. I have modified to those to test the 'open' field instead. I've added versions of this test with truth maintenance enabled (for triples and sids modes). I've modified TestSids?, which runs before this test in the TestBigdataSailWithSids? test suite, to improve its finally clauses handling the open connection and the open sail. I've also checked TestTxCreate?, which runs before this test in the TestBigdataSailWithSids? and the TestBigdataSailWithQuads? test suites. There were ambiguous invocations of BigdataSailConnection#isOpen?() in two derived classes. I have modified to those to test the 'open' field instead. Renamed 'open' fields on BigdataSail? and BigdataSailConnection? as openSail and openConn to help identify incorrect inheritance problems. Renamed assertOpen() methods as assertOpenConn() and assertOpenSail(). Renamed assertWritable() as assertWritableConn() Modified toString() on the connection classes to show whether the connection is open. Made the anonymous BigdataSailConnection? classes into named inner classes in an attempt to prevent future ambiguity in the inheritance patterns. Note: It would be far better if BigdataSailConnection? were a static class since that would remove the opportunity entirely for incorrect inheritance patterns. TestSearchQuery - the Journal was not closing the TemporaryStoreFactory for a normal close() but only in destroyResources(). I moved that code into _close(), which is now overridden by the Journal. TestSearchQuery#test_restart() - improved nested try/finally to close connections. [1] https://sourceforge.net/apps/trac/bigdata/ticket/315 (TestRollbacksTx does not release buffers/close stores) Modified Paths: -------------- branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/journal/Journal.java branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/journal/TemporaryRawStore.java branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/journal/TemporaryStore.java branches/QUADS_QUERY_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/BigdataSail.java branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithSids.java branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithoutSids.java branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestProvenanceQuery.java branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestQuery.java branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestSearchQuery.java branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestSids.java branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/contrib/TestRollbacks.java branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/contrib/TestRollbacksTx.java branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/tck/BigdataConnectionTest.java Added Paths: ----------- branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/contrib/TestRollbacksTM.java Modified: branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/journal/Journal.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/journal/Journal.java 2011-06-02 10:46:36 UTC (rev 4599) +++ branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/journal/Journal.java 2011-06-02 12:52:57 UTC (rev 4600) @@ -41,7 +41,6 @@ import java.util.concurrent.Semaphore; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; import org.apache.log4j.Logger; @@ -1188,16 +1187,32 @@ } - public void deleteResources() { - - super.deleteResources(); - +// public void deleteResources() { +// +// super.deleteResources(); +// +// // Note: can be null if error in ctor. +// if (tempStoreFactory != null) +// tempStoreFactory.closeAll(); +// +// } + + /** + * {@inheritDoc} + * <p> + * Overridden to close the {@link TemporaryStoreFactory}. + */ + @Override + protected void _close() { + + super._close(); + // Note: can be null if error in ctor. if (tempStoreFactory != null) tempStoreFactory.closeAll(); } - + public <T> Future<T> submit(AbstractTask<T> task) { return concurrencyManager.submit(task); Modified: branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/journal/TemporaryRawStore.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/journal/TemporaryRawStore.java 2011-06-02 10:46:36 UTC (rev 4599) +++ branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/journal/TemporaryRawStore.java 2011-06-02 12:52:57 UTC (rev 4600) @@ -62,10 +62,8 @@ */ public class TemporaryRawStore extends AbstractRawWormStore implements IMRMW { - protected static final Logger log = Logger.getLogger(TemporaryRawStore.class); + private static final Logger log = Logger.getLogger(TemporaryRawStore.class); -// protected static final boolean INFO = log.isInfoEnabled(); - /** * Note: various things must be synchronized on {@link #buf} in order to * serialize reads, writes, etc. This is because it is {@link #buf} on which Modified: branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/journal/TemporaryStore.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/journal/TemporaryStore.java 2011-06-02 10:46:36 UTC (rev 4599) +++ branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/journal/TemporaryStore.java 2011-06-02 12:52:57 UTC (rev 4600) @@ -34,6 +34,8 @@ import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; +import org.apache.log4j.Logger; + import com.bigdata.bfs.BigdataFileSystem; import com.bigdata.bfs.GlobalFileSystemHelper; import com.bigdata.btree.BTree; @@ -64,6 +66,8 @@ */ public class TemporaryStore extends TemporaryRawStore implements IBTreeManager { + private static final Logger log = Logger.getLogger(TemporaryStore.class); + /** * The size of the live index cache for the {@link Name2Addr} instance. * Modified: branches/QUADS_QUERY_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/BigdataSail.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/BigdataSail.java 2011-06-02 10:46:36 UTC (rev 4599) +++ branches/QUADS_QUERY_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/BigdataSail.java 2011-06-02 12:52:57 UTC (rev 4600) @@ -545,7 +545,7 @@ * <code>true</code> iff the {@link BigdataSail} has been * {@link #initialize()}d and not {@link #shutDown()}. */ - private boolean open; + private boolean openSail; /** * Set <code>true</code> by ctor variants that open/create the database @@ -1066,9 +1066,9 @@ * if the {@link BigdataSail} has not been {@link #initialize()}d * or has been {@link #shutDown()}. */ - protected void assertOpen() { + protected void assertOpenSail() { - if (!open) + if (!openSail) throw new IllegalStateException(); } @@ -1079,7 +1079,7 @@ */ public boolean isOpen() { - return open; + return openSail; } @@ -1090,7 +1090,7 @@ @Override protected void initializeInternal() throws SailException { - if (open) + if (openSail) throw new IllegalStateException(); /* @@ -1103,7 +1103,7 @@ } - open = true; + openSail = true; } @@ -1127,7 +1127,7 @@ public void shutDown() throws SailException { - assertOpen(); + assertOpenSail(); /* * Note: DO NOT shutdown the query engine. It is shared by all @@ -1146,7 +1146,7 @@ */ protected void shutDownInternal() throws SailException { - if (open) { + if (openSail) { try { @@ -1161,7 +1161,7 @@ } finally { - open = false; + openSail = false; } @@ -1368,102 +1368,24 @@ } } - + /** - * Return a read-only connection backed by a read-only transaction. The + * Return a read-only connection backed by a read-only transaction. The * transaction will be closed when the connection is closed. - * @param timestamp The timestamp. + * + * @param timestamp + * The timestamp. + * * @return The transaction. + * * @throws IOException * @see ITransactionService#newTx(long) */ - private BigdataSailConnection _getReadOnlyConnection(final long timestamp) throws IOException { - - final String namespace = database.getNamespace(); + private BigdataSailConnection _getReadOnlyConnection(final long timestamp) + throws IOException { - final IIndexManager indexManager = database.getIndexManager(); + return new BigdataSailReadOnlyConnection(timestamp); - final ITransactionService txService = getTxService(); - - return new BigdataSailConnection(null/*lock*/,false/*unisolated*/) { - - /** - * The transaction id. - */ - private long tx; - - /** - * Constructor starts a new transaction. - */ - { - newTx(); - } - - /** - * Obtain a new read-only transaction from the journal's - * transaction service, and attach this SAIL connection to the new - * view of the database. - */ - protected void newTx() throws IOException { - - this.tx = txService.newTx(timestamp); - - final AbstractTripleStore txView = (AbstractTripleStore) indexManager - .getResourceLocator().locate(namespace, tx); - - attach(txView); - - } - - /** - * NOP - */ - @Override - public synchronized void commit() throws SailException { - - // NOP. - - } - - /** - * NOP - */ - @Override - public synchronized void rollback() throws SailException { - - // NOP - - } - - /** - * A specialized close that will also abort the current read-only - * transaction. - */ - @Override - public synchronized void close() throws SailException { - - if (!isOpen()) { - - return; - - } - - super.close(); - - try { - - txService.abort(tx); - - } catch(IOException ex) { - - throw new SailException(ex); - - } - - } - - }; - } /** @@ -1491,149 +1413,10 @@ } - final ITransactionService txService = getTxService(); - - final String namespace = database.getNamespace(); - final Lock readLock = lock.readLock(); readLock.lock(); - - return new BigdataSailConnection(readLock,false/*unisolated*/) { - - /** - * The transaction id. - */ - private long tx; - /** - * Constructor starts a new transaction. - */ - { - newTx(); - } - - /** - * Obtain a new read/write transaction from the journal's - * transaction service, and attach this SAIL connection to the new - * view of the database. - */ - protected void newTx() throws IOException { - - this.tx = txService.newTx(ITx.UNISOLATED); - - final AbstractTripleStore txView = (AbstractTripleStore) indexManager - .getResourceLocator().locate(namespace, tx); - - attach(txView); - - } - - /** - * A specialized commit that goes through the transaction service - * available on the journal's transaction manager. Once the commit - * happens, a new read/write transaction is automatically started - * so that this connection can continue to absorb writes. - * <p> - * Note: writes to the lexicon without dirtying the isolated indices - * (i.e. writes to the SPO relation) will cause the writes to the - * lexicon to never be committed. Probably not a significant issue. - */ - @Override - public synchronized void commit() throws SailException { - - /* - * don't double commit, but make a note that writes to the lexicon without - * dirtying the isolated indices will cause the writes to the lexicon to never - * be committed - */ - - assertWritable(); - - /* - * Flush any pending writes. - * - * Note: This must be done before you compute the closure so that the - * pending writes will be read by the inference engine when it computes - * the closure. - */ - - flushStatementBuffers(true/* assertions */, true/* retractions */); - - try { - - txService.commit(tx); - - newTx(); - - } catch(IOException ex) { - - throw new SailException(ex); - - } - - } - - /** - * A specialized rollback that goes through the transaction service - * available on the journal's transaction manager. Once the abort - * happens, a new read/write transaction is automatically started - * so that this connection can continue to absorb writes. - */ - @Override - public synchronized void rollback() throws SailException { - - /* - * Note: DO NOT invoke super.rollback(). That will cause a - * database (Journal) level abort(). The Journal level abort() - * will discard the writes buffered on the unisolated indices - * (the lexicon indices). That will cause lost updates and break - * the eventually consistent design for the TERM2ID and ID2TERM - * indices. - */ -// super.rollback(); - - try { - - txService.abort(tx); - - newTx(); - - } catch(IOException ex) { - - throw new SailException(ex); - - } - - } - - /** - * A specialized close that will also abort the current read/write - * transaction. - */ - @Override - public synchronized void close() throws SailException { - - if (!isOpen()) { - - return; - - } - - super.close(); - - try { - - txService.abort(tx); - - } catch(IOException ex) { - - throw new SailException(ex); - - } - - } - - }; + return new BigdataSailRWTxConnection(readLock); } @@ -1691,7 +1474,7 @@ /** * True iff the {@link SailConnection} is open. */ - private boolean open; + protected boolean openConn; /** * non-<code>null</code> iff truth maintenance is being performed. @@ -1749,9 +1532,10 @@ public String toString() { - return getClass().getName() + "{timestamp=" - + TimestampUtility.toString(database.getTimestamp()) + "}"; - + return getClass().getName() + "{timestamp=" + + TimestampUtility.toString(database.getTimestamp()) + + ",open=" + openConn + "}"; + } public BigdataSail getBigdataSail() { @@ -1900,15 +1684,15 @@ * * @param database */ - public synchronized void attach(final AbstractTripleStore database) { + protected synchronized void attach(final AbstractTripleStore database) { - BigdataSail.this.assertOpen(); + BigdataSail.this.assertOpenSail(); this.database = database; readOnly = database.isReadOnly(); - open = true; + openConn = true; assertBuffer = null; @@ -2159,7 +1943,7 @@ public void setNamespace(final String prefix, final String namespace) throws SailException { - assertWritable(); + assertWritableConn(); // database.addNamespace(namespace,prefix); namespaces.put(prefix, namespace); @@ -2318,7 +2102,7 @@ } - assertWritable(); + assertWritableConn(); // flush any pending retractions first! flushStatementBuffers(false/* flushAssertBuffer */, true/* flushRetractBuffer */); @@ -2352,7 +2136,7 @@ if (log.isInfoEnabled()) log.info("contexts=" + Arrays.toString(contexts)); - assertWritable(); + assertWritableConn(); // discard any pending writes. clearBuffers(); @@ -2615,7 +2399,7 @@ private synchronized int removeStatements(final Resource s, final URI p, final Value o, final Resource c) throws SailException { - assertWritable(); + assertWritableConn(); flushStatementBuffers(true/* flushAssertBuffer */, false/* flushRetractBuffer */); @@ -2875,7 +2659,7 @@ */ public synchronized void rollback() throws SailException { - assertWritable(); + assertWritableConn(); // discard buffered assertions and/or retractions. clearBuffers(); @@ -2899,7 +2683,7 @@ */ public synchronized void commit() throws SailException { - assertWritable(); + assertWritableConn(); /* * Flush any pending writes. @@ -2938,7 +2722,7 @@ final public boolean isOpen() throws SailException { - return open; + return openConn; } @@ -2959,7 +2743,7 @@ // assertOpen(); - if (!open) { + if (!openConn) { return; @@ -3002,7 +2786,7 @@ ((Journal) getDatabase().getIndexManager()) .releaseUnisolatedConnection(); } - open = false; + openConn = false; } } @@ -3101,9 +2885,9 @@ } - protected void assertOpen() throws SailException { + protected void assertOpenConn() throws SailException { - if(!open) { + if(!openConn) { throw new SailException("Closed"); @@ -3111,9 +2895,9 @@ } - protected void assertWritable() throws SailException { + protected void assertWritableConn() throws SailException { - assertOpen(); + assertOpenConn(); if (readOnly) { @@ -3342,7 +3126,7 @@ */ public synchronized void computeClosure() throws SailException { - assertWritable(); + assertWritableConn(); flushStatementBuffers(true/* assertions */, true/* retractions */); @@ -3357,7 +3141,7 @@ */ public synchronized void removeAllEntailments() throws SailException { - assertWritable(); + assertWritableConn(); flushStatementBuffers(true/* assertions */, true/* retractions */); @@ -3423,7 +3207,7 @@ * native joins and the BigdataEvaluationStatistics rely on * this. */ - Object[] newVals = replaceValues(dataset, tupleExpr, bindings); + final Object[] newVals = replaceValues(dataset, tupleExpr, bindings); dataset = (Dataset) newVals[0]; bindings = (BindingSet) newVals[1]; @@ -3455,9 +3239,10 @@ if (log.isInfoEnabled()) log.info("Optimized query: " + tupleExpr); - final Object[] newVals2 = replaceValues(dataset, tupleExpr, bindings); - dataset = (Dataset) newVals2[0]; - bindings = (BindingSet) newVals2[1]; + replaceValues(dataset, tupleExpr, bindings); +// final Object[] newVals2 = replaceValues(dataset, tupleExpr, bindings); +// dataset = (Dataset) newVals2[0]; +// bindings = (BindingSet) newVals2[1]; return tupleExpr; @@ -3543,7 +3328,7 @@ log.info("Optimized query: " + tupleExpr); final Object[] newVals2 = replaceValues(dataset, tupleExpr, bindings); - dataset = (Dataset) newVals2[0]; +// dataset = (Dataset) newVals2[0]; bindings = (BindingSet) newVals2[1]; // Note: evaluation begins with an empty binding set NOT the @@ -3610,6 +3395,302 @@ private IChangeLog changeLog; - } + } // class BigdataSailConnection + /** + * A connection backed by a read/write transaction. + */ + private class BigdataSailRWTxConnection extends BigdataSailConnection { + + /** + * The transaction service. + */ + private final ITransactionService txService; + + /** + * The transaction id. + */ + private long tx; + + /** + * Constructor starts a new transaction. + */ + public BigdataSailRWTxConnection(final Lock readLock) + throws IOException { + + super(readLock, false/* unisolated */); + + txService = getTxService(); + + newTx(); + + } + + /** + * Obtain a new read/write transaction from the journal's + * transaction service, and attach this SAIL connection to the new + * view of the database. + */ + protected void newTx() throws IOException { + + // The view of the database *outside* of this connection. + final AbstractTripleStore database = BigdataSail.this.database; + + // The namespace of the triple store. + final String namespace = database.getNamespace(); + + // Open a new read/write transaction. + this.tx = txService.newTx(ITx.UNISOLATED); + + try { + + /* + * Locate a view of the triple store isolated by that + * transaction. + */ + final AbstractTripleStore txView = (AbstractTripleStore) database + .getIndexManager().getResourceLocator().locate( + namespace, tx); + + // Attach that transaction view to this SailConnection. + attach(txView); + + } catch (Throwable t) { + + try { + txService.abort(tx); + } catch (IOException ex) { + log.error(ex, ex); + } + + throw new RuntimeException(t); + + } + + } + + /** + * A specialized commit that goes through the transaction service + * available on the journal's transaction manager. Once the commit + * happens, a new read/write transaction is automatically started + * so that this connection can continue to absorb writes. + * <p> + * Note: writes to the lexicon without dirtying the isolated indices + * (i.e. writes to the SPO relation) will cause the writes to the + * lexicon to never be committed. Probably not a significant issue. + */ + @Override + public synchronized void commit() throws SailException { + + /* + * don't double commit, but make a note that writes to the lexicon + * without dirtying the isolated indices will cause the writes to + * the lexicon to never be committed + */ + + assertWritableConn(); + + /* + * Flush any pending writes. + * + * Note: This must be done before you compute the closure so that + * the pending writes will be read by the inference engine when it + * computes the closure. + */ + + flushStatementBuffers(true/* assertions */, true/* retractions */); + + try { + + txService.commit(tx); + + newTx(); + + } catch(IOException ex) { + + throw new SailException(ex); + + } + + } + + /** + * A specialized rollback that goes through the transaction service + * available on the journal's transaction manager. Once the abort + * happens, a new read/write transaction is automatically started + * so that this connection can continue to absorb writes. + */ + @Override + public synchronized void rollback() throws SailException { + + /* + * Note: DO NOT invoke super.rollback(). That will cause a + * database (Journal) level abort(). The Journal level abort() + * will discard the writes buffered on the unisolated indices + * (the lexicon indices). That will cause lost updates and break + * the eventually consistent design for the TERM2ID and ID2TERM + * indices. + */ +// super.rollback(); + + try { + + txService.abort(tx); + + newTx(); + + } catch(IOException ex) { + + throw new SailException(ex); + + } + + } + + /** + * A specialized close that will also abort the current read/write + * transaction. + */ + @Override + public synchronized void close() throws SailException { + + if (!openConn) { + + return; + + } + + super.close(); + + try { + + txService.abort(tx); + + } catch(IOException ex) { + + throw new SailException(ex); + + } + + } + + } // class BigdataSailReadWriteTxConnection + + private class BigdataSailReadOnlyConnection extends BigdataSailConnection { + + /** + * The transaction service. + */ + private final ITransactionService txService; + + /** + * The transaction id. + */ + private long tx; + + /** + * Constructor starts a new transaction. + */ + BigdataSailReadOnlyConnection(final long timestamp) throws IOException { + + super(null/* lock */, false/* unisolated */); + + txService = getTxService(); + + newTx(timestamp); + + } + + /** + * Obtain a new read-only transaction from the journal's transaction + * service, and attach this SAIL connection to the new view of the + * database. + */ + protected void newTx(final long timestamp) throws IOException { + + // The view of the database *outside* of this connection. + final AbstractTripleStore database = BigdataSail.this.database; + + // The namespace of the triple store. + final String namespace = database.getNamespace(); + + // Obtain a new read-only transaction reading from that timestamp. + this.tx = txService.newTx(timestamp); + + try { + + /* + * Locate a view of the triple store isolated by that + * transaction. + */ + final AbstractTripleStore txView = (AbstractTripleStore) database + .getIndexManager().getResourceLocator().locate( + namespace, tx); + + // Attach that transaction view to this SailConnection. + attach(txView); + + } catch (Throwable t) { + + try { + txService.abort(tx); + } catch (IOException ex) { + log.error(ex, ex); + } + + throw new RuntimeException(t); + + } + + } + + /** + * NOP + */ + @Override + public synchronized void commit() throws SailException { + + // NOP. + + } + + /** + * NOP + */ + @Override + public synchronized void rollback() throws SailException { + + // NOP + + } + + /** + * A specialized close that will also abort the current read-only + * transaction. + */ + @Override + public synchronized void close() throws SailException { + + if (!openConn) { + + return; + + } + + super.close(); + + try { + + txService.abort(tx); + + } catch(IOException ex) { + + throw new SailException(ex); + + } + + } + + } // class BigdataSailReadOnlyConnection + } Modified: branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithSids.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithSids.java 2011-06-02 10:46:36 UTC (rev 4599) +++ branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithSids.java 2011-06-02 12:52:57 UTC (rev 4600) @@ -94,6 +94,7 @@ suite.addTestSuite(com.bigdata.rdf.sail.contrib.TestRollbacks.class); suite.addTestSuite(com.bigdata.rdf.sail.contrib.TestRollbacksTx.class); + suite.addTestSuite(com.bigdata.rdf.sail.contrib.TestRollbacksTM.class); return suite; Modified: branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithoutSids.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithoutSids.java 2011-06-02 10:46:36 UTC (rev 4599) +++ branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithoutSids.java 2011-06-02 12:52:57 UTC (rev 4600) @@ -88,6 +88,7 @@ suite.addTestSuite(com.bigdata.rdf.sail.contrib.TestRollbacks.class); suite.addTestSuite(com.bigdata.rdf.sail.contrib.TestRollbacksTx.class); + suite.addTestSuite(com.bigdata.rdf.sail.contrib.TestRollbacksTM.class); return suite; Modified: branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestProvenanceQuery.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestProvenanceQuery.java 2011-06-02 10:46:36 UTC (rev 4599) +++ branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestProvenanceQuery.java 2011-06-02 12:52:57 UTC (rev 4600) @@ -85,10 +85,10 @@ final BigdataSail sail = getSail(); - sail.initialize(); - try { + sail.initialize(); + if (!((BigdataSail) sail).database.getStatementIdentifiers()) { log.warn("Statement identifiers are not enabled"); @@ -234,7 +234,8 @@ final BindingSet solution = itr.next(); - System.out.println("solution[" + i + "] : " + solution); + if (log.isInfoEnabled()) + log.info("solution[" + i + "] : " + solution); final Value actual = solution.getValue("Y"); Modified: branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestQuery.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestQuery.java 2011-06-02 10:46:36 UTC (rev 4599) +++ branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestQuery.java 2011-06-02 12:52:57 UTC (rev 4600) @@ -27,19 +27,19 @@ package com.bigdata.rdf.sail; import info.aduna.iteration.CloseableIteration; + import java.io.File; import java.io.FilenameFilter; import java.io.IOException; import java.util.HashSet; import java.util.Set; + import org.openrdf.model.URI; import org.openrdf.model.Value; import org.openrdf.model.impl.URIImpl; import org.openrdf.model.vocabulary.RDF; import org.openrdf.query.BindingSet; import org.openrdf.query.QueryEvaluationException; -import org.openrdf.query.QueryLanguage; -import org.openrdf.query.TupleQuery; import org.openrdf.query.algebra.Join; import org.openrdf.query.algebra.Projection; import org.openrdf.query.algebra.ProjectionElem; @@ -52,6 +52,7 @@ import org.openrdf.repository.RepositoryConnection; import org.openrdf.rio.RDFFormat; import org.openrdf.sail.SailException; + import com.bigdata.rdf.sail.BigdataSail.BigdataSailConnection; import com.bigdata.rdf.store.DataLoader; @@ -77,11 +78,6 @@ } /** - * The namespace used when the LUBM data set was generated. - */ - final String ub = "http://www.lehigh.edu/~zhp2/2004/0401/univ-bench.owl#"; - - /** * Load the data set (LUBM with 1 university). * * @throws IOException @@ -121,9 +117,10 @@ } - log.info("Loading " + n + " files from " + dir); + if(log.isInfoEnabled()) + log.info("Loading " + n + " files from " + dir); - DataLoader dataLoader = sail.database.getDataLoader(); + final DataLoader dataLoader = sail.database.getDataLoader(); dataLoader.loadData(resource, baseURL, rdfFormat); @@ -161,14 +158,21 @@ final BigdataSail sail = getSail(); - sail.initialize(); - try { + sail.initialize(); + loadData(sail); final BigdataSailConnection conn = sail.getConnection(); + try { + + /** + * The namespace used when the LUBM data set was generated. + */ + final String ub = "http://www.lehigh.edu/~zhp2/2004/0401/univ-bench.owl#"; + final URI graduateStudent = new URIImpl(ub+"GraduateStudent"); final URI takesCourse = new URIImpl(ub+"takesCourse"); @@ -275,16 +279,18 @@ while (itr.hasNext()) { - BindingSet solution = itr.next(); + final BindingSet solution = itr.next(); - System.out.println("solution["+i+"] : "+solution); - + if (log.isInfoEnabled()) + log.info("solution[" + i + "] : " + solution); + final Value actual = solution.getValue("X"); final boolean found = expected.remove(actual); - assertTrue("Not expecting X=" + actual, found); - + if (!found) + fail("Not expecting X=" + actual); + i++; } @@ -301,11 +307,14 @@ finally { - conn.close(); - cxn.close(); } + } finally { + + conn.close(); + + } } finally { Modified: branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestSearchQuery.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestSearchQuery.java 2011-06-02 10:46:36 UTC (rev 4599) +++ branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestSearchQuery.java 2011-06-02 12:52:57 UTC (rev 4600) @@ -186,7 +186,8 @@ */ { - StatementBuffer sb = new StatementBuffer(sail.database, 100/* capacity */); + final StatementBuffer<Statement> sb = new StatementBuffer<Statement>( + sail.database, 100/* capacity */); sb.add(new URIImpl("http://www.bigdata.com/A"), RDFS.LABEL, new LiteralImpl("Yellow Rose")); @@ -376,10 +377,12 @@ " }"; // the ontology (nothing is indexed for full text search). - final Graph test_restart_1 = new GraphImpl(); { + final Graph test_restart_1 = new GraphImpl(); + { - test_restart_1.add(new StatementImpl(ORGANIZATION, RDFS.SUBCLASSOF, ENTITY)); - + test_restart_1.add(new StatementImpl(ORGANIZATION, RDFS.SUBCLASSOF, + ENTITY)); + } // the entity data (the rdfs:label gets indexed for full text search) @@ -422,8 +425,8 @@ { // load ontology and optionally the entity data. final RepositoryConnection cxn = repo.getConnection(); - cxn.setAutoCommit(false); try { + cxn.setAutoCommit(false); log.info("loading ontology"); cxn.add(test_restart_1); if (!doYouWantMeToBreak) { @@ -443,8 +446,8 @@ if (doYouWantMeToBreak) { // load the entity data. final RepositoryConnection cxn = repo.getConnection(); - cxn.setAutoCommit(false); try { + cxn.setAutoCommit(false); log.info("loading entity data"); cxn.add(test_restart_2); cxn.commit(); @@ -540,9 +543,9 @@ final BigdataSailRepository repo = new BigdataSailRepository(sail); final BigdataSailRepositoryConnection cxn = (BigdataSailRepositoryConnection) repo.getConnection(); - cxn.setAutoCommit(false); - try { + + cxn.setAutoCommit(false); final BNode a = new BNodeImpl("_:a"); final BNode b = new BNodeImpl("_:b"); @@ -702,12 +705,13 @@ final BigdataSailRepository repo = new BigdataSailRepository(sail); final BigdataSailRepositoryConnection cxn = (BigdataSailRepositoryConnection) repo.getConnection(); - cxn.setAutoCommit(false); try { - final ValueFactory vf = sail.getValueFactory(); + cxn.setAutoCommit(false); + final ValueFactory vf = sail.getValueFactory(); + final URI s1 = vf.createURI(BD.NAMESPACE+"s1"); final URI s2 = vf.createURI(BD.NAMESPACE+"s2"); final URI s3 = vf.createURI(BD.NAMESPACE+"s3"); @@ -1006,7 +1010,7 @@ result = tupleQuery.evaluate(); - Collection<BindingSet> answer = new LinkedList<BindingSet>(); + final Collection<BindingSet> answer = new LinkedList<BindingSet>(); final ITextIndexer search = sail.getDatabase().getLexiconRelation().getSearchEngine(); @@ -1226,7 +1230,7 @@ result = tupleQuery.evaluate(); - Collection<BindingSet> answer = new LinkedList<BindingSet>(); + final Collection<BindingSet> answer = new LinkedList<BindingSet>(); final ITextIndexer search = sail.getDatabase().getLexiconRelation().getSearchEngine(); Modified: branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestSids.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestSids.java 2011-06-02 10:46:36 UTC (rev 4599) +++ branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestSids.java 2011-06-02 12:52:57 UTC (rev 4600) @@ -95,13 +95,17 @@ public void testSids() throws Exception { final BigdataSail sail = getSail(); - sail.initialize(); - final BigdataSailRepository repo = new BigdataSailRepository(sail); - final BigdataSailRepositoryConnection cxn = - (BigdataSailRepositoryConnection) repo.getConnection(); - cxn.setAutoCommit(false); try { + + sail.initialize(); + final BigdataSailRepository repo = new BigdataSailRepository(sail); + final BigdataSailRepositoryConnection cxn = + (BigdataSailRepositoryConnection) repo.getConnection(); + + try { + + cxn.setAutoCommit(false); cxn.add(getClass().getResourceAsStream("sids.rdf"), "", RDFFormat.RDFXML); @@ -176,8 +180,11 @@ } + } finally { + cxn.close(); + } + } finally { - cxn.close(); sail.__tearDownUnitTest(); } @@ -186,15 +193,19 @@ public void testSids2() throws Exception { final BigdataSail sail = getSail(); - sail.initialize(); - final BigdataSailRepository repo = new BigdataSailRepository(sail); - final BigdataSailRepositoryConnection cxn = - (BigdataSailRepositoryConnection) repo.getConnection(); - cxn.setAutoCommit(false); try { - final ValueFactory vf = sail.getValueFactory(); + sail.initialize(); + final BigdataSailRepository repo = new BigdataSailRepository(sail); + final BigdataSailRepositoryConnection cxn = + (BigdataSailRepositoryConnection) repo.getConnection(); + + try { + + cxn.setAutoCommit(false); + + final ValueFactory vf = sail.getValueFactory(); final URI host1 = vf.createURI("http://localhost/host1"); final URI host = vf.createURI("http://domainnamespace.com/host#Host"); @@ -314,9 +325,13 @@ } } + + } finally { + + cxn.close(); + } } finally { - cxn.close(); sail.__tearDownUnitTest(); } Modified: branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/contrib/TestRollbacks.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/contrib/TestRollbacks.java 2011-06-02 10:46:36 UTC (rev 4599) +++ branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/contrib/TestRollbacks.java 2011-06-02 12:52:57 UTC (rev 4600) @@ -245,9 +245,9 @@ RepositoryConnection conn = null; try { int counter2 = 0; - conn = repo.getConnection(); - conn.setAutoCommit(false); - while (firstCause.get() == null&&counter<maxCounter) { + conn = repo.getConnection(); + conn.setAutoCommit(false); + while (firstCause.get() == null && counter < maxCounter) { if (writer) writer(conn); else Added: branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/contrib/TestRollbacksTM.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/contrib/TestRollbacksTM.java (rev 0) +++ branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/contrib/TestRollbacksTM.java 2011-06-02 12:52:57 UTC (rev 4600) @@ -0,0 +1,66 @@ +/** +Copyright (C) SYSTAP, LLC 2011. All rights reserved. + +Contact: + SYSTAP, LLC + 4501 Tower Road + Greensboro, NC 27410 + lic...@bi... + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; version 2 of the License. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ +package com.bigdata.rdf.sail.contrib; + +import java.util.Properties; + +import com.bigdata.rdf.axioms.NoAxioms; +import com.bigdata.rdf.axioms.RdfsAxioms; +import com.bigdata.rdf.sail.BigdataSail; +import com.bigdata.rdf.vocab.NoVocabulary; +import com.bigdata.rdf.vocab.RDFSVocabulary; + +/** + * Concrete instance of {@link TestRollbacks} which overrides the properties to + * enable truth maintenance support in the SAIL. + * + * @author <a href="mailto:tho...@us...">Bryan Thompson</a> + * @version $Id$ + */ +public class TestRollbacksTM extends TestRollbacks { + + public TestRollbacksTM() { + super(); + } + + public TestRollbacksTM(String name) { + super(name); + } + + @Override + public Properties getProperties() { + + final Properties props = super.getProperties(); + + props.setProperty(BigdataSail.Options.AXIOMS_CLASS, + RdfsAxioms.class.getName()); + props.setProperty(BigdataSail.Options.VOCABULARY_CLASS, + RDFSVocabulary.class.getName()); + props.setProperty(BigdataSail.Options.TRUTH_MAINTENANCE, "true"); + props.setProperty(BigdataSail.Options.JUSTIFY, "true"); + + return props; + + } + +} Property changes on: branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/contrib/TestRollbacksTM.java ___________________________________________________________________ Added: svn:keywords + Id Date Revision Author HeadURL Modified: branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/contrib/TestRollbacksTx.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/contrib/TestRollbacksTx.java 2011-06-02 10:46:36 UTC (rev 4599) +++ branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/contrib/TestRollbacksTx.java 2011-06-02 12:52:57 UTC (rev 4600) @@ -1,3 +1,25 @@ +/** +Copyright (C) SYSTAP, LLC 2011. All rights reserved. + +Contact: + SYSTAP, LLC + 4501 Tower Road + Greensboro, NC 27410 + lic...@bi... + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; version 2 of the License. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ package com.bigdata.rdf.sail.contrib; import java.util.Properties; @@ -4,6 +26,13 @@ import com.bigdata.rdf.sail.BigdataSail; +/** + * Concrete instance of {@link TestRollbacks} which overrides the properties to + * enable full transaction support in the SAIL. + * + * @author <a href="mailto:tho...@us...">Bryan Thompson</a> + * @version $Id$ + */ public class TestRollbacksTx extends TestRollbacks { public TestRollbacksTx() { Modified: branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/tck/BigdataConnectionTest.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/tck/BigdataConnectionTest.java 2011-06-02 10:46:36 UTC (rev 4599) +++ branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/tck/BigdataConnectionTest.java 2011-06-02 12:52:57 UTC (rev 4600) @@ -168,14 +168,32 @@ : ((BigdataSailRepository) testRepository).getDatabase() .getIndexManager(); + /* + * Note: The code in the block below was taken verbatim from + * super.testDown() in order to explore a tear down issue in testOpen(). + */ super.tearDown(); +// { +// +// testCon2.close(); +// testCon2 = null; +// +// testCon.close(); +// testCon = null; +// +// testRepository.shutDown(); +// testRepository = null; +// +// vf = null; +// +// } if (backend != null) backend.destroy(); } - /** + /** * This test has been overridden because Sesame assumes "read-committed" * transaction semantics while bidata uses snapshot isolation for its * transactions. @@ -249,5 +267,18 @@ assertFalse(testCon2.hasStatement(bob, name, nameBob, false)); // Yes. This is snapshot isolation semantics. } - + +// /** +// * Copied into the local test suite unchanged in order to debug with this +// * test. +// */ +// @Override +// public void testOpen() throws Exception { +// assertTrue(testCon.isOpen()); +// assertTrue(testCon2.isOpen()); +// testCon.close(); +// assertFalse(testCon.isOpen()); +// assertTrue(testCon2.isOpen()); +// } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |