diff options
author | Bjørn Christian Seime <bjorncs@oath.com> | 2018-04-16 16:04:36 +0200 |
---|---|---|
committer | Bjørn Christian Seime <bjorncs@oath.com> | 2018-04-16 16:12:11 +0200 |
commit | 80bf8ce667fe63af8c6034aa50a1a72b3c51ea02 (patch) | |
tree | 584761c6d9ef58d4a2ee729f6dd4a4ce1f935e87 /jdisc_core/src/main/java/com/yahoo/jdisc/core/ApplicationLoader.java | |
parent | 7c90afed7e18ebac57ba0dd7986c1a4159f78c98 (diff) |
Introduce simple container watchdog
This watchdog uses information from the reference count framework in
jdisc_core. Contains no use of System.gc() or WeakReference.
Diffstat (limited to 'jdisc_core/src/main/java/com/yahoo/jdisc/core/ApplicationLoader.java')
-rw-r--r-- | jdisc_core/src/main/java/com/yahoo/jdisc/core/ApplicationLoader.java | 10 |
1 files changed, 9 insertions, 1 deletions
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 81eb5815a01..3ba48ffd8cd 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 @@ -15,6 +15,7 @@ import com.yahoo.jdisc.application.OsgiFramework; import com.yahoo.jdisc.application.OsgiHeader; import com.yahoo.jdisc.service.ContainerNotReadyException; import com.yahoo.jdisc.service.CurrentContainer; +import com.yahoo.jdisc.statistics.ContainerWatchdogMetrics; import org.osgi.framework.Bundle; import org.osgi.framework.BundleContext; import org.osgi.framework.BundleException; @@ -40,6 +41,7 @@ public class ApplicationLoader implements BootstrapLoader, ContainerActivator, C private final AtomicReference<ActiveContainer> containerRef = new AtomicReference<>(); private final Object appLock = new Object(); private final List<Bundle> appBundles = new ArrayList<>(); + private final ContainerWatchdog watchdog = new ContainerWatchdog(); private Application application; private ApplicationInUseTracker applicationInUseTracker; @@ -68,6 +70,7 @@ public class ApplicationLoader implements BootstrapLoader, ContainerActivator, C next.retainReference(applicationInUseTracker); } + watchdog.onContainerActivation(next); prev = containerRef.getAndSet(next); if (prev == null) { return null; @@ -193,8 +196,9 @@ public class ApplicationLoader implements BootstrapLoader, ContainerActivator, C public void destroy() { log.finer("Destroying application loader."); try { + watchdog.close(); osgiFramework.stop(); - } catch (BundleException e) { + } catch (BundleException | InterruptedException e) { e.printStackTrace(); } } @@ -205,6 +209,10 @@ public class ApplicationLoader implements BootstrapLoader, ContainerActivator, C } } + public ContainerWatchdogMetrics getContainerWatchdogMetrics() { + return watchdog; + } + public OsgiFramework osgiFramework() { return osgiFramework; } |