本文整理了Java中com.hazelcast.jet.Job.getStatus()
方法的一些代码示例,展示了Job.getStatus()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Job.getStatus()
方法的具体详情如下:
包路径:com.hazelcast.jet.Job
类名称:Job
方法名:getStatus
[英]Returns the current status of this job.
[中]返回此作业的当前状态。
代码示例来源:origin: hazelcast/hazelcast-jet
private static void assertJobRunning(String name, Job job) {
if (job.getStatus() != JobStatus.RUNNING) {
throw new RuntimeException("Job '" + name + "' is not running. Current state: " + job.getStatus());
}
}
代码示例来源:origin: hazelcast/hazelcast-jet
private static void waitForJobStatus(Job job, JobStatus status) {
while (job.getStatus() != status) {
LockSupport.parkNanos(TimeUnit.MILLISECONDS.toNanos(WAIT_INTERVAL_MILLIS));
}
}
代码示例来源:origin: hazelcast/hazelcast-jet
private static void assertJobActive(String name, Job job) {
if (!isActive(job.getStatus())) {
throw new RuntimeException("Job '" + name + "' is not active. Current state: " + job.getStatus());
}
}
代码示例来源:origin: hazelcast/hazelcast-jet-code-samples
private static void waitForStatus(Job job, JobStatus expectedStatus) throws InterruptedException {
for (JobStatus status; (status = job.getStatus()) != expectedStatus;) {
System.out.println("Job is " + status + "...");
Thread.sleep(1);
}
System.out.println("Job is " + expectedStatus + ".");
}
}
代码示例来源:origin: hazelcast/hazelcast-jet-code-samples
private static void waitForComplete(Job job) {
while (job.getStatus() != JobStatus.COMPLETED) {
uncheckRun(() -> SECONDS.sleep(1));
}
}
}
代码示例来源:origin: hazelcast/hazelcast-jet-code-samples
private static void waitForComplete(Job job) {
while (job.getStatus() != JobStatus.COMPLETED) {
uncheckRun(() -> SECONDS.sleep(1));
}
}
}
代码示例来源:origin: hazelcast/hazelcast-jet-code-samples
private static void cancel(Job job) {
job.cancel();
while (job.getStatus() != JobStatus.COMPLETED) {
uncheckRun(() -> SECONDS.sleep(1));
}
}
代码示例来源:origin: hazelcast/hazelcast-code-samples
/**
* <p>Run a Jet analysis job to examine the journal of updates to
* HTTP sessions. As we don't want it to run for ever, give it a
* second or two to do some work then end it.
* </p>
*/
@ShellMethod(key = "ANALYSIS", value = "Analyse the orders")
public void analyseSessions() throws Exception {
IMap<String, Integer> sequenceMap = this.hazelcastInstance.getMap(Constants.IMAP_NAME_SEQUENCE);
sequenceMap.clear();
Job analysisJob = this.jetInstance.newJob(SequenceAnalysis.build());
analysisJob.getFuture();
// Give the job time to do something
int wait = 2;
log.info("Sleep {} seconds", wait);
TimeUnit.SECONDS.sleep(wait);
if (analysisJob.getStatus() == JobStatus.RUNNING) {
analysisJob.cancel();
} else {
log.error("Job status {}", analysisJob.getStatus());
}
System.out.printf("%d sequence%s found%n", sequenceMap.size(), (sequenceMap.size() == 1 ? "" : "s"));
}
代码示例来源:origin: hazelcast/hazelcast-jet
@Override
public Job getJob(long jobId) {
try {
Job job = newJobProxy(jobId);
// get the status for the side-effect of throwing an exception if the jobId is invalid
job.getStatus();
return job;
} catch (Throwable t) {
if (peel(t) instanceof JobNotFoundException) {
return null;
}
throw rethrow(t);
}
}
代码示例来源:origin: hazelcast/hazelcast-jet
@Command(
description = "Resumes a suspended job"
)
public void resume(
@Parameters(index = "0",
paramLabel = "<job name or id>",
description = "Name of the job to resume")
String name
) throws IOException {
runWithJet(jet -> {
Job job = getJob(jet, name);
if (job.getStatus() != JobStatus.SUSPENDED) {
throw new RuntimeException("Job '" + name + "' is not suspended. Current state: " + job.getStatus());
}
println("Resuming job " + formatJob(job) + "...");
job.resume();
waitForJobStatus(job, JobStatus.RUNNING);
println("Job was successfully resumed.");
});
}
代码示例来源:origin: hazelcast/hazelcast-jet
@Nonnull @Override
public Job newJobIfAbsent(@Nonnull DAG dag, @Nonnull JobConfig config) {
if (config.getName() == null) {
return newJob(dag, config);
} else {
while (true) {
Job job = getJob(config.getName());
if (job != null) {
JobStatus status = job.getStatus();
if (status != JobStatus.FAILED && status != JobStatus.COMPLETED) {
return job;
}
}
try {
return newJob(dag, config);
} catch (JobAlreadyExistsException e) {
logFine(getLogger(), "Could not submit job with duplicate name: %s", config.getName());
}
}
}
}
代码示例来源:origin: hazelcast/hazelcast-jet-code-samples
System.out.println("Tracked job: " + trackedJob1.getName() + ", status: " + trackedJob1.getStatus());
System.out.println("Status: " + trackedJob1.getStatus());
System.out.println("Tracked job status: " + trackedJob2.getStatus());
代码示例来源:origin: hazelcast/hazelcast-jet-code-samples
System.out.println("Status: " + job.getStatus());
代码示例来源:origin: hazelcast/hazelcast-jet-code-samples
while (job.getStatus() != JobStatus.RUNNING) {
Thread.sleep(1);
代码示例来源:origin: hazelcast/hazelcast-jet
@Test
public void test_listJobs() {
// Given
Job job = newJob();
// When
run("jobs");
// Then
String actual = captureOut();
assertContains(actual, job.getName());
assertContains(actual, job.getIdString());
assertContains(actual, job.getStatus().toString());
}
内容来源于网络,如有侵权,请联系作者删除!