SLIDER-768 API to add an operation to query liveness

Project: http://git-wip-us.apache.org/repos/asf/incubator-slider/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-slider/commit/dce12366
Tree: http://git-wip-us.apache.org/repos/asf/incubator-slider/tree/dce12366
Diff: http://git-wip-us.apache.org/repos/asf/incubator-slider/diff/dce12366

Branch: refs/heads/develop
Commit: dce123661b08ef9767942f119730c90b01b7fcd7
Parents: 680d64d
Author: Steve Loughran <[email protected]>
Authored: Fri Jan 30 18:21:04 2015 +0000
Committer: Steve Loughran <[email protected]>
Committed: Fri Jan 30 18:21:04 2015 +0000

----------------------------------------------------------------------
 .../slider/api/types/ApplicationLivenessInformation.java | 11 ++++++++++-
 .../apache/slider/client/rest/SliderApplicationAPI.java  | 10 ++++++++++
 .../slider/agent/rest/RestAPIClientTestDelegates.groovy  |  9 +++++++++
 3 files changed, 29 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/dce12366/slider-core/src/main/java/org/apache/slider/api/types/ApplicationLivenessInformation.java
----------------------------------------------------------------------
diff --git 
a/slider-core/src/main/java/org/apache/slider/api/types/ApplicationLivenessInformation.java
 
b/slider-core/src/main/java/org/apache/slider/api/types/ApplicationLivenessInformation.java
index ab11263..d4d4278 100644
--- 
a/slider-core/src/main/java/org/apache/slider/api/types/ApplicationLivenessInformation.java
+++ 
b/slider-core/src/main/java/org/apache/slider/api/types/ApplicationLivenessInformation.java
@@ -32,7 +32,16 @@ import org.codehaus.jackson.map.annotate.JsonSerialize;
 public class ApplicationLivenessInformation {
   public boolean allRequestsSatisfied;
   public int requested;
-  
+
+  @Override
+  public String toString() {
+    final StringBuilder sb =
+        new StringBuilder("ApplicationLivenessInformation{");
+    sb.append("allRequestsSatisfied=").append(allRequestsSatisfied);
+    sb.append(", requested=").append(requested);
+    sb.append('}');
+    return sb.toString();
+  }
 }
 
 

http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/dce12366/slider-core/src/main/java/org/apache/slider/client/rest/SliderApplicationAPI.java
----------------------------------------------------------------------
diff --git 
a/slider-core/src/main/java/org/apache/slider/client/rest/SliderApplicationAPI.java
 
b/slider-core/src/main/java/org/apache/slider/client/rest/SliderApplicationAPI.java
index 514e5eb..a8dfe8f 100644
--- 
a/slider-core/src/main/java/org/apache/slider/client/rest/SliderApplicationAPI.java
+++ 
b/slider-core/src/main/java/org/apache/slider/client/rest/SliderApplicationAPI.java
@@ -24,6 +24,7 @@ import com.sun.jersey.api.client.GenericType;
 import com.sun.jersey.api.client.WebResource;
 import com.sun.jersey.api.representation.Form;
 import org.apache.commons.lang.StringUtils;
+import org.apache.slider.api.types.ApplicationLivenessInformation;
 import org.apache.slider.api.types.ComponentInformation;
 import org.apache.slider.api.types.ContainerInformation;
 import org.apache.slider.core.conf.AggregateConf;
@@ -271,4 +272,13 @@ public class SliderApplicationAPI extends BaseRestClient {
     return pingOut.post(PingResource.class, f);
   }
 
+  /**
+   * Get the application liveness
+   * @return current liveness information
+   * @throws IOException
+   */
+  public ApplicationLivenessInformation getApplicationLiveness() throws 
IOException {
+    return getApplicationResource(LIVE_LIVENESS,
+        ApplicationLivenessInformation.class);
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/dce12366/slider-core/src/test/groovy/org/apache/slider/agent/rest/RestAPIClientTestDelegates.groovy
----------------------------------------------------------------------
diff --git 
a/slider-core/src/test/groovy/org/apache/slider/agent/rest/RestAPIClientTestDelegates.groovy
 
b/slider-core/src/test/groovy/org/apache/slider/agent/rest/RestAPIClientTestDelegates.groovy
index de89b8e..1851dd7 100644
--- 
a/slider-core/src/test/groovy/org/apache/slider/agent/rest/RestAPIClientTestDelegates.groovy
+++ 
b/slider-core/src/test/groovy/org/apache/slider/agent/rest/RestAPIClientTestDelegates.groovy
@@ -240,9 +240,18 @@ class RestAPIClientTestDelegates extends 
AbstractRestTestDelegate {
     testLiveResources()
     testLiveContainers();
     testRESTModel()
+    testAppLiveness()
   }
 
   public void testSuiteComplexVerbs() {
     testPing();
   }
+  
+  public void testAppLiveness() {
+    def liveness = appAPI.applicationLiveness
+    describe "Liveness:\n$liveness"
+    
+    assert liveness.allRequestsSatisfied
+    assert !liveness.requested
+  }
 }

Reply via email to