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);
}
}
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.");
});
}
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);
});
}
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()));
});
}
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.");
});
}
Aggregations