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

Rename duration based to cost #903

Merged
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__pycache__/
108 changes: 54 additions & 54 deletions design/APISamples.md

Large diffs are not rendered by default.

28 changes: 14 additions & 14 deletions design/MonitoringModeAPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -943,13 +943,13 @@ Returns the latest recommendations of all the experiments
"notifications": {
"112101": {
"type": "info",
"message": "Duration Based Recommendations Available",
"message": "Cost Recommendations Available",
"code": 112101
}
},
"data": {
"2023-04-02T08:00:00.680Z": {
"duration_based": {
"cost": {
"short_term": {
"monitoring_start_time": "2023-04-01T06:45:00.000Z",
"monitoring_end_time": "2023-04-02T08:00:00.680Z",
Expand Down Expand Up @@ -1202,13 +1202,13 @@ Returns all the recommendations of all the experiments
"notifications": {
"112101": {
"type": "info",
"message": "Duration Based Recommendations Available",
"message": "Cost Recommendations Available",
"code": 112101
}
},
"data": {
"2023-04-02T06:00:00.770Z": {
"duration_based": {
"cost": {
"short_term": {
"monitoring_start_time": "2023-04-01T04:45:00.000Z",
"monitoring_end_time": "2023-04-02T06:00:00.770Z",
Expand Down Expand Up @@ -1311,7 +1311,7 @@ Returns all the recommendations of all the experiments
...
...
"2023-04-02T04:30:00.000Z": {
"duration_based": {
"cost": {
"short_term": {
"monitoring_start_time": "2023-04-01T03:15:00.000Z",
"monitoring_end_time": "2023-04-02T04:30:00.000Z",
Expand Down Expand Up @@ -1558,13 +1558,13 @@ If no parameter is passed API returns all the latest recommendations available f
"notifications": {
"112101": {
"type": "info",
"message": "Duration Based Recommendations Available",
"message": "Cost Recommendations Available",
"code": 112101
}
},
"data": {
"2022-12-21T00:40:17.000Z": {
"duration_based": {
"cost": {
"short_term": {
"monitoring_start_time": "2022-12-20T00:40:17.000Z",
"monitoring_end_time": "2022-12-21T00:40:17.000Z",
Expand Down Expand Up @@ -1718,13 +1718,13 @@ Returns the latest result of that experiment
"notifications": {
"112101": {
"type": "info",
"message": "Duration Based Recommendations Available",
"message": "Cost Recommendations Available",
"code": 112101
}
},
"data": {
"2022-12-21T00:40:17.000Z": {
"duration_based": {
"cost": {
"short_term": {
"monitoring_start_time": "2022-12-20T00:40:17.000Z",
"monitoring_end_time": "2022-12-21T00:40:17.000Z",
Expand Down Expand Up @@ -1877,13 +1877,13 @@ Returns all the results of that experiment
"notifications": {
"112101": {
"type": "info",
"message": "Duration Based Recommendations Available",
"message": "Cost Recommendations Available",
"code": 112101
}
},
"data": {
"2022-12-20T17:55:05.000Z": {
"duration_based": {
"cost": {
"short_term": {
"monitoring_start_time": "2022-12-19T17:55:05.000Z",
"monitoring_end_time": "2022-12-20T17:55:05.000Z",
Expand Down Expand Up @@ -1983,7 +1983,7 @@ Returns all the results of that experiment
}
},
"2022-12-21T00:10:16.000Z": {
"duration_based": {
"cost": {
"short_term": {
"monitoring_start_time": "2022-12-20T00:10:16.000Z",
"monitoring_end_time": "2022-12-21T00:10:16.000Z",
Expand Down Expand Up @@ -2138,13 +2138,13 @@ Time - `2022-12-20T17:55:05.000Z`**
"notifications": {
"112101": {
"type": "info",
"message": "Duration Based Recommendations Available",
"message": "Cost Recommendations Available",
"code": 112101
}
},
"data": {
"2022-12-20T17:55:05.000Z": {
"duration_based": {
"cost": {
"short_term": {
"monitoring_start_time": "2022-12-19T17:55:05.000Z",
"monitoring_end_time": "2022-12-20T17:55:05.000Z",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import com.autotune.analyzer.recommendations.Recommendation;
import com.autotune.analyzer.recommendations.RecommendationConstants;
import com.autotune.analyzer.recommendations.RecommendationNotification;
import com.autotune.analyzer.recommendations.engine.DurationBasedRecommendationEngine;
import com.autotune.analyzer.recommendations.engine.CostRecommendationEngine;
import com.autotune.analyzer.recommendations.engine.KruizeRecommendationEngine;
import com.autotune.analyzer.utils.AnalyzerConstants;
import com.autotune.common.data.result.ContainerData;
Expand Down Expand Up @@ -54,9 +54,9 @@ private void init() {
// Add new engines
kruizeRecommendationEngineList = new ArrayList<KruizeRecommendationEngine>();
// Create Duration based engine
DurationBasedRecommendationEngine durationBasedRecommendationEngine = new DurationBasedRecommendationEngine();
CostRecommendationEngine costRecommendationEngine = new CostRecommendationEngine();
// TODO: Create profile based engine
AnalyzerConstants.RegisterRecommendationEngineStatus _unused_status = registerEngine(durationBasedRecommendationEngine);
AnalyzerConstants.RegisterRecommendationEngineStatus _unused_status = registerEngine(costRecommendationEngine);
// TODO: Add profile based once recommendation algos are available
}

Expand Down Expand Up @@ -141,13 +141,13 @@ public void generateRecommendation(KruizeObject kruizeObject, List<ExperimentRes
}
// check if notification exists
boolean notificationExist = false;
if (containerRecommendations.getNotificationMap().containsKey(RecommendationConstants.NotificationCodes.INFO_DURATION_BASED_RECOMMENDATIONS_AVAILABLE))
if (containerRecommendations.getNotificationMap().containsKey(RecommendationConstants.NotificationCodes.INFO_COST_RECOMMENDATIONS_AVAILABLE))
notificationExist = true;

// If there is no notification add one
if (!notificationExist) {
RecommendationNotification recommendationNotification = new RecommendationNotification(
RecommendationConstants.RecommendationNotification.INFO_DURATION_BASED_RECOMMENDATIONS_AVAILABLE
RecommendationConstants.RecommendationNotification.INFO_COST_RECOMMENDATIONS_AVAILABLE
);
containerRecommendations.getNotificationMap().put(recommendationNotification.getCode(), recommendationNotification);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*******************************************************************************/
package com.autotune.analyzer.recommendations;

import com.autotune.analyzer.recommendations.subCategory.DurationBasedRecommendationSubCategory;
import com.autotune.analyzer.recommendations.subCategory.CostRecommendationSubCategory;
import com.autotune.analyzer.recommendations.subCategory.RecommendationSubCategory;
import com.autotune.common.data.result.IntervalResults;
import com.autotune.common.data.result.ContainerData;
Expand Down Expand Up @@ -59,11 +59,11 @@ public static void generateRecommendation(KruizeObject kruizeObject) {
HashMap<String, Recommendation> recommendationPeriodMap = new HashMap<>();
// TODO: Add all possible cases which are added in RecommendationCategory
switch (recommendationCategory) {
case DURATION_BASED:
case COST:
for (RecommendationSubCategory recommendationSubCategory : recommendationCategory.getRecommendationSubCategories()) {
DurationBasedRecommendationSubCategory durationBasedRecommendationSubCategory = (DurationBasedRecommendationSubCategory) recommendationSubCategory;
String recPeriod = durationBasedRecommendationSubCategory.getSubCategory();
int days = durationBasedRecommendationSubCategory.getDuration();
CostRecommendationSubCategory costRecommendationSubCategory = (CostRecommendationSubCategory) recommendationSubCategory;
String recPeriod = costRecommendationSubCategory.getSubCategory();
int days = costRecommendationSubCategory.getDuration();
monitorStartDate = addDays(monitorEndDate, -1 * days);
if (monitorStartDate.compareTo(minDate) >= 0 || days == 1) {
Timestamp finalMonitorStartDate = monitorStartDate;
Expand Down Expand Up @@ -97,11 +97,11 @@ public static void generateRecommendation(KruizeObject kruizeObject) {
// This needs to be moved to common area after implementing other categories of recommedations
recCatMap.put(recommendationCategory.getName(), recommendationPeriodMap);
boolean notifyExist = false;
if (containerData.getContainerRecommendations().getNotificationMap().containsKey(RecommendationConstants.NotificationCodes.INFO_DURATION_BASED_RECOMMENDATIONS_AVAILABLE))
if (containerData.getContainerRecommendations().getNotificationMap().containsKey(RecommendationConstants.NotificationCodes.INFO_COST_RECOMMENDATIONS_AVAILABLE))
notifyExist = true;
if (!notifyExist) {
RecommendationNotification recommendationNotification = new RecommendationNotification(
RecommendationConstants.RecommendationNotification.INFO_DURATION_BASED_RECOMMENDATIONS_AVAILABLE
RecommendationConstants.RecommendationNotification.INFO_COST_RECOMMENDATIONS_AVAILABLE
);
containerData.getContainerRecommendations().getNotificationMap().put(recommendationNotification.getCode(), recommendationNotification);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.autotune.analyzer.recommendations;

import com.autotune.analyzer.recommendations.subCategory.DurationBasedRecommendationSubCategory;
import com.autotune.analyzer.recommendations.subCategory.CostRecommendationSubCategory;
import com.autotune.analyzer.recommendations.subCategory.RecommendationSubCategory;
import com.autotune.utils.KruizeConstants;

Expand All @@ -12,10 +12,10 @@
public class RecommendationConstants {

public enum RecommendationCategory {
DURATION_BASED(
KruizeConstants.JSONKeys.DURATION_BASED,
new DurationBasedRecommendationSubCategory[]{
new DurationBasedRecommendationSubCategory(
COST(
KruizeConstants.JSONKeys.COST,
new CostRecommendationSubCategory[]{
new CostRecommendationSubCategory(
KruizeConstants.JSONKeys.SHORT_TERM,
KruizeConstants.RecommendationEngineConstants
.DurationBasedEngine.DurationAmount.SHORT_TERM_DURATION_DAYS,
Expand All @@ -27,7 +27,7 @@ public enum RecommendationCategory {
.DurationBasedEngine.RecommendationDurationRanges
.SHORT_TERM_TOTAL_DURATION_LOWER_BOUND_MINS
),
new DurationBasedRecommendationSubCategory(
new CostRecommendationSubCategory(
KruizeConstants.JSONKeys.MEDIUM_TERM,
KruizeConstants.RecommendationEngineConstants
.DurationBasedEngine.DurationAmount.MEDIUM_TERM_DURATION_DAYS,
Expand All @@ -39,7 +39,7 @@ public enum RecommendationCategory {
.DurationBasedEngine.RecommendationDurationRanges
.MEDIUM_TERM_TOTAL_DURATION_LOWER_BOUND_MINS
),
new DurationBasedRecommendationSubCategory(
new CostRecommendationSubCategory(
KruizeConstants.JSONKeys.LONG_TERM,
KruizeConstants.RecommendationEngineConstants
.DurationBasedEngine.DurationAmount.LONG_TERM_DURATION_DAYS,
Expand Down Expand Up @@ -96,9 +96,9 @@ public int getSeverity() {
}
}
public enum RecommendationNotification {
INFO_DURATION_BASED_RECOMMENDATIONS_AVAILABLE(
RecommendationConstants.NotificationCodes.INFO_DURATION_BASED_RECOMMENDATIONS_AVAILABLE,
RecommendationConstants.RecommendationNotificationMsgConstant.DURATION_BASED_RECOMMENDATIONS_AVAILABLE,
INFO_COST_RECOMMENDATIONS_AVAILABLE(
RecommendationConstants.NotificationCodes.INFO_COST_RECOMMENDATIONS_AVAILABLE,
RecommendationConstants.RecommendationNotificationMsgConstant.COST_RECOMMENDATIONS_AVAILABLE,
RecommendationConstants.RecommendationNotificationTypes.INFO
),
INFO_NOT_ENOUGH_DATA(
Expand Down Expand Up @@ -288,11 +288,11 @@ private NotificationCodes() {

// Subsystem subsection: Default Engine
// Range: 112000 - 112099
// Subsystem subsection: Duration Based Engine
// Subsystem subsection: Cost Engine
// Range: 112100 - 112199
public static final int DURATION_BASED_ENGINE_START = 112100;
public static final int INFO_DURATION_BASED_RECOMMENDATIONS_AVAILABLE = 112101;
public static final int DURATION_BASED_ENGINE_END = 112199;
public static final int COST_ENGINE_START = 112100;
public static final int INFO_COST_RECOMMENDATIONS_AVAILABLE = 112101;
public static final int COST_ENGINE_END = 112199;
// Subsystem subsection: Profile Based Engine
// Range: 112200 - 112299

Expand Down Expand Up @@ -540,14 +540,14 @@ private NotificationCodes() {

CONTRADICTING_MAP.put(INFO_NOT_ENOUGH_DATA, Arrays.asList(CODES_CONTRADICT_NOT_ENOUGH_DATA));

// Contradicting Codes for DURATION_BASED_RECOMMENDATIONS_AVAILABLE
Integer[] CODES_CONTRADICT_DURATION_BASED_RECOMMENDATIONS_AVAILABLE = {
// Contradicting Codes for COST_RECOMMENDATIONS_AVAILABLE
Integer[] CODES_CONTRADICT_COST_RECOMMENDATIONS_AVAILABLE = {
INFO_NOT_ENOUGH_DATA
};

CONTRADICTING_MAP.put(
INFO_DURATION_BASED_RECOMMENDATIONS_AVAILABLE,
Arrays.asList(CODES_CONTRADICT_DURATION_BASED_RECOMMENDATIONS_AVAILABLE)
INFO_COST_RECOMMENDATIONS_AVAILABLE,
Arrays.asList(CODES_CONTRADICT_COST_RECOMMENDATIONS_AVAILABLE)
);

// Contradicting Codes for CPU_RECORDS_ARE_IDLE
Expand Down Expand Up @@ -658,7 +658,7 @@ public static final class RecommendationValueConstants {

public static final class RecommendationNotificationMsgConstant {
public static final String NOT_ENOUGH_DATA = "There is not enough data available to generate a recommendation.";
public static final String DURATION_BASED_RECOMMENDATIONS_AVAILABLE = "Duration Based Recommendations Available";
public static final String COST_RECOMMENDATIONS_AVAILABLE = "Cost Recommendations Available";
public static final String CPU_RECORDS_ARE_IDLE = "CPU Usage is less than a millicore, No CPU Recommendations can be generated";
public static final String CPU_RECORDS_ARE_ZERO = "CPU usage is zero, No CPU Recommendations can be generated";
public static final String MEMORY_RECORDS_ARE_ZERO = "Memory Usage is zero, No Memory Recommendations can be generated";
Expand Down Expand Up @@ -697,7 +697,7 @@ private RecommendationEngine() {

public static class EngineNames {
public static String DEFAULT_NAME = "Default";
public static String DURATION_BASED = "Duration Based";
public static String COST = "Cost";
public static String PROFILE_BASED = "Profile Based";

private EngineNames() {
Expand All @@ -706,7 +706,7 @@ private EngineNames() {
}

public static class EngineKeys {
public static String DURATION_BASED_KEY = "duration_based";
public static String COST_KEY = "cost";
public static String PROFILE_BASED_KEY = "profile_based";

private EngineKeys() {
Expand Down
Loading
Loading