Search in sources :

Example 11 with Command

use of picocli.CommandLine.Command in project neo4j by neo4j.

the class StoreInfoCommand method execute.

@Override
public void execute() {
    var storageEngineFactory = StorageEngineFactory.defaultStorageEngine();
    var config = CommandHelpers.buildConfig(ctx, allowCommandExpansion);
    var neo4jLayout = Neo4jLayout.of(config);
    try (var fs = ctx.fs();
        var jobScheduler = createInitialisedScheduler();
        var pageCache = StandalonePageCacheFactory.createPageCache(fs, jobScheduler, PageCacheTracer.NULL)) {
        validatePath(fs, all, path, neo4jLayout);
        if (all) {
            var collector = structured ? Collectors.joining(",", "[", "]") : Collectors.joining(System.lineSeparator() + System.lineSeparator());
            var result = Arrays.stream(fs.listFiles(path)).sorted(comparing(Path::getFileName)).map(dbPath -> neo4jLayout.databaseLayout(dbPath.getFileName().toString())).filter(dbLayout -> Validators.isExistingDatabase(fs, dbLayout)).map(dbLayout -> printInfo(fs, dbLayout, pageCache, storageEngineFactory, config, structured, true)).collect(collector);
            ctx.out().println(result);
        } else {
            var databaseLayout = neo4jLayout.databaseLayout(path.getFileName().toString());
            ctx.out().println(printInfo(fs, databaseLayout, pageCache, storageEngineFactory, config, structured, false));
        }
    } catch (CommandFailedException e) {
        throw e;
    } catch (Exception e) {
        throw new CommandFailedException(format("Failed to execute command: '%s'.", e.getMessage()), e);
    }
}
Also used : Arrays(java.util.Arrays) Parameters(picocli.CommandLine.Parameters) NullLogService(org.neo4j.logging.internal.NullLogService) CursorContext(org.neo4j.io.pagecache.context.CursorContext) Config(org.neo4j.configuration.Config) EmptyMemoryTracker(org.neo4j.memory.EmptyMemoryTracker) JobSchedulerFactory.createInitialisedScheduler(org.neo4j.kernel.impl.scheduler.JobSchedulerFactory.createInitialisedScheduler) DatabaseLayout(org.neo4j.io.layout.DatabaseLayout) PageCacheTracer(org.neo4j.io.pagecache.tracing.PageCacheTracer) Recovery.isRecoveryRequired(org.neo4j.kernel.recovery.Recovery.isRecoveryRequired) AbstractCommand(org.neo4j.cli.AbstractCommand) Comparator.comparing(java.util.Comparator.comparing) Command(picocli.CommandLine.Command) Path(java.nio.file.Path) MemoryTracker(org.neo4j.memory.MemoryTracker) PageCache(org.neo4j.io.pagecache.PageCache) Validators(org.neo4j.kernel.impl.util.Validators) StandalonePageCacheFactory(org.neo4j.io.pagecache.impl.muninn.StandalonePageCacheFactory) Collectors(java.util.stream.Collectors) Neo4jLayout(org.neo4j.io.layout.Neo4jLayout) String.format(java.lang.String.format) ExecutionContext(org.neo4j.cli.ExecutionContext) Objects(java.util.Objects) StorageEngineFactory(org.neo4j.storageengine.api.StorageEngineFactory) Option(picocli.CommandLine.Option) List(java.util.List) FileLockException(org.neo4j.kernel.internal.locker.FileLockException) CommandFailedException(org.neo4j.cli.CommandFailedException) Pair(org.neo4j.internal.helpers.collection.Pair) StoreVersion(org.neo4j.storageengine.api.StoreVersion) FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) CommandFailedException(org.neo4j.cli.CommandFailedException) FileLockException(org.neo4j.kernel.internal.locker.FileLockException) CommandFailedException(org.neo4j.cli.CommandFailedException)

Aggregations

Command (picocli.CommandLine.Command)11 HelpCommand (picocli.CommandLine.HelpCommand)9 Job (com.hazelcast.jet.Job)6 JobStateSnapshot (com.hazelcast.jet.JobStateSnapshot)3 Util.idToString (com.hazelcast.jet.Util.idToString)3 HazelcastClientInstanceImpl (com.hazelcast.client.impl.clientside.HazelcastClientInstanceImpl)2 MCClusterMetadata (com.hazelcast.client.impl.management.MCClusterMetadata)2 ClientClusterService (com.hazelcast.client.impl.spi.ClientClusterService)2 Cluster (com.hazelcast.cluster.Cluster)2 JetException (com.hazelcast.jet.JetException)2 Util.toLocalDateTime (com.hazelcast.jet.impl.util.Util.toLocalDateTime)2 LocalDateTime (java.time.LocalDateTime)2 Arrays (java.util.Arrays)2 List (java.util.List)2 Option (picocli.CommandLine.Option)2 Parameters (picocli.CommandLine.Parameters)2 HazelcastClient (com.hazelcast.client.HazelcastClient)1 ClientConfig (com.hazelcast.client.config.ClientConfig)1 XmlClientConfigBuilder (com.hazelcast.client.config.XmlClientConfigBuilder)1 YamlClientConfigBuilder (com.hazelcast.client.config.YamlClientConfigBuilder)1