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

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

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

Job.suspend介绍

[英]Gracefully suspends the current execution of the job. The job's status will become JobStatus#SUSPENDED. To resume the job, call #resume().

You can suspend a job even if it's not configured for JobConfig#setProcessingGuarantee. Such a job will resume with empty state, as if it has just been started.

This call just initiates the suspension process and doesn't wait for it to complete. Suspension starts with creating a terminal state snapshot. Should the terminal snapshot fail, the job will suspend anyway, but the previous snapshot (if there was one) won't be deleted. When the job resumes, its processing starts from the point of the last snapshot.

NOTE: if the cluster becomes unstable (a member leaves or similar) while the job is in the process of being suspended, it may end up getting immediately restarted. Call #getStatus() to find out and possibly try to suspend again.
[中]优雅地暂停作业的当前执行。该作业的状态将变为JobStatus#SUSPENDED。要恢复作业,请调用#resume()。
即使未为JobConfig#SetProcessingGuarrance配置作业,也可以挂起作业。这样的作业将以空状态继续,就好像它刚刚启动一样。
此调用只是启动暂停过程,而不是等待它完成。暂停从创建终端状态快照开始。如果终端快照失败,作业仍将挂起,但不会删除以前的快照(如果有)。当作业恢复时,其处理从最后一个快照开始。
注意:如果集群在作业挂起过程中变得不稳定(成员离开或类似),它可能会立即重新启动。调用#getStatus()查找并可能再次尝试挂起。

代码示例

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

job.suspend();
waitForStatus(job, JobStatus.SUSPENDED);

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

@Command(
    description = "Suspends a running job",
    mixinStandardHelpOptions = true
)
public void suspend(
    @Parameters(index = "0",
        paramLabel = "<job name or id>",
        description = "Name of the job to suspend"
    ) String name
) throws IOException {
  runWithJet(jet -> {
    Job job = getJob(jet, name);
    assertJobRunning(name, job);
    printf("Suspending job %s...%n", formatJob(job));
    job.suspend();
    waitForJobStatus(job, JobStatus.SUSPENDED);
    println("Job was successfully suspended.");
  });
}

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

@Test
public void test_resumeJob_byJobId() {
  // Given
  Job job = newJob();
  assertJobStatusEventually(job, JobStatus.RUNNING);
  job.suspend();
  // When
  run("resume", job.getIdString());
  // Then
  assertJobStatusEventually(job, JobStatus.RUNNING);
}

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

@Test
public void test_resumeJob_byJobName() {
  // Given
  Job job = newJob();
  assertJobStatusEventually(job, JobStatus.RUNNING);
  job.suspend();
  // When
  run("resume", job.getName());
  // Then
  assertJobStatusEventually(job, JobStatus.RUNNING);
}

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

@Test
public void test_restartJob_jobNotRunning() {
  // Given
  Job job = newJob();
  assertJobStatusEventually(job, JobStatus.RUNNING);
  job.suspend();
  assertJobStatusEventually(job, JobStatus.SUSPENDED);
  // When
  // Then
  exception.expectMessage("is not running");
  run("restart", job.getName());
}

相关文章