Skip to content

Commit

Permalink
Fix app deletion in the cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
mekya committed Apr 4, 2021
1 parent 0cfa301 commit 92e93b0
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/main/java/io/antmedia/AntMediaApplicationAdapter.java
Expand Up @@ -159,8 +159,9 @@ public boolean appStart(IScope app) {
if (app.getContext().hasBean(IClusterNotifier.BEAN_NAME)) {
//which means it's in cluster mode
clusterNotifier = (IClusterNotifier) app.getContext().getBean(IClusterNotifier.BEAN_NAME);
logger.info("Registering settings listener to the cluster notifier for app: {}", app.getName());
clusterNotifier.registerSettingUpdateListener(getAppSettings().getAppName(), settings -> {
logger.info("Registering settings listener to the cluster notifier for app: {}", app.getName());

updateSettings(settings, false);
});
AppSettings storedSettings = clusterNotifier.getClusterStore().getSettings(app.getName());
Expand All @@ -178,7 +179,7 @@ else if (storedSettings.isToBeDeleted())
updateClusterSettings = true;
}

logger.info("Updating settings while app({}) is being started. App exists in cluster db -> {}", app.getName(), updateClusterSettings);
logger.info("Updating settings while app({}) is being started. Update cluster db for appsettings -> {}", app.getName(), updateClusterSettings);
updateSettings(storedSettings, updateClusterSettings);

}
Expand Down Expand Up @@ -1345,8 +1346,10 @@ public synchronized boolean updateSettings(AppSettings newSettings, boolean noti
updateAppSettingsBean(appSettings, newSettings);

if (notifyCluster && clusterNotifier != null) {
//we should set to be deleted because app deletion fully depends on the cluster synch
appSettings.setToBeDeleted(newSettings.isToBeDeleted());
boolean saveSettings = clusterNotifier.getClusterStore().saveSettings(appSettings);
logger.info("Save settings to cluster db -> {} for app: {}", saveSettings, getScope().getName());
logger.info("Saving settings to cluster db -> {} for app: {}", saveSettings, getScope().getName());
}

result = true;
Expand Down

0 comments on commit 92e93b0

Please sign in to comment.