Search in sources :

Example 26 with Location

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

the class TDBInternal method expel.

/**
 * Stop managing a DatasetGraph. Use with great care.
 */
public static synchronized void expel(DatasetGraph dsg, boolean force) {
    Location locContainer = null;
    Location locStorage = null;
    if (dsg instanceof DatasetGraphSwitchable) {
        locContainer = ((DatasetGraphSwitchable) dsg).getLocation();
        dsg = ((DatasetGraphSwitchable) dsg).getWrapped();
    }
    if (dsg instanceof DatasetGraphTDB)
        locStorage = ((DatasetGraphTDB) dsg).getLocation();
    DatabaseConnection.internalExpel(locContainer, force);
    StoreConnection.internalExpel(locStorage, force);
}
Also used : DatasetGraphSwitchable(org.apache.jena.tdb2.store.DatasetGraphSwitchable) Location(org.apache.jena.dboe.base.file.Location) DatasetGraphTDB(org.apache.jena.tdb2.store.DatasetGraphTDB)

Example 27 with Location

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

the class TDBInternal method expel.

/**
 * Stop managing a DatasetGraph. Use with great care.
 */
public static synchronized void expel(DatasetGraph dsg) {
    Location locContainer = null;
    Location locStorage = null;
    if (dsg instanceof DatasetGraphSwitchable) {
        locContainer = ((DatasetGraphSwitchable) dsg).getLocation();
        dsg = ((DatasetGraphSwitchable) dsg).getWrapped();
    }
    if (dsg instanceof DatasetGraphTDB)
        locStorage = ((DatasetGraphTDB) dsg).getLocation();
    if (locContainer != null)
        DatabaseConnection.internalExpel(locContainer, false);
    StoreConnection.internalExpel(locStorage, false);
}
Also used : DatasetGraphSwitchable(org.apache.jena.tdb2.store.DatasetGraphSwitchable) Location(org.apache.jena.dboe.base.file.Location) DatasetGraphTDB(org.apache.jena.tdb2.store.DatasetGraphTDB)

Example 28 with Location

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

the class TestStoreParamsChoose method params_choose_new_persist_1.

@Test
public void params_choose_new_persist_1() {
    // new database, app defined.
    Location loc = Location.create(DIR);
    FileOps.clearAll(loc.getDirectoryPath());
    // Clear.
    StoreParams p = StoreParamsFactory.decideStoreParams(loc, true, pApp, null, pDft);
    // Check location now has a pLoc.
    String fn = loc.getPath(Names.TDB_CONFIG_FILE);
    assertTrue(FileOps.exists(fn));
    StoreParams pLoc2 = StoreParamsCodec.read(loc);
    assertTrue(StoreParams.sameValues(pLoc2, p));
}
Also used : StoreParams(org.apache.jena.tdb2.params.StoreParams) Location(org.apache.jena.dboe.base.file.Location) ConfigTest(org.apache.jena.tdb2.ConfigTest) Test(org.junit.Test)

Example 29 with Location

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

the class TestDatabaseMgr method testDatabaseMgrDisk.

@Test
public void testDatabaseMgrDisk() {
    TDBInternal.reset();
    // The named disk location
    String DIRx = ConfigTest.getCleanDir();
    Location LOC = Location.create(DIRx);
    FileOps.clearDirectory(DIRx);
    try {
        DatasetGraph dg1 = DatabaseMgr.connectDatasetGraph(LOC);
        DatasetGraph dg2 = DatabaseMgr.connectDatasetGraph(Location.create(LOC.getDirectoryPath()));
        assertSame(dg1, dg2);
        Txn.executeWrite(dg1, () -> {
            dg1.add(quad1);
        });
        Txn.executeRead(dg2, () -> {
            assertTrue(dg2.contains(quad1));
        });
    } finally {
        FileOps.clearDirectory(DIRx);
    }
}
Also used : Location(org.apache.jena.dboe.base.file.Location) DatasetGraph(org.apache.jena.sparql.core.DatasetGraph) Test(org.junit.Test)

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