From: Robert Varga Date: Sun, 12 Jul 2020 10:22:35 +0000 (+0200) Subject: Convert sal-remoterpc-provided to OSGi DS X-Git-Tag: v2.0.3~8 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=af949a92a9c9f055dcb71958ef805730c45377ce;hp=eb38eebf5bcb5190246d7a022731ca2922c8ce18;ds=sidebyside Convert sal-remoterpc-provided to OSGi DS Declarative Services offer better integration with OSGi lifecycle, use them instead of blueprint. Change-Id: I49b41fa0fba4714f54e097820b85aefe7da67364 Signed-off-by: Robert Varga --- diff --git a/opendaylight/md-sal/sal-remoterpc-connector/pom.xml b/opendaylight/md-sal/sal-remoterpc-connector/pom.xml index e3d0668f86..d83880c1d4 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/pom.xml +++ b/opendaylight/md-sal/sal-remoterpc-connector/pom.xml @@ -32,6 +32,12 @@ com.typesafe.akka akka-osgi_2.13 + + + org.osgi + org.osgi.compendium + + com.typesafe.akka @@ -77,11 +83,7 @@ org.osgi - org.osgi.core - - - org.slf4j - slf4j-api + osgi.cmpn org.scala-lang diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/OSGiRemoteOpsProvider.java b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/OSGiRemoteOpsProvider.java new file mode 100644 index 0000000000..605337111c --- /dev/null +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/OSGiRemoteOpsProvider.java @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2020 PANTHEON.tech, s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.controller.remote.rpc; + +import akka.actor.ActorRef; +import akka.actor.ActorSystem; +import akka.actor.PoisonPill; +import org.opendaylight.controller.cluster.ActorSystemProvider; +import org.opendaylight.mdsal.dom.api.DOMActionProviderService; +import org.opendaylight.mdsal.dom.api.DOMActionService; +import org.opendaylight.mdsal.dom.api.DOMRpcProviderService; +import org.opendaylight.mdsal.dom.api.DOMRpcService; +import org.osgi.service.component.annotations.Activate; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.Deactivate; +import org.osgi.service.component.annotations.Reference; +import org.osgi.service.metatype.annotations.AttributeDefinition; +import org.osgi.service.metatype.annotations.Designate; +import org.osgi.service.metatype.annotations.ObjectClassDefinition; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@Component(immediate = true, configurationPid = "org.opendaylight.controller.remoterpc") +@Designate(ocd = OSGiRemoteOpsProvider.Config.class) +public final class OSGiRemoteOpsProvider { + @ObjectClassDefinition() + public @interface Config { + @AttributeDefinition(name = "enable-metric-capture") + boolean metricCapture() default true; + @AttributeDefinition(name = "bounded-mailbox-capacity") + int boundedMailboxCapacity() default 1000; + } + + private static final Logger LOG = LoggerFactory.getLogger(OSGiRemoteOpsProvider.class); + + @Reference + ActorSystemProvider actorSystemProvider = null; + @Reference + DOMRpcProviderService rpcProviderService = null; + @Reference + DOMRpcService rpcService = null; + @Reference + DOMActionProviderService actionProviderService = null; + @Reference + DOMActionService actionService = null; + + private ActorRef opsManager; + + @Activate + void activate(final Config config) { + LOG.info("Remote Operations service starting"); + final ActorSystem actorSystem = actorSystemProvider.getActorSystem(); + final RemoteOpsProviderConfig opsConfig = RemoteOpsProviderConfig.newInstance(actorSystem.name(), + config.metricCapture(), config.boundedMailboxCapacity()); + + opsManager = actorSystem.actorOf(OpsManager.props(rpcProviderService, rpcService, opsConfig, + actionProviderService, actionService), opsConfig.getRpcManagerName()); + LOG.debug("Ops Manager started at {}", opsManager); + LOG.info("Remote Operations service started"); + } + + @Deactivate + void deactivate() { + LOG.info("Remote Operations service stopping"); + LOG.debug("Stopping Ops Manager at {}", opsManager); + opsManager.tell(PoisonPill.getInstance(), ActorRef.noSender()); + opsManager = null; + LOG.info("Remote Operations services stopped"); + } +} diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/main/resources/OSGI-INF/blueprint/remote-rpc.xml b/opendaylight/md-sal/sal-remoterpc-connector/src/main/resources/OSGI-INF/blueprint/remote-rpc.xml deleted file mode 100644 index c33659ae1e..0000000000 --- a/opendaylight/md-sal/sal-remoterpc-connector/src/main/resources/OSGI-INF/blueprint/remote-rpc.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -