Merge "Miscellaneous bug-fixes"

This commit is contained in:
Zuul 2024-06-05 15:04:54 +00:00 committed by Gerrit Code Review
commit c9f2765630
7 changed files with 32 additions and 18 deletions

View File

@ -38,6 +38,7 @@ public class Constants {
public static int kept_values_per_metric = 5; //Default to be overriden from the configuration file. This indicates how many metric values are kept to calculate the "previous" metric value during the rate of change calculation
public static String roc_calculation_mode = "prototype";
public static boolean single_slo_rule_active = true; //default value to be overriden
public static boolean assume_slo_rule_version_is_always_updated = false;
public static double roc_limit = 1;
public static double epsilon = 0.00000000001;
public static Level debug_logging_level = Level.OFF;

View File

@ -30,7 +30,6 @@ import static utility_beans.generic_component_functionality.CharacterizedThread.
@SpringBootApplication
public class Main {
public static Long current_slo_rules_version = -1L;//initialization
public static HashMap<String,DetectorSubcomponent> detectors = new HashMap<>();
public static void main(String[] args) {
@ -64,6 +63,7 @@ public class Main {
kept_values_per_metric = Integer.parseInt(prop.getProperty("stored_values_per_metric", "5"));
//TODO remove from docs as well: self_publish_rule_file = Boolean.parseBoolean(prop.getProperty("self_publish_rule_file"));
single_slo_rule_active = Boolean.parseBoolean(prop.getProperty("single_slo_rule_active"));
assume_slo_rule_version_is_always_updated = Boolean.parseBoolean((prop.getProperty("assume_slo_rule_version_is_always_updated")));
time_horizon_seconds = Integer.parseInt(prop.getProperty("time_horizon_seconds"));
slo_violation_probability_threshold = Double.parseDouble(prop.getProperty("slo_violation_probability_threshold"));

View File

@ -26,6 +26,7 @@ import static utility_beans.monitoring.RealtimeMonitoringAttribute.aggregate_met
public class DetectorSubcomponent extends SLOViolationDetectorSubcomponent {
public static final SynchronizedInteger detector_integer_id = new SynchronizedInteger();
private Long current_slo_rule_version = -1L;
public static Map<String,DetectorSubcomponent> detector_subcomponents = Collections.synchronizedMap(new HashMap<>()); //A HashMap containing all detector subcomponents
private DetectorSubcomponentState subcomponent_state;
public final AtomicBoolean stop_signal = new AtomicBoolean(false);
@ -165,4 +166,12 @@ public class DetectorSubcomponent extends SLOViolationDetectorSubcomponent {
return associated_detector;
}
public Long getCurrent_slo_rule_version() {
return current_slo_rule_version;
}
public void setCurrent_slo_rule_version(Long current_slo_rule_version) {
this.current_slo_rule_version = current_slo_rule_version;
}
}

View File

@ -1,6 +1,5 @@
package slo_violation_detector_engine.detector;
import groovy.util.logging.Log;
import metric_retrieval.AttributeSubscription;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
@ -21,7 +20,6 @@ import static configuration.Constants.*;
import static slo_violation_detector_engine.director.DirectorSubcomponent.MESSAGE_CONTENTS;
import static slo_violation_detector_engine.generic.ComponentState.prop;
import static slo_violation_detector_engine.generic.Runnables.get_severity_calculation_runnable;
import static runtime.Main.*;
import static utility_beans.monitoring.PredictedMonitoringAttribute.getPredicted_monitoring_attributes;
public class DetectorSubcomponentUtilities {
@ -119,13 +117,21 @@ public class DetectorSubcomponentUtilities {
}
public static boolean slo_rule_arrived_has_updated_version(String rule_representation) {
public static boolean slo_rule_arrived_has_updated_version(String rule_representation,DetectorSubcomponent detector, boolean assume_version_is_always_updated) {
if (assume_version_is_always_updated){ //This behaviour shortcuts this method
return true;
}
//TODO: The json object version is ignored for now. However, it should not be, we should keep track separately per application
JSONObject json_object = null;
long json_object_version = 1;
try {
json_object = (JSONObject) new JSONParser().parse(rule_representation);
//json_object_version = (Long) json_object.get("version");
json_object_version++;
if (json_object.containsKey("version")){
json_object_version = (Long) json_object.get("version");
}else{
Logger.getGlobal().log(info_logging_level,"The rule which was received does not have a version field, and as we do not assume the version of the rule is always updated, it is ignored");
}
//json_object_version++;
} catch (NullPointerException n){
n.printStackTrace();
Logger.getGlobal().log(info_logging_level,"Unfortunately a null message was sent to the SLO Violation Detector, which is being ignored");
@ -135,9 +141,9 @@ public class DetectorSubcomponentUtilities {
Logger.getGlobal().log(info_logging_level,"Could not parse the JSON of the new SLO, assuming it is not an updated rule...");
return false;
}
if (json_object_version > current_slo_rules_version){
Logger.getGlobal().log(info_logging_level,"An SLO with updated version ("+json_object_version+" vs older "+current_slo_rules_version+") has arrived");
current_slo_rules_version=json_object_version;
if (json_object_version > detector.getCurrent_slo_rule_version()){
Logger.getGlobal().log(info_logging_level,"An SLO with updated version ("+json_object_version+" vs older "+detector.getCurrent_slo_rule_version()+") has arrived");
detector.setCurrent_slo_rule_version(json_object_version);
return true;
}else {
Logger.getGlobal().log(info_logging_level,"Taking no action for the received SLO message as the version number is not updated");
@ -267,7 +273,7 @@ public class DetectorSubcomponentUtilities {
associated_detector_subcomponent.can_modify_slo_rules.setValue(false);
associated_detector_subcomponent.slo_rule_arrived.set(false);
String rule_representation = MESSAGE_CONTENTS.get_synchronized_contents(associated_detector_subcomponent.get_application_name(),slo_rules_topic);
if (slo_rule_arrived_has_updated_version(rule_representation)) {
if (slo_rule_arrived_has_updated_version(rule_representation,associated_detector_subcomponent,assume_slo_rule_version_is_always_updated)) {
if (single_slo_rule_active) {
associated_detector_subcomponent.getSubcomponent_state().slo_rules.clear();
}

View File

@ -113,8 +113,6 @@ public class DirectorSubcomponent extends SLOViolationDetectorSubcomponent {
BrokerSubscriber device_lost_subscriber = new BrokerSubscriber(topic_for_lost_device_announcement, broker_ip, broker_port, broker_username, broker_password, amq_library_configuration_location,EMPTY);
BiFunction<BrokerSubscriptionDetails, String, String> device_lost_subscriber_function = (broker_details, message) -> {
BrokerPublisher persistent_publisher = new BrokerPublisher(topic_for_severity_announcement, broker_ip, broker_port, broker_username, broker_password, amq_library_configuration_location, true);

View File

@ -75,6 +75,11 @@ public class BrokerSubscriber {
throw new RuntimeException(e);
}
}
this.topic = topic;
this.broker_ip = broker_ip;
this.broker_port = broker_port;
this.brokerUsername = brokerUsername;
this.brokerPassword = brokerPassword;
broker_details = new BrokerSubscriptionDetails(broker_ip, brokerUsername, brokerPassword, application_name, topic);
boolean subscriber_configuration_changed;
if (!broker_and_topics_to_subscribe_to.containsKey(broker_ip)) {
@ -106,12 +111,6 @@ public class BrokerSubscriber {
Logger.getGlobal().log(INFO, "HIGH level subscriber " + topic);
}
active_consumers_per_topic_per_broker_ip.get(broker_ip).put(topic, current_consumer);
this.topic = topic;
this.broker_ip = broker_ip;
this.broker_port = broker_port;
this.brokerUsername = brokerUsername;
this.brokerPassword = brokerPassword;
add_topic_consumer_to_broker_connector(current_consumer);
}
}

View File

@ -4,6 +4,7 @@ metrics_bounds = avgResponseTime;unbounded;unbounded,custom2;0;3
slo_rules_topic = eu.nebulouscloud.monitoring.slo.new
single_slo_rule_active = true
assume_slo_rule_version_is_always_updated = false
#broker_ip_url = tcp://localhost:61616?wireFormat.maxInactivityDuration=0
broker_ip_url = nebulous-activemq
broker_port = 5672