diff --git a/build.gradle b/build.gradle index c2b0d4a921f..dd94458a821 100644 --- a/build.gradle +++ b/build.gradle @@ -7,7 +7,7 @@ buildscript { } dependencies { - classpath("org.springframework.boot:spring-boot-gradle-plugin:1.3.5.RELEASE") + classpath("org.springframework.boot:spring-boot-gradle-plugin:1.3.6.RELEASE") classpath("io.spring.gradle:dependency-management-plugin:0.6.0.RELEASE") classpath("org.asciidoctor:asciidoctor-gradle-plugin:1.5.3") classpath("gradle.plugin.com.gorylenko.gradle-git-properties:gradle-git-properties:1.4.11") @@ -63,7 +63,7 @@ subprojects { dependencyManagement { imports { - mavenBom 'io.spring.platform:platform-bom:2.0.5.RELEASE' + mavenBom 'io.spring.platform:platform-bom:2.0.6.RELEASE' // mavenBom 'org.springframework.cloud:spring-cloud-starter-parent:Brixton.RC1' } } diff --git a/genie-client/src/main/java/com/netflix/genie/client/JobClient.java b/genie-client/src/main/java/com/netflix/genie/client/JobClient.java index 0c1ed1f0830..5498e4a9c2a 100644 --- a/genie-client/src/main/java/com/netflix/genie/client/JobClient.java +++ b/genie-client/src/main/java/com/netflix/genie/client/JobClient.java @@ -481,7 +481,7 @@ public JobStatus waitForCompletion(final String jobId, final long blockTimeout, final JobStatus status = this.getJobStatus(jobId); - if (status == JobStatus.FAILED || status == JobStatus.KILLED || status == JobStatus.SUCCEEDED) { + if (status.isFinished()) { return status; } diff --git a/genie-common/src/main/java/com/netflix/genie/common/dto/JobStatus.java b/genie-common/src/main/java/com/netflix/genie/common/dto/JobStatus.java index 73ceadcf176..d4d53ecff52 100644 --- a/genie-common/src/main/java/com/netflix/genie/common/dto/JobStatus.java +++ b/genie-common/src/main/java/com/netflix/genie/common/dto/JobStatus.java @@ -71,4 +71,22 @@ public static JobStatus parse(final String value) throws GeniePreconditionExcept "Unacceptable job status. Must be one of {Init, Running, Succeeded, Killed, Failed, Invalid}" ); } + + /** + * Check whether this job is in an active state or not. + * + * @return True if the job is still actively processing in some manner + */ + public boolean isActive() { + return this == INIT || this == RUNNING; + } + + /** + * Check whether the job is no longer running. + * + * @return True if the job is no longer processing for one reason or another. + */ + public boolean isFinished() { + return this == SUCCEEDED || this == KILLED || this == FAILED || this == INVALID; + } } diff --git a/genie-common/src/test/java/com/netflix/genie/common/dto/JobStatusUnitTests.java b/genie-common/src/test/java/com/netflix/genie/common/dto/JobStatusUnitTests.java index a79ac98fa50..ded7f9bedb7 100644 --- a/genie-common/src/test/java/com/netflix/genie/common/dto/JobStatusUnitTests.java +++ b/genie-common/src/test/java/com/netflix/genie/common/dto/JobStatusUnitTests.java @@ -65,4 +65,30 @@ public void testInvalidJobStatus() throws GeniePreconditionException { public void testBlankJobStatus() throws GeniePreconditionException { JobStatus.parse(null); } + + /** + * Test to make sure isActive is working properly. + */ + @Test + public void testIsActive() { + Assert.assertTrue(JobStatus.RUNNING.isActive()); + Assert.assertTrue(JobStatus.INIT.isActive()); + Assert.assertFalse(JobStatus.FAILED.isActive()); + Assert.assertFalse(JobStatus.INVALID.isActive()); + Assert.assertFalse(JobStatus.KILLED.isActive()); + Assert.assertFalse(JobStatus.SUCCEEDED.isActive()); + } + + /** + * Test to make sure isFinished is working properly. + */ + @Test + public void testIsFinished() { + Assert.assertFalse(JobStatus.RUNNING.isFinished()); + Assert.assertFalse(JobStatus.INIT.isFinished()); + Assert.assertTrue(JobStatus.FAILED.isFinished()); + Assert.assertTrue(JobStatus.INVALID.isFinished()); + Assert.assertTrue(JobStatus.KILLED.isFinished()); + Assert.assertTrue(JobStatus.SUCCEEDED.isFinished()); + } }