Mercurial > hg > thermostat-ng > web-gateway
changeset 290:de2b19515d30
Use constants for jvm-gc delta parameters
Reviewed-by: jerboaa
Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2017-October/025513.html
author | Jie Kang <jkang@redhat.com> |
---|---|
date | Tue, 24 Oct 2017 09:38:35 -0400 |
parents | 0c455094e241 |
children | dd3f50e39a56 |
files | common/core/src/main/java/com/redhat/thermostat/gateway/common/core/servlet/RequestParameters.java services/jvm-gc/src/main/java/com/redhat/thermostat/gateway/service/jvm/gc/http/JvmGcHttpHandler.java tests/integration-tests/src/test/java/com/redhat/thermostat/gateway/service/jvm/gc/JvmGcServiceIntegrationTest.java |
diffstat | 3 files changed, 22 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/common/core/src/main/java/com/redhat/thermostat/gateway/common/core/servlet/RequestParameters.java Mon Oct 23 16:48:52 2017 -0400 +++ b/common/core/src/main/java/com/redhat/thermostat/gateway/common/core/servlet/RequestParameters.java Tue Oct 24 09:38:35 2017 -0400 @@ -50,4 +50,7 @@ String TIMESTAMP = "timeStamp"; String ALIVE_ONLY = "aliveOnly"; + + String BEFORE = "before"; + String AFTER = "after"; }
--- a/services/jvm-gc/src/main/java/com/redhat/thermostat/gateway/service/jvm/gc/http/JvmGcHttpHandler.java Mon Oct 23 16:48:52 2017 -0400 +++ b/services/jvm-gc/src/main/java/com/redhat/thermostat/gateway/service/jvm/gc/http/JvmGcHttpHandler.java Tue Oct 24 09:38:35 2017 -0400 @@ -153,8 +153,8 @@ public Response getJvmGcDelta(@PathParam("jvmId") String jvmId, @QueryParam(RequestParameters.LIMIT) @DefaultValue("1") Integer limit, @QueryParam(RequestParameters.OFFSET) @DefaultValue("0") Integer offset, - @QueryParam("after") Long afterTimeStamp, - @QueryParam("before") Long beforeTimeStamp, + @QueryParam(RequestParameters.AFTER) Long afterTimeStamp, + @QueryParam(RequestParameters.BEFORE) Long beforeTimeStamp, @QueryParam(RequestParameters.METADATA) @DefaultValue("false") Boolean metadata, @Context HttpServletRequest httpServletRequest, @Context ServletContext context) {
--- a/tests/integration-tests/src/test/java/com/redhat/thermostat/gateway/service/jvm/gc/JvmGcServiceIntegrationTest.java Mon Oct 23 16:48:52 2017 -0400 +++ b/tests/integration-tests/src/test/java/com/redhat/thermostat/gateway/service/jvm/gc/JvmGcServiceIntegrationTest.java Tue Oct 24 09:38:35 2017 -0400 @@ -102,6 +102,8 @@ private static final String METADATA_PREFIX = "metadata"; private static final String INCLUDE_PREFIX = "include"; private static final String EXCLUDE_PREFIX = "exclude"; + private static final String AFTER_PREFIX = "after"; + private static final String BEFORE_PREFIX = "before"; private static final String TIMESTAMP_TOKEN = "\"$TIMESTAMP$\""; private static final String JVMID_TOKEN = "\"$JVMID_TOKEN\""; @@ -666,7 +668,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("limit", "2").send(); + ContentResponse response = client.newRequest(deltaJvmUrl).method(HttpMethod.GET).param(LIMIT_PREFIX, "2").send(); verifyResponse(response, expectedResponse, 200); } @@ -689,7 +691,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("limit", "10").send(); + ContentResponse response = client.newRequest(deltaJvmUrl).method(HttpMethod.GET).param(LIMIT_PREFIX, "10").send(); verifyResponse(response, expectedResponse, 200); } @@ -708,7 +710,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("limit", "1").param("offset", offset).send(); + ContentResponse response = client.newRequest(deltaJvmUrl).method(HttpMethod.GET).param(LIMIT_PREFIX, "1").param(OFFSET_PREFIX, offset).send(); verifyResponse(response, expectedResponse, 200); @@ -716,7 +718,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("limit", "1").param("offset", offset).send(); + response = client.newRequest(deltaJvmUrl).method(HttpMethod.GET).param(LIMIT_PREFIX, "1").param(OFFSET_PREFIX, offset).send(); verifyResponse(response, expectedResponse, 200); } @@ -737,7 +739,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("limit", "10").param("after", "400").send(); + ContentResponse response = client.newRequest(deltaJvmUrl).method(HttpMethod.GET).param(LIMIT_PREFIX, "10").param(AFTER_PREFIX, "400").send(); verifyResponse(response, expectedResponse, 200); } @@ -756,8 +758,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("limit", "10") - .param("after", "400").param("offset", "1").send(); + ContentResponse response = client.newRequest(deltaJvmUrl).method(HttpMethod.GET).param(LIMIT_PREFIX, "10") + .param(AFTER_PREFIX, "400").param(OFFSET_PREFIX, "1").send(); verifyResponse(response, expectedResponse, 200); } @@ -776,8 +778,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("limit", "10") - .param("before", "500").send(); + ContentResponse response = client.newRequest(deltaJvmUrl).method(HttpMethod.GET).param(LIMIT_PREFIX, "10") + .param(BEFORE_PREFIX, "500").send(); verifyResponse(response, expectedResponse, 200); } @@ -795,8 +797,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("limit", "10") - .param("before", "600").param("after", "400").send(); + ContentResponse response = client.newRequest(deltaJvmUrl).method(HttpMethod.GET).param(LIMIT_PREFIX, "10") + .param(BEFORE_PREFIX, "600").param(AFTER_PREFIX, "400").send(); verifyResponse(response, expectedResponse, 200); } @@ -825,8 +827,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("limit", "10") - .param("after", "500").send(); + ContentResponse response = client.newRequest(deltaJvmUrl).method(HttpMethod.GET).param(LIMIT_PREFIX, "10") + .param(AFTER_PREFIX, "500").send(); verifyResponse(response, expectedResponse, 200); } @@ -863,7 +865,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("limit", "10").send(); + ContentResponse response = client.newRequest(deltaUrl + "/jvm-X").method(HttpMethod.GET).param(LIMIT_PREFIX, "10").send(); verifyResponse(response, expectedResponse, 200); /* @@ -880,7 +882,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("limit", "10").send(); + response = client.newRequest(deltaUrl + "/jvm-Y").method(HttpMethod.GET).param(LIMIT_PREFIX, "10").send(); verifyResponse(response, expectedResponse, 200);