summaryrefslogtreecommitdiffstats
path: root/container-disc
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 /container-disc
parentd7616adac5ab388192acfea71625296295909ee2 (diff)
Include generation number in log message for deconstruction
Diffstat (limited to 'container-disc')
-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
2 files changed, 12 insertions, 9 deletions
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);