com.hazelcast.jet.Job.exportSnapshot()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(2.9k)|赞(0)|评价(0)|浏览(112)

本文整理了Java中com.hazelcast.jet.Job.exportSnapshot()方法的一些代码示例,展示了Job.exportSnapshot()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Job.exportSnapshot()方法的具体详情如下:
包路径:com.hazelcast.jet.Job
类名称:Job
方法名:exportSnapshot

Job.exportSnapshot介绍

[英]Exports a state snapshot and saves it under the given name. You can start a new job using the exported state using JobConfig#setInitialSnapshotName(String).

The snapshot will be independent from the job that created it. Jet won't automatically delete the IMap it is exported into. You must manually call JobStateSnapshot#destroy()to delete it. If your state is large, make sure you have enough memory to store it.

If a snapshot with the same name already exists, it will be overwritten. If a snapshot is already in progress for this job (either automatic or user-requested), the requested one will wait and start immediately after the previous one completes. If a snapshot with the same name is requested for two jobs at the same time, their data will likely be damaged (similar to two processes writing to the same file).

You can call this method on a suspended job: in that case it will export the last successful snapshot. You can also export the state of non-snapshotted jobs (those with ProcessingGuarantee#NONE).

If you issue any graceful job-control actions such as a graceful member shutdown or suspending a snapshotted job while Jet is exporting a snapshot, they will wait in a queue for this snapshot to complete. Forceful job-control actions will interrupt the export procedure.

You can access the exported state map using JetInstance#getJobStateSnapshot(String).
[中]导出状态快照并以给定名称保存。可以使用JobConfig#setInitialSnapshotName(字符串)使用导出状态启动新作业。
快照将独立于创建快照的作业。Jet不会自动删除其导出到的IMap。必须手动调用JobStateSnapshot#destroy()将其删除。如果您的状态很大,请确保您有足够的内存来存储它。
如果已存在同名的快照,则将覆盖该快照。如果此作业的快照已在进行中(自动或用户请求),则请求的快照将等待,并在前一个快照完成后立即启动。如果同时为两个作业请求具有相同名称的快照,则它们的数据可能会损坏(类似于两个进程写入同一文件)。
您可以对挂起的作业调用此方法:在这种情况下,它将导出最后一个成功的快照。您还可以导出非快照作业的状态(那些具有ProcessingGuarrance#NONE的作业)。
如果在Jet导出快照时发出任何正常作业控制操作,例如正常成员关闭或挂起快照作业,则它们将在队列中等待此快照完成。强制作业控制操作将中断导出过程。
您可以使用JetInstance#getJobStateSnapshot(字符串)访问导出的状态映射。

代码示例

代码示例来源:origin: hazelcast/hazelcast-jet

@Test
public void test_deleteSnapshot_bySnapshotName() {
  // Given
  Job job = newJob();
  assertJobStatusEventually(job, JobStatus.RUNNING);
  JobStateSnapshot snapshot = job.exportSnapshot("my-snapshot");
  // When
  run("delete-snapshot", snapshot.name());
  // Then
  JobStateSnapshot ss = jet.getJobStateSnapshot(snapshot.name());
  assertNull("Snapshot should have been deleted", ss);
}

代码示例来源:origin: hazelcast/hazelcast-jet

@Test
public void test_listSnapshots() {
  // Given
  Job job = newJob();
  assertJobStatusEventually(job, JobStatus.RUNNING);
  JobStateSnapshot snapshot = job.exportSnapshot("my-snapshot");
  // When
  run("snapshots");
  // Then
  String actual = captureOut();
  assertContains(actual, snapshot.name());
  assertContains(actual, snapshot.jobName());
}

代码示例来源:origin: hazelcast/hazelcast-jet

} else {
  printf("Saving snapshot with name '%s' from job '%s'...%n", snapshotName, formatJob(job));
  job.exportSnapshot(snapshotName);

相关文章