-
Notifications
You must be signed in to change notification settings - Fork 56
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
[WIP] Adds cluster_name parameter to listRecommendations API #944
[WIP] Adds cluster_name parameter to listRecommendations API #944
Conversation
2a4d524
to
214e623
Compare
@@ -145,7 +146,60 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) t | |||
String.format(AnalyzerErrorConstants.APIErrors.ListRecommendationsAPI.INVALID_EXPERIMENT_NAME_MSG, experimentName) | |||
); | |||
} | |||
} else { | |||
}else if(null != clusterName){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should be space after braces and Parantheses
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
try { | ||
new ExperimentDBService().loadExperimentsAndRecommendationsFromDBByClusterName(mKruizeExperimentMap, clusterName); | ||
} catch (Exception e) { | ||
LOGGER.error("Loading saved cluster {} failed: {} ", clusterName, e.getMessage()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Error message should be:
LOGGER.error("Loading experiments and recommendations based on cluster {} failed: {} ", clusterName, e.getMessage());
String.format(AnalyzerErrorConstants.APIErrors.ListRecommendationsAPI.INVALID_CLUSTER_NAME_MSG, clusterName) | ||
); | ||
} | ||
}else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add Space here as well and re-check all other places
List<KruizeResultsEntry> loadResultsByExperimentName(String experimentName, String cluster_name, Timestamp interval_start_time, Integer limitRows) throws Exception; | ||
|
||
// Load all results for a particular clusterName | ||
List<KruizeResultsEntry> loadResultsByClusterName(String clusterName, Timestamp interval_start_time, Integer limitRows) throws Exception; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method is not required. You can remove this.
.setParameter("clusterName", clusterName).list(); | ||
statusValue = "success"; | ||
} catch (Exception e) { | ||
LOGGER.error("Not able to load cluster {} due to {}", clusterName, e.getMessage()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change the Logger error message here as well as per the changes I suggested above.
@@ -498,6 +520,36 @@ public List<KruizeResultsEntry> loadResultsByExperimentName(String experimentNam | |||
} | |||
return kruizeResultsEntries; | |||
} | |||
@Override | |||
public List<KruizeResultsEntry> loadResultsByClusterName(String clusterName, Timestamp interval_end_time, Integer limitRows) throws Exception { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this whole implementation as well, we aren't using this anywhere.
@@ -23,8 +24,11 @@ public static final class SQLQUERY { | |||
KruizeConstants.JSONKeys.CLUSTER_NAME, KruizeConstants.JSONKeys.EXPERIMENT_NAME, KruizeConstants.JSONKeys.INTERVAL_START_TIME, KruizeConstants.JSONKeys.INTERVAL_END_TIME); | |||
public static final String SELECT_FROM_RESULTS_BY_EXP_NAME_AND_END_TIME = String.format("from KruizeResultsEntry k WHERE k.cluster_name = :%s and k.experiment_name = :%s and k.interval_end_time = :%s", KruizeConstants.JSONKeys.CLUSTER_NAME, KruizeConstants.JSONKeys.EXPERIMENT_NAME, KruizeConstants.JSONKeys.INTERVAL_END_TIME); | |||
public static final String SELECT_FROM_RESULTS_BY_EXP_NAME_AND_MAX_END_TIME = String.format("from KruizeResultsEntry k WHERE k.cluster_name = :%s and k.experiment_name = :%s and k.interval_end_time = (SELECT MAX(e.interval_end_time) FROM KruizeResultsEntry e where e.experiment_name = :%s )", KruizeConstants.JSONKeys.CLUSTER_NAME, KruizeConstants.JSONKeys.EXPERIMENT_NAME, KruizeConstants.JSONKeys.EXPERIMENT_NAME); | |||
public static final String SELECT_FROM_RESULTS_BY_CLUSTER_NAME = "from KruizeResultsEntry k WHERE k.cluster_name = :clusterName"; | |||
public static final String SELECT_FROM_RESULTS_BY_CLUSTER_NAME_AND_DATE_RANGE = String.format("from KruizeResultsEntry k WHERE k.cluster_name = :%s and k.interval_end_time <= :%s ORDER BY k.interval_end_time DESC", KruizeConstants.JSONKeys.CLUSTER_NAME, KruizeConstants.JSONKeys.INTERVAL_END_TIME, KruizeConstants.JSONKeys.INTERVAL_START_TIME); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both of these constants can be removed as well
@@ -189,6 +189,53 @@ public void loadRecommendationsFromDBByName(Map<String, KruizeObject> mainKruize | |||
} | |||
} | |||
} | |||
// Todo - confirm if experimentResultData to be changed to clusterResultData | |||
public void loadResultsFromDBByClusterName(Map<String, KruizeObject> mainKruizeExperimentMap, String clusterName, Timestamp interval_end_time, Integer limitRows) throws Exception { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method isn't required as well, can be removed.
} | ||
} | ||
if (failureThreshHold > 0 && failureCount == failureThreshHold) { | ||
throw new Exception("Experiments of cluster " + clusterName + " unable to load from DB."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change this exception message so that it makes more sense
@@ -313,6 +388,16 @@ public void loadExperimentAndRecommendationsFromDBByName(Map<String, KruizeObjec | |||
loadRecommendationsFromDBByName(mainKruizeExperimentMap, experimentName); | |||
} | |||
|
|||
public void loadExperimentsAndResultsFromDBByClusterName(Map<String, KruizeObject> mainKruizeExperimentMap, String clusterName) throws Exception { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this as well.
5dc255e
to
117fa52
Compare
@khansaad - I have incorporated review comments and rebased branch 'add_clusterName_parameter' onto 'mvp_demo'. |
Closing stale PRs |
This PR fixes #940
/listRecommendations
API by addingcluster_name
query parameter to retrieve recommendations for a specific cluster based on its name