X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-remoterpc-connector%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fremote%2Frpc%2FRoutedRpcListener.java;h=2aaac5a78ed531fc830bfca7540d2603a2e0f41b;hp=a6eeac02708a20e8a746581d80c5054a776ed671;hb=531621aac4cff9d39cbd8668a53bdeba8a0e6d81;hpb=4a8d4efda0828bc0c147dee3644c51baa6ff5a15 diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/RoutedRpcListener.java b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/RoutedRpcListener.java index a6eeac0270..2aaac5a78e 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/RoutedRpcListener.java +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/RoutedRpcListener.java @@ -13,15 +13,14 @@ import akka.actor.ActorRef; import com.google.common.base.Preconditions; import org.opendaylight.controller.md.sal.common.api.routing.RouteChange; import org.opendaylight.controller.md.sal.common.api.routing.RouteChangeListener; -import org.opendaylight.controller.remote.rpc.messages.AddRoutedRpc; -import org.opendaylight.controller.remote.rpc.messages.RemoveRoutedRpc; -import org.opendaylight.controller.remote.rpc.utils.ActorUtil; +import org.opendaylight.controller.remote.rpc.registry.RpcRegistry; import org.opendaylight.controller.sal.connector.api.RpcRouter; import org.opendaylight.controller.sal.core.api.RpcRoutingContext; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.ArrayList; import java.util.HashSet; import java.util.Map; import java.util.Set; @@ -29,23 +28,24 @@ import java.util.Set; public class RoutedRpcListener implements RouteChangeListener{ private static final Logger LOG = LoggerFactory.getLogger(RoutedRpcListener.class); private final ActorRef rpcRegistry; - private final String actorPath; - public RoutedRpcListener(ActorRef rpcRegistry, String actorPath) { + public RoutedRpcListener(ActorRef rpcRegistry) { Preconditions.checkNotNull(rpcRegistry, "rpc registry actor should not be null"); - Preconditions.checkNotNull(actorPath, "actor path of rpc broker on current node should not be null"); this.rpcRegistry = rpcRegistry; - this.actorPath = actorPath; } @Override public void onRouteChange(RouteChange routeChange) { Map> announcements = routeChange.getAnnouncements(); - announce(getRouteIdentifiers(announcements)); + if(announcements != null && announcements.size() > 0){ + announce(getRouteIdentifiers(announcements)); + } Map> removals = routeChange.getRemovals(); - remove(getRouteIdentifiers(removals)); + if(removals != null && removals.size() > 0 ) { + remove(getRouteIdentifiers(removals)); + } } /** @@ -53,14 +53,11 @@ public class RoutedRpcListener implements RouteChangeListener> announcements) { - LOG.debug("Announcing [{}]", announcements); - AddRoutedRpc addRpcMsg = new AddRoutedRpc(announcements, actorPath); - try { - ActorUtil.executeLocalOperation(rpcRegistry, addRpcMsg, ActorUtil.LOCAL_ASK_DURATION, ActorUtil.LOCAL_AWAIT_DURATION); - } catch (Exception e) { - // Just logging it because Akka API throws this exception - LOG.error(e.toString()); + if(LOG.isDebugEnabled()) { + LOG.debug("Announcing [{}]", announcements); } + RpcRegistry.Messages.AddOrUpdateRoutes addRpcMsg = new RpcRegistry.Messages.AddOrUpdateRoutes(new ArrayList<>(announcements)); + rpcRegistry.tell(addRpcMsg, ActorRef.noSender()); } /** @@ -68,14 +65,11 @@ public class RoutedRpcListener implements RouteChangeListener> removals){ - LOG.debug("Removing [{}]", removals); - RemoveRoutedRpc removeRpcMsg = new RemoveRoutedRpc(removals, actorPath); - try { - ActorUtil.executeLocalOperation(rpcRegistry, removeRpcMsg, ActorUtil.LOCAL_ASK_DURATION, ActorUtil.LOCAL_AWAIT_DURATION); - } catch (Exception e) { - // Just logging it because Akka API throws this exception - LOG.error(e.toString()); + if(LOG.isDebugEnabled()) { + LOG.debug("Removing [{}]", removals); } + RpcRegistry.Messages.RemoveRoutes removeRpcMsg = new RpcRegistry.Messages.RemoveRoutes(new ArrayList<>(removals)); + rpcRegistry.tell(removeRpcMsg, ActorRef.noSender()); } /**