summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjørn Christian Seime <bjorncs@verizonmedia.com>2022-01-25 14:41:35 +0100
committerBjørn Christian Seime <bjorncs@verizonmedia.com>2022-01-25 14:42:45 +0100
commitd39c153e007d4b613ba7e4dbe3f222691861d1c8 (patch)
tree564cbe83ad8021807db872f70c5d6cb1b6f81e83
parentd7616adac5ab388192acfea71625296295909ee2 (diff)
Include generation number in log message for deconstruction
-rw-r--r--container-core/src/main/java/com/yahoo/container/core/config/testutil/HandlersConfigurerTestWrapper.java2
-rw-r--r--container-core/src/main/java/com/yahoo/container/di/ComponentDeconstructor.java2
-rw-r--r--container-core/src/main/java/com/yahoo/container/di/Container.java4
-rw-r--r--container-core/src/test/java/com/yahoo/container/di/ContainerTest.java4
-rw-r--r--container-disc/src/main/java/com/yahoo/container/jdisc/component/Deconstructor.java11
-rw-r--r--container-disc/src/test/java/com/yahoo/container/jdisc/component/DeconstructorTest.java10
6 files changed, 18 insertions, 15 deletions
diff --git a/container-core/src/main/java/com/yahoo/container/core/config/testutil/HandlersConfigurerTestWrapper.java b/container-core/src/main/java/com/yahoo/container/core/config/testutil/HandlersConfigurerTestWrapper.java
index eadb6b52294..5178b864e8e 100644
--- a/container-core/src/main/java/com/yahoo/container/core/config/testutil/HandlersConfigurerTestWrapper.java
+++ b/container-core/src/main/java/com/yahoo/container/core/config/testutil/HandlersConfigurerTestWrapper.java
@@ -109,7 +109,7 @@ public class HandlersConfigurerTestWrapper {
}
private ComponentDeconstructor getTestDeconstructor() {
- return (components, bundles) -> components.forEach(component -> {
+ return (generation, components, bundles) -> components.forEach(component -> {
if (component instanceof AbstractComponent) {
AbstractComponent abstractComponent = (AbstractComponent) component;
if (abstractComponent.isDeconstructable()) abstractComponent.deconstruct();
diff --git a/container-core/src/main/java/com/yahoo/container/di/ComponentDeconstructor.java b/container-core/src/main/java/com/yahoo/container/di/ComponentDeconstructor.java
index 95a15e12735..0df91103985 100644
--- a/container-core/src/main/java/com/yahoo/container/di/ComponentDeconstructor.java
+++ b/container-core/src/main/java/com/yahoo/container/di/ComponentDeconstructor.java
@@ -13,7 +13,7 @@ import java.util.List;
public interface ComponentDeconstructor {
/** Deconstructs the given components in order, then the given bundles. */
- void deconstruct(List<Object> components, Collection<Bundle> bundles);
+ void deconstruct(long generation, List<Object> components, Collection<Bundle> bundles);
/** Wait for all previous destruction tasks to complete */
default void shutdown() {}
diff --git a/container-core/src/main/java/com/yahoo/container/di/Container.java b/container-core/src/main/java/com/yahoo/container/di/Container.java
index 8d8a05408a9..b37a7b9f69f 100644
--- a/container-core/src/main/java/com/yahoo/container/di/Container.java
+++ b/container-core/src/main/java/com/yahoo/container/di/Container.java
@@ -171,7 +171,7 @@ public class Container {
if ( ! newComponents.containsKey(component))
obsoleteComponents.add(component);
- return () -> componentDeconstructor.deconstruct(obsoleteComponents, obsoleteBundles);
+ return () -> componentDeconstructor.deconstruct(oldGraph.generation(), obsoleteComponents, obsoleteBundles);
}
private Set<Bundle> installApplicationBundles(Map<ConfigKey<? extends ConfigInstance>, ConfigInstance> configsIncludingBootstrapConfigs) {
@@ -264,7 +264,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.generation(), graph.allConstructedComponentsAndProviders(), Collections.emptyList());
}
public static <T extends ConfigInstance> T getConfig(ConfigKey<T> key,
diff --git a/container-core/src/test/java/com/yahoo/container/di/ContainerTest.java b/container-core/src/test/java/com/yahoo/container/di/ContainerTest.java
index 35c2e8f25c6..1570c529cdf 100644
--- a/container-core/src/test/java/com/yahoo/container/di/ContainerTest.java
+++ b/container-core/src/test/java/com/yahoo/container/di/ContainerTest.java
@@ -219,7 +219,7 @@ public class ContainerTest extends ContainerTestBase {
public void providers_are_destructed() {
writeBootstrapConfigs("id1", DestructableProvider.class);
- ComponentDeconstructor deconstructor = (components, bundles) -> {
+ ComponentDeconstructor deconstructor = (generation, components, bundles) -> {
components.forEach(component -> {
if (component instanceof AbstractComponent) {
((AbstractComponent) component).deconstruct();
@@ -312,7 +312,7 @@ public class ContainerTest extends ContainerTestBase {
public static class TestDeconstructor implements ComponentDeconstructor {
@Override
- public void deconstruct(List<Object> components, Collection<Bundle> bundles) {
+ public void deconstruct(long generation, List<Object> components, Collection<Bundle> bundles) {
components.forEach(component -> {
if (component instanceof DestructableComponent) {
DestructableComponent vespaComponent = (DestructableComponent) component;
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 ee592c2e8d1..336554b1b87 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
@@ -48,7 +48,7 @@ public class Deconstructor implements ComponentDeconstructor {
public Deconstructor() { this(Duration.ofSeconds(45)); }
@Override
- public void deconstruct(List<Object> components, Collection<Bundle> bundles) {
+ public void deconstruct(long generation, List<Object> components, Collection<Bundle> bundles) {
Collection<Deconstructable> destructibleComponents = new ArrayList<>();
for (var component : components) {
if (component instanceof AbstractComponent) {
@@ -64,7 +64,7 @@ public class Deconstructor implements ComponentDeconstructor {
}
}
if (!destructibleComponents.isEmpty() || !bundles.isEmpty()) {
- executor.execute(new DestructComponentTask(destructibleComponents, bundles));
+ executor.execute(new DestructComponentTask(generation, destructibleComponents, bundles));
}
}
@@ -93,10 +93,12 @@ public class Deconstructor implements ComponentDeconstructor {
private static class DestructComponentTask implements Runnable {
private final Random random = new Random(System.nanoTime());
+ private final long generation;
private final Collection<Deconstructable> components;
private final Collection<Bundle> bundles;
- DestructComponentTask(Collection<Deconstructable> components, Collection<Bundle> bundles) {
+ DestructComponentTask(long generation, Collection<Deconstructable> components, Collection<Bundle> bundles) {
+ this.generation = generation;
this.components = components;
this.bundles = bundles;
}
@@ -113,7 +115,8 @@ public class Deconstructor implements ComponentDeconstructor {
@Override
public void run() {
long start = System.currentTimeMillis();
- log.info(String.format("Starting deconstruction of %d old components from previous config generation", components.size()));
+ log.info(String.format("Starting deconstruction of %d old components from graph generation %d",
+ components.size(), generation));
for (var component : components) {
log.log(FINE, () -> "Starting deconstruction of " + component);
try {
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 579275deb0f..715c2759aa6 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
@@ -33,7 +33,7 @@ public class DeconstructorTest {
deconstructor = new Deconstructor();
var slowDeconstructComponent = new SlowDeconstructComponent();
- deconstructor.deconstruct(List.of(slowDeconstructComponent), emptyList());
+ deconstructor.deconstruct(0, List.of(slowDeconstructComponent), emptyList());
deconstructor.shutdown();
assertTrue(slowDeconstructComponent.destructed);
}
@@ -41,7 +41,7 @@ public class DeconstructorTest {
@Test
public void require_abstract_component_destructed() throws InterruptedException {
TestAbstractComponent abstractComponent = new TestAbstractComponent();
- deconstructor.deconstruct(List.of(abstractComponent), emptyList());
+ deconstructor.deconstruct(0, List.of(abstractComponent), emptyList());
waitForDeconstructToComplete(() -> abstractComponent.destructed);
assertTrue(abstractComponent.destructed);
@@ -50,7 +50,7 @@ public class DeconstructorTest {
@Test
public void require_provider_destructed() throws InterruptedException {
TestProvider provider = new TestProvider();
- deconstructor.deconstruct(List.of(provider), emptyList());
+ deconstructor.deconstruct(0, List.of(provider), emptyList());
waitForDeconstructToComplete(() -> provider.destructed);
assertTrue(provider.destructed);
@@ -59,7 +59,7 @@ public class DeconstructorTest {
@Test
public void require_shared_resource_released() throws InterruptedException {
TestSharedResource sharedResource = new TestSharedResource();
- deconstructor.deconstruct(List.of(sharedResource), emptyList());
+ deconstructor.deconstruct(0, List.of(sharedResource), emptyList());
waitForDeconstructToComplete(() -> sharedResource.released);
assertTrue(sharedResource.released);
}
@@ -68,7 +68,7 @@ public class DeconstructorTest {
public void bundles_are_uninstalled() throws InterruptedException {
var bundle = new UninstallableMockBundle();
// Done by executor, so it takes some time even with a 0 delay.
- deconstructor.deconstruct(emptyList(), singleton(bundle));
+ deconstructor.deconstruct(0, emptyList(), singleton(bundle));
waitForDeconstructToComplete(() -> bundle.uninstalled);
assertTrue(bundle.uninstalled);