Search in sources :

Example 1 with Option

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);
        });
    });
}
Also used : JobSummary(com.hazelcast.jet.impl.JobSummary) Arrays(java.util.Arrays) BuildInfoProvider.getBuildInfo(com.hazelcast.instance.BuildInfoProvider.getBuildInfo) Parameters(picocli.CommandLine.Parameters) Member(com.hazelcast.cluster.Member) LogManager(java.util.logging.LogManager) ITypeConverter(picocli.CommandLine.ITypeConverter) JetClientInstanceImpl(com.hazelcast.jet.impl.JetClientInstanceImpl) HazelcastVersionProvider(com.hazelcast.client.console.HazelcastCommandLine.HazelcastVersionProvider) ClientInvocation(com.hazelcast.client.impl.spi.impl.ClientInvocation) JobStatus(com.hazelcast.jet.core.JobStatus) CommandLine(picocli.CommandLine) XmlClientConfigBuilder(com.hazelcast.client.config.XmlClientConfigBuilder) MCClusterMetadata(com.hazelcast.client.impl.management.MCClusterMetadata) YamlClientConfigBuilder(com.hazelcast.client.config.YamlClientConfigBuilder) Collections.emptyList(java.util.Collections.emptyList) Mixin(picocli.CommandLine.Mixin) Collection(java.util.Collection) ExecutionException(picocli.CommandLine.ExecutionException) ConsumerEx(com.hazelcast.function.ConsumerEx) ClientClusterService(com.hazelcast.client.impl.spi.ClientClusterService) InvocationTargetException(java.lang.reflect.InvocationTargetException) LockSupport(java.util.concurrent.locks.LockSupport) Option(picocli.CommandLine.Option) List(java.util.List) Util.idToString(com.hazelcast.jet.Util.idToString) JobStateSnapshot(com.hazelcast.jet.JobStateSnapshot) Util.toLocalDateTime(com.hazelcast.jet.impl.util.Util.toLocalDateTime) Util.uncheckCall(com.hazelcast.jet.impl.util.Util.uncheckCall) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings) RunAll(picocli.CommandLine.RunAll) JobSummary(com.hazelcast.jet.impl.JobSummary) HazelcastClientInstanceImpl(com.hazelcast.client.impl.clientside.HazelcastClientInstanceImpl) FutureUtil(com.hazelcast.internal.util.FutureUtil) HelpCommand(picocli.CommandLine.HelpCommand) HazelcastClient(com.hazelcast.client.HazelcastClient) LocalDateTime(java.time.LocalDateTime) CompletableFuture(java.util.concurrent.CompletableFuture) MCGetClusterMetadataCodec(com.hazelcast.client.impl.protocol.codec.MCGetClusterMetadataCodec) Function(java.util.function.Function) Level(java.util.logging.Level) JetException(com.hazelcast.jet.JetException) HazelcastBootstrap(com.hazelcast.instance.impl.HazelcastBootstrap) DefaultExceptionHandler(picocli.CommandLine.DefaultExceptionHandler) ClientConfig(com.hazelcast.client.config.ClientConfig) BuildInfo(com.hazelcast.instance.BuildInfo) ParseResult(picocli.CommandLine.ParseResult) Command(picocli.CommandLine.Command) Job(com.hazelcast.jet.Job) JobNotFoundException(com.hazelcast.jet.core.JobNotFoundException) PrintStream(java.io.PrintStream) HazelcastInstance(com.hazelcast.core.HazelcastInstance) Cluster(com.hazelcast.cluster.Cluster) Ansi(picocli.CommandLine.Help.Ansi) IOException(java.io.IOException) Preconditions.checkNotNull(com.hazelcast.internal.util.Preconditions.checkNotNull) File(java.io.File) TimeUnit(java.util.concurrent.TimeUnit) ClientDelegatingFuture(com.hazelcast.client.impl.ClientDelegatingFuture) ClusterState(com.hazelcast.cluster.ClusterState) HazelcastClientProxy(com.hazelcast.client.impl.clientside.HazelcastClientProxy) IVersionProvider(picocli.CommandLine.IVersionProvider) Comparator(java.util.Comparator) Collections(java.util.Collections) Util(com.hazelcast.jet.Util) SECONDS(java.util.concurrent.TimeUnit.SECONDS) JetClientInstanceImpl(com.hazelcast.jet.impl.JetClientInstanceImpl) Util.idToString(com.hazelcast.jet.Util.idToString) HelpCommand(picocli.CommandLine.HelpCommand) Command(picocli.CommandLine.Command)

Aggregations

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 HazelcastVersionProvider (com.hazelcast.client.console.HazelcastCommandLine.HazelcastVersionProvider)1 ClientDelegatingFuture (com.hazelcast.client.impl.ClientDelegatingFuture)1 HazelcastClientInstanceImpl (com.hazelcast.client.impl.clientside.HazelcastClientInstanceImpl)1 HazelcastClientProxy (com.hazelcast.client.impl.clientside.HazelcastClientProxy)1 MCClusterMetadata (com.hazelcast.client.impl.management.MCClusterMetadata)1 MCGetClusterMetadataCodec (com.hazelcast.client.impl.protocol.codec.MCGetClusterMetadataCodec)1 ClientClusterService (com.hazelcast.client.impl.spi.ClientClusterService)1 ClientInvocation (com.hazelcast.client.impl.spi.impl.ClientInvocation)1 Cluster (com.hazelcast.cluster.Cluster)1 ClusterState (com.hazelcast.cluster.ClusterState)1 Member (com.hazelcast.cluster.Member)1 HazelcastInstance (com.hazelcast.core.HazelcastInstance)1 ConsumerEx (com.hazelcast.function.ConsumerEx)1 BuildInfo (com.hazelcast.instance.BuildInfo)1 BuildInfoProvider.getBuildInfo (com.hazelcast.instance.BuildInfoProvider.getBuildInfo)1 HazelcastBootstrap (com.hazelcast.instance.impl.HazelcastBootstrap)1