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 26ebb835942e8dae9c65e1055a0d59f81327f2ae..5cde9e4c46251c9ab87e49307b5989cda1fb016b 100644 (file)
@@ -35,5 +35,6 @@ odl-cluster-data {
 
       # snapshot-store.local.dir = "target/snapshots"
     }
+    disable-default-actor-system-quarantined-event-handling = "false"
   }
 }
index 75872f4ddbf202d3ed5f4d68b22fe523072572f8..eb98c4f3399973d17f57facb9c1961aceb3ad1db 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 977674c59b010cdfac37ca29b9c3a8f8a30d195d..182a1b40858ee2c010d02d6a5065372a965a6e03 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" />