diff options
author | jonmv <venstad@gmail.com> | 2023-11-30 14:41:03 +0100 |
---|---|---|
committer | jonmv <venstad@gmail.com> | 2023-11-30 14:41:03 +0100 |
commit | 946bcd749dc6ab4469aca245508cec8251d6053a (patch) | |
tree | 649f30f01a539dd2f2a3c10fbfc2cf6a72bf9f8b /jdisc_core/src/main/java/com/yahoo/jdisc/core | |
parent | 3491100f5bee54d0918f3f9ba33d9b0b44026f55 (diff) |
Keep old container alive until servers are switched
Diffstat (limited to 'jdisc_core/src/main/java/com/yahoo/jdisc/core')
3 files changed, 16 insertions, 3 deletions
diff --git a/jdisc_core/src/main/java/com/yahoo/jdisc/core/ActiveContainer.java b/jdisc_core/src/main/java/com/yahoo/jdisc/core/ActiveContainer.java index e2d2da660c7..d3abfa77fca 100644 --- a/jdisc_core/src/main/java/com/yahoo/jdisc/core/ActiveContainer.java +++ b/jdisc_core/src/main/java/com/yahoo/jdisc/core/ActiveContainer.java @@ -55,7 +55,7 @@ public class ActiveContainer extends AbstractResource implements CurrentContaine } }); guiceInjector = builder.guiceModules().activate(); - termination = new ContainerTermination(builder.appContext()); + termination = new ContainerTermination(builder.appContext(), refer()); } @Override diff --git a/jdisc_core/src/main/java/com/yahoo/jdisc/core/ApplicationLoader.java b/jdisc_core/src/main/java/com/yahoo/jdisc/core/ApplicationLoader.java index 0ca32197d5e..d6618d50bc3 100644 --- a/jdisc_core/src/main/java/com/yahoo/jdisc/core/ApplicationLoader.java +++ b/jdisc_core/src/main/java/com/yahoo/jdisc/core/ApplicationLoader.java @@ -186,7 +186,7 @@ public class ApplicationLoader implements BootstrapLoader, ContainerActivator, C synchronized (appLock) { application = null; } - activateContainer(null); + try (DeactivatedContainer deactivated = activateContainer(null)) { } synchronized (appLock) { this.applicationInUseTracker = null; } diff --git a/jdisc_core/src/main/java/com/yahoo/jdisc/core/ContainerTermination.java b/jdisc_core/src/main/java/com/yahoo/jdisc/core/ContainerTermination.java index 4c7c26358d6..7177c337fdd 100644 --- a/jdisc_core/src/main/java/com/yahoo/jdisc/core/ContainerTermination.java +++ b/jdisc_core/src/main/java/com/yahoo/jdisc/core/ContainerTermination.java @@ -1,6 +1,7 @@ // Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.jdisc.core; +import com.yahoo.jdisc.ResourceReference; import com.yahoo.jdisc.application.DeactivatedContainer; /** @@ -10,11 +11,14 @@ public class ContainerTermination implements DeactivatedContainer, Runnable { private final Object lock = new Object(); private final Object appContext; + private final ResourceReference containerReference; private Runnable task; private boolean done; + private boolean closed; - public ContainerTermination(Object appContext) { + public ContainerTermination(Object appContext, ResourceReference containerReference) { this.appContext = appContext; + this.containerReference = containerReference; } @Override @@ -38,6 +42,15 @@ public class ContainerTermination implements DeactivatedContainer, Runnable { } @Override + public void close() { + synchronized (lock) { + if (closed) return; + closed = true; + containerReference.close(); + } + } + + @Override public void run() { Runnable task; synchronized (lock) { |