Package com.hp.hpl.jena.tdb.base.file

Examples of com.hp.hpl.jena.tdb.base.file.Location


    // ---- statics managing the cache.
    /** Obtain a StoreConenction for a particular location */
    public static StoreConnection make(String location)
    {
        return make(new Location(location)) ;
    }
View Full Code Here


        return cache.get(location) ;
    }

    private static StoreConnection _makeAndCache(DatasetGraphTDB dsg)
    {
        Location location = dsg.getLocation() ;
        StoreConnection sConn = cache.get(location) ;
        if (sConn == null)
        {
            sConn = new StoreConnection(dsg) ;
           
            if (SystemTDB.DiskLocationMultiJvmUsagePrevention)
            {
                // Obtain the lock ASAP
                LocationLock lock = location.getLock();
                if (lock.canLock()) {
                    if (!lock.canObtain())
                        throw new TDBException("Can't open database at location " + location.getDirectoryPath() + " as it is already locked by the process with PID " + lock.getOwner() + ".  TDB databases do not permit concurrent usage across JVMs so in order to prevent possible data corruption you cannot open this location from the JVM that does not own the lock for the dataset");

                    lock.obtain();
                    // There's an interesting race condition here that two JVMs might write out the lock file one after another without
                    // colliding and causing an IO error in either.  The best way to check for this is simply to check we now own the lock
                    // and if not error
                    if (!lock.isOwned()) {
                        throw new TDBException("Can't open database at location " + location.getDirectoryPath() + " as it is alread locked by the process with PID " + lock.getOwner() + ".  TDB databases do not permit concurrent usage across JVMs so in order to prevent possible data corruption you cannot open this location from the JVM that does not own the lock for the dataset");
                    }
                }
            }
           
            sConn.forceRecoverFromJournal() ;
//            boolean actionTaken = JournalControl.recoverFromJournal(dsg.getConfig(), sConn.transactionManager.getJournal()) ;
//            if ( false && actionTaken )
//            {
//                // This should be unnecessary because we wrote the journal replay
//                // via the DSG storage configuration. 
//                sConn.transactionManager.closedown() ;
//                sConn.baseDSG.close() ;
//                dsg = DatasetBuilderStd.build(location) ;
//                sConn = new StoreConnection(dsg) ;
//            }
           
            if (!location.isMemUnique())
                // Don't cache use-once in-memory datasets.
                cache.put(location, sConn) ;
            String NS = TDB.PATH ;
            TransactionInfo txInfo = new TransactionInfo(sConn.transactionManager) ;
            ARQMgt.register(NS + ".system:type=Transactions", txInfo) ;
View Full Code Here

    public Location getLocation()
    {
        List<String> x = locations() ;
        if ( x.size() == 0 )
            return null ;
        return new Location(x.get(0)) ;
    }
View Full Code Here

    @After
    public void cleanupTest() {
        if (currDataset != null) {
            currDataset.close();
        }
        StoreConnection.expel(new Location(tempDir.getRoot().getAbsolutePath()), true);
    }
View Full Code Here

//                                            int dftKeyLength, int dftValueLength,
//                                            int readCacheSize,int writeCacheSize)
   
    public static void dumpNodeIndex(String dir)
    {
        Location location = new Location(dir) ;
        Index nodeToId = SetupTDB.makeIndex(location,  Names.indexNode2Id, SystemTDB.LenNodeHash, SystemTDB.SizeOfNodeId, -1 ,-1) ;
        for ( Record aNodeToId : nodeToId )
        {
            System.out.println( aNodeToId );
        }
View Full Code Here

    @Test public void persistent1()
    {
        String dir = ConfigTest.getTestingDir() ;
        FileOps.clearDirectory(dir) ;
       
        DatasetPrefixesTDB prefixes = DatasetPrefixesTDB.create(new Location(dir), new DatasetControlMRSW()) ;
        PrefixMapping pmap1 = prefixes.getPrefixMapping() ;
       
        String x = pmap1.getNsPrefixURI("x") ;
        assertNull(x) ;
        prefixes.close();
View Full Code Here

    @Test public void persistent2()
    {
        String dir = ConfigTest.getTestingDir() ;
        FileOps.clearDirectory(dir) ;
       
        DatasetPrefixesTDB prefixes = DatasetPrefixesTDB.create(new Location(dir), new DatasetControlMRSW()) ;
        PrefixMapping pmap1 = prefixes.getPrefixMapping() ;
       
        pmap1.setNsPrefix("x", "http://foo/") ;
        prefixes.close() ;
       
        prefixes = DatasetPrefixesTDB.create(new Location(dir), new DatasetControlMRSW()) ;
        assertEquals("http://foo/", pmap1.getNsPrefixURI("x")) ;
        prefixes.close();
    }
View Full Code Here

   
    @Before public void before()
    {  
      String dirname = ConfigTest.getCleanDir() ;
      StoreConnection.reset() ;
    graphLocation = new GraphLocation(new Location(dirname)) ;
        graphLocation.createDataset() ;
    }
View Full Code Here

    static public void run(String location)
    {
        if ( false )
        {
            Journal journal = Journal.create(new Location(location)) ;
            JournalControl.print(journal) ;
            journal.close() ;
        }
        //String location = args[0]; // + "/" + UUID.randomUUID().toString();
View Full Code Here

    private static Quad quad1 = SSE.parseQuad("(_ <foo:bar> rdfs:label 'foo')") ;
    private static Quad quad2 = SSE.parseQuad("(_ <foo:bar> rdfs:label 'bar')") ;
   
    @Before public void setup() {
        path = ConfigTest.getCleanDir() ;
        location = new Location (path) ;
        if ( useTransactionsSetup )
            setupTxn() ;
        else
            setupPlain() ;
    }
View Full Code Here

TOP

Related Classes of com.hp.hpl.jena.tdb.base.file.Location

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.