Search in sources :

Example 26 with DatasetGraphTxn

use of org.apache.jena.tdb.transaction.DatasetGraphTxn in project jena by apache.

the class AbstractTestTransSeq method trans_readBlock_07.

@Test
public void trans_readBlock_07() {
    // WRITE(start)-READ(start)-add-WRITE(commit)-READ sees old DSG.
    // READ before WRITE remains seeing old view - READ after WRITE starts 
    StoreConnection sConn = getStoreConnection();
    DatasetGraphTxn dsgW = sConn.begin(ReadWrite.WRITE);
    dsgW.add(q);
    DatasetGraphTxn dsgR = sConn.begin(ReadWrite.READ);
    dsgW.commit();
    dsgW.end();
    assertFalse(dsgR.contains(q));
    dsgR.end();
    DatasetGraphTxn dsgR2 = sConn.begin(ReadWrite.READ);
    assertTrue(dsgR2.contains(q));
    dsgR2.end();
    sConn.flush();
    DatasetGraph dsg = sConn.getBaseDataset();
    assertTrue(dsg.contains(q));
}
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 27 with DatasetGraphTxn

use of org.apache.jena.tdb.transaction.DatasetGraphTxn in project jena by apache.

the class AbstractTestTransSeq method trans_30.

//@Test 
public void trans_30() {
    // WRITE lots
    StoreConnection sConn = getStoreConnection();
    DatasetGraphTxn dsg = sConn.begin(ReadWrite.WRITE);
    for (int i = 0; i < 600; i++) {
        Quad q = SSE.parseQuad("(_ <s> <p> " + i + ")");
        dsg.add(q);
    }
    dsg.commit();
    dsg.end();
}
Also used : StoreConnection(org.apache.jena.tdb.StoreConnection) Quad(org.apache.jena.sparql.core.Quad) DatasetGraphTxn(org.apache.jena.tdb.transaction.DatasetGraphTxn)

Example 28 with DatasetGraphTxn

use of org.apache.jena.tdb.transaction.DatasetGraphTxn in project jena by apache.

the class AbstractTestTransSeq method trans_readBlock_05.

@Test
public void trans_readBlock_05() {
    // READ(block)-WRITE(commit)-WRITE(abort)-WRITE(commit)-READ(close)-check
    StoreConnection sConn = getStoreConnection();
    DatasetGraphTxn dsgR1 = sConn.begin(ReadWrite.READ);
    DatasetGraphTxn dsgW1 = sConn.begin(ReadWrite.WRITE);
    dsgW1.add(q1);
    dsgW1.commit();
    dsgW1.end();
    assertFalse(dsgR1.contains(q1));
    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
    assertTrue(dsgW3.contains(q1));
    assertFalse(dsgW3.contains(q2));
    dsgW3.commit();
    dsgW3.end();
    assertFalse(dsgR1.contains(q3));
    dsgR1.end();
    sConn.flush();
    DatasetGraph dsg = sConn.getBaseDataset();
    assertTrue(dsg.contains(q1));
    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)

Example 29 with DatasetGraphTxn

use of org.apache.jena.tdb.transaction.DatasetGraphTxn in project jena by apache.

the class AbstractTestTransSeq method trans_21.

@Test(expected = TDBException.class)
public void trans_21() {
    // READ-add
    StoreConnection sConn = getStoreConnection();
    DatasetGraphTxn dsg = sConn.begin(ReadWrite.READ);
    dsg.add(q);
}
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 30 with DatasetGraphTxn

use of org.apache.jena.tdb.transaction.DatasetGraphTxn 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)

Aggregations

DatasetGraphTxn (org.apache.jena.tdb.transaction.DatasetGraphTxn)33 StoreConnection (org.apache.jena.tdb.StoreConnection)32 BaseTest (org.apache.jena.atlas.junit.BaseTest)27 Test (org.junit.Test)27 DatasetGraph (org.apache.jena.sparql.core.DatasetGraph)15 ConfigTest (org.apache.jena.tdb.ConfigTest)8 Dataset (org.apache.jena.query.Dataset)2 Quad (org.apache.jena.sparql.core.Quad)2 Location (org.apache.jena.tdb.base.file.Location)2 DatasetGraphTDB (org.apache.jena.tdb.store.DatasetGraphTDB)2 CountDownLatch (java.util.concurrent.CountDownLatch)1 ExecutorService (java.util.concurrent.ExecutorService)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Model (org.apache.jena.rdf.model.Model)1 BeforeClass (org.junit.BeforeClass)1