X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-remoterpc-connector%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fremote%2Frpc%2FRemoteRpcProviderFactory.java;h=c82a72eaa56c82e40388b8fb612eed7b198dbae8;hb=3e5bfba47ae5fe04360343073273a141730daefd;hp=0e6b795c058877069640a848fe1144575db37443;hpb=3671ac415342e718f34c16d272647abd15b742c1;p=controller.git diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/RemoteRpcProviderFactory.java b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/RemoteRpcProviderFactory.java index 0e6b795c05..c82a72eaa5 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/RemoteRpcProviderFactory.java +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/RemoteRpcProviderFactory.java @@ -8,19 +8,44 @@ package org.opendaylight.controller.remote.rpc; - -import org.opendaylight.controller.remote.rpc.utils.DefaultAkkaConfigurationReader; +import akka.actor.ActorSystem; +import akka.osgi.BundleDelegatingClassLoader; +import com.typesafe.config.Config; import org.opendaylight.controller.sal.core.api.Broker; import org.opendaylight.controller.sal.core.api.RpcProvisionRegistry; import org.osgi.framework.BundleContext; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class RemoteRpcProviderFactory { - public static RemoteRpcProvider createInstance(final Broker broker, final BundleContext bundleContext){ + private static final Logger LOG = LoggerFactory.getLogger(RemoteRpcProviderFactory.class); + + public static RemoteRpcProvider createInstance( + final Broker broker, final BundleContext bundleContext, final RemoteRpcProviderConfig config){ - ActorSystemFactory.createInstance(bundleContext, new DefaultAkkaConfigurationReader()); RemoteRpcProvider rpcProvider = - new RemoteRpcProvider(ActorSystemFactory.getInstance(), (RpcProvisionRegistry) broker); + new RemoteRpcProvider(createActorSystem(bundleContext, config), (RpcProvisionRegistry) broker); + broker.registerProvider(rpcProvider); return rpcProvider; } + + private static ActorSystem createActorSystem(BundleContext bundleContext, RemoteRpcProviderConfig config){ + + // Create an OSGi bundle classloader for actor system + BundleDelegatingClassLoader classLoader = + new BundleDelegatingClassLoader(bundleContext.getBundle(), + Thread.currentThread().getContextClassLoader()); + + Config actorSystemConfig = config.get(); + if(LOG.isDebugEnabled()) { + LOG.debug("Actor system configuration\n{}", actorSystemConfig.root().render()); + } + if (config.isMetricCaptureEnabled()) { + LOG.info("Instrumentation is enabled in actor system {}. Metrics can be viewed in JMX console.", + config.getActorSystemName()); + } + + return ActorSystem.create(config.getActorSystemName(), actorSystemConfig, classLoader); + } }