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;
.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) {
private ListenerRegistration<SchemaContextListener> 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;
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) {
@Override
public void onSessionInitiated(final Broker.ProviderSession session) {
- brokerSession = session;
+ schemaService = session.getService(SchemaService.class);
+ rpcService = session.getService(DOMRpcService.class);
start();
}
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());
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<Builder>{
public Builder(String actorSystemName){
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);
}
}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+ xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
+ xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
+ odl:restart-dependents-on-updates="true" odl:use-default-for-reference-types="true">
+
+ <cm:property-placeholder persistent-id="org.opendaylight.controller.remoterpc" update-strategy="none">
+ <cm:default-properties>
+ <cm:property name="enable-metric-capture" value="false"/>
+ <cm:property name="bounded-mailbox-capacity" value="1000"/>
+ </cm:default-properties>
+ </cm:property-placeholder>
+
+ <reference id="actorSystemProvider" interface="org.opendaylight.controller.cluster.ActorSystemProvider" />
+ <reference id="schemaService" interface="org.opendaylight.controller.sal.core.api.model.SchemaService" />
+ <reference id="domRpcService" interface="org.opendaylight.controller.md.sal.dom.api.DOMRpcService"/>
+ <reference id="domRpcRegistry" interface="org.opendaylight.controller.md.sal.dom.api.DOMRpcProviderService"/>
+
+ <bean id="actorSystem" factory-ref="actorSystemProvider" factory-method="getActorSystem"/>
+
+ <bean id="remoteRpcProviderConfig" class="org.opendaylight.controller.remote.rpc.RemoteRpcProviderConfig"
+ factory-method="newInstance">
+ <argument>
+ <bean factory-ref="actorSystem" factory-method="name"/>
+ </argument>
+ <argument value="${enable-metric-capture}"/>
+ <argument value="${bounded-mailbox-capacity}"/>
+ </bean>
+
+ <bean id="remoteRpcProvider" class="org.opendaylight.controller.remote.rpc.RemoteRpcProviderFactory"
+ factory-method="createInstance" init-method="start" destroy-method="close">
+ <argument ref="domRpcRegistry"/>
+ <argument ref="actorSystem"/>
+ <argument ref="remoteRpcProviderConfig"/>
+ <property name="schemaService" ref="schemaService"/>
+ <property name="rpcService" ref="domRpcService"/>
+ </bean>
+
+</blueprint>