Search in sources :

Example 1 with Location

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

the class TestTDBFactory method testTDBFresh23.

@Test
public void testTDBFresh23() {
    Location loc = Location.mem("FOO");
    boolean b = TDBFactory.inUseLocation(loc);
    TDBFactory.createDataset(loc);
    b = TDBFactory.inUseLocation(loc);
    assertTrue("Expected true for a named memory location", b);
}
Also used : Location(org.apache.jena.tdb.base.file.Location) BaseTest(org.apache.jena.atlas.junit.BaseTest) Test(org.junit.Test)

Example 2 with Location

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

the class TestTDBFactory method testTDBFresh22.

@Test
public void testTDBFresh22() {
    Location loc = Location.mem();
    boolean b = TDBFactory.inUseLocation(loc);
    TDBFactory.createDataset(loc);
    b = TDBFactory.inUseLocation(loc);
    assertFalse("Expected false for a unique memory location", b);
}
Also used : Location(org.apache.jena.tdb.base.file.Location) BaseTest(org.apache.jena.atlas.junit.BaseTest) Test(org.junit.Test)

Example 3 with Location

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

the class JournalControl method findJournal.

private static Journal findJournal(DatasetGraphTDB dsg) {
    Location loc = dsg.getLocation();
    String journalFilename = loc.absolute(Names.journalFile);
    File f = new File(journalFilename);
    if (f.exists() && f.isFile() && f.length() > 0)
        return Journal.create(loc);
    else
        return null;
}
Also used : BufferChannelFile(org.apache.jena.tdb.base.file.BufferChannelFile) File(java.io.File) ObjectFile(org.apache.jena.tdb.base.objectfile.ObjectFile) Location(org.apache.jena.tdb.base.file.Location)

Example 4 with Location

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

the class DebugTDB method dumpNodeIndex.

//    public static RangeIndex makeRangeIndex(Location location, String indexName, 
//                                            int dftKeyLength, int dftValueLength,
//                                            int readCacheSize,int writeCacheSize)
public static void dumpNodeIndex(String dir) {
    Location location = Location.create(dir);
    Index nodeToId = SetupTDB.makeIndex(location, Names.indexNode2Id, SystemTDB.BlockSize, SystemTDB.LenNodeHash, SystemTDB.SizeOfNodeId, -1, -1);
    for (Record aNodeToId : nodeToId) {
        System.out.println(aNodeToId);
    }
}
Also used : Index(org.apache.jena.tdb.index.Index) TupleIndex(org.apache.jena.tdb.store.tupletable.TupleIndex) RangeIndex(org.apache.jena.tdb.index.RangeIndex) Record(org.apache.jena.tdb.base.record.Record) TupleIndexRecord(org.apache.jena.tdb.store.tupletable.TupleIndexRecord) Location(org.apache.jena.tdb.base.file.Location)

Example 5 with Location

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

the class TestLocationLock method location_lock_dir_02.

@Test
public void location_lock_dir_02() throws IOException {
    Assume.assumeTrue(negativePidsTreatedAsAlive);
    Location dir = Location.create(tempDir.getRoot().getAbsolutePath());
    LocationLock lock = dir.getLock();
    Assert.assertTrue(lock.canLock());
    Assert.assertFalse(lock.isLocked());
    Assert.assertFalse(lock.isOwned());
    Assert.assertTrue(lock.canObtain());
    // Write a fake PID to the lock file
    try (BufferedWriter writer = new BufferedWriter(new FileWriter(dir.getPath("tdb.lock")))) {
        // Fake PID that would never be valid
        writer.write(Integer.toString(-1234));
    }
    Assert.assertTrue(lock.isLocked());
    Assert.assertFalse(lock.isOwned());
    Assert.assertFalse(lock.canObtain());
}
Also used : FileWriter(java.io.FileWriter) LocationLock(org.apache.jena.tdb.base.file.LocationLock) Location(org.apache.jena.tdb.base.file.Location) BufferedWriter(java.io.BufferedWriter) Test(org.junit.Test)

Aggregations

Location (org.apache.jena.tdb.base.file.Location)29 Test (org.junit.Test)16 BaseTest (org.apache.jena.atlas.junit.BaseTest)9 LocationLock (org.apache.jena.tdb.base.file.LocationLock)8 ConfigTest (org.apache.jena.tdb.ConfigTest)6 BufferedWriter (java.io.BufferedWriter)4 FileWriter (java.io.FileWriter)4 DatasetGraph (org.apache.jena.sparql.core.DatasetGraph)4 StoreConnection (org.apache.jena.tdb.StoreConnection)4 TupleIndex (org.apache.jena.tdb.store.tupletable.TupleIndex)4 Record (org.apache.jena.tdb.base.record.Record)3 StoreParams (org.apache.jena.tdb.setup.StoreParams)3 AssemblerException (org.apache.jena.assembler.exceptions.AssemblerException)2 Tuple (org.apache.jena.atlas.lib.tuple.Tuple)2 Dataset (org.apache.jena.query.Dataset)2 VocabTDB.pLocation (org.apache.jena.tdb.assembler.VocabTDB.pLocation)2 RecordFactory (org.apache.jena.tdb.base.record.RecordFactory)2 RangeIndex (org.apache.jena.tdb.index.RangeIndex)2 BPlusTree (org.apache.jena.tdb.index.bplustree.BPlusTree)2 ColumnMap (org.apache.jena.tdb.lib.ColumnMap)2