Search in sources :

Example 91 with DatasetGraph

use of org.apache.jena.sparql.core.DatasetGraph in project jena by apache.

the class AbstractTestTransSeq method trans_04.

@Test
public void trans_04() {
    // WRITE-abort-READ-check
    StoreConnection sConn = getStoreConnection();
    DatasetGraphTxn dsgW = sConn.begin(ReadWrite.WRITE);
    dsgW.add(q);
    assertTrue(dsgW.contains(q));
    dsgW.abort();
    dsgW.end();
    DatasetGraphTxn dsg2 = sConn.begin(ReadWrite.READ);
    assertFalse(dsg2.contains(q));
    dsg2.end();
    sConn.flush();
    DatasetGraph dsg = sConn.getBaseDataset();
    assertFalse(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 92 with DatasetGraph

use of org.apache.jena.sparql.core.DatasetGraph in project jena by apache.

the class AbstractTestTransSeq method trans_readBlock_06.

@Test
public void trans_readBlock_06() {
    // WRITE(start)-READ(start)-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);
    DatasetGraphTxn dsgR = sConn.begin(ReadWrite.READ);
    dsgW.add(q);
    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 93 with DatasetGraph

use of org.apache.jena.sparql.core.DatasetGraph in project jena by apache.

the class TestTDBInternal method exclusive_5.

@Test
public void exclusive_5() {
    DatasetGraph dsg = TDBFactory.createDatasetGraph();
    TransactionManager txnmgr = TDBInternal.getTransactionManager(dsg);
    ReentrantReadWriteLock rwx = (ReentrantReadWriteLock) txnmgr.getExclusivityLock$();
    dsg.begin(ReadWrite.READ);
    boolean b = txnmgr.tryExclusiveMode();
    Assert.assertFalse(b);
}
Also used : ReentrantReadWriteLock(java.util.concurrent.locks.ReentrantReadWriteLock) DatasetGraph(org.apache.jena.sparql.core.DatasetGraph) Test(org.junit.Test)

Example 94 with DatasetGraph

use of org.apache.jena.sparql.core.DatasetGraph in project jena by apache.

the class TestTDBInternal method exclusive_4.

@Test
public void exclusive_4() {
    DatasetGraph dsg = TDBFactory.createDatasetGraph();
    TransactionManager txnmgr = TDBInternal.getTransactionManager(dsg);
    ReentrantReadWriteLock rwx = (ReentrantReadWriteLock) txnmgr.getExclusivityLock$();
    checkLock(rwx, 0, 0);
    boolean b = txnmgr.tryExclusiveMode();
    Assert.assertTrue("Exclusive 1", b);
    checkLock(rwx, 0, 1);
    txnmgr.finishExclusiveMode();
    checkLock(rwx, 0, 0);
    b = txnmgr.tryExclusiveMode();
    Assert.assertTrue("Exclusive 2", b);
}
Also used : ReentrantReadWriteLock(java.util.concurrent.locks.ReentrantReadWriteLock) DatasetGraph(org.apache.jena.sparql.core.DatasetGraph) Test(org.junit.Test)

Example 95 with DatasetGraph

use of org.apache.jena.sparql.core.DatasetGraph in project jena by apache.

the class TestTDBInternal method basics_2.

@Test
public void basics_2() {
    DatasetGraph dsg = TDBFactory.createDatasetGraph();
    TransactionManager txnmgr = TDBInternal.getTransactionManager(dsg);
    Assert.assertNotNull(txnmgr);
}
Also used : DatasetGraph(org.apache.jena.sparql.core.DatasetGraph) Test(org.junit.Test)

Aggregations

DatasetGraph (org.apache.jena.sparql.core.DatasetGraph)222 Test (org.junit.Test)132 BaseTest (org.apache.jena.atlas.junit.BaseTest)59 Quad (org.apache.jena.sparql.core.Quad)47 Node (org.apache.jena.graph.Node)29 Graph (org.apache.jena.graph.Graph)18 StoreConnection (org.apache.jena.tdb.StoreConnection)17 DatasetGraphTxn (org.apache.jena.tdb.transaction.DatasetGraphTxn)15 Model (org.apache.jena.rdf.model.Model)10 IOException (java.io.IOException)7 Triple (org.apache.jena.graph.Triple)7 Dataset (org.apache.jena.query.Dataset)7 StreamRDF (org.apache.jena.riot.system.StreamRDF)7 ReentrantReadWriteLock (java.util.concurrent.locks.ReentrantReadWriteLock)5 ResultSet (org.apache.jena.query.ResultSet)5 JsonLDWriteContext (org.apache.jena.riot.JsonLDWriteContext)5 Element (org.apache.jena.sparql.syntax.Element)5 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 RiotException (org.apache.jena.riot.RiotException)4 QueryIterator (org.apache.jena.sparql.engine.QueryIterator)4