From cefa47369d3df164fec9744dfe86f17333c91167 Mon Sep 17 00:00:00 2001 From: msvinaykumar Date: Thu, 12 Oct 2023 15:41:01 +0530 Subject: [PATCH 1/5] stage test debug changes Signed-off-by: msvinaykumar --- .../services/UpdateRecommendations.java | 18 +++++++++++++++--- .../analyzer/services/UpdateResults.java | 10 ++++++++++ 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/autotune/analyzer/services/UpdateRecommendations.java b/src/main/java/com/autotune/analyzer/services/UpdateRecommendations.java index 09ef82beb..c73de7669 100644 --- a/src/main/java/com/autotune/analyzer/services/UpdateRecommendations.java +++ b/src/main/java/com/autotune/analyzer/services/UpdateRecommendations.java @@ -65,7 +65,7 @@ public class UpdateRecommendations extends HttpServlet { private static final long serialVersionUID = 1L; private static final Logger LOGGER = LoggerFactory.getLogger(UpdateRecommendations.class); - + private int requestCount = 0; @Override public void init(ServletConfig config) throws ServletException { super.init(config); @@ -75,7 +75,8 @@ public void init(ServletConfig config) throws ServletException { * Generates recommendations * * @param request an {@link HttpServletRequest} object that - * contains the request the client has made + * contains + * the request the client has made * of the servlet * @param response an {@link HttpServletResponse} object that * contains the response the servlet sends @@ -85,6 +86,9 @@ public void init(ServletConfig config) throws ServletException { */ @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + requestCount++; + int calCount = requestCount ; + LOGGER.debug("UpdateRecommendations API request count: {}" , calCount); String statusValue = "failure"; Timer.Sample timerBUpdateRecommendations = Timer.start(MetricsConfig.meterRegistry()); try { @@ -148,7 +152,7 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response) } } } - + LOGGER.debug("UpdateRecommendations API request count: {} experiment_name : {} and interval_start_time : {} and interval_end_time : {} " , calCount , experiment_name, intervalStartTimeStr, intervalEndTimeStr); LOGGER.debug("experiment_name : {} and interval_start_time : {} and interval_end_time : {} ", experiment_name, intervalStartTimeStr, intervalEndTimeStr); List experimentResultDataList = new ArrayList<>(); @@ -163,10 +167,12 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response) if (null != kruizeObject) experimentResultDataList = new ExperimentDBService().getExperimentResultData(experiment_name, kruizeObject, interval_start_time, interval_end_time); // Todo this object is not required else { + LOGGER.debug("UpdateRecommendations API request count: {} failed" , calCount); sendErrorResponse(response, null, HttpServletResponse.SC_BAD_REQUEST, String.format("%s%s", MISSING_EXPERIMENT_NAME, experiment_name)); return; } } catch (Exception e) { + LOGGER.debug("UpdateRecommendations API request count: {} failed" , calCount); sendErrorResponse(response, e, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage()); return; } @@ -177,12 +183,15 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response) new ExperimentInitiator().generateAndAddRecommendations(kruizeObject, experimentResultDataList, interval_start_time, interval_end_time); // TODO: experimentResultDataList not required ValidationOutputData validationOutputData = new ExperimentDBService().addRecommendationToDB(mainKruizeExperimentMAP, experimentResultDataList); if (validationOutputData.isSuccess()) { + LOGGER.debug("UpdateRecommendations API request count: {} success" , calCount); sendSuccessResponse(response, kruizeObject, interval_end_time); statusValue = "success"; } else { + LOGGER.debug("UpdateRecommendations API request count: {} failed" , calCount); sendErrorResponse(response, null, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, validationOutputData.getMessage()); } } catch (Exception e) { + LOGGER.debug("UpdateRecommendations API request count: {} failed" , calCount); e.printStackTrace(); LOGGER.error("Failed to create recommendation for experiment: {} and interval_start_time: {} and interval_end_time: {}", experiment_name, @@ -193,14 +202,17 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response) } } else { + LOGGER.debug("UpdateRecommendations API request count: {} failed" , calCount); sendErrorResponse(response, null, HttpServletResponse.SC_BAD_REQUEST, String.format("%s%s", MISSING_INTERVAL_END_TIME, intervalEndTimeStr)); return; } } catch (Exception e) { + LOGGER.debug("UpdateRecommendations API request count: {} failed" , calCount); LOGGER.error("Exception: " + e.getMessage()); e.printStackTrace(); sendErrorResponse(response, e, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage()); } finally { + LOGGER.debug("UpdateRecommendations API request count: {} completed" , calCount); if (null != timerBUpdateRecommendations) { MetricsConfig.timerUpdateRecomendations = MetricsConfig.timerBUpdateRecommendations.tag("status", statusValue).register(MetricsConfig.meterRegistry()); timerBUpdateRecommendations.stop(MetricsConfig.timerUpdateRecomendations); diff --git a/src/main/java/com/autotune/analyzer/services/UpdateResults.java b/src/main/java/com/autotune/analyzer/services/UpdateResults.java index 54b34ec05..89e863de1 100644 --- a/src/main/java/com/autotune/analyzer/services/UpdateResults.java +++ b/src/main/java/com/autotune/analyzer/services/UpdateResults.java @@ -56,6 +56,7 @@ public class UpdateResults extends HttpServlet { private static final long serialVersionUID = 1L; private static final Logger LOGGER = LoggerFactory.getLogger(UpdateResults.class); public static ConcurrentHashMap performanceProfilesMap = new ConcurrentHashMap<>(); + private int requestCount = 0; @Override public void init(ServletConfig config) throws ServletException { @@ -64,12 +65,17 @@ public void init(ServletConfig config) throws ServletException { @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + requestCount++; + int calCount = requestCount + 1; + LOGGER.debug("updateResults API request count: {}" , calCount); String statusValue = "failure"; Timer.Sample timerUpdateResults = Timer.start(MetricsConfig.meterRegistry()); try { String inputData = request.getReader().lines().collect(Collectors.joining()); + LOGGER.debug("updateResults API request payload for requestID {} is {}",calCount,inputData); List experimentResultDataList = new ArrayList<>(); List updateResultsAPIObjects = Arrays.asList(new Gson().fromJson(inputData, UpdateResultsAPIObject[].class)); + LOGGER.debug("updateResults API request payload for requestID {} bulk count is {}",calCount,updateResultsAPIObjects.size()); // check for bulk entries and respond accordingly if (updateResultsAPIObjects.size() > KruizeDeploymentInfo.bulk_update_results_limit) { LOGGER.error(AnalyzerErrorConstants.AutotuneObjectErrors.UNSUPPORTED_EXPERIMENT_RESULTS); @@ -97,16 +103,20 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response) ); request.setAttribute("data", jsonObjectList); String errorMessage = String.format("Out of a total of %s records, %s failed to save", updateResultsAPIObjects.size(), failureAPIObjs.size()); + LOGGER.debug("updateResults API request payload for requestID {} failed",calCount); sendErrorResponse(request, response, null, HttpServletResponse.SC_BAD_REQUEST, errorMessage); } else { + LOGGER.debug("updateResults API request payload for requestID {} success",calCount); sendSuccessResponse(response, AnalyzerConstants.ServiceConstants.RESULT_SAVED); statusValue = "success"; } } catch (Exception e) { + LOGGER.debug("updateResults API request payload for requestID {} failed",calCount); LOGGER.error("Exception: " + e.getMessage()); e.printStackTrace(); sendErrorResponse(request, response, e, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage()); } finally { + LOGGER.debug("updateResults API request payload for requestID {} completed",calCount); if (null != timerUpdateResults) { MetricsConfig.timerUpdateResults = MetricsConfig.timerBUpdateResults.tag("status", statusValue).register(MetricsConfig.meterRegistry()); timerUpdateResults.stop(MetricsConfig.timerUpdateResults); From 64c4988845dddd1407d7d5c80bee6213b0f1c3d3 Mon Sep 17 00:00:00 2001 From: msvinaykumar Date: Thu, 12 Oct 2023 17:34:59 +0530 Subject: [PATCH 2/5] stage test debug changes Signed-off-by: msvinaykumar --- .../com/autotune/analyzer/services/UpdateRecommendations.java | 2 +- .../java/com/autotune/analyzer/services/UpdateResults.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/autotune/analyzer/services/UpdateRecommendations.java b/src/main/java/com/autotune/analyzer/services/UpdateRecommendations.java index c73de7669..fb2455bcd 100644 --- a/src/main/java/com/autotune/analyzer/services/UpdateRecommendations.java +++ b/src/main/java/com/autotune/analyzer/services/UpdateRecommendations.java @@ -65,7 +65,7 @@ public class UpdateRecommendations extends HttpServlet { private static final long serialVersionUID = 1L; private static final Logger LOGGER = LoggerFactory.getLogger(UpdateRecommendations.class); - private int requestCount = 0; + private static int requestCount = 0; @Override public void init(ServletConfig config) throws ServletException { super.init(config); diff --git a/src/main/java/com/autotune/analyzer/services/UpdateResults.java b/src/main/java/com/autotune/analyzer/services/UpdateResults.java index 89e863de1..d5ec4f29b 100644 --- a/src/main/java/com/autotune/analyzer/services/UpdateResults.java +++ b/src/main/java/com/autotune/analyzer/services/UpdateResults.java @@ -56,7 +56,7 @@ public class UpdateResults extends HttpServlet { private static final long serialVersionUID = 1L; private static final Logger LOGGER = LoggerFactory.getLogger(UpdateResults.class); public static ConcurrentHashMap performanceProfilesMap = new ConcurrentHashMap<>(); - private int requestCount = 0; + private static int requestCount = 0; @Override public void init(ServletConfig config) throws ServletException { @@ -66,7 +66,7 @@ public void init(ServletConfig config) throws ServletException { @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { requestCount++; - int calCount = requestCount + 1; + int calCount = requestCount; LOGGER.debug("updateResults API request count: {}" , calCount); String statusValue = "failure"; Timer.Sample timerUpdateResults = Timer.start(MetricsConfig.meterRegistry()); From 51525aae4c8f3300238ca6a8f7347ff3e0455bff Mon Sep 17 00:00:00 2001 From: msvinaykumar Date: Thu, 12 Oct 2023 18:33:27 +0530 Subject: [PATCH 3/5] stage test debug changes Signed-off-by: msvinaykumar --- .../com/autotune/analyzer/services/UpdateRecommendations.java | 3 +-- .../java/com/autotune/analyzer/services/UpdateResults.java | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/autotune/analyzer/services/UpdateRecommendations.java b/src/main/java/com/autotune/analyzer/services/UpdateRecommendations.java index fb2455bcd..9c63a3605 100644 --- a/src/main/java/com/autotune/analyzer/services/UpdateRecommendations.java +++ b/src/main/java/com/autotune/analyzer/services/UpdateRecommendations.java @@ -86,8 +86,7 @@ public void init(ServletConfig config) throws ServletException { */ @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - requestCount++; - int calCount = requestCount ; + int calCount = requestCount++ ; LOGGER.debug("UpdateRecommendations API request count: {}" , calCount); String statusValue = "failure"; Timer.Sample timerBUpdateRecommendations = Timer.start(MetricsConfig.meterRegistry()); diff --git a/src/main/java/com/autotune/analyzer/services/UpdateResults.java b/src/main/java/com/autotune/analyzer/services/UpdateResults.java index d5ec4f29b..5a1650869 100644 --- a/src/main/java/com/autotune/analyzer/services/UpdateResults.java +++ b/src/main/java/com/autotune/analyzer/services/UpdateResults.java @@ -65,8 +65,7 @@ public void init(ServletConfig config) throws ServletException { @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - requestCount++; - int calCount = requestCount; + int calCount = requestCount++; LOGGER.debug("updateResults API request count: {}" , calCount); String statusValue = "failure"; Timer.Sample timerUpdateResults = Timer.start(MetricsConfig.meterRegistry()); From 2f2396afd4dc9ef75fa2e1f40bf6a21266cc13bb Mon Sep 17 00:00:00 2001 From: msvinaykumar Date: Thu, 12 Oct 2023 18:36:20 +0530 Subject: [PATCH 4/5] stage test debug changes Signed-off-by: msvinaykumar --- .../services/UpdateRecommendations.java | 23 ++++++++++--------- .../analyzer/services/UpdateResults.java | 14 +++++------ 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/src/main/java/com/autotune/analyzer/services/UpdateRecommendations.java b/src/main/java/com/autotune/analyzer/services/UpdateRecommendations.java index 9c63a3605..bd04ddfd3 100644 --- a/src/main/java/com/autotune/analyzer/services/UpdateRecommendations.java +++ b/src/main/java/com/autotune/analyzer/services/UpdateRecommendations.java @@ -66,6 +66,7 @@ public class UpdateRecommendations extends HttpServlet { private static final long serialVersionUID = 1L; private static final Logger LOGGER = LoggerFactory.getLogger(UpdateRecommendations.class); private static int requestCount = 0; + @Override public void init(ServletConfig config) throws ServletException { super.init(config); @@ -86,8 +87,8 @@ public void init(ServletConfig config) throws ServletException { */ @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - int calCount = requestCount++ ; - LOGGER.debug("UpdateRecommendations API request count: {}" , calCount); + int calCount = requestCount++; + LOGGER.debug("UpdateRecommendations API request count: {}", calCount); String statusValue = "failure"; Timer.Sample timerBUpdateRecommendations = Timer.start(MetricsConfig.meterRegistry()); try { @@ -151,7 +152,7 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response) } } } - LOGGER.debug("UpdateRecommendations API request count: {} experiment_name : {} and interval_start_time : {} and interval_end_time : {} " , calCount , experiment_name, intervalStartTimeStr, intervalEndTimeStr); + LOGGER.debug("UpdateRecommendations API request count: {} experiment_name : {} and interval_start_time : {} and interval_end_time : {} ", calCount, experiment_name, intervalStartTimeStr, intervalEndTimeStr); LOGGER.debug("experiment_name : {} and interval_start_time : {} and interval_end_time : {} ", experiment_name, intervalStartTimeStr, intervalEndTimeStr); List experimentResultDataList = new ArrayList<>(); @@ -166,12 +167,12 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response) if (null != kruizeObject) experimentResultDataList = new ExperimentDBService().getExperimentResultData(experiment_name, kruizeObject, interval_start_time, interval_end_time); // Todo this object is not required else { - LOGGER.debug("UpdateRecommendations API request count: {} failed" , calCount); + LOGGER.debug("UpdateRecommendations API request count: {} failed", calCount); sendErrorResponse(response, null, HttpServletResponse.SC_BAD_REQUEST, String.format("%s%s", MISSING_EXPERIMENT_NAME, experiment_name)); return; } } catch (Exception e) { - LOGGER.debug("UpdateRecommendations API request count: {} failed" , calCount); + LOGGER.debug("UpdateRecommendations API request count: {} failed", calCount); sendErrorResponse(response, e, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage()); return; } @@ -182,15 +183,15 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response) new ExperimentInitiator().generateAndAddRecommendations(kruizeObject, experimentResultDataList, interval_start_time, interval_end_time); // TODO: experimentResultDataList not required ValidationOutputData validationOutputData = new ExperimentDBService().addRecommendationToDB(mainKruizeExperimentMAP, experimentResultDataList); if (validationOutputData.isSuccess()) { - LOGGER.debug("UpdateRecommendations API request count: {} success" , calCount); + LOGGER.debug("UpdateRecommendations API request count: {} success", calCount); sendSuccessResponse(response, kruizeObject, interval_end_time); statusValue = "success"; } else { - LOGGER.debug("UpdateRecommendations API request count: {} failed" , calCount); + LOGGER.debug("UpdateRecommendations API request count: {} failed", calCount); sendErrorResponse(response, null, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, validationOutputData.getMessage()); } } catch (Exception e) { - LOGGER.debug("UpdateRecommendations API request count: {} failed" , calCount); + LOGGER.debug("UpdateRecommendations API request count: {} failed", calCount); e.printStackTrace(); LOGGER.error("Failed to create recommendation for experiment: {} and interval_start_time: {} and interval_end_time: {}", experiment_name, @@ -201,17 +202,17 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response) } } else { - LOGGER.debug("UpdateRecommendations API request count: {} failed" , calCount); + LOGGER.debug("UpdateRecommendations API request count: {} failed", calCount); sendErrorResponse(response, null, HttpServletResponse.SC_BAD_REQUEST, String.format("%s%s", MISSING_INTERVAL_END_TIME, intervalEndTimeStr)); return; } } catch (Exception e) { - LOGGER.debug("UpdateRecommendations API request count: {} failed" , calCount); + LOGGER.debug("UpdateRecommendations API request count: {} failed", calCount); LOGGER.error("Exception: " + e.getMessage()); e.printStackTrace(); sendErrorResponse(response, e, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage()); } finally { - LOGGER.debug("UpdateRecommendations API request count: {} completed" , calCount); + LOGGER.debug("UpdateRecommendations API request count: {} completed", calCount); if (null != timerBUpdateRecommendations) { MetricsConfig.timerUpdateRecomendations = MetricsConfig.timerBUpdateRecommendations.tag("status", statusValue).register(MetricsConfig.meterRegistry()); timerBUpdateRecommendations.stop(MetricsConfig.timerUpdateRecomendations); diff --git a/src/main/java/com/autotune/analyzer/services/UpdateResults.java b/src/main/java/com/autotune/analyzer/services/UpdateResults.java index 5a1650869..61741c0cf 100644 --- a/src/main/java/com/autotune/analyzer/services/UpdateResults.java +++ b/src/main/java/com/autotune/analyzer/services/UpdateResults.java @@ -66,15 +66,15 @@ public void init(ServletConfig config) throws ServletException { @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { int calCount = requestCount++; - LOGGER.debug("updateResults API request count: {}" , calCount); + LOGGER.debug("updateResults API request count: {}", calCount); String statusValue = "failure"; Timer.Sample timerUpdateResults = Timer.start(MetricsConfig.meterRegistry()); try { String inputData = request.getReader().lines().collect(Collectors.joining()); - LOGGER.debug("updateResults API request payload for requestID {} is {}",calCount,inputData); + LOGGER.debug("updateResults API request payload for requestID {} is {}", calCount, inputData); List experimentResultDataList = new ArrayList<>(); List updateResultsAPIObjects = Arrays.asList(new Gson().fromJson(inputData, UpdateResultsAPIObject[].class)); - LOGGER.debug("updateResults API request payload for requestID {} bulk count is {}",calCount,updateResultsAPIObjects.size()); + LOGGER.debug("updateResults API request payload for requestID {} bulk count is {}", calCount, updateResultsAPIObjects.size()); // check for bulk entries and respond accordingly if (updateResultsAPIObjects.size() > KruizeDeploymentInfo.bulk_update_results_limit) { LOGGER.error(AnalyzerErrorConstants.AutotuneObjectErrors.UNSUPPORTED_EXPERIMENT_RESULTS); @@ -102,20 +102,20 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response) ); request.setAttribute("data", jsonObjectList); String errorMessage = String.format("Out of a total of %s records, %s failed to save", updateResultsAPIObjects.size(), failureAPIObjs.size()); - LOGGER.debug("updateResults API request payload for requestID {} failed",calCount); + LOGGER.debug("updateResults API request payload for requestID {} failed", calCount); sendErrorResponse(request, response, null, HttpServletResponse.SC_BAD_REQUEST, errorMessage); } else { - LOGGER.debug("updateResults API request payload for requestID {} success",calCount); + LOGGER.debug("updateResults API request payload for requestID {} success", calCount); sendSuccessResponse(response, AnalyzerConstants.ServiceConstants.RESULT_SAVED); statusValue = "success"; } } catch (Exception e) { - LOGGER.debug("updateResults API request payload for requestID {} failed",calCount); + LOGGER.debug("updateResults API request payload for requestID {} failed", calCount); LOGGER.error("Exception: " + e.getMessage()); e.printStackTrace(); sendErrorResponse(request, response, e, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage()); } finally { - LOGGER.debug("updateResults API request payload for requestID {} completed",calCount); + LOGGER.debug("updateResults API request payload for requestID {} completed", calCount); if (null != timerUpdateResults) { MetricsConfig.timerUpdateResults = MetricsConfig.timerBUpdateResults.tag("status", statusValue).register(MetricsConfig.meterRegistry()); timerUpdateResults.stop(MetricsConfig.timerUpdateResults); From 9f5b65ef033cf160cd53f4539062ef64a80b9d52 Mon Sep 17 00:00:00 2001 From: msvinaykumar Date: Thu, 12 Oct 2023 18:38:11 +0530 Subject: [PATCH 5/5] stage test debug changes Signed-off-by: msvinaykumar --- .../com/autotune/analyzer/services/UpdateRecommendations.java | 2 +- src/main/java/com/autotune/analyzer/services/UpdateResults.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/autotune/analyzer/services/UpdateRecommendations.java b/src/main/java/com/autotune/analyzer/services/UpdateRecommendations.java index bd04ddfd3..f4963448a 100644 --- a/src/main/java/com/autotune/analyzer/services/UpdateRecommendations.java +++ b/src/main/java/com/autotune/analyzer/services/UpdateRecommendations.java @@ -87,7 +87,7 @@ public void init(ServletConfig config) throws ServletException { */ @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - int calCount = requestCount++; + int calCount = ++requestCount; LOGGER.debug("UpdateRecommendations API request count: {}", calCount); String statusValue = "failure"; Timer.Sample timerBUpdateRecommendations = Timer.start(MetricsConfig.meterRegistry()); diff --git a/src/main/java/com/autotune/analyzer/services/UpdateResults.java b/src/main/java/com/autotune/analyzer/services/UpdateResults.java index 61741c0cf..c923e924e 100644 --- a/src/main/java/com/autotune/analyzer/services/UpdateResults.java +++ b/src/main/java/com/autotune/analyzer/services/UpdateResults.java @@ -65,7 +65,7 @@ public void init(ServletConfig config) throws ServletException { @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - int calCount = requestCount++; + int calCount = ++requestCount; LOGGER.debug("updateResults API request count: {}", calCount); String statusValue = "failure"; Timer.Sample timerUpdateResults = Timer.start(MetricsConfig.meterRegistry());