aboutsummaryrefslogtreecommitdiffstats
path: root/container-core/src/main/java/com/yahoo/container/core
diff options
context:
space:
mode:
authorgjoranv <gv@verizonmedia.com>2022-09-08 00:13:36 +0200
committergjoranv <gv@verizonmedia.com>2022-09-08 00:13:36 +0200
commite00663f15d41565c525282930c2983b0f039febd (patch)
tree16b24baf37814f5fa8aebea6f32e9287d64b20f3 /container-core/src/main/java/com/yahoo/container/core
parentceb337dea57c909ac83bc168e1b79872eae6dbfe (diff)
Always return the set of bundles to uninstall upon completeGen,
regardless of success or failure.
Diffstat (limited to 'container-core/src/main/java/com/yahoo/container/core')
-rw-r--r--container-core/src/main/java/com/yahoo/container/core/config/ApplicationBundleLoader.java34
-rw-r--r--container-core/src/main/java/com/yahoo/container/core/config/HandlersConfigurerDi.java4
2 files changed, 18 insertions, 20 deletions
diff --git a/container-core/src/main/java/com/yahoo/container/core/config/ApplicationBundleLoader.java b/container-core/src/main/java/com/yahoo/container/core/config/ApplicationBundleLoader.java
index c1cf18582d5..cbff119c0ba 100644
--- a/container-core/src/main/java/com/yahoo/container/core/config/ApplicationBundleLoader.java
+++ b/container-core/src/main/java/com/yahoo/container/core/config/ApplicationBundleLoader.java
@@ -50,51 +50,49 @@ public class ApplicationBundleLoader {
}
/**
- * Installs the given set of bundles and returns the set of bundles that is no longer used
- * by the application, and should therefore be scheduled for uninstall.
- *
- * TODO: return void, and instead return the bundles to remove from completeGeneration()
+ * Installs the given set of bundles and updates state for which bundles and file references
+ * that are active or should be uninstalled in case of success or failure.
*/
- public synchronized Set<Bundle> useBundles(List<FileReference> newFileReferences) {
+ public synchronized void useBundles(List<FileReference> newFileReferences) {
if (! readyForNewBundles)
throw new IllegalStateException("Bundles must be committed or reverted before using new bundles.");
- obsoleteBundles = removeObsoleteBundles(newFileReferences);
- Set<Bundle> bundlesToUninstall = new LinkedHashSet<>(obsoleteBundles.values());
- log.info("Bundles to schedule for uninstall: " + bundlesToUninstall);
-
- osgi.allowDuplicateBundles(bundlesToUninstall);
+ obsoleteBundles = removeObsoleteReferences(newFileReferences);
+ osgi.allowDuplicateBundles(obsoleteBundles.values());
bundlesFromNewGeneration = installBundles(newFileReferences);
BundleStarter.startBundles(activeBundles.values());
log.info(installedBundlesMessage());
readyForNewBundles = false;
-
- return bundlesToUninstall;
}
public synchronized Collection<Bundle> completeGeneration(GenerationStatus status) {
Collection<Bundle> ret = List.of();
if (readyForNewBundles) return ret;
+ readyForNewBundles = true;
if (status == GenerationStatus.SUCCESS) {
- commitBundles();
+ return commitBundles();
} else {
- ret = revertToPreviousGeneration();
+ return revertToPreviousGeneration();
}
- readyForNewBundles = true;
- return ret;
}
/**
* Commit to the current set of bundles. Must be called after the component graph creation proved successful,
* to prevent uninstalling bundles unintentionally upon a future call to {@link #revertToPreviousGeneration()}.
+ * Returns the set of bundles that is no longer used by the application, and should therefore be scheduled
+ * for uninstall.
*/
- private void commitBundles() {
+ private Collection<Bundle> commitBundles() {
+ Set<Bundle> bundlesToUninstall = new LinkedHashSet<>(obsoleteBundles.values());
+ log.info("Bundles to be uninstalled from previous generation: " + bundlesToUninstall);
+
bundlesFromNewGeneration = Map.of();
obsoleteBundles = Map.of();
readyForNewBundles = true;
+ return bundlesToUninstall;
}
/**
@@ -128,7 +126,7 @@ public class ApplicationBundleLoader {
*
* Returns the map of bundles that are not needed by the new application generation.
*/
- private Map<FileReference, Bundle> removeObsoleteBundles(List<FileReference> newReferences) {
+ private Map<FileReference, Bundle> removeObsoleteReferences(List<FileReference> newReferences) {
Map<FileReference, Bundle> obsoleteReferences = new LinkedHashMap<>(activeBundles);
newReferences.forEach(obsoleteReferences::remove);
diff --git a/container-core/src/main/java/com/yahoo/container/core/config/HandlersConfigurerDi.java b/container-core/src/main/java/com/yahoo/container/core/config/HandlersConfigurerDi.java
index f573de1f4ac..f2620cc8baa 100644
--- a/container-core/src/main/java/com/yahoo/container/core/config/HandlersConfigurerDi.java
+++ b/container-core/src/main/java/com/yahoo/container/core/config/HandlersConfigurerDi.java
@@ -98,9 +98,9 @@ public class HandlersConfigurerDi {
}
@Override
- public Set<Bundle> useApplicationBundles(Collection<FileReference> bundles, long generation) {
+ public void useApplicationBundles(Collection<FileReference> bundles, long generation) {
log.info("Installing bundles for application generation " + generation);
- return applicationBundleLoader.useBundles(new ArrayList<>(bundles));
+ applicationBundleLoader.useBundles(new ArrayList<>(bundles));
}
@Override