Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stage test debug changes #985

Merged
merged 5 commits into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,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 {
Expand All @@ -75,7 +76,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
Expand All @@ -85,6 +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);
String statusValue = "failure";
Timer.Sample timerBUpdateRecommendations = Timer.start(MetricsConfig.meterRegistry());
try {
Expand Down Expand Up @@ -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<ExperimentResultData> experimentResultDataList = new ArrayList<>();
Expand All @@ -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;
}
Expand All @@ -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,
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, PerformanceProfile> performanceProfilesMap = new ConcurrentHashMap<>();
private static int requestCount = 0;

@Override
public void init(ServletConfig config) throws ServletException {
Expand All @@ -64,12 +65,16 @@ 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);
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<ExperimentResultData> experimentResultDataList = new ArrayList<>();
List<UpdateResultsAPIObject> 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);
Expand Down Expand Up @@ -97,16 +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);
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);
Expand Down
Loading