summaryrefslogtreecommitdiffstats
path: root/container-di/src/main/java/com/yahoo/container/di/Container.java
diff options
context:
space:
mode:
Diffstat (limited to 'container-di/src/main/java/com/yahoo/container/di/Container.java')
-rw-r--r--container-di/src/main/java/com/yahoo/container/di/Container.java36
1 files changed, 10 insertions, 26 deletions
diff --git a/container-di/src/main/java/com/yahoo/container/di/Container.java b/container-di/src/main/java/com/yahoo/container/di/Container.java
index 9a9245f4ba2..f82fd22f40d 100644
--- a/container-di/src/main/java/com/yahoo/container/di/Container.java
+++ b/container-di/src/main/java/com/yahoo/container/di/Container.java
@@ -18,13 +18,9 @@ import com.yahoo.container.di.componentgraph.core.Node;
import com.yahoo.container.di.config.RestApiContext;
import com.yahoo.container.di.config.SubscriberFactory;
import com.yahoo.vespa.config.ConfigKey;
-import org.osgi.framework.Bundle;
-import java.util.Collection;
-import java.util.Collections;
import java.util.HashSet;
import java.util.IdentityHashMap;
-import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.logging.Level;
@@ -69,22 +65,19 @@ public class Container {
});
}
- private void deconstructObsoleteComponents(ComponentGraph oldGraph,
- ComponentGraph newGraph,
- Collection<Bundle> obsoleteBundles) {
+ private void deconstructObsoleteComponents(ComponentGraph oldGraph, ComponentGraph newGraph) {
IdentityHashMap<Object, Object> oldComponents = new IdentityHashMap<>();
oldGraph.allConstructedComponentsAndProviders().forEach(c -> oldComponents.put(c, null));
newGraph.allConstructedComponentsAndProviders().forEach(oldComponents::remove);
- componentDeconstructor.deconstruct(oldComponents.keySet(), obsoleteBundles);
+ componentDeconstructor.deconstruct(oldComponents.keySet());
}
public ComponentGraph getNewComponentGraph(ComponentGraph oldGraph, Injector fallbackInjector, boolean restartOnRedeploy) {
try {
- Collection<Bundle> obsoleteBundles = new HashSet<>();
- ComponentGraph newGraph = getConfigAndCreateGraph(oldGraph, fallbackInjector, restartOnRedeploy, obsoleteBundles);
+ ComponentGraph newGraph = getConfigAndCreateGraph(oldGraph, fallbackInjector, restartOnRedeploy);
newGraph.reuseNodes(oldGraph);
constructComponents(newGraph);
- deconstructObsoleteComponents(oldGraph, newGraph, obsoleteBundles);
+ deconstructObsoleteComponents(oldGraph, newGraph);
return newGraph;
} catch (Throwable t) {
// TODO: Wrap ComponentConstructorException in an Error when generation==0 (+ unit test that Error is thrown)
@@ -129,13 +122,8 @@ public class Container {
}
}
- private ComponentGraph getConfigAndCreateGraph(ComponentGraph graph,
- Injector fallbackInjector,
- boolean restartOnRedeploy,
- Collection<Bundle> obsoleteBundles) // NOTE: Return value
- {
+ private ComponentGraph getConfigAndCreateGraph(ComponentGraph graph, Injector fallbackInjector, boolean restartOnRedeploy) {
ConfigSnapshot snapshot;
-
while (true) {
snapshot = configurer.getConfigs(graph.configKeys(), leastGeneration, restartOnRedeploy);
@@ -143,6 +131,7 @@ public class Container {
graph.configKeys(), graph.generation(), snapshot));
if (snapshot instanceof BootstrapConfigs) {
+ // TODO: remove require when proven unnecessary
if (getBootstrapGeneration() <= previousConfigGeneration) {
throw new IllegalStateException(String.format(
"Got bootstrap configs out of sequence for old config generation %d.\n" + "Previous config generation is %d",
@@ -153,12 +142,8 @@ public class Container {
"Got new bootstrap generation\n" + "bootstrap generation = %d\n" + "components generation: %d\n"
+ "previous generation: %d\n",
getBootstrapGeneration(), getComponentsGeneration(), previousConfigGeneration));
-
- Collection<Bundle> bundlesToRemove = installBundles(snapshot.configs());
- obsoleteBundles.addAll(bundlesToRemove);
-
+ installBundles(snapshot.configs());
graph = createComponentsGraph(snapshot.configs(), getBootstrapGeneration(), fallbackInjector);
-
// Continues loop
} else if (snapshot instanceof ConfigRetriever.ComponentsConfigs) {
@@ -199,9 +184,9 @@ public class Container {
}
}
- private Set<Bundle> installBundles(Map<ConfigKey<? extends ConfigInstance>, ConfigInstance> configsIncludingBootstrapConfigs) {
+ private void installBundles(Map<ConfigKey<? extends ConfigInstance>, ConfigInstance> configsIncludingBootstrapConfigs) {
BundlesConfig bundlesConfig = getConfig(bundlesConfigKey, configsIncludingBootstrapConfigs);
- return osgi.useBundles(bundlesConfig.bundle());
+ osgi.useBundles(bundlesConfig.bundle());
}
private ComponentGraph createComponentsGraph(Map<ConfigKey<? extends ConfigInstance>, ConfigInstance> configsIncludingBootstrapConfigs,
@@ -259,8 +244,7 @@ public class Container {
}
private void deconstructAllComponents(ComponentGraph graph, ComponentDeconstructor deconstructor) {
- // This is only used for shutdown, so no need to uninstall any bundles.
- deconstructor.deconstruct(graph.allConstructedComponentsAndProviders(), Collections.emptyList());
+ deconstructor.deconstruct(graph.allConstructedComponentsAndProviders());
}
public static <T extends ConfigInstance> T getConfig(ConfigKey<T> key,