use of picocli.CommandLine.Option in project hazelcast by hazelcast.
the class HazelcastCommandLine method listJobs.
@Command(name = "list-jobs", description = "Lists running jobs on the cluster")
public void listJobs(@Mixin(name = "verbosity") Verbosity verbosity, @Mixin(name = "targets") TargetsMixin targets, @Option(names = { "-a", "--all" }, description = "Lists all jobs including completed and failed ones") boolean listAll) {
runWithHazelcast(targets, verbosity, false, hz -> {
JetClientInstanceImpl jetClientInstanceImpl = (JetClientInstanceImpl) hz.getJet();
List<JobSummary> summaries = jetClientInstanceImpl.getJobSummaryList();
String format = "%-19s %-18s %-23s %s";
printf(format, "ID", "STATUS", "SUBMISSION TIME", "NAME");
summaries.stream().filter(job -> listAll || isActive(job.getStatus())).forEach(job -> {
String idString = idToString(job.getJobId());
String name = job.getName().equals(idString) ? "N/A" : job.getName();
printf(format, idString, job.getStatus(), toLocalDateTime(job.getSubmissionTime()), name);
});
});
}
Aggregations