public Result hasVersion( File neostoreFile, String expectedVersion ) { Optional<String> storeVersion; try { storeVersion = getVersion( neostoreFile ); } catch ( IOException e ) { // since we cannot read let's assume the file is not there return new Result( Outcome.missingStoreFile, null, neostoreFile.getName() ); } return storeVersion .map( v -> expectedVersion.equals( v ) ? new Result( Outcome.ok, null, neostoreFile.getName() ) : new Result( Outcome.unexpectedStoreVersion, v, neostoreFile.getName() ) ) .orElseGet( () -> new Result( Outcome.storeVersionNotFound, null, neostoreFile.getName() ) ); }
@Override public void execute( String[] args ) throws IncorrectUsage, CommandFailed { final Path databaseDirectory = arguments.parse( args ).getMandatoryPath( "store" ); Validators.CONTAINS_EXISTING_DATABASE.validate( databaseDirectory.toFile() ); try ( DefaultFileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction(); JobScheduler jobScheduler = createInitialisedScheduler(); PageCache pageCache = StandalonePageCacheFactory.createPageCache( fileSystem, jobScheduler ) ) { DatabaseLayout databaseLayout = DatabaseLayout.of( databaseDirectory.toFile() ); final String storeVersion = new StoreVersionCheck( pageCache ) .getVersion( databaseLayout.metadataStore() ) .orElseThrow( () -> new CommandFailed( String.format( "Could not find version metadata in store '%s'", databaseDirectory ) ) ); final String fmt = "%-30s%s"; out.accept( String.format( fmt, "Store format version:", storeVersion ) ); RecordFormats format = RecordFormatSelector.selectForVersion( storeVersion ); out.accept( String.format( fmt, "Store format introduced in:", format.introductionVersion() ) ); findSuccessor( format ) .map( next -> String.format( fmt, "Store format superseded in:", next.introductionVersion() ) ) .ifPresent( out ); } catch ( Exception e ) { throw new CommandFailed( e.getMessage(), e ); } }
public Result hasVersion( File neostoreFile, String expectedVersion ) { Optional<String> storeVersion; try { storeVersion = getVersion( neostoreFile ); } catch ( IOException e ) { // since we cannot read let's assume the file is not there return new Result( Outcome.missingStoreFile, null, neostoreFile.getName() ); } return storeVersion .map( v -> expectedVersion.equals( v ) ? new Result( Outcome.ok, null, neostoreFile.getName() ) : new Result( Outcome.unexpectedStoreVersion, v, neostoreFile.getName() ) ) .orElseGet( () -> new Result( Outcome.storeVersionNotFound, null, neostoreFile.getName() ) ); }
@Override public void execute( String[] args ) throws IncorrectUsage, CommandFailed { final Path databaseDirectory = arguments.parse( args ).getMandatoryPath( "store" ); Validators.CONTAINS_EXISTING_DATABASE.validate( databaseDirectory.toFile() ); try ( DefaultFileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction(); JobScheduler jobScheduler = createInitialisedScheduler(); PageCache pageCache = StandalonePageCacheFactory.createPageCache( fileSystem, jobScheduler ) ) { DatabaseLayout databaseLayout = DatabaseLayout.of( databaseDirectory.toFile() ); final String storeVersion = new StoreVersionCheck( pageCache ) .getVersion( databaseLayout.metadataStore() ) .orElseThrow( () -> new CommandFailed( String.format( "Could not find version metadata in store '%s'", databaseDirectory ) ) ); final String fmt = "%-30s%s"; out.accept( String.format( fmt, "Store format version:", storeVersion ) ); RecordFormats format = RecordFormatSelector.selectForVersion( storeVersion ); out.accept( String.format( fmt, "Store format introduced in:", format.introductionVersion() ) ); findSuccessor( format ) .map( next -> String.format( fmt, "Store format superseded in:", next.introductionVersion() ) ) .ifPresent( out ); } catch ( Exception e ) { throw new CommandFailed( e.getMessage(), e ); } }