diff options
author | gjoranv <gjoranv@gmail.com> | 2019-11-04 15:55:23 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-04 15:55:23 +0100 |
commit | 2ef1e922a1d845b3cd79e9fb329925e7e9896919 (patch) | |
tree | 429207fa364a2f6ecbc523b78c3bc4d7f967cf39 /container-disc/src | |
parent | 8b0f9567b6f4baed6565174b68a356b4b8bdcd51 (diff) |
Revert "Gjoranv/allow duplicate bundles"
Diffstat (limited to 'container-disc/src')
3 files changed, 9 insertions, 39 deletions
diff --git a/container-disc/src/main/java/com/yahoo/container/jdisc/DisableOsgiFramework.java b/container-disc/src/main/java/com/yahoo/container/jdisc/DisableOsgiFramework.java index b81923c5c0a..362fefa405d 100644 --- a/container-disc/src/main/java/com/yahoo/container/jdisc/DisableOsgiFramework.java +++ b/container-disc/src/main/java/com/yahoo/container/jdisc/DisableOsgiFramework.java @@ -6,7 +6,6 @@ import org.osgi.framework.Bundle; import org.osgi.framework.BundleContext; import org.osgi.framework.BundleException; -import java.util.Collection; import java.util.List; /** @@ -53,16 +52,6 @@ public final class DisableOsgiFramework implements OsgiFramework { } @Override - public List<Bundle> getBundles(Bundle requestingBundle) { - throw newException(); - } - - @Override - public void allowDuplicateBundles(Collection<Bundle> bundles) { - throw newException(); - } - - @Override public void start() throws BundleException { throw newException(); } diff --git a/container-disc/src/main/java/com/yahoo/container/jdisc/component/Deconstructor.java b/container-disc/src/main/java/com/yahoo/container/jdisc/component/Deconstructor.java index 371f29e86a3..284e3a69b61 100644 --- a/container-disc/src/main/java/com/yahoo/container/jdisc/component/Deconstructor.java +++ b/container-disc/src/main/java/com/yahoo/container/jdisc/component/Deconstructor.java @@ -7,8 +7,6 @@ import com.yahoo.container.di.ComponentDeconstructor; import com.yahoo.container.di.componentgraph.Provider; import com.yahoo.jdisc.SharedResource; import com.yahoo.log.LogLevel; -import org.osgi.framework.Bundle; -import org.osgi.framework.BundleException; import java.time.Duration; import java.util.ArrayList; @@ -19,7 +17,6 @@ import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; import java.util.logging.Logger; -import static java.util.logging.Level.SEVERE; import static java.util.logging.Level.WARNING; /** @@ -40,7 +37,7 @@ public class Deconstructor implements ComponentDeconstructor { } @Override - public void deconstruct(Collection<Object> components, Collection<Bundle> bundles) { + public void deconstruct(Collection<Object> components) { Collection<AbstractComponent> destructibleComponents = new ArrayList<>(); for (var component : components) { if (component instanceof AbstractComponent) { @@ -60,24 +57,20 @@ public class Deconstructor implements ComponentDeconstructor { } } if (! destructibleComponents.isEmpty()) - executor.schedule(new DestructComponentTask(destructibleComponents, bundles), - delay.getSeconds(), TimeUnit.SECONDS); + executor.schedule(new DestructComponentTask(destructibleComponents), delay.getSeconds(), TimeUnit.SECONDS); } private static class DestructComponentTask implements Runnable { private final Random random = new Random(System.nanoTime()); private final Collection<AbstractComponent> components; - private final Collection<Bundle> bundles; - DestructComponentTask(Collection<AbstractComponent> components, - Collection<Bundle> bundles) { + DestructComponentTask(Collection<AbstractComponent> components) { this.components = components; - this.bundles = bundles; } /** - * Returns a random delay between 0 and 10 minutes which will be different across identical containers invoking this at the same time. + * Returns a random delay betweeen 0 and 10 minutes which will be different across identical containers invoking this at the same time. * Used to randomize restart to avoid simultaneous cluster restarts. */ private Duration getRandomizedShutdownDelay() { @@ -87,6 +80,7 @@ public class Deconstructor implements ComponentDeconstructor { @Override public void run() { + log.info("Starting deconstruction of " + components.size() + " components"); for (var component : components) { log.info("Starting deconstruction of component " + component); try { @@ -108,19 +102,7 @@ public class Deconstructor implements ComponentDeconstructor { log.log(WARNING, "Non-error not exception throwable thrown when deconstructing component " + component, e); } } - // It should now be safe to uninstall the old bundles. - for (var bundle : bundles) { - try { - log.info("Uninstalling bundle " + bundle); - bundle.uninstall(); - } catch (BundleException e) { - log.log(SEVERE, "Could not uninstall bundle " + bundle); - } - } - // NOTE: It could be tempting to refresh packages here, but if active bundles were using any of - // the removed ones, they would switch wiring in the middle of a generation's lifespan. - // This would happen if the dependent active bundle has not been rebuilt with a new version - // of its dependency(ies). + log.info("Finished deconstructing " + components.size() + " components"); } } diff --git a/container-disc/src/test/java/com/yahoo/container/jdisc/component/DeconstructorTest.java b/container-disc/src/test/java/com/yahoo/container/jdisc/component/DeconstructorTest.java index 345f75f7eb6..395b1aa7c44 100644 --- a/container-disc/src/test/java/com/yahoo/container/jdisc/component/DeconstructorTest.java +++ b/container-disc/src/test/java/com/yahoo/container/jdisc/component/DeconstructorTest.java @@ -10,7 +10,6 @@ import org.junit.Test; import java.util.Collections; -import static java.util.Collections.emptyList; import static java.util.Collections.singleton; import static org.junit.Assert.assertTrue; @@ -29,7 +28,7 @@ public class DeconstructorTest { public void require_abstract_component_destructed() throws InterruptedException { TestAbstractComponent abstractComponent = new TestAbstractComponent(); // Done by executor, so it takes some time even with a 0 delay. - deconstructor.deconstruct(singleton(abstractComponent), emptyList()); + deconstructor.deconstruct(singleton(abstractComponent)); int cnt = 0; while (! abstractComponent.destructed && (cnt++ < 12000)) { Thread.sleep(10); @@ -40,14 +39,14 @@ public class DeconstructorTest { @Test public void require_provider_destructed() { TestProvider provider = new TestProvider(); - deconstructor.deconstruct(singleton(provider), emptyList()); + deconstructor.deconstruct(singleton(provider)); assertTrue(provider.destructed); } @Test public void require_shared_resource_released() { TestSharedResource sharedResource = new TestSharedResource(); - deconstructor.deconstruct(singleton(sharedResource), emptyList()); + deconstructor.deconstruct(singleton(sharedResource)); assertTrue(sharedResource.released); } |