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

Add new APIs for recommendations summary at Clusters and Namespaces level #893

Closed
wants to merge 23 commits into from
Closed
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
2380d56
add listClusters API
khansaad Jul 14, 2023
e7c13f2
add summarize API(in-progress), add corr. API object, add common meth…
khansaad Jul 26, 2023
3f13a2b
Merge remote-tracking branch 'upstream/mvp_demo' into add_cluster_apis
khansaad Jul 26, 2023
07737af
fix NPE, add variation logic
khansaad Jul 26, 2023
bc17b4b
update logic to sum up the recommendations data, notifications-summar…
khansaad Aug 1, 2023
1d2d8ed
add workloads class, validation for wrong params, refactoring, etc
khansaad Aug 2, 2023
bdb91c2
Merge remote-tracking branch 'upstream/mvp_demo' into add_cluster_apis
khansaad Aug 7, 2023
4e8d755
update logic to fix the json response issue, temporarily fetching all…
khansaad Aug 7, 2023
6aea0d6
update DB query to fetch data from the DB, fix duplicate records with…
khansaad Aug 9, 2023
bd8561e
Merge remote-tracking branch 'upstream/mvp_demo' into add_cluster_apis
khansaad Aug 11, 2023
0e440c2
updated logic to improve DB response time
khansaad Aug 13, 2023
3c50de6
Merge remote-tracking branch 'upstream/mvp_demo' into add_cluster_apis
khansaad Aug 13, 2023
44152c5
handle case when current config is missing, add more try-catch blocks
khansaad Aug 14, 2023
912046c
add ActionSummary object to classify the workloads, add 'fetchFromDB'…
khansaad Aug 16, 2023
7b6e852
Merge remote-tracking branch 'upstream/mvp_demo' into add_cluster_apis
khansaad Aug 17, 2023
9d5faad
Merge remote-tracking branch 'upstream/mvp_demo' into add_cluster_apis
khansaad Aug 23, 2023
66618a7
fix issues with variation and total DB count, API objects names. Adde…
khansaad Aug 28, 2023
82ddd0c
fix issues reported in testing related to caching and JSON structure
khansaad Aug 28, 2023
1f1f8d0
add missed javadocs for new classes and methods and other changes as …
khansaad Aug 29, 2023
6a68292
minor update to change info object name
khansaad Aug 30, 2023
33bcb0e
Merge remote-tracking branch 'upstream/mvp_demo' into add_cluster_apis
khansaad Sep 6, 2023
62f5071
Merge remote-tracking branch 'upstream/mvp_demo' into add_cluster_apis
khansaad Sep 26, 2023
b189df5
changes made wrt the new listRecommendation API and minor refactoring
khansaad Sep 29, 2023
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
2 changes: 2 additions & 0 deletions src/main/java/com/autotune/analyzer/Analyzer.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ public static void addServlets(ServletContextHandler context) {
context.addServlet(ListRecommendations.class, ServerContext.RECOMMEND_RESULTS);
context.addServlet(PerformanceProfileService.class, ServerContext.CREATE_PERF_PROFILE);
context.addServlet(PerformanceProfileService.class, ServerContext.LIST_PERF_PROFILES);
context.addServlet(ListClusters.class, ServerContext.LIST_CLUSTER_NAMES);
context.addServlet(Summarize.class, ServerContext.SUMMARIZE);

// Adding UI support API's
context.addServlet(ListNamespaces.class, ServerContext.LIST_NAMESPACES);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ public String toString() {
", confidence_level=" + confidence_level +
", config=" + config +
", current=" + currentConfig +
", variation=" + variation +
", notifications=" + notifications +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ public RecommendationConfigItem() {

}

public RecommendationConfigItem(Double amount) {
this.amount = amount;
}
public String getErrorMsg() {
return errorMsg;
}
Expand All @@ -48,4 +51,21 @@ public Double getAmount() {
public String getFormat() {
return format;
}

public void setAmount(Double amount) {
this.amount = amount;
}

public void setFormat(String format) {
this.format = format;
}

@Override
public String toString() {
return "RecommendationConfigItem{" +
"amount=" + amount +
", format='" + format + '\'' +
", errorMsg='" + errorMsg + '\'' +
'}';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
/*******************************************************************************
* Copyright (c) 2023 Red Hat, IBM Corporation and others.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/

package com.autotune.analyzer.recommendations.summary;

import com.autotune.analyzer.utils.AnalyzerConstants;
import com.autotune.utils.KruizeConstants;
import com.google.gson.annotations.SerializedName;

import java.util.HashMap;

public class ActionSummary {
@SerializedName(KruizeConstants.JSONKeys.IDLE)
private HashMap<AnalyzerConstants.ActionSummaryRecommendationItem, ResourceInfo> idle;
@SerializedName(KruizeConstants.JSONKeys.OPTIMIZED)
private HashMap<AnalyzerConstants.ActionSummaryRecommendationItem, ResourceInfo> optimized;
@SerializedName(KruizeConstants.JSONKeys.CRITICAL)
private HashMap<AnalyzerConstants.ActionSummaryRecommendationItem, ResourceInfo> critical;
@SerializedName(KruizeConstants.JSONKeys.OPTIMIZABLE)
private HashMap<AnalyzerConstants.ActionSummaryRecommendationItem, ResourceInfo> optimizable;
@SerializedName(KruizeConstants.JSONKeys.ERROR)
private HashMap<AnalyzerConstants.ActionSummaryRecommendationItem, ResourceInfo> error;
@SerializedName(KruizeConstants.JSONKeys.INFO)
private HashMap<AnalyzerConstants.ActionSummaryRecommendationItem, ResourceInfo> info;
@SerializedName(KruizeConstants.JSONKeys.TOTAL)
private HashMap<AnalyzerConstants.ActionSummaryRecommendationItem, ResourceInfo> total;

public ActionSummary() {
this.idle = new HashMap<>();
this.optimized = new HashMap<>();
this.critical = new HashMap<>();
this.optimizable = new HashMap<>();
this.error = new HashMap<>();
this.info = new HashMap<>();
this.total = new HashMap<>();
}

public HashMap<AnalyzerConstants.ActionSummaryRecommendationItem, ResourceInfo> getIdle() {
return idle;
}

public void setIdle(HashMap<AnalyzerConstants.ActionSummaryRecommendationItem, ResourceInfo> idle) {
this.idle = idle;
}

public HashMap<AnalyzerConstants.ActionSummaryRecommendationItem, ResourceInfo> getOptimized() {
return optimized;
}

public void setOptimized(HashMap<AnalyzerConstants.ActionSummaryRecommendationItem, ResourceInfo> optimized) {
this.optimized = optimized;
}

public HashMap<AnalyzerConstants.ActionSummaryRecommendationItem, ResourceInfo> getCritical() {
return critical;
}

public void setCritical(HashMap<AnalyzerConstants.ActionSummaryRecommendationItem, ResourceInfo> critical) {
this.critical = critical;
}

public HashMap<AnalyzerConstants.ActionSummaryRecommendationItem, ResourceInfo> getOptimizable() {
return optimizable;
}

public void setOptimizable(HashMap<AnalyzerConstants.ActionSummaryRecommendationItem, ResourceInfo> optimizable) {
this.optimizable = optimizable;
}

public HashMap<AnalyzerConstants.ActionSummaryRecommendationItem, ResourceInfo> getError() {
return error;
}

public void setError(HashMap<AnalyzerConstants.ActionSummaryRecommendationItem, ResourceInfo> error) {
this.error = error;
}

public HashMap<AnalyzerConstants.ActionSummaryRecommendationItem, ResourceInfo> getInfo() {
return info;
}

public void setInfo(HashMap<AnalyzerConstants.ActionSummaryRecommendationItem, ResourceInfo> info) {
this.info = info;
}

public HashMap<AnalyzerConstants.ActionSummaryRecommendationItem, ResourceInfo> getTotal() {
return total;
}

public void setTotal(HashMap<AnalyzerConstants.ActionSummaryRecommendationItem, ResourceInfo> total) {
this.total = total;
}

public ActionSummary merge(ActionSummary other) {
mergeMap(idle, other.getIdle());
mergeMap(optimized, other.getOptimized());
mergeMap(critical, other.getCritical());
mergeMap(optimizable, other.getOptimizable());
mergeMap(error, other.getError());
mergeMap(info, other.getInfo());
mergeMap(total, other.getTotal());
return this;
}

private void mergeMap(HashMap<AnalyzerConstants.ActionSummaryRecommendationItem, ResourceInfo> original, HashMap<AnalyzerConstants.ActionSummaryRecommendationItem, ResourceInfo> toMerge) {
for (HashMap.Entry<AnalyzerConstants.ActionSummaryRecommendationItem, ResourceInfo> entry : toMerge.entrySet()) {
AnalyzerConstants.ActionSummaryRecommendationItem key = entry.getKey();
ResourceInfo value = entry.getValue();

ResourceInfo originalValue = original.get(key);
if (originalValue == null) {
original.put(key, value);
} else {
originalValue.setCount(originalValue.getCount() + value.getCount());
originalValue.getWorkloadNames().addAll(value.getWorkloadNames());
}
}
}
@Override
public String toString() {
return "ActionSummary{" +
"idle=" + idle +
", optimized=" + optimized +
", critical=" + critical +
", optimizable=" + optimizable +
", error=" + error +
", info=" + info +
", total=" + total +
'}';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/*******************************************************************************
* Copyright (c) 2023 Red Hat, IBM Corporation and others.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/

package com.autotune.analyzer.recommendations.summary;

public class NotificationsSummary {

private int info;

private int notice;

private int warning;

private int error;

private int critical;

public int getInfo() {
return info;
}

public void setInfo(int info) {
this.info = info;
}

public int getNotice() {
return notice;
}

public void setNotice(int notice) {
this.notice = notice;
}

public int getWarning() {
return warning;
}

public void setWarning(int warning) {
this.warning = warning;
}

public int getError() {
return error;
}

public void setError(int error) {
this.error = error;
}

public int getCritical() {
return critical;
}

public void setCritical(int critical) {
this.critical = critical;
}

public NotificationsSummary mergeNotificationsSummary(NotificationsSummary notifications1, NotificationsSummary notifications2) {

int infoCount = notifications1.getInfo() + notifications2.getInfo();
int noticeCount = notifications1.getNotice() + notifications2.getNotice();
int warningCount = notifications1.getWarning() + notifications2.getWarning();
int errorCount = notifications1.getError() + notifications2.getError();
int criticalCount = notifications1.getCritical() + notifications2.getCritical();

NotificationsSummary mergedSummary = new NotificationsSummary();
mergedSummary.setInfo(infoCount);
mergedSummary.setNotice(noticeCount);
mergedSummary.setWarning(warningCount);
mergedSummary.setError(errorCount);
mergedSummary.setCritical(criticalCount);
return mergedSummary;
}
@Override
public String toString() {
return "NotificationsSummary{" +
"info=" + info +
", notice=" + notice +
", warning=" + warning +
", error=" + error +
", critical=" + critical +
'}';
}
}
Loading
Loading