Add option to disable default ActorSystemQuarantinedEvent handling 52/90552/2
authorTibor Král <tibor.kral@pantheon.tech>
Thu, 11 Jun 2020 08:28:55 +0000 (10:28 +0200)
committerRobert Varga <nite@hq.sk>
Mon, 22 Jun 2020 10:18:43 +0000 (10:18 +0000)
The default reaction to ThisActorSystemQuarantinedEvent is to
restart the entire Karaf container. However some users may want
to process the event differently.

JIRA: CONTROLLER-1949
Change-Id: Id65d31749dd97cb067611f7cfe4df76a6fe12204
Signed-off-by: Tibor Král <tibor.kral@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
opendaylight/md-sal/sal-clustering-config/src/main/resources/initial/akka.conf
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/akka/osgi/impl/QuarantinedMonitorActorPropsFactory.java
opendaylight/md-sal/sal-distributed-datastore/src/main/resources/OSGI-INF/blueprint/clustered-datastore.xml

index 26ebb83..5cde9e4 100644 (file)
@@ -35,5 +35,6 @@ odl-cluster-data {
 
       # snapshot-store.local.dir = "target/snapshots"
     }
+    disable-default-actor-system-quarantined-event-handling = "false"
   }
 }
index 75872f4..eb98c4f 100644 (file)
@@ -8,6 +8,8 @@
 package org.opendaylight.controller.cluster.akka.osgi.impl;
 
 import akka.actor.Props;
+import com.typesafe.config.Config;
+import com.typesafe.config.ConfigException;
 import org.opendaylight.controller.cluster.common.actor.QuarantinedMonitorActor;
 import org.osgi.framework.BundleContext;
 import org.slf4j.Logger;
@@ -16,11 +18,23 @@ import org.slf4j.LoggerFactory;
 public final class QuarantinedMonitorActorPropsFactory {
     private static final Logger LOG = LoggerFactory.getLogger(QuarantinedMonitorActorPropsFactory.class);
 
+    private static final String DEFAULT_HANDLING_DISABLED =
+        "akka.disable-default-actor-system-quarantined-event-handling";
+
     private QuarantinedMonitorActorPropsFactory() {
 
     }
 
-    public static Props createProps(final BundleContext bundleContext) {
+    public static Props createProps(final BundleContext bundleContext, final Config akkaConfig) {
+        try {
+            if (akkaConfig.getBoolean(DEFAULT_HANDLING_DISABLED)) {
+                LOG.info("{} was set, default handling is disabled", DEFAULT_HANDLING_DISABLED);
+                return QuarantinedMonitorActor.props(() -> { });
+            }
+        } catch (ConfigException configEx) {
+            LOG.info("Akka config doesn't contain property {}. Therefore default handling will be used",
+                DEFAULT_HANDLING_DISABLED);
+        }
         return QuarantinedMonitorActor.props(() -> {
             // restart the entire karaf container
             LOG.warn("Restarting karaf container");
index 977674c..182a1b4 100644 (file)
     <argument ref="blueprintBundleContext" />
   </bean>
 
-  <bean id="actorSystemProps" class="org.opendaylight.controller.cluster.akka.osgi.impl.QuarantinedMonitorActorPropsFactory"
-          factory-method="createProps">
-    <argument ref="blueprintBundleContext" />
-  </bean>
-
   <bean id="akkaReader" class="org.opendaylight.controller.cluster.common.actor.FileAkkaConfigurationReader"/>
   <bean id="akkaConfig" class="org.opendaylight.controller.cluster.akka.impl.AkkaConfigFactory"
           factory-method="createAkkaConfig">
     <argument ref="akkaReader" />
   </bean>
 
+  <bean id="actorSystemProps" class="org.opendaylight.controller.cluster.akka.osgi.impl.QuarantinedMonitorActorPropsFactory"
+        factory-method="createProps">
+    <argument ref="blueprintBundleContext" />
+    <argument ref="akkaConfig"/>
+  </bean>
+
   <bean id="actorSystemProvider" class="org.opendaylight.controller.cluster.akka.impl.ActorSystemProviderImpl"
           destroy-method="close">
     <argument ref="bundleClassLoader" />

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.