public boolean verify ( PrintStream out ) throws RepositoryException { final StorableCodecFactory codecFactory = mStorableCodecFactory ; final String name = mName ; final boolean readOnly = mReadOnly ; final boolean runCheckpointer = mRunCheckpointer ; final boolean runDeadlockDetector = mRunDeadlockDetector ; final boolean lockConflictDeadlockDetect = mLockConflictDeadlockDetect ; final boolean isPrivate = mPrivate ; if ( mName == null ) { // Allow a dummy name for verification. mName = "BDB verification" ; } if ( mStorableCodecFactory == null ) { mStorableCodecFactory = new CompressedStorableCodecFactory ( mCompressionMap ) ; } mReadOnly = true ; mRunCheckpointer = false ; mRunDeadlockDetector = false ; mLockConflictDeadlockDetect = false ; try { assertReady ( ) ; File homeFile = getEnvironmentHomeFile ( ) ; if ( ! homeFile . exists ( ) ) { throw new RepositoryException ( "Environment home directory does not exist: " + homeFile ) ; } AtomicReference < Repository > rootRef = new AtomicReference < Repository > ( ) ; BDBRepository repo ; try { repo = getRepositoryConstructor ( ) . newInstance ( rootRef , this ) ; } catch ( Exception e ) { ThrowUnchecked . fireFirstDeclaredCause ( e , RepositoryException . class ) ; // Not reached. return false ; } rootRef . set ( repo ) ; try { return repo . verify ( out ) ; } catch ( Exception e ) { throw repo . toRepositoryException ( e ) ; } finally { repo . close ( ) ; } } finally { mName = name ; mStorableCodecFactory = codecFactory ; mReadOnly = readOnly ; mRunCheckpointer = runCheckpointer ; mRunDeadlockDetector = runDeadlockDetector ; mLockConflictDeadlockDetect = lockConflictDeadlockDetect ; } }
Opens the BDB environment checks if it is corrupt and then closes it . Only one process should open the environment for verification . Expect it to take a long time .