Search in sources :

Example 1 with Version

use of org.neo4j.kernel.internal.Version in project neo4j by neo4j.

the class VersionCommand method execute.

@Override
public void execute(String[] args) throws IncorrectUsage, CommandFailed {
    final Path storeDir = arguments.parseMandatoryPath("store", args);
    Validators.CONTAINS_EXISTING_DATABASE.validate(storeDir.toFile());
    try (DefaultFileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction();
        PageCache pageCache = StandalonePageCacheFactory.createPageCache(fileSystem)) {
        final String storeVersion = new StoreVersionCheck(pageCache).getVersion(storeDir.resolve(MetaDataStore.DEFAULT_NAME).toFile()).orElseThrow(() -> new CommandFailed(String.format("Could not find version metadata in store '%s'", storeDir)));
        final String fmt = "%-25s%s";
        out.accept(String.format(fmt, "Store format version:", storeVersion));
        RecordFormats format = RecordFormatSelector.selectForVersion(storeVersion);
        out.accept(String.format(fmt, "Introduced in version:", format.introductionVersion()));
        findSuccessor(format).map(next -> String.format(fmt, "Superseded in version:", next.introductionVersion())).ifPresent(out);
        out.accept(String.format(fmt, "Current version:", Version.getNeo4jVersion()));
    } catch (IOException e) {
        throw new CommandFailed(e.getMessage(), e);
    }
}
Also used : MandatoryCanonicalPath(org.neo4j.commandline.arguments.common.MandatoryCanonicalPath) Path(java.nio.file.Path) PageCache(org.neo4j.io.pagecache.PageCache) Validators(org.neo4j.kernel.impl.util.Validators) StandalonePageCacheFactory(org.neo4j.io.pagecache.impl.muninn.StandalonePageCacheFactory) Version(org.neo4j.kernel.internal.Version) IOException(java.io.IOException) RecordFormatSelector(org.neo4j.kernel.impl.store.format.RecordFormatSelector) StoreVersionCheck(org.neo4j.kernel.impl.storemigration.StoreVersionCheck) AdminCommand(org.neo4j.commandline.admin.AdminCommand) RecordFormats(org.neo4j.kernel.impl.store.format.RecordFormats) Consumer(java.util.function.Consumer) MandatoryCanonicalPath(org.neo4j.commandline.arguments.common.MandatoryCanonicalPath) DefaultFileSystemAbstraction(org.neo4j.io.fs.DefaultFileSystemAbstraction) Arguments(org.neo4j.commandline.arguments.Arguments) OutsideWorld(org.neo4j.commandline.admin.OutsideWorld) RecordFormatSelector.findSuccessor(org.neo4j.kernel.impl.store.format.RecordFormatSelector.findSuccessor) MetaDataStore(org.neo4j.kernel.impl.store.MetaDataStore) CommandFailed(org.neo4j.commandline.admin.CommandFailed) IncorrectUsage(org.neo4j.commandline.admin.IncorrectUsage) Path(java.nio.file.Path) StoreVersionCheck(org.neo4j.kernel.impl.storemigration.StoreVersionCheck) DefaultFileSystemAbstraction(org.neo4j.io.fs.DefaultFileSystemAbstraction) RecordFormats(org.neo4j.kernel.impl.store.format.RecordFormats) CommandFailed(org.neo4j.commandline.admin.CommandFailed) IOException(java.io.IOException) PageCache(org.neo4j.io.pagecache.PageCache)

Aggregations

IOException (java.io.IOException)1 Path (java.nio.file.Path)1 Consumer (java.util.function.Consumer)1 AdminCommand (org.neo4j.commandline.admin.AdminCommand)1 CommandFailed (org.neo4j.commandline.admin.CommandFailed)1 IncorrectUsage (org.neo4j.commandline.admin.IncorrectUsage)1 OutsideWorld (org.neo4j.commandline.admin.OutsideWorld)1 Arguments (org.neo4j.commandline.arguments.Arguments)1 MandatoryCanonicalPath (org.neo4j.commandline.arguments.common.MandatoryCanonicalPath)1 DefaultFileSystemAbstraction (org.neo4j.io.fs.DefaultFileSystemAbstraction)1 PageCache (org.neo4j.io.pagecache.PageCache)1 StandalonePageCacheFactory (org.neo4j.io.pagecache.impl.muninn.StandalonePageCacheFactory)1 MetaDataStore (org.neo4j.kernel.impl.store.MetaDataStore)1 RecordFormatSelector (org.neo4j.kernel.impl.store.format.RecordFormatSelector)1 RecordFormatSelector.findSuccessor (org.neo4j.kernel.impl.store.format.RecordFormatSelector.findSuccessor)1 RecordFormats (org.neo4j.kernel.impl.store.format.RecordFormats)1 StoreVersionCheck (org.neo4j.kernel.impl.storemigration.StoreVersionCheck)1 Validators (org.neo4j.kernel.impl.util.Validators)1 Version (org.neo4j.kernel.internal.Version)1