Search in sources :

Example 6 with DatasetGraphTxn

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

the class TDBBackup method backup.

public static void backup(Location location, OutputStream backupfile) {
    Dataset ds = TDBFactory.createDataset(location);
    StoreConnection sConn = StoreConnection.make(location);
    DatasetGraphTxn dsg = sConn.begin(ReadWrite.READ, "backup");
    RDFDataMgr.write(backupfile, dsg, Lang.NQUADS);
    dsg.end();
}
Also used : Dataset(org.apache.jena.query.Dataset) DatasetGraphTxn(org.apache.jena.tdb.transaction.DatasetGraphTxn)

Example 7 with DatasetGraphTxn

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

the class TestTransRestart method setupTxn.

private void setupTxn() {
    StoreConnection.release(location);
    FileOps.clearDirectory(path);
    StoreConnection sc = StoreConnection.make(location);
    DatasetGraphTxn dsg = sc.begin(ReadWrite.WRITE);
    dsg.add(quad1);
    dsg.commit();
    dsg.end();
    sc.flush();
    StoreConnection.release(location);
}
Also used : StoreConnection(org.apache.jena.tdb.StoreConnection) DatasetGraphTxn(org.apache.jena.tdb.transaction.DatasetGraphTxn)

Example 8 with DatasetGraphTxn

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

the class AbstractTestTransSeq method trans_01.

// Basics.
@Test
public void trans_01() {
    StoreConnection sConn = getStoreConnection();
    DatasetGraphTxn dsg = sConn.begin(ReadWrite.READ);
    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 9 with DatasetGraphTxn

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

the class AbstractTestTransSeq method trans_readBlock_01.

@Test
public void trans_readBlock_01() {
    // READ(start)-WRITE(commit)-READ(finish)-check
    StoreConnection sConn = getStoreConnection();
    DatasetGraphTxn dsgR1 = sConn.begin(ReadWrite.READ);
    DatasetGraphTxn dsgW = sConn.begin(ReadWrite.WRITE);
    dsgW.add(q);
    dsgW.commit();
    dsgW.end();
    assertFalse(dsgR1.contains(q));
    dsgR1.end();
    //**** Not hitting the queue ****
    // Order of tweaking counters?
    // also writer and counters?
    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 10 with DatasetGraphTxn

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

the class AbstractTestTransSeq method trans_readBlock_03.

@Test
public void trans_readBlock_03() {
    // READ(start)-WRITE(commit)-WRITE(commit)-READ(finish)-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);
    dsgW2.commit();
    dsgW2.end();
    assertFalse(dsgR1.contains(q1));
    assertFalse(dsgR1.contains(q2));
    dsgR1.end();
    DatasetGraphTxn dsgR2 = sConn.begin(ReadWrite.READ);
    assertTrue(dsgR2.contains(q1));
    assertTrue(dsgR2.contains(q2));
    dsgR2.end();
    sConn.flush();
    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)

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