in gateway-discovery-cm/src/main/java/org/apache/knox/gateway/topology/discovery/cm/monitor/PollingConfigurationAnalyzer.java [304:368]
private boolean hasConfigChanged(String address, String clusterName, List<RelevantEvent> relevantEvents) {
// If there are start events, then check the previously-recorded properties for the same service to
// identify if the configuration has changed
final Map<String, ServiceConfigurationModel> serviceConfigurations =
configCache.getClusterServiceConfigurations(address, clusterName);
// Those services for which a start even has been handled
final List<String> handledServiceTypes = new ArrayList<>();
boolean configHasChanged = false;
for (RelevantEvent re : relevantEvents) {
if (alreadyProcessed(re)) {
log.activationEventAlreadyProcessed(re.auditEvent.getId());
continue;
}
if (re.isRoleAddedEvent() || re.isRoleDeletedEvent()) {
continue;
}
String serviceType = re.getServiceType();
if (CM_SERVICE_TYPE.equals(serviceType)) {
if (CM_SERVICE.equals(re.getService())) {
// This is a 'rolling cluster restart' or 'restart waiting for staleness' event, so assume configuration has changed
configHasChanged = true;
}
}
// Determine if we've already handled a start event for this service type
if (!configHasChanged && !handledServiceTypes.contains(serviceType)) {
// Get the previously-recorded configuration
ServiceConfigurationModel serviceConfig = serviceConfigurations.get(re.getServiceType());
if (serviceConfig != null) {
// Get the current config for the started service, and compare with the previously-recorded config
ServiceConfigurationModel currentConfig =
getCurrentServiceConfiguration(address, clusterName, re.getService());
if (currentConfig != null) {
log.analyzingCurrentServiceConfiguration(re.getService());
try {
configHasChanged = hasConfigurationChanged(serviceConfig, currentConfig);
} catch (Exception e) {
log.errorAnalyzingCurrentServiceConfiguration(re.getService(), e);
}
}
} else {
// A new service (no prior config) represent a config change, since a descriptor may have referenced
// the "new" service, but discovery had previously not succeeded because the service had not been
// configured (appropriately) at that time.
log.serviceEnabled(re.getService());
configHasChanged = true;
}
handledServiceTypes.add(serviceType);
}
if (configHasChanged) {
break; // No need to continue checking once we've identified one reason to perform discovery again
}
}
return configHasChanged;
}