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%2Fregistry%2FRoutingTable.java;h=52b1106c873872609e4300abe52d558ee89a6011;hp=d99faabfe45365fdc69dd7c45fa566f09e43f6e4;hb=1c9255fca204f4f7207d4fe3521fbfcdf087e10d;hpb=f3bc7a6b7d0326e5594604cdc144b967c2a9cdb4 diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/registry/RoutingTable.java b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/registry/RoutingTable.java index d99faabfe4..52b1106c87 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/registry/RoutingTable.java +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/registry/RoutingTable.java @@ -10,23 +10,22 @@ package org.opendaylight.controller.remote.rpc.registry; import akka.actor.ActorRef; import akka.japi.Option; import akka.japi.Pair; -import org.opendaylight.controller.remote.rpc.registry.gossip.Copier; -import org.opendaylight.controller.sal.connector.api.RpcRouter; - import java.io.Serializable; -import java.util.Collections; import java.util.HashMap; import java.util.Map; +import org.opendaylight.controller.remote.rpc.registry.gossip.Copier; +import org.opendaylight.controller.sal.connector.api.RpcRouter; public class RoutingTable implements Copier, Serializable { + private static final long serialVersionUID = 1L; - private Map, Long> table = new HashMap<>(); + private final Map, Long> table = new HashMap<>(); private ActorRef router; @Override public RoutingTable copy() { RoutingTable copy = new RoutingTable(); - copy.setTable(Collections.unmodifiableMap(table)); + copy.table.putAll(table); copy.setRouter(this.getRouter()); return copy; @@ -35,10 +34,11 @@ public class RoutingTable implements Copier, Serializable { public Option> getRouterFor(RpcRouter.RouteIdentifier routeId){ Long updatedTime = table.get(routeId); - if (updatedTime == null || router == null) + if (updatedTime == null || router == null) { return Option.none(); - else + } else { return Option.option(new Pair<>(router, updatedTime)); + } } public void addRoute(RpcRouter.RouteIdentifier routeId){ @@ -49,23 +49,16 @@ public class RoutingTable implements Copier, Serializable { table.remove(routeId); } - public Boolean contains(RpcRouter.RouteIdentifier routeId){ + public boolean contains(RpcRouter.RouteIdentifier routeId){ return table.containsKey(routeId); } - public Boolean isEmpty(){ + public boolean isEmpty(){ return table.isEmpty(); } - /// - /// Getter, Setters - /// - //TODO: Remove public - public Map, Long> getTable() { - return table; - } - void setTable(Map, Long> table) { - this.table = table; + public int size() { + return table.size(); } public ActorRef getRouter() {