diff options
author | gjoranv <gv@yahoo-inc.com> | 2017-04-25 14:33:33 +0200 |
---|---|---|
committer | gjoranv <gv@yahoo-inc.com> | 2017-04-25 14:37:57 +0200 |
commit | 20ff7472415dacce973414c99ee5face4f0d69fe (patch) | |
tree | 69c84f9add1f895f94987de8efc2bf992197b621 | |
parent | dfedaf3af4452ea9ae9145a61e42625843044304 (diff) |
Add debug logging for AbstractComponent deconstruction.
-rw-r--r-- | container-disc/src/main/java/com/yahoo/container/jdisc/component/Deconstructor.java | 15 |
1 files changed, 11 insertions, 4 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 c5796ffd290..f5061c416c8 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 @@ -2,7 +2,6 @@ package com.yahoo.container.jdisc.component; import com.yahoo.component.AbstractComponent; -import com.yahoo.concurrent.DaemonThreadFactory; import com.yahoo.concurrent.ThreadFactoryFactory; import com.yahoo.container.di.ComponentDeconstructor; import com.yahoo.container.di.componentgraph.Provider; @@ -11,12 +10,17 @@ import com.yahoo.jdisc.SharedResource; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; +import java.util.logging.Logger; + +import static com.yahoo.log.LogLevel.DEBUG; /** * @author tonyv * @author gv */ public class Deconstructor implements ComponentDeconstructor { + private static final Logger log = Logger.getLogger(Deconstructor.class.getName()); + private final ScheduledExecutorService executor = Executors.newScheduledThreadPool(1, ThreadFactoryFactory.getDaemonThreadFactory("deconstructor")); @@ -31,9 +35,10 @@ public class Deconstructor implements ComponentDeconstructor { public void deconstruct(Object component) { if (component instanceof AbstractComponent) { AbstractComponent abstractComponent = (AbstractComponent) component; - if (abstractComponent.isDeconstructable()) - executor.schedule( - new DestructComponentTask(abstractComponent), delay, TimeUnit.SECONDS); + if (abstractComponent.isDeconstructable()) { + log.log(DEBUG, () -> "Scheduling deconstruction of " + abstractComponent); + executor.schedule(new DestructComponentTask(abstractComponent), delay, TimeUnit.SECONDS); + } } else if (component instanceof Provider) { ((Provider)component).deconstruct(); } else if (component instanceof SharedResource) { @@ -50,7 +55,9 @@ public class Deconstructor implements ComponentDeconstructor { } public void run() { + log.log(DEBUG, () -> "Starting deconstruction of " + component); component.deconstruct(); + log.log(DEBUG, () -> "Finished deconstructing " + component); } } } |