brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From geom...@apache.org
Subject [1/2] brooklyn-server git commit: Adds method to reset the shutdown flag within BrooklynShutdownHooks
Date Fri, 30 Jun 2017 13:14:29 GMT
Repository: brooklyn-server
Updated Branches:
  refs/heads/master 864380690 -> edfc80e93


Adds method to reset the shutdown flag within BrooklynShutdownHooks

Under karaf if you restarted the brooklyn-init bundle
either manually or due to a re-wire the management context would not
restart (requiring you to restart karaf). This change allows the OSGi
launcher to reset the shutdown flag enabling bundle / management context
restart


Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/70683089
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/70683089
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/70683089

Branch: refs/heads/master
Commit: 7068308917b7424a4ff3cdab1f4416e45508c399
Parents: 5ea1b1b
Author: Mark McKenna <m4rkmckenna@gmail.com>
Authored: Thu Jun 29 16:54:12 2017 +0100
Committer: Mark McKenna <m4rkmckenna@gmail.com>
Committed: Fri Jun 30 12:31:49 2017 +0100

----------------------------------------------------------------------
 .../mgmt/internal/BrooklynShutdownHooks.java    | 24 ++++++++++++++------
 .../brooklyn/launcher/osgi/OsgiLauncher.java    |  2 ++
 2 files changed, 19 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/70683089/core/src/main/java/org/apache/brooklyn/core/mgmt/internal/BrooklynShutdownHooks.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/mgmt/internal/BrooklynShutdownHooks.java
b/core/src/main/java/org/apache/brooklyn/core/mgmt/internal/BrooklynShutdownHooks.java
index 91ca5dc..2e4e0c6 100644
--- a/core/src/main/java/org/apache/brooklyn/core/mgmt/internal/BrooklynShutdownHooks.java
+++ b/core/src/main/java/org/apache/brooklyn/core/mgmt/internal/BrooklynShutdownHooks.java
@@ -18,11 +18,8 @@
  */
 package org.apache.brooklyn.core.mgmt.internal;
 
-import java.util.List;
-import java.util.Set;
-import java.util.concurrent.Semaphore;
-import java.util.concurrent.atomic.AtomicBoolean;
-
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.collect.Lists;
 import org.apache.brooklyn.api.entity.Entity;
 import org.apache.brooklyn.api.mgmt.ManagementContext;
 import org.apache.brooklyn.api.mgmt.Task;
@@ -40,8 +37,10 @@ import org.apache.brooklyn.util.time.Duration;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.collect.Lists;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.Semaphore;
+import java.util.concurrent.atomic.AtomicBoolean;
 
 public class BrooklynShutdownHooks {
 
@@ -100,6 +99,17 @@ public class BrooklynShutdownHooks {
         }
     }
 
+    public static void resetShutdownFlag() {
+        try {
+            semaphore.acquire();
+            isShutDown.compareAndSet(true, false);
+        } catch (InterruptedException e) {
+            throw new IllegalStateException("Could not reset shutdown flag", e);
+        } finally {
+            semaphore.release();
+        }
+    }
+
     public static void invokeStopAppsOnShutdown(ManagementContext managementContext) {
         try {
             semaphore.acquire();

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/70683089/karaf/init/src/main/java/org/apache/brooklyn/launcher/osgi/OsgiLauncher.java
----------------------------------------------------------------------
diff --git a/karaf/init/src/main/java/org/apache/brooklyn/launcher/osgi/OsgiLauncher.java
b/karaf/init/src/main/java/org/apache/brooklyn/launcher/osgi/OsgiLauncher.java
index e3aa079..fec5f71 100644
--- a/karaf/init/src/main/java/org/apache/brooklyn/launcher/osgi/OsgiLauncher.java
+++ b/karaf/init/src/main/java/org/apache/brooklyn/launcher/osgi/OsgiLauncher.java
@@ -20,6 +20,7 @@ import org.apache.brooklyn.api.mgmt.ha.HighAvailabilityMode;
 import org.apache.brooklyn.core.BrooklynVersionService;
 import org.apache.brooklyn.core.catalog.internal.CatalogInitialization;
 import org.apache.brooklyn.core.internal.BrooklynProperties;
+import org.apache.brooklyn.core.mgmt.internal.BrooklynShutdownHooks;
 import org.apache.brooklyn.core.mgmt.persist.PersistMode;
 import org.apache.brooklyn.launcher.common.BasicLauncher;
 import org.apache.brooklyn.launcher.common.BrooklynPropertiesFactoryHelper;
@@ -96,6 +97,7 @@ public class OsgiLauncher extends BasicLauncher<OsgiLauncher> {
     // init-method can't find the start method for some reason, provide an alternative
     public void init() {
         synchronized (reloadLock) {
+            BrooklynShutdownHooks.resetShutdownFlag();
             LOG.debug("OsgiLauncher init");
             catalogInitialization(new CatalogInitialization(String.format("file:%s", defaultCatalogLocation),
false, null, false));
             start();


Mime
View raw message