Search in sources :

Example 16 with Location

use of org.apache.jena.dboe.base.file.Location in project jena by apache.

the class TestStoreConnectionLock method lock_store_connection_01.

@Test
public void lock_store_connection_01() {
    Location dir = Location.create(tempDir.getRoot().getAbsolutePath());
    ProcessFileLock lock = StoreConnection.lockForLocation(dir);
    assertFalse(lock.isLockedHere());
    StoreConnection sConn = StoreConnection.connectCreate(dir);
    assertEquals(dir, sConn.getLocation());
    assertEquals(lock, sConn.getLock());
    assertTrue(lock.isLockedHere());
    StoreConnection.release(dir);
    assertFalse(lock.isLockedHere());
}
Also used : StoreConnection(org.apache.jena.tdb2.sys.StoreConnection) ProcessFileLock(org.apache.jena.dboe.base.file.ProcessFileLock) Location(org.apache.jena.dboe.base.file.Location) Test(org.junit.Test)

Example 17 with Location

use of org.apache.jena.dboe.base.file.Location in project jena by apache.

the class TestStoreConnectionLock method lock_store_connection_02.

@Test(expected = AlreadyLocked.class)
public void lock_store_connection_02() {
    Location dir = Location.create(tempDir.getRoot().getAbsolutePath());
    ProcessFileLock lock = StoreConnection.lockForLocation(dir);
    lock.lockEx();
    StoreConnection sConn = StoreConnection.connectCreate(dir);
}
Also used : StoreConnection(org.apache.jena.tdb2.sys.StoreConnection) ProcessFileLock(org.apache.jena.dboe.base.file.ProcessFileLock) Location(org.apache.jena.dboe.base.file.Location) Test(org.junit.Test)

Example 18 with Location

use of org.apache.jena.dboe.base.file.Location in project jena by apache.

the class TL method createTestDataset.

private static Dataset createTestDataset() {
    Location location = cleanLocation();
    Dataset dataset = TDB2Factory.connectDataset(location);
    return dataset;
}
Also used : Dataset(org.apache.jena.query.Dataset) Location(org.apache.jena.dboe.base.file.Location)

Example 19 with Location

use of org.apache.jena.dboe.base.file.Location in project jena by apache.

the class TL method cleanLocation.

// Or use these for @Before, @After style.
public static Location cleanLocation() {
    // To avoid the problems on MS Windows where memory mapped files
    // can't be deleted from a running JVM, we use a different, cleaned
    // directory each time.
    String dirname = ConfigTest.getCleanDir();
    Location location = Location.create(dirname);
    return location;
}
Also used : Location(org.apache.jena.dboe.base.file.Location)

Example 20 with Location

use of org.apache.jena.dboe.base.file.Location in project jena by apache.

the class TestDatabaseOps method compact_dsg_1.

@Test
public void compact_dsg_1() {
    DatasetGraph dsg = DatabaseMgr.connectDatasetGraph(dir);
    DatasetGraphSwitchable dsgs = (DatasetGraphSwitchable) dsg;
    DatasetGraph dsg1 = dsgs.get();
    Location loc1 = ((DatasetGraphTDB) dsg1).getLocation();
    Txn.executeWrite(dsg, () -> {
        dsg.add(quad2);
        dsg.add(quad1);
    });
    DatabaseMgr.compact(dsg, false);
    assertFalse(StoreConnection.isSetup(loc1));
    DatasetGraph dsg2 = dsgs.get();
    Location loc2 = ((DatasetGraphTDB) dsg2).getLocation();
    assertNotEquals(dsg1, dsg2);
    assertNotEquals(loc1, loc2);
    Txn.executeRead(dsg, () -> {
        assertTrue(dsg.contains(quad2));
        assertTrue(dsg.contains(quad1));
    });
    // dsg1 was closed and expelled. We must carefully reopen its storage only.
    DatasetGraph dsgOld = StoreConnection.connectCreate(loc1).getDatasetGraph();
    Txn.executeWrite(dsgOld, () -> dsgOld.delete(quad2));
    Txn.executeRead(dsg, () -> assertTrue(dsg.contains(quad2)));
    Txn.executeRead(dsg2, () -> assertTrue(dsg2.contains(quad2)));
}
Also used : DatasetGraphSwitchable(org.apache.jena.tdb2.store.DatasetGraphSwitchable) DatasetGraph(org.apache.jena.sparql.core.DatasetGraph) Location(org.apache.jena.dboe.base.file.Location) DatasetGraphTDB(org.apache.jena.tdb2.store.DatasetGraphTDB) Test(org.junit.Test) ConfigTest(org.apache.jena.tdb2.ConfigTest)

Aggregations

Location (org.apache.jena.dboe.base.file.Location)29 Test (org.junit.Test)12 DatasetGraph (org.apache.jena.sparql.core.DatasetGraph)10 DatasetGraphTDB (org.apache.jena.tdb2.store.DatasetGraphTDB)10 ConfigTest (org.apache.jena.tdb2.ConfigTest)7 DatasetGraphSwitchable (org.apache.jena.tdb2.store.DatasetGraphSwitchable)7 StoreParams (org.apache.jena.tdb2.params.StoreParams)4 Dataset (org.apache.jena.query.Dataset)3 TDBException (org.apache.jena.tdb2.TDBException)3 Path (java.nio.file.Path)2 AssemblerException (org.apache.jena.assembler.exceptions.AssemblerException)2 ProcessFileLock (org.apache.jena.dboe.base.file.ProcessFileLock)2 Graph (org.apache.jena.graph.Graph)2 StoreConnection (org.apache.jena.tdb2.sys.StoreConnection)2 RuntimeIOException (org.apache.jena.atlas.RuntimeIOException)1 Timer (org.apache.jena.atlas.lib.Timer)1 TupleMap (org.apache.jena.atlas.lib.tuple.TupleMap)1 CmdException (org.apache.jena.cmd.CmdException)1 BlockMgr (org.apache.jena.dboe.base.block.BlockMgr)1 BufferChannel (org.apache.jena.dboe.base.file.BufferChannel)1