2 * Copyright (c) 2017 Pantheon Technologies s.r.o. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.controller.cluster.akka.osgi.impl;
10 import akka.actor.Props;
11 import com.typesafe.config.Config;
12 import com.typesafe.config.ConfigException;
13 import org.opendaylight.controller.cluster.common.actor.QuarantinedMonitorActor;
14 import org.osgi.framework.BundleContext;
15 import org.slf4j.Logger;
16 import org.slf4j.LoggerFactory;
18 public final class QuarantinedMonitorActorPropsFactory {
19 private static final Logger LOG = LoggerFactory.getLogger(QuarantinedMonitorActorPropsFactory.class);
21 private static final String DEFAULT_HANDLING_DISABLED =
22 "akka.disable-default-actor-system-quarantined-event-handling";
24 private QuarantinedMonitorActorPropsFactory() {
28 public static Props createProps(final BundleContext bundleContext, final Config akkaConfig) {
30 if (akkaConfig.getBoolean(DEFAULT_HANDLING_DISABLED)) {
31 LOG.info("{} was set, default handling is disabled", DEFAULT_HANDLING_DISABLED);
32 return QuarantinedMonitorActor.props(() -> { });
34 } catch (ConfigException configEx) {
35 LOG.info("Akka config doesn't contain property {}. Therefore default handling will be used",
36 DEFAULT_HANDLING_DISABLED);
38 return QuarantinedMonitorActor.props(() -> {
39 // restart the entire karaf container
40 LOG.warn("Restarting karaf container");
41 System.setProperty("karaf.restart.jvm", "true");
42 System.setProperty("karaf.restart", "true");
43 bundleContext.getBundle(0).stop();