Search in sources :

Example 1 with JobStateSnapshot

use of com.hazelcast.jet.JobStateSnapshot 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 2 with JobStateSnapshot

use of com.hazelcast.jet.JobStateSnapshot in project hazelcast by hazelcast.

the class HazelcastCommandLine method listSnapshots.

@Command(name = "list-snapshots", description = "Lists exported snapshots on the cluster")
public void listSnapshots(@Mixin(name = "verbosity") Verbosity verbosity, @Mixin(name = "targets") TargetsMixin targets, @Option(names = { "-F", "--full-job-name" }, description = "Don't trim job name to fit, can break layout") boolean fullJobName) {
    runWithHazelcast(targets, verbosity, false, hz -> {
        Collection<JobStateSnapshot> snapshots = hz.getJet().getJobStateSnapshots();
        printf("%-23s %-15s %-24s %s", "TIME", "SIZE (bytes)", "JOB NAME", "SNAPSHOT NAME");
        snapshots.stream().sorted(Comparator.comparing(JobStateSnapshot::name)).forEach(ss -> {
            LocalDateTime creationTime = toLocalDateTime(ss.creationTime());
            String jobName = ss.jobName() == null ? Util.idToString(ss.jobId()) : ss.jobName();
            if (!fullJobName) {
                jobName = shorten(jobName);
            }
            printf("%-23s %-,15d %-24s %s", creationTime, ss.payloadSize(), jobName, ss.name());
        });
    });
}
Also used : Util.toLocalDateTime(com.hazelcast.jet.impl.util.Util.toLocalDateTime) LocalDateTime(java.time.LocalDateTime) JobStateSnapshot(com.hazelcast.jet.JobStateSnapshot) Util.idToString(com.hazelcast.jet.Util.idToString) HelpCommand(picocli.CommandLine.HelpCommand) Command(picocli.CommandLine.Command)

Example 3 with JobStateSnapshot

use of com.hazelcast.jet.JobStateSnapshot in project hazelcast by hazelcast.

the class PlanExecutor method execute.

SqlResult execute(DropSnapshotPlan plan) {
    JobStateSnapshot snapshot = hazelcastInstance.getJet().getJobStateSnapshot(plan.getSnapshotName());
    if (snapshot == null) {
        if (plan.isIfExists()) {
            return UpdateSqlResultImpl.createUpdateCountResult(0);
        }
        throw QueryException.error("The snapshot doesn't exist: " + plan.getSnapshotName());
    }
    snapshot.destroy();
    return UpdateSqlResultImpl.createUpdateCountResult(0);
}
Also used : JobStateSnapshot(com.hazelcast.jet.JobStateSnapshot)

Aggregations

JobStateSnapshot (com.hazelcast.jet.JobStateSnapshot)3 Command (picocli.CommandLine.Command)2 HelpCommand (picocli.CommandLine.HelpCommand)2 JetException (com.hazelcast.jet.JetException)1 Util.idToString (com.hazelcast.jet.Util.idToString)1 Util.toLocalDateTime (com.hazelcast.jet.impl.util.Util.toLocalDateTime)1 LocalDateTime (java.time.LocalDateTime)1