Merge "Bugfix in EmsBootInitializer and two minor changes"

This commit is contained in:
Zuul 2024-05-29 15:58:53 +00:00 committed by Gerrit Code Review
commit e0569619b7
3 changed files with 16 additions and 3 deletions

View File

@ -45,6 +45,7 @@ public class EmsBootInitializer extends AbstractExternalBrokerService implements
private final NebulousEmsTranslatorProperties translatorProperties;
private final String applicationId;
private final AtomicBoolean processingResponse = new AtomicBoolean(false);
private final AtomicBoolean alreadyInitialized = new AtomicBoolean(false);
private ScheduledFuture<?> bootFuture;
private Consumer consumer;
private Publisher publisher;
@ -96,7 +97,7 @@ public class EmsBootInitializer extends AbstractExternalBrokerService implements
processEmsBootResponseMessage(body);
}
};
consumer = new Consumer(properties.getEmsBootResponseTopic(), properties.getEmsBootResponseTopic(), messageHandler, null, true, true);
consumer = new Consumer(properties.getEmsBootResponseTopic(), properties.getEmsBootResponseTopic(), messageHandler, applicationId, true, true);
publisher = new Publisher(properties.getEmsBootTopic(), properties.getEmsBootTopic(), true, true);
connectToBroker(List.of(publisher), List.of(consumer));
}
@ -118,6 +119,10 @@ public class EmsBootInitializer extends AbstractExternalBrokerService implements
}
protected void processEmsBootResponseMessage(Map body) {
if (alreadyInitialized.get()) {
log.warn("EmsBootInitializer: Received EMS Boot response but EMS is already initialized. Ignoring it.");
return;
}
if (! processingResponse.compareAndSet(false, true)) {
log.warn("EmsBootInitializer: A previous EMS Boot response is still being processed. Ignoring this one.");
return;
@ -137,6 +142,11 @@ public class EmsBootInitializer extends AbstractExternalBrokerService implements
Model: {}
""", appId, bindingsMap, metricsList, modelStr);
if (! StringUtils.equals(applicationId, appId)) {
log.warn("EmsBootInitializer: Ignoring EMS Boot response. Response App-Id does not match the configured App Id: {} != {}", appId, applicationId);
return;
}
try {
// Process metric model and bindings
processMetricModel(appId, modelStr);
@ -153,6 +163,9 @@ public class EmsBootInitializer extends AbstractExternalBrokerService implements
log.warn("EmsBootInitializer: EXCEPTION while processing EMS Boot Response message: ", e);
}
// Mark EMS as initialized
alreadyInitialized.set(true);
processingResponse.set(false);
}

View File

@ -152,7 +152,7 @@ public class ExternalBrokerPublisherService extends AbstractExternalBrokerServic
// If an SLO, also send an Event Type VI event to combined SLO topics
if (sloSet.contains(topic)) {
publishMessage(publishersMap.get(COMBINED_SLO_PUBLISHER_KEY), Map.of(
"severity", 0.5,
"severity", 1.0,
"predictionTime", Instant.now().toEpochMilli(),
"probability", 1.0
));

View File

@ -230,7 +230,7 @@ class ConstraintsHelper extends AbstractHelper {
private Constraint decomposeComposingConstraintSpec(TranslationContext _TC, Map spec, NamesKey parentNamesKey, Constraint parentConstraint) {
// Construct SLO namesKey
String name = "random-"+System.currentTimeMillis();
String name = "random_"+System.currentTimeMillis();
NamesKey namesKey = createNamesKey(getContainerName(spec), name);
// Decompose composing constraint