Search in sources :

Example 1 with Command

use of picocli.CommandLine.Command in project syndesis by syndesisio.

the class SyndesisCommandLine method configure.

@Override
public void configure(final CommandLine commandLine) {
    for (final Class<?> command : COMMANDS) {
        final Object cmd;
        try {
            cmd = command.getDeclaredConstructor().newInstance();
        } catch (final ReflectiveOperationException e) {
            throw new IllegalStateException("Unable to instantiate", e);
        }
        final Command annotation = command.getAnnotation(Command.class);
        commandLine.addSubcommand(annotation.name(), cmd);
    }
}
Also used : Command(picocli.CommandLine.Command) MigrateCommand(io.syndesis.server.cli.command.migrate.MigrateCommand)

Example 2 with Command

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

the class HazelcastCommandLine method restart.

@Command(description = "Restarts a running job")
public void restart(@Mixin(name = "verbosity") Verbosity verbosity, @Mixin(name = "targets") TargetsMixin targets, @Parameters(index = "0", paramLabel = "<job name or id>", description = "Name of the job to restart") String name) {
    runWithHazelcast(targets, verbosity, false, hz -> {
        Job job = getJob(hz, name);
        assertJobRunning(name, job);
        println("Restarting job " + formatJob(job) + "...");
        job.restart();
        waitForJobStatus(job, JobStatus.RUNNING);
        println("Job restarted.");
    });
}
Also used : Job(com.hazelcast.jet.Job) HelpCommand(picocli.CommandLine.HelpCommand) Command(picocli.CommandLine.Command)

Example 3 with Command

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

the class HazelcastCommandLine method deleteSnapshot.

@Command(name = "delete-snapshot", description = "Deletes a named snapshot")
public void deleteSnapshot(@Mixin(name = "verbosity") Verbosity verbosity, @Mixin(name = "targets") TargetsMixin targets, @Parameters(index = "0", paramLabel = "<snapshot name>", description = "Name of the snapshot") String snapshotName) {
    runWithHazelcast(targets, verbosity, false, hz -> {
        JobStateSnapshot jobStateSnapshot = hz.getJet().getJobStateSnapshot(snapshotName);
        if (jobStateSnapshot == null) {
            throw new JetException(String.format("Didn't find a snapshot named '%s'", snapshotName));
        }
        jobStateSnapshot.destroy();
        printf("Deleted snapshot '%s'.", snapshotName);
    });
}
Also used : JobStateSnapshot(com.hazelcast.jet.JobStateSnapshot) JetException(com.hazelcast.jet.JetException) HelpCommand(picocli.CommandLine.HelpCommand) Command(picocli.CommandLine.Command)

Example 4 with Command

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

the class HazelcastCommandLine method cluster.

@Command(description = "Shows current cluster state and information about members")
public void cluster(@Mixin(name = "verbosity") Verbosity verbosity, @Mixin(name = "targets") TargetsMixin targets) {
    runWithHazelcast(targets, verbosity, false, hz -> {
        HazelcastClientInstanceImpl hazelcastClientImpl = getHazelcastClientInstanceImpl(hz);
        ClientClusterService clientClusterService = hazelcastClientImpl.getClientClusterService();
        MCClusterMetadata clusterMetadata = FutureUtil.getValue(getClusterMetadata(hazelcastClientImpl, clientClusterService.getMasterMember()));
        Cluster cluster = hazelcastClientImpl.getCluster();
        println("State: " + clusterMetadata.getCurrentState());
        println("Version: " + clusterMetadata.getMemberVersion());
        println("Size: " + cluster.getMembers().size());
        println("");
        String format = "%-24s %-19s";
        printf(format, "ADDRESS", "UUID");
        cluster.getMembers().forEach(member -> printf(format, member.getAddress(), member.getUuid()));
    });
}
Also used : HazelcastClientInstanceImpl(com.hazelcast.client.impl.clientside.HazelcastClientInstanceImpl) Cluster(com.hazelcast.cluster.Cluster) Util.idToString(com.hazelcast.jet.Util.idToString) ClientClusterService(com.hazelcast.client.impl.spi.ClientClusterService) MCClusterMetadata(com.hazelcast.client.impl.management.MCClusterMetadata) HelpCommand(picocli.CommandLine.HelpCommand) Command(picocli.CommandLine.Command)

Example 5 with Command

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

the class HazelcastCommandLine method suspend.

@Command(description = "Suspends a running job")
public void suspend(@Mixin(name = "verbosity") Verbosity verbosity, @Mixin(name = "targets") TargetsMixin targets, @Parameters(index = "0", paramLabel = "<job name or id>", description = "Name of the job to suspend") String name) {
    runWithHazelcast(targets, verbosity, false, hz -> {
        Job job = getJob(hz, name);
        assertJobRunning(name, job);
        printf("Suspending job %s...", formatJob(job));
        job.suspend();
        waitForJobStatus(job, JobStatus.SUSPENDED);
        println("Job suspended.");
    });
}
Also used : Job(com.hazelcast.jet.Job) HelpCommand(picocli.CommandLine.HelpCommand) Command(picocli.CommandLine.Command)

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