changeset 289:0c455094e241

Use long form query parameters for jvm-gc delta endpoint Reviewed-by: chkoehle Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2017-October/025507.html
author Jie Kang <jkang@redhat.com>
date Mon, 23 Oct 2017 16:48:52 -0400
parents 45826353de65
children de2b19515d30
files services/jvm-gc/src/main/java/com/redhat/thermostat/gateway/service/jvm/gc/http/JvmGcHttpHandler.java services/jvm-gc/src/main/resources/jvm-gc-swagger.yaml tests/integration-tests/src/test/java/com/redhat/thermostat/gateway/service/jvm/gc/JvmGcServiceIntegrationTest.java
diffstat 3 files changed, 22 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/services/jvm-gc/src/main/java/com/redhat/thermostat/gateway/service/jvm/gc/http/JvmGcHttpHandler.java	Mon Oct 23 09:07:47 2017 -0400
+++ b/services/jvm-gc/src/main/java/com/redhat/thermostat/gateway/service/jvm/gc/http/JvmGcHttpHandler.java	Mon Oct 23 16:48:52 2017 -0400
@@ -151,11 +151,11 @@
     @Consumes({ "application/json" })
     @Produces({ "application/json", "text/html; charset=utf-8" })
     public Response getJvmGcDelta(@PathParam("jvmId") String jvmId,
-                                  @QueryParam("l") @DefaultValue("1") Integer limit,
-                                  @QueryParam("o") @DefaultValue("0") Integer offset,
-                                  @QueryParam("a") Long afterTimeStamp,
-                                  @QueryParam("b") Long beforeTimeStamp,
-                                  @QueryParam("m") @DefaultValue("false") Boolean metadata,
+                                  @QueryParam(RequestParameters.LIMIT) @DefaultValue("1") Integer limit,
+                                  @QueryParam(RequestParameters.OFFSET) @DefaultValue("0") Integer offset,
+                                  @QueryParam("after") Long afterTimeStamp,
+                                  @QueryParam("before") Long beforeTimeStamp,
+                                  @QueryParam(RequestParameters.METADATA) @DefaultValue("false") Boolean metadata,
                                   @Context HttpServletRequest httpServletRequest,
                                   @Context ServletContext context) {
         try {
--- a/services/jvm-gc/src/main/resources/jvm-gc-swagger.yaml	Mon Oct 23 09:07:47 2017 -0400
+++ b/services/jvm-gc/src/main/resources/jvm-gc-swagger.yaml	Mon Oct 23 16:48:52 2017 -0400
@@ -260,13 +260,13 @@
     type: string
     required: false
   before:
-    name: b
+    name: before
     in: query
     description: Before timeStamp. A long that specifies to return documents before the timeStamp.
     type: integer
     format: int64
   after:
-    name: a
+    name: after
     in: query
     description: After timeStamp. A long that specifies to return documents after the timeStamp.
     type: integer
--- a/tests/integration-tests/src/test/java/com/redhat/thermostat/gateway/service/jvm/gc/JvmGcServiceIntegrationTest.java	Mon Oct 23 09:07:47 2017 -0400
+++ b/tests/integration-tests/src/test/java/com/redhat/thermostat/gateway/service/jvm/gc/JvmGcServiceIntegrationTest.java	Mon Oct 23 16:48:52 2017 -0400
@@ -666,7 +666,7 @@
         String expectedResponse = "{\"response\":[{\"collectorName\":\"CMS\",\"timeStamp\":{\"$numberLong\":\"600\"}," +
                 "\"wallTimeInMicros\":{\"$numberLong\":\"212864\"}" + SYSTEM_JVM_FRAGMENT +  "," +
                 "\"wallTimeDelta\":{\"$numberLong\":\"0\"}}]}";
-        ContentResponse response = client.newRequest(deltaJvmUrl).method(HttpMethod.GET).param("l", "2").send();
+        ContentResponse response = client.newRequest(deltaJvmUrl).method(HttpMethod.GET).param("limit", "2").send();
 
         verifyResponse(response, expectedResponse, 200);
     }
@@ -689,7 +689,7 @@
                 "\"wallTimeDelta\":{\"$numberLong\":\"156887\"}},{\"collectorName\":\"CMS\"," +
                 "\"timeStamp\":{\"$numberLong\":\"400\"},\"wallTimeInMicros\":{\"$numberLong\":\"14000\"}" + SYSTEM_JVM_FRAGMENT + "," +
                 "\"wallTimeDelta\":{\"$numberLong\":\"0\"}}]}";
-        ContentResponse response = client.newRequest(deltaJvmUrl).method(HttpMethod.GET).param("l", "10").send();
+        ContentResponse response = client.newRequest(deltaJvmUrl).method(HttpMethod.GET).param("limit", "10").send();
 
         verifyResponse(response, expectedResponse, 200);
     }
@@ -708,7 +708,7 @@
         String expectedResponse = "{\"response\":[{\"collectorName\":\"CMS\",\"timeStamp\":{\"$numberLong\":\"500\"}," +
                 "\"wallTimeInMicros\":{\"$numberLong\":\"170887\"}" + SYSTEM_JVM_FRAGMENT + "," +
                 "\"wallTimeDelta\":{\"$numberLong\":\"156887\"}}]}";
-        ContentResponse response = client.newRequest(deltaJvmUrl).method(HttpMethod.GET).param("l", "1").param("o", offset).send();
+        ContentResponse response = client.newRequest(deltaJvmUrl).method(HttpMethod.GET).param("limit", "1").param("offset", offset).send();
 
         verifyResponse(response, expectedResponse, 200);
 
@@ -716,7 +716,7 @@
         expectedResponse = "{\"response\":[{\"collectorName\":\"CMS\",\"timeStamp\":{\"$numberLong\":\"400\"}," +
                 "\"wallTimeInMicros\":{\"$numberLong\":\"14000\"}" + SYSTEM_JVM_FRAGMENT + "," +
                 "\"wallTimeDelta\":{\"$numberLong\":\"0\"}}]}";
-        response = client.newRequest(deltaJvmUrl).method(HttpMethod.GET).param("l", "1").param("o", offset).send();
+        response = client.newRequest(deltaJvmUrl).method(HttpMethod.GET).param("limit", "1").param("offset", offset).send();
 
         verifyResponse(response, expectedResponse, 200);
     }
@@ -737,7 +737,7 @@
                 "\"wallTimeDelta\":{\"$numberLong\":\"41977\"}},{\"collectorName\":\"CMS\"," +
                 "\"timeStamp\":{\"$numberLong\":\"500\"},\"wallTimeInMicros\":{\"$numberLong\":\"170887\"}" + SYSTEM_JVM_FRAGMENT + "," +
                 "\"wallTimeDelta\":{\"$numberLong\":\"156887\"}}]}";
-        ContentResponse response = client.newRequest(deltaJvmUrl).method(HttpMethod.GET).param("l", "10").param("a", "400").send();
+        ContentResponse response = client.newRequest(deltaJvmUrl).method(HttpMethod.GET).param("limit", "10").param("after", "400").send();
 
         verifyResponse(response, expectedResponse, 200);
     }
@@ -756,8 +756,8 @@
         String expectedResponse = "{\"response\":[{\"collectorName\":\"CMS\",\"timeStamp\":{\"$numberLong\":\"500\"}," +
                 "\"wallTimeInMicros\":{\"$numberLong\":\"170887\"}" + SYSTEM_JVM_FRAGMENT + "," +
                 "\"wallTimeDelta\":{\"$numberLong\":\"156887\"}}]}";
-        ContentResponse response = client.newRequest(deltaJvmUrl).method(HttpMethod.GET).param("l", "10")
-                .param("a", "400").param("o", "1").send();
+        ContentResponse response = client.newRequest(deltaJvmUrl).method(HttpMethod.GET).param("limit", "10")
+                .param("after", "400").param("offset", "1").send();
 
         verifyResponse(response, expectedResponse, 200);
     }
@@ -776,8 +776,8 @@
         String expectedResponse = "{\"response\":[{\"collectorName\":\"CMS\",\"timeStamp\":{\"$numberLong\":\"400\"}," +
                 "\"wallTimeInMicros\":{\"$numberLong\":\"14000\"}" + SYSTEM_JVM_FRAGMENT + "," +
                 "\"wallTimeDelta\":{\"$numberLong\":\"0\"}}]}";
-        ContentResponse response = client.newRequest(deltaJvmUrl).method(HttpMethod.GET).param("l", "10")
-                .param("b", "500").send();
+        ContentResponse response = client.newRequest(deltaJvmUrl).method(HttpMethod.GET).param("limit", "10")
+                .param("before", "500").send();
 
         verifyResponse(response, expectedResponse, 200);
     }
@@ -795,8 +795,8 @@
 
         String expectedResponse = "{\"response\":[{\"collectorName\":\"CMS\",\"timeStamp\":{\"$numberLong\":\"500\"},\"wallTimeInMicros\":{\"$numberLong\":\"170887\"}" +
                                   SYSTEM_JVM_FRAGMENT + ",\"wallTimeDelta\":{\"$numberLong\":\"156887\"}}]}";
-        ContentResponse response = client.newRequest(deltaJvmUrl).method(HttpMethod.GET).param("l", "10")
-                .param("b", "600").param("a", "400").send();
+        ContentResponse response = client.newRequest(deltaJvmUrl).method(HttpMethod.GET).param("limit", "10")
+                .param("before", "600").param("after", "400").send();
 
         verifyResponse(response, expectedResponse, 200);
     }
@@ -825,8 +825,8 @@
                 "\"wallTimeDelta\":{\"$numberLong\":\"41977\"}},{\"collectorName\":\"ABC\",\"timeStamp\":{\"$numberLong\":\"550\"}," +
                 "\"wallTimeInMicros\":{\"$numberLong\":\"1000\"}" + SYSTEM_JVM_FRAGMENT + "," +
                 "\"wallTimeDelta\":{\"$numberLong\":\"500\"}}]}";
-        ContentResponse response = client.newRequest(deltaJvmUrl).method(HttpMethod.GET).param("l", "10")
-                .param("a", "500").send();
+        ContentResponse response = client.newRequest(deltaJvmUrl).method(HttpMethod.GET).param("limit", "10")
+                .param("after", "500").send();
 
         verifyResponse(response, expectedResponse, 200);
     }
@@ -863,7 +863,7 @@
                 "\"wallTimeInMicros\":170887,\"wallTimeDelta\":{\"$numberLong\":156887}}," +
                 "{\"jvmId\":\"jvm-X\",\"collectorName\":\"CMS\",\"timeStamp\":400," +
                 "\"wallTimeInMicros\":14000,\"wallTimeDelta\":{\"$numberLong\":0}}]}";
-        ContentResponse response = client.newRequest(deltaUrl + "/jvm-X").method(HttpMethod.GET).param("l", "10").send();
+        ContentResponse response = client.newRequest(deltaUrl + "/jvm-X").method(HttpMethod.GET).param("limit", "10").send();
         verifyResponse(response, expectedResponse, 200);
 
         /*
@@ -880,7 +880,7 @@
                 "\"wallTimeInMicros\":1000,\"wallTimeDelta\":{\"$numberLong\":500}}," +
                 "{\"jvmId\":\"jvm-Y\",\"collectorName\":\"CMS\",\"timeStamp\":440," +
                 "\"wallTimeInMicros\":500,\"wallTimeDelta\":{\"$numberLong\":0}}]}";
-        response = client.newRequest(deltaUrl + "/jvm-Y").method(HttpMethod.GET).param("l", "10").send();
+        response = client.newRequest(deltaUrl + "/jvm-Y").method(HttpMethod.GET).param("limit", "10").send();
 
 
         verifyResponse(response, expectedResponse, 200);