diff options
Diffstat (limited to 'container-disc/src/main/java/com/yahoo/container/jdisc/component/Deconstructor.java')
-rw-r--r-- | container-disc/src/main/java/com/yahoo/container/jdisc/component/Deconstructor.java | 23 |
1 files changed, 12 insertions, 11 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 f13c078c41d..10326227405 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 @@ -9,7 +9,6 @@ import com.yahoo.jdisc.SharedResource; import com.yahoo.log.LogLevel; import java.security.SecureRandom; -import java.util.Random; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; @@ -37,20 +36,22 @@ public class Deconstructor implements ComponentDeconstructor { @Override public void deconstruct(Object component) { + // The mix of deconstructing some components on separate thread and some on caller thread could in theory violate + // ordering contraints between components. if (component instanceof AbstractComponent) { AbstractComponent abstractComponent = (AbstractComponent) component; if (abstractComponent.isDeconstructable()) { executor.schedule(new DestructComponentTask(abstractComponent), delay, TimeUnit.SECONDS); } } else if (component instanceof Provider) { - log.info("Starting deconstruction of " + component); + // TODO Providers should most likely be deconstructed similarily to AbstractComponent + log.info("Starting deconstruction of provider " + component); ((Provider)component).deconstruct(); - log.info("Finished deconstructing " + component); + log.info("Finished deconstructing of provider " + component); } else if (component instanceof SharedResource) { + log.info("Releasing container reference to resource " + component); // No need to delay release, as jdisc does ref-counting - log.info("Starting deconstruction of " + component); ((SharedResource)component).release(); - log.info("Finished deconstructing " + component); } } @@ -68,29 +69,29 @@ public class Deconstructor implements ComponentDeconstructor { } public void run() { - log.info("Starting deconstruction of " + component); + log.info("Starting deconstruction of component " + component); try { component.deconstruct(); - log.info("Finished deconstructing " + component); + log.info("Finished deconstructing of component " + component); } catch (Exception | NoClassDefFoundError e) { // May get class not found due to it being already unloaded - log.log(WARNING, "Exception thrown when deconstructing " + component, e); + log.log(WARNING, "Exception thrown when deconstructing component " + component, e); } catch (Error e) { try { // Randomize restart over 10 minutes to avoid simultaneous cluster restarts long randomSleepSeconds = random() * 60 * 10; - log.log(LogLevel.FATAL, "Error when deconstructing " + component + ". Will sleep for " + + log.log(LogLevel.FATAL, "Error when deconstructing component " + component + ". Will sleep for " + randomSleepSeconds + " seconds then restart", e); Thread.sleep(randomSleepSeconds * 1000); } catch (InterruptedException exception) { log.log(WARNING, "Randomized wait before dying disrupted. Dying now."); } - com.yahoo.protect.Process.logAndDie("Shutting down due to error when deconstructing " + component); + com.yahoo.protect.Process.logAndDie("Shutting down due to error when deconstructing component " + component); } catch (Throwable e) { - log.log(WARNING, "Non-error not exception throwable thrown when deconstructing " + component, e); + log.log(WARNING, "Non-error not exception throwable thrown when deconstructing component " + component, e); } } } |