Code Review
/
controller.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Removed uncessary calls to RpcBroker to find routes.
[controller.git]
/
opendaylight
/
md-sal
/
sal-remoterpc-connector
/
src
/
main
/
java
/
org
/
opendaylight
/
controller
/
remote
/
rpc
/
RemoteRpcProvider.java
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 8b4ce31d2ea0ee7e82352e72fd5249b37e6873a6..a1b6286a59c764aff95d57650e4356943ea44544 100644
(file)
--- 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
@@
-11,18
+11,19
@@
package org.opendaylight.controller.remote.rpc;
import akka.actor.ActorRef;
import akka.actor.ActorSystem;
import akka.actor.ActorRef;
import akka.actor.ActorSystem;
+import java.util.Collection;
+import org.opendaylight.controller.md.sal.dom.api.DOMRpcProviderService;
+import org.opendaylight.controller.md.sal.dom.api.DOMRpcService;
import org.opendaylight.controller.remote.rpc.messages.UpdateSchemaContext;
import org.opendaylight.controller.sal.core.api.Broker;
import org.opendaylight.controller.sal.core.api.Provider;
import org.opendaylight.controller.remote.rpc.messages.UpdateSchemaContext;
import org.opendaylight.controller.sal.core.api.Broker;
import org.opendaylight.controller.sal.core.api.Provider;
-import org.opendaylight.controller.sal.core.api.RpcProvisionRegistry;
import org.opendaylight.controller.sal.core.api.model.SchemaService;
import org.opendaylight.controller.sal.core.api.model.SchemaService;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.api.SchemaContextListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.api.SchemaContextListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.Collection;
-
/**
* This is the base class which initialize all the actors, listeners and
* default RPc implementation so remote invocation of rpcs.
/**
* This is the base class which initialize all the actors, listeners and
* default RPc implementation so remote invocation of rpcs.
@@
-31,30
+32,37
@@
public class RemoteRpcProvider implements AutoCloseable, Provider, SchemaContext
private static final Logger LOG = LoggerFactory.getLogger(RemoteRpcProvider.class);
private static final Logger LOG = LoggerFactory.getLogger(RemoteRpcProvider.class);
- private final
RpcProvisionRegistry
rpcProvisionRegistry;
+ private final
DOMRpcProviderService
rpcProvisionRegistry;
+ private ListenerRegistration<SchemaContextListener> schemaListenerRegistration;
private ActorSystem actorSystem;
private Broker.ProviderSession brokerSession;
private SchemaContext schemaContext;
private ActorRef rpcManager;
private ActorSystem actorSystem;
private Broker.ProviderSession brokerSession;
private SchemaContext schemaContext;
private ActorRef rpcManager;
- private RemoteRpcProviderConfig config;
+ private
final
RemoteRpcProviderConfig config;
- public RemoteRpcProvider(
ActorSystem actorSystem, RpcProvisionRegistry
rpcProvisionRegistry) {
+ public RemoteRpcProvider(
final ActorSystem actorSystem, final DOMRpcProviderService
rpcProvisionRegistry) {
this.actorSystem = actorSystem;
this.rpcProvisionRegistry = rpcProvisionRegistry;
this.actorSystem = actorSystem;
this.rpcProvisionRegistry = rpcProvisionRegistry;
-
this.
config = new RemoteRpcProviderConfig(actorSystem.settings().config());
+ config = new RemoteRpcProviderConfig(actorSystem.settings().config());
}
@Override
public void close() throws Exception {
}
@Override
public void close() throws Exception {
- if (this.actorSystem != null)
- this.actorSystem.shutdown();
+ if (actorSystem != null) {
+ actorSystem.shutdown();
+ actorSystem = null;
+ }
+ if (schemaListenerRegistration != null) {
+ schemaListenerRegistration.close();
+ schemaListenerRegistration = null;
+ }
}
@Override
}
@Override
- public void onSessionInitiated(Broker.ProviderSession session) {
-
this.
brokerSession = session;
+ public void onSessionInitiated(
final
Broker.ProviderSession session) {
+ brokerSession = session;
start();
}
start();
}
@@
-66,19
+74,18
@@
public class RemoteRpcProvider implements AutoCloseable, Provider, SchemaContext
private void start() {
LOG.info("Starting remote rpc service...");
private void start() {
LOG.info("Starting remote rpc service...");
- SchemaService schemaService = brokerSession.getService(SchemaService.class);
+ final SchemaService schemaService = brokerSession.getService(SchemaService.class);
+ final DOMRpcService rpcService = brokerSession.getService(DOMRpcService.class);
schemaContext = schemaService.getGlobalContext();
schemaContext = schemaService.getGlobalContext();
-
- rpcManager = actorSystem.actorOf(RpcManager.props(schemaContext, brokerSession, rpcProvisionRegistry),
- config.getRpcManagerName());
-
+ rpcManager = actorSystem.actorOf(RpcManager.props(schemaContext,
+ rpcProvisionRegistry, rpcService), config.getRpcManagerName());
+ schemaListenerRegistration = schemaService.registerSchemaContextListener(this);
LOG.debug("rpc manager started");
}
@Override
LOG.debug("rpc manager started");
}
@Override
- public void onGlobalContextUpdated(SchemaContext schemaContext) {
+ public void onGlobalContextUpdated(
final
SchemaContext schemaContext) {
this.schemaContext = schemaContext;
rpcManager.tell(new UpdateSchemaContext(schemaContext), null);
this.schemaContext = schemaContext;
rpcManager.tell(new UpdateSchemaContext(schemaContext), null);
-
}
}
}
}