public void open ( File versionDir ) { /* acquire modification lock */ fileModificationLock . writeLock ( ) . lock ( ) ; try { /* check that the store is currently closed */ if ( isOpen ) throw new IllegalStateException ( "Attempt to open already open store." ) ; // Find version directory from symbolic link or max version id if ( versionDir == null ) { versionDir = ReadOnlyUtils . getCurrentVersion ( storeDir ) ; if ( versionDir == null ) versionDir = new File ( storeDir , "version-0" ) ; } // Set the max version id long versionId = ReadOnlyUtils . getVersionId ( versionDir ) ; if ( versionId == - 1 ) { throw new VoldemortException ( "Unable to parse id from version directory " + versionDir . getAbsolutePath ( ) ) ; } Utils . mkdirs ( versionDir ) ; // Validate symbolic link, and create it if it doesn't already exist Utils . symlink ( versionDir . getAbsolutePath ( ) , storeDir . getAbsolutePath ( ) + File . separator + "latest" ) ; this . fileSet = new ChunkedFileSet ( versionDir , routingStrategy , nodeId , maxValueBufferAllocationSize ) ; storeVersionManager . syncInternalStateFromFileSystem ( false ) ; this . lastSwapped = System . currentTimeMillis ( ) ; this . isOpen = true ; } catch ( IOException e ) { logger . error ( "Error in opening store" , e ) ; } finally { fileModificationLock . writeLock ( ) . unlock ( ) ; } }
Open the store with the version directory specified . If null is specified we open the directory with the maximum version