From: Tom Pantelis Date: Sun, 6 Mar 2016 04:38:19 +0000 (-0500) Subject: Add blueprint wiring to sal-remoterpc-connector X-Git-Tag: release/boron~226 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=b3b985fc482c43274ea1f8fa70c05ed16d96af4d Add blueprint wiring to sal-remoterpc-connector Change-Id: I23877888fd49e7dbe4568a7b7a51409589d5ff63 Signed-off-by: Tom Pantelis --- diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/config/yang/config/remote_rpc_connector/RemoteRPCBrokerModule.java b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/config/yang/config/remote_rpc_connector/RemoteRPCBrokerModule.java index c68503c0fa..4ada10a887 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/config/yang/config/remote_rpc_connector/RemoteRPCBrokerModule.java +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/config/yang/config/remote_rpc_connector/RemoteRPCBrokerModule.java @@ -9,6 +9,8 @@ package org.opendaylight.controller.config.yang.config.remote_rpc_connector; import akka.actor.ActorSystem; +import org.opendaylight.controller.md.sal.dom.api.DOMRpcProviderService; +import org.opendaylight.controller.remote.rpc.RemoteRpcProvider; import org.opendaylight.controller.remote.rpc.RemoteRpcProviderConfig; import org.opendaylight.controller.remote.rpc.RemoteRpcProviderFactory; import org.opendaylight.controller.sal.core.api.Broker; @@ -44,7 +46,10 @@ public class RemoteRPCBrokerModule extends org.opendaylight.controller.config.ya .mailboxCapacity(getBoundedMailboxCapacity()) .build(); - return RemoteRpcProviderFactory.createInstance(broker, bundleContext, actorSystem, config); + RemoteRpcProvider rpcProvider = RemoteRpcProviderFactory.createInstance((DOMRpcProviderService)broker, + actorSystem, config); + broker.registerProvider(rpcProvider); + return rpcProvider; } public void setBundleContext(BundleContext bundleContext) { diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/RemoteRpcProvider.java b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/RemoteRpcProvider.java index bdfdfc2832..80aebd1918 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/RemoteRpcProvider.java +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/RemoteRpcProvider.java @@ -37,7 +37,8 @@ public class RemoteRpcProvider implements AutoCloseable, Provider, SchemaContext private ListenerRegistration schemaListenerRegistration; private final ActorSystem actorSystem; - private Broker.ProviderSession brokerSession; + private SchemaService schemaService; + private DOMRpcService rpcService; private SchemaContext schemaContext; private ActorRef rpcManager; private final RemoteRpcProviderConfig config; @@ -51,6 +52,14 @@ public class RemoteRpcProvider implements AutoCloseable, Provider, SchemaContext this.config = Preconditions.checkNotNull(config); } + public void setRpcService(DOMRpcService rpcService) { + this.rpcService = rpcService; + } + + public void setSchemaService(SchemaService schemaService) { + this.schemaService = schemaService; + } + @Override public void close() throws Exception { if (schemaListenerRegistration != null) { @@ -61,7 +70,8 @@ public class RemoteRpcProvider implements AutoCloseable, Provider, SchemaContext @Override public void onSessionInitiated(final Broker.ProviderSession session) { - brokerSession = session; + schemaService = session.getService(SchemaService.class); + rpcService = session.getService(DOMRpcService.class); start(); } @@ -70,11 +80,9 @@ public class RemoteRpcProvider implements AutoCloseable, Provider, SchemaContext return null; } - private void start() { + public void start() { LOG.info("Starting remote rpc service..."); - final SchemaService schemaService = brokerSession.getService(SchemaService.class); - final DOMRpcService rpcService = brokerSession.getService(DOMRpcService.class); schemaContext = schemaService.getGlobalContext(); rpcManager = actorSystem.actorOf(RpcManager.props(schemaContext, rpcProvisionRegistry, rpcService, config), config.getRpcManagerName()); diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/RemoteRpcProviderConfig.java b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/RemoteRpcProviderConfig.java index 995b1d5172..cb5097d24e 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/RemoteRpcProviderConfig.java +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/RemoteRpcProviderConfig.java @@ -82,6 +82,15 @@ public class RemoteRpcProviderConfig extends CommonConfig { return cachedGossipTickInterval; } + /** + * This is called via blueprint xml as the builder pattern can't be used. + */ + public static RemoteRpcProviderConfig newInstance(String actorSystemName, boolean metricCaptureEnabled, + int mailboxCapacity) { + return new Builder(actorSystemName).metricCaptureEnabled(metricCaptureEnabled). + mailboxCapacity(mailboxCapacity).build(); + } + public static class Builder extends CommonConfig.Builder{ public Builder(String actorSystemName){ 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 af36b8afc9..c6ec928ea7 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 @@ -10,16 +10,11 @@ package org.opendaylight.controller.remote.rpc; import akka.actor.ActorSystem; import org.opendaylight.controller.md.sal.dom.api.DOMRpcProviderService; -import org.opendaylight.controller.sal.core.api.Broker; -import org.osgi.framework.BundleContext; public class RemoteRpcProviderFactory { - public static RemoteRpcProvider createInstance(final Broker broker, final BundleContext bundleContext, + public static RemoteRpcProvider createInstance(final DOMRpcProviderService rpcProviderService, final ActorSystem actorSystem, final RemoteRpcProviderConfig config) { - final RemoteRpcProvider rpcProvider = new RemoteRpcProvider(actorSystem, (DOMRpcProviderService) broker, config); - - broker.registerProvider(rpcProvider); - return rpcProvider; + return new RemoteRpcProvider(actorSystem, rpcProviderService, config); } } diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/main/resources/org/opendaylight/blueprint/remote-rpc.xml b/opendaylight/md-sal/sal-remoterpc-connector/src/main/resources/org/opendaylight/blueprint/remote-rpc.xml new file mode 100644 index 0000000000..453c252cd6 --- /dev/null +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/main/resources/org/opendaylight/blueprint/remote-rpc.xml @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +