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