Search in sources :

Example 36 with StoreConnection

use of org.apache.jena.tdb.StoreConnection in project jena by apache.

the class AbstractTestTransSeq method trans_20.

// Not a test
//@Test (expected=TDBTransactionException.class)
public void trans_20() {
    // Two WRITE : This would block.
    StoreConnection sConn = getStoreConnection();
    DatasetGraphTxn dsgW1 = sConn.begin(ReadWrite.WRITE);
    DatasetGraphTxn dsgW2 = sConn.begin(ReadWrite.WRITE);
}
Also used : StoreConnection(org.apache.jena.tdb.StoreConnection) DatasetGraphTxn(org.apache.jena.tdb.transaction.DatasetGraphTxn)

Example 37 with StoreConnection

use of org.apache.jena.tdb.StoreConnection in project jena by apache.

the class AbstractTestTransSeq method trans_02.

@Test
public void trans_02() {
    StoreConnection sConn = getStoreConnection();
    DatasetGraphTxn dsg = sConn.begin(ReadWrite.WRITE);
    try {
        dsg.add(q);
        assertTrue(dsg.contains(q));
        dsg.commit();
    } finally {
        dsg.end();
    }
}
Also used : StoreConnection(org.apache.jena.tdb.StoreConnection) DatasetGraphTxn(org.apache.jena.tdb.transaction.DatasetGraphTxn) Test(org.junit.Test) BaseTest(org.apache.jena.atlas.junit.BaseTest)

Example 38 with StoreConnection

use of org.apache.jena.tdb.StoreConnection in project jena by apache.

the class AbstractTestTransSeq method trans_06.

@Test
public void trans_06() {
    // READ(start)-READ(finish)-WRITE(start)-WRITE(commit)-check
    StoreConnection sConn = getStoreConnection();
    DatasetGraphTxn dsgR2 = sConn.begin(ReadWrite.READ);
    assertFalse(dsgR2.contains(q1));
    assertFalse(dsgR2.contains(q2));
    dsgR2.end();
    DatasetGraphTxn dsgW1 = sConn.begin(ReadWrite.WRITE);
    dsgW1.add(q1);
    dsgW1.add(q2);
    dsgW1.commit();
    dsgW1.end();
    sConn.forceRecoverFromJournal();
    DatasetGraph dsg = sConn.getBaseDataset();
    assertTrue(dsg.contains(q1));
    assertTrue(dsg.contains(q2));
}
Also used : StoreConnection(org.apache.jena.tdb.StoreConnection) DatasetGraphTxn(org.apache.jena.tdb.transaction.DatasetGraphTxn) DatasetGraph(org.apache.jena.sparql.core.DatasetGraph) Test(org.junit.Test) BaseTest(org.apache.jena.atlas.junit.BaseTest)

Example 39 with StoreConnection

use of org.apache.jena.tdb.StoreConnection in project jena by apache.

the class AbstractTestTransSeq method trans_readBlock_04.

@Test
public void trans_readBlock_04() {
    // READ(block)-WRITE(abort)-WRITE(commit)-READ(close)-check
    StoreConnection sConn = getStoreConnection();
    DatasetGraphTxn dsgR1 = sConn.begin(ReadWrite.READ);
    DatasetGraphTxn dsgW2 = sConn.begin(ReadWrite.WRITE);
    dsgW2.add(q2);
    // ABORT
    dsgW2.abort();
    dsgW2.end();
    assertFalse(dsgR1.contains(q2));
    DatasetGraphTxn dsgW3 = sConn.begin(ReadWrite.WRITE);
    dsgW3.add(q3);
    // Can see W1
    assertFalse(dsgW3.contains(q2));
    dsgW3.commit();
    dsgW3.end();
    assertFalse(dsgR1.contains(q3));
    dsgR1.end();
    sConn.flush();
    DatasetGraph dsg = sConn.getBaseDataset();
    assertFalse(dsg.contains(q2));
    assertTrue(dsg.contains(q3));
}
Also used : StoreConnection(org.apache.jena.tdb.StoreConnection) DatasetGraphTxn(org.apache.jena.tdb.transaction.DatasetGraphTxn) DatasetGraph(org.apache.jena.sparql.core.DatasetGraph) Test(org.junit.Test) BaseTest(org.apache.jena.atlas.junit.BaseTest)

Aggregations

StoreConnection (org.apache.jena.tdb.StoreConnection)39 DatasetGraphTxn (org.apache.jena.tdb.transaction.DatasetGraphTxn)32 Test (org.junit.Test)29 BaseTest (org.apache.jena.atlas.junit.BaseTest)28 DatasetGraph (org.apache.jena.sparql.core.DatasetGraph)17 ConfigTest (org.apache.jena.tdb.ConfigTest)9 Location (org.apache.jena.tdb.base.file.Location)4 DatasetGraphTDB (org.apache.jena.tdb.store.DatasetGraphTDB)3 Quad (org.apache.jena.sparql.core.Quad)2 File (java.io.File)1 FileFilter (java.io.FileFilter)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 ExecutorService (java.util.concurrent.ExecutorService)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Dataset (org.apache.jena.query.Dataset)1 Model (org.apache.jena.rdf.model.Model)1 NodeTable (org.apache.jena.tdb.store.nodetable.NodeTable)1 BeforeClass (org.junit.BeforeClass)1 ModLocation (tdb.cmdline.ModLocation)1