adding or removing routes.
Removed few redundant defensive null checks.
Change-Id: I24310d2a3871a4bff2afa5a06b3657f4d2709794
Signed-off-by: Abhishek Kumar <abhishk2@cisco.com>
return table.containsKey(routeId);
}
return table.containsKey(routeId);
}
+ public Boolean isEmpty(){
+ return table.isEmpty();
+ }
///
/// Getter, Setters
///
///
/// Getter, Setters
///
import java.util.List;
import java.util.Map;
import java.util.List;
import java.util.Map;
-import static org.opendaylight.controller.remote.rpc.registry.RpcRegistry.Messages.AddOrUpdateRoute;
-import static org.opendaylight.controller.remote.rpc.registry.RpcRegistry.Messages.RemoveRoute;
+import static org.opendaylight.controller.remote.rpc.registry.RpcRegistry.Messages.AddOrUpdateRoutes;
+import static org.opendaylight.controller.remote.rpc.registry.RpcRegistry.Messages.RemoveRoutes;
import static org.opendaylight.controller.remote.rpc.registry.RpcRegistry.Messages.SetLocalRouter;
import static org.opendaylight.controller.remote.rpc.registry.RpcRegistry.Messages.SetLocalRouter;
+import static org.opendaylight.controller.remote.rpc.registry.RpcRegistry.Messages.FindRouters;
import static org.opendaylight.controller.remote.rpc.registry.gossip.Messages.BucketStoreMessages.GetAllBuckets;
import static org.opendaylight.controller.remote.rpc.registry.gossip.Messages.BucketStoreMessages.GetAllBucketsReply;
import static org.opendaylight.controller.remote.rpc.registry.gossip.Messages.BucketStoreMessages.GetLocalBucket;
import static org.opendaylight.controller.remote.rpc.registry.gossip.Messages.BucketStoreMessages.GetAllBuckets;
import static org.opendaylight.controller.remote.rpc.registry.gossip.Messages.BucketStoreMessages.GetAllBucketsReply;
import static org.opendaylight.controller.remote.rpc.registry.gossip.Messages.BucketStoreMessages.GetLocalBucket;
/**
* Registry to look up cluster nodes that have registered for a given rpc.
/**
* Registry to look up cluster nodes that have registered for a given rpc.
* It uses {@link org.opendaylight.controller.remote.rpc.registry.gossip.BucketStore} to maintain this
* cluster wide information.
* It uses {@link org.opendaylight.controller.remote.rpc.registry.gossip.BucketStore} to maintain this
* cluster wide information.
*/
public class RpcRegistry extends UntypedActor {
*/
public class RpcRegistry extends UntypedActor {
if (message instanceof SetLocalRouter)
receiveSetLocalRouter((SetLocalRouter) message);
if (message instanceof SetLocalRouter)
receiveSetLocalRouter((SetLocalRouter) message);
- if (message instanceof AddOrUpdateRoute)
- receiveAddRoute((AddOrUpdateRoute) message);
+ if (message instanceof AddOrUpdateRoutes)
+ receiveAddRoutes((AddOrUpdateRoutes) message);
- else if (message instanceof RemoveRoute)
- receiveRemoveRoute((RemoveRoute) message);
+ else if (message instanceof RemoveRoutes)
+ receiveRemoveRoutes((RemoveRoutes) message);
else if (message instanceof Messages.FindRouters)
else if (message instanceof Messages.FindRouters)
- receiveGetRouter((Messages.FindRouters) message);
+ receiveGetRouter((FindRouters) message);
* @param message contains {@link akka.actor.ActorRef} for rpc broker
*/
private void receiveSetLocalRouter(SetLocalRouter message) {
* @param message contains {@link akka.actor.ActorRef} for rpc broker
*/
private void receiveSetLocalRouter(SetLocalRouter message) {
- if (message == null || message.getRouter() == null)
- return;//ignore
-
localRouter = message.getRouter();
}
/**
localRouter = message.getRouter();
}
/**
- * //TODO: update this to accept multiple route registration
- private void receiveAddRoute(AddOrUpdateRoute msg) {
- if (msg.getRouteIdentifier() == null)
- return;//ignore
+ private void receiveAddRoutes(AddOrUpdateRoutes msg) {
Preconditions.checkState(localRouter != null, "Router must be set first");
Future<Object> futureReply = Patterns.ask(bucketStore, new GetLocalBucket(), 1000);
Preconditions.checkState(localRouter != null, "Router must be set first");
Future<Object> futureReply = Patterns.ask(bucketStore, new GetLocalBucket(), 1000);
- futureReply.map(getMapperToAddRoute(msg.getRouteIdentifier()), getContext().dispatcher());
+ futureReply.map(getMapperToAddRoutes(msg.getRouteIdentifiers()), getContext().dispatcher());
- * //TODO: update this to accept multiple routes
- * @param msg
+ * @param msg contains list of route ids to remove
- private void receiveRemoveRoute(RemoveRoute msg) {
- if (msg.getRouteIdentifier() == null)
- return;//ignore
+ private void receiveRemoveRoutes(RemoveRoutes msg) {
Future<Object> futureReply = Patterns.ask(bucketStore, new GetLocalBucket(), 1000);
Future<Object> futureReply = Patterns.ask(bucketStore, new GetLocalBucket(), 1000);
- futureReply.map(getMapperToRemoveRoute(msg.getRouteIdentifier()), getContext().dispatcher());
+ futureReply.map(getMapperToRemoveRoutes(msg.getRouteIdentifiers()), getContext().dispatcher());
}
/**
* Finds routers for the given rpc.
}
/**
* Finds routers for the given rpc.
- private void receiveGetRouter(Messages.FindRouters msg) {
+ private void receiveGetRouter(FindRouters msg) {
final ActorRef sender = getSender();
final ActorRef sender = getSender();
- //if empty message, return empty list
- if (msg.getRouteIdentifier() == null) {
- sender.tell(createEmptyReply(), getSelf());
- return;
- }
-
Future<Object> futureReply = Patterns.ask(bucketStore, new GetAllBuckets(), 1000);
futureReply.map(getMapperToGetRouter(msg.getRouteIdentifier(), sender), getContext().dispatcher());
Future<Object> futureReply = Patterns.ask(bucketStore, new GetAllBuckets(), 1000);
futureReply.map(getMapperToGetRouter(msg.getRouteIdentifier(), sender), getContext().dispatcher());
/**
* Helper to create a reply when routers are found for the given rpc
/**
* Helper to create a reply when routers are found for the given rpc
* @param buckets
* @param routeId
* @return
* @param buckets
* @param routeId
* @return
private Messages.FindRoutersReply createReplyWithRouters(Map<Address, Bucket> buckets, RpcRouter.RouteIdentifier<?, ?, ?> routeId) {
List<Pair<ActorRef, Long>> routers = new ArrayList<>();
private Messages.FindRoutersReply createReplyWithRouters(Map<Address, Bucket> buckets, RpcRouter.RouteIdentifier<?, ?, ?> routeId) {
List<Pair<ActorRef, Long>> routers = new ArrayList<>();
Option<Pair<ActorRef, Long>> routerWithUpdateTime = null;
for (Bucket bucket : buckets.values()) {
RoutingTable table = (RoutingTable) bucket.getData();
Option<Pair<ActorRef, Long>> routerWithUpdateTime = null;
for (Bucket bucket : buckets.values()) {
RoutingTable table = (RoutingTable) bucket.getData();
if (table == null)
continue;
routerWithUpdateTime = table.getRouterFor(routeId);
if (table == null)
continue;
routerWithUpdateTime = table.getRouterFor(routeId);
if (routerWithUpdateTime.isEmpty())
continue;
if (routerWithUpdateTime.isEmpty())
continue;
- * Receives all buckets returned from bucket store and finds routers for the buckets where given rpc(routeId) is found
+ * Receives all buckets returned from bucket store and finds routers for the buckets where given rpc(routeId) is found
*
* @param routeId the rpc
* @param sender client who asked to find the routers.
*
* @param routeId the rpc
* @param sender client who asked to find the routers.
* Receives local bucket from bucket store and updates routing table in it by removing the route. Subsequently,
* it updates the local bucket in bucket store.
*
* Receives local bucket from bucket store and updates routing table in it by removing the route. Subsequently,
* it updates the local bucket in bucket store.
*
- * @param routeId rpc to remote
+ * @param routeIds rpc to remote
- private Mapper<Object, Void> getMapperToRemoveRoute(final RpcRouter.RouteIdentifier<?, ?, ?> routeId) {
+ private Mapper<Object, Void> getMapperToRemoveRoutes(final List<RpcRouter.RouteIdentifier<?, ?, ?>> routeIds) {
return new Mapper<Object, Void>() {
@Override
public Void apply(Object replyMessage) {
return new Mapper<Object, Void>() {
@Override
public Void apply(Object replyMessage) {
table = new RoutingTable();
table.setRouter(localRouter);
table = new RoutingTable();
table.setRouter(localRouter);
- table.removeRoute(routeId);
+ if (!table.isEmpty()) {
+ for (RpcRouter.RouteIdentifier<?, ?, ?> routeId : routeIds) {
+ table.removeRoute(routeId);
+ }
+ }
bucket.setData(table);
UpdateBucket updateBucketMessage = new UpdateBucket(bucket);
bucket.setData(table);
UpdateBucket updateBucketMessage = new UpdateBucket(bucket);
* Receives local bucket from bucket store and updates routing table in it by adding the route. Subsequently,
* it updates the local bucket in bucket store.
*
* Receives local bucket from bucket store and updates routing table in it by adding the route. Subsequently,
* it updates the local bucket in bucket store.
*
- * @param routeId rpc to add
+ * @param routeIds rpc to add
- private Mapper<Object, Void> getMapperToAddRoute(final RpcRouter.RouteIdentifier<?, ?, ?> routeId) {
+ private Mapper<Object, Void> getMapperToAddRoutes(final List<RpcRouter.RouteIdentifier<?, ?, ?>> routeIds) {
return new Mapper<Object, Void>() {
@Override
return new Mapper<Object, Void>() {
@Override
table = new RoutingTable();
table.setRouter(localRouter);
table = new RoutingTable();
table.setRouter(localRouter);
- table.addRoute(routeId);
+ for (RpcRouter.RouteIdentifier<?, ?, ?> routeId : routeIds) {
+ table.addRoute(routeId);
+ }
public static class ContainsRoute {
public static class ContainsRoute {
- final RpcRouter.RouteIdentifier<?,?,?> routeIdentifier;
+ final List<RpcRouter.RouteIdentifier<?, ?, ?>> routeIdentifiers;
- public ContainsRoute(RpcRouter.RouteIdentifier<?, ?, ?> routeIdentifier) {
- Preconditions.checkArgument(routeIdentifier != null);
- this.routeIdentifier = routeIdentifier;
+ public ContainsRoute(List<RpcRouter.RouteIdentifier<?, ?, ?>> routeIdentifiers) {
+ Preconditions.checkArgument(routeIdentifiers != null &&
+ !routeIdentifiers.isEmpty(),
+ "Route Identifiers must be supplied");
+ this.routeIdentifiers = routeIdentifiers;
- public RpcRouter.RouteIdentifier<?,?,?> getRouteIdentifier(){
- return this.routeIdentifier;
+ public List<RpcRouter.RouteIdentifier<?, ?, ?>> getRouteIdentifiers() {
+ return this.routeIdentifiers;
}
@Override
public String toString() {
}
@Override
public String toString() {
- return this.getClass().getSimpleName() + "{" +
- "routeIdentifier=" + routeIdentifier +
+ return "ContainsRoute{" +
+ "routeIdentifiers=" + routeIdentifiers +
- public static class AddOrUpdateRoute extends ContainsRoute{
+ public static class AddOrUpdateRoutes extends ContainsRoute {
- public AddOrUpdateRoute(RpcRouter.RouteIdentifier<?, ?, ?> routeIdentifier) {
- super(routeIdentifier);
+ public AddOrUpdateRoutes(List<RpcRouter.RouteIdentifier<?, ?, ?>> routeIdentifiers) {
+ super(routeIdentifiers);
- public static class RemoveRoute extends ContainsRoute {
+ public static class RemoveRoutes extends ContainsRoute {
- public RemoveRoute(RpcRouter.RouteIdentifier<?, ?, ?> routeIdentifier) {
- super(routeIdentifier);
+ public RemoveRoutes(List<RpcRouter.RouteIdentifier<?, ?, ?>> routeIdentifiers) {
+ super(routeIdentifiers);
- public static class SetLocalRouter{
+ public static class SetLocalRouter {
private final ActorRef router;
public SetLocalRouter(ActorRef router) {
private final ActorRef router;
public SetLocalRouter(ActorRef router) {
+ Preconditions.checkArgument(router != null, "Router must not be null");
- public ActorRef getRouter(){
+ public ActorRef getRouter() {
- public static class FindRouters extends ContainsRoute {
+ public static class FindRouters {
+ private final RpcRouter.RouteIdentifier<?, ?, ?> routeIdentifier;
+
public FindRouters(RpcRouter.RouteIdentifier<?, ?, ?> routeIdentifier) {
public FindRouters(RpcRouter.RouteIdentifier<?, ?, ?> routeIdentifier) {
- super(routeIdentifier);
+ Preconditions.checkArgument(routeIdentifier != null, "Route must not be null");
+ this.routeIdentifier = routeIdentifier;
+ }
+
+ public RpcRouter.RouteIdentifier<?, ?, ?> getRouteIdentifier() {
+ return routeIdentifier;
+ }
+
+ @Override
+ public String toString() {
+ return "FindRouters{" +
+ "routeIdentifier=" + routeIdentifier +
+ '}';
final List<Pair<ActorRef, Long>> routerWithUpdateTime;
public FindRoutersReply(List<Pair<ActorRef, Long>> routerWithUpdateTime) {
final List<Pair<ActorRef, Long>> routerWithUpdateTime;
public FindRoutersReply(List<Pair<ActorRef, Long>> routerWithUpdateTime) {
+ Preconditions.checkArgument(routerWithUpdateTime != null, "List of routers found must not be null");
this.routerWithUpdateTime = routerWithUpdateTime;
}
this.routerWithUpdateTime = routerWithUpdateTime;
}
- public List<Pair<ActorRef, Long>> getRouterWithUpdateTime(){
+ public List<Pair<ActorRef, Long>> getRouterWithUpdateTime() {
return routerWithUpdateTime;
}
return routerWithUpdateTime;
}
/**
* Gossiper that syncs bucket store across nodes in the cluster.
/**
* Gossiper that syncs bucket store across nodes in the cluster.
- * <p>
- * It keeps a local scheduler that periodically sends Gossip ticks to itself to send bucket store's bucket versions
- * to a randomly selected remote gossiper.
- * <p>
- * When bucket versions are received from a remote gossiper, it is compared with bucket store's bucket versions.
- * Which ever buckets are newer locally, are sent to remote gossiper. If any bucket is older in bucket store, a
- * gossip status is sent to remote gossiper so that it can send the newer buckets.
- * <p>
- * When a bucket is received from a remote gossiper, its sent to the bucket store for update.
+ * <p/>
+ * It keeps a local scheduler that periodically sends Gossip ticks to
+ * itself to send bucket store's bucket versions to a randomly selected remote
+ * gossiper.
+ * <p/>
+ * When bucket versions are received from a remote gossiper, it is compared
+ * with bucket store's bucket versions. Which ever buckets are newer
+ * locally, are sent to remote gossiper. If any bucket is older in bucket store,
+ * a gossip status is sent to remote gossiper so that it can send the newer buckets.
+ * <p/>
+ * When a bucket is received from a remote gossiper, its sent to the bucket store
+ * for update.
/**
* Helpful for testing
/**
* Helpful for testing
- * @param autoStartGossipTicks used for turning off gossip ticks during testing. Gossip tick can be manually sent.
+ * @param autoStartGossipTicks used for turning off gossip ticks during testing.
+ * Gossip tick can be manually sent.
*/
public Gossiper(Boolean autoStartGossipTicks){
this.autoStartGossipTicks = autoStartGossipTicks;
*/
public Gossiper(Boolean autoStartGossipTicks){
this.autoStartGossipTicks = autoStartGossipTicks;
if (autoStartGossipTicks) {
gossipTask = getContext().system().scheduler().schedule(
new FiniteDuration(1, TimeUnit.SECONDS), //initial delay
if (autoStartGossipTicks) {
gossipTask = getContext().system().scheduler().schedule(
new FiniteDuration(1, TimeUnit.SECONDS), //initial delay
- new FiniteDuration(500, TimeUnit.MILLISECONDS), //interval
+ new FiniteDuration(500, TimeUnit.MILLISECONDS), //interval
getSelf(), //target
new Messages.GossiperMessages.GossipTick(), //message
getContext().dispatcher(), //execution context
getSelf(), //target
new Messages.GossiperMessages.GossipTick(), //message
getContext().dispatcher(), //execution context
* @param status bucket versions from a remote member
*/
void receiveGossipStatus(GossipStatus status){
* @param status bucket versions from a remote member
*/
void receiveGossipStatus(GossipStatus status){
- //Dont want to accept messages from non-members
+ //Don't accept messages from non-members
if (!clusterMembers.contains(status.from()))
return;
final ActorRef sender = getSender();
if (!clusterMembers.contains(status.from()))
return;
final ActorRef sender = getSender();
Future<Object> futureReply = Patterns.ask(getContext().parent(), new GetBucketVersions(), 1000);
Future<Object> futureReply = Patterns.ask(getContext().parent(), new GetBucketVersions(), 1000);
futureReply.map(getMapperToProcessRemoteStatus(sender, status), getContext().dispatcher());
}
futureReply.map(getMapperToProcessRemoteStatus(sender, status), getContext().dispatcher());
}
void receiveGossip(GossipEnvelope envelope){
//TODO: Add more validations
if (!selfAddress.equals(envelope.to())) {
void receiveGossip(GossipEnvelope envelope){
//TODO: Add more validations
if (!selfAddress.equals(envelope.to())) {
- log.info("Ignoring message intended for someone else. From [{}] to [{}]", envelope.from(), envelope.to());
+ log.debug("Ignoring message intended for someone else. From [{}] to [{}]", envelope.from(), envelope.to());
- if (envelope.getBuckets() == null)
- return; //nothing to do
updateRemoteBuckets(envelope.getBuckets());
updateRemoteBuckets(envelope.getBuckets());
*/
void updateRemoteBuckets(Map<Address, Bucket> buckets) {
*/
void updateRemoteBuckets(Map<Address, Bucket> buckets) {
- if (buckets == null || buckets.isEmpty())
- return; //nothing to merge
-
UpdateRemoteBuckets updateRemoteBuckets = new UpdateRemoteBuckets(buckets);
UpdateRemoteBuckets updateRemoteBuckets = new UpdateRemoteBuckets(buckets);
getContext().parent().tell(updateRemoteBuckets, getSelf());
}
getContext().parent().tell(updateRemoteBuckets, getSelf());
}
void sendGossipTo(final ActorRef remote, final Set<Address> addresses){
Future<Object> futureReply = Patterns.ask(getContext().parent(), new GetBucketsByMembers(addresses), 1000);
void sendGossipTo(final ActorRef remote, final Set<Address> addresses){
Future<Object> futureReply = Patterns.ask(getContext().parent(), new GetBucketsByMembers(addresses), 1000);
futureReply.map(getMapperToSendGossip(remote), getContext().dispatcher());
futureReply.map(getMapperToSendGossip(remote), getContext().dispatcher());
//Get local status from bucket store and send to remote
Future<Object> futureReply = Patterns.ask(getContext().parent(), new GetBucketVersions(), 1000);
//Get local status from bucket store and send to remote
Future<Object> futureReply = Patterns.ask(getContext().parent(), new GetBucketVersions(), 1000);
ActorSelection remoteRef = getContext().system().actorSelection(
remoteActorSystemAddress.toString() + getSelf().path().toStringWithoutAddress());
ActorSelection remoteRef = getContext().system().actorSelection(
remoteActorSystemAddress.toString() + getSelf().path().toStringWithoutAddress());
- * Process bucket versions received from {@link org.opendaylight.controller.remote.rpc.registry.gossip.BucketStore}.
+ * Process bucket versions received from
+ * {@link org.opendaylight.controller.remote.rpc.registry.gossip.BucketStore}.
* Then this method compares remote bucket versions with local bucket versions.
* <ul>
* <li>The buckets that are newer locally, send
* Then this method compares remote bucket versions with local bucket versions.
* <ul>
* <li>The buckets that are newer locally, send
- * {@link org.opendaylight.controller.remote.rpc.registry.gossip.Messages.GossiperMessages.GossipEnvelope} to remote
+ * {@link org.opendaylight.controller.remote.rpc.registry.gossip.Messages.GossiperMessages.GossipEnvelope}
+ * to remote
* <li>The buckets that are older locally, send
* <li>The buckets that are older locally, send
- * {@link org.opendaylight.controller.remote.rpc.registry.gossip.Messages.GossiperMessages.GossipStatus} to remote so that
- * remote sends GossipEnvelop.
+ * {@link org.opendaylight.controller.remote.rpc.registry.gossip.Messages.GossiperMessages.GossipStatus}
+ * to remote so that remote sends GossipEnvelop.
* </ul>
*
* @param sender the remote member
* </ul>
*
* @param sender the remote member
- * Processes the message from {@link org.opendaylight.controller.remote.rpc.registry.gossip.BucketStore} that contains
- * {@link org.opendaylight.controller.remote.rpc.registry.gossip.Bucket}. These buckets are sent to a remote member encapsulated
- * in {@link org.opendaylight.controller.remote.rpc.registry.gossip.Messages.GossiperMessages.GossipEnvelope}
+ * Processes the message from {@link org.opendaylight.controller.remote.rpc.registry.gossip.BucketStore}
+ * that contains {@link org.opendaylight.controller.remote.rpc.registry.gossip.Bucket}.
+ * These buckets are sent to a remote member encapsulated in
+ * {@link org.opendaylight.controller.remote.rpc.registry.gossip.Messages.GossiperMessages.GossipEnvelope}
*
* @param sender the remote member that sent
* {@link org.opendaylight.controller.remote.rpc.registry.gossip.Messages.GossiperMessages.GossipStatus}
*
* @param sender the remote member that sent
* {@link org.opendaylight.controller.remote.rpc.registry.gossip.Messages.GossiperMessages.GossipStatus}
public Void apply(Object msg) {
if (msg instanceof GetBucketsByMembersReply) {
Map<Address, Bucket> buckets = ((GetBucketsByMembersReply) msg).getBuckets();
public Void apply(Object msg) {
if (msg instanceof GetBucketsByMembersReply) {
Map<Address, Bucket> buckets = ((GetBucketsByMembersReply) msg).getBuckets();
- log.info("Buckets to send from {}: {}", selfAddress, buckets);
+ log.debug("Buckets to send from {}: {}", selfAddress, buckets);
GossipEnvelope envelope = new GossipEnvelope(selfAddress, sender.path().address(), buckets);
sender.tell(envelope, getSelf());
}
GossipEnvelope envelope = new GossipEnvelope(selfAddress, sender.path().address(), buckets);
sender.tell(envelope, getSelf());
}
import java.util.Map;
import java.util.Set;
import java.util.Map;
import java.util.Set;
+import static org.opendaylight.controller.remote.rpc.registry.gossip.Messages.BucketStoreMessages.ContainsBucketVersions;
+import static org.opendaylight.controller.remote.rpc.registry.gossip.Messages.BucketStoreMessages.ContainsBuckets;
+
+
/**
* These messages are used by {@link org.opendaylight.controller.remote.rpc.registry.gossip.BucketStore} and
* {@link org.opendaylight.controller.remote.rpc.registry.gossip.Gossiper} actors.
/**
* These messages are used by {@link org.opendaylight.controller.remote.rpc.registry.gossip.BucketStore} and
* {@link org.opendaylight.controller.remote.rpc.registry.gossip.Gossiper} actors.
Map<Address, Long> versions;
public ContainsBucketVersions(Map<Address, Long> versions) {
Map<Address, Long> versions;
public ContainsBucketVersions(Map<Address, Long> versions) {
- Preconditions.checkArgument(versions != null, "versions can not be null");
+ Preconditions.checkArgument(versions != null, "versions can not be null or empty");
+
this.versions = versions;
}
this.versions = versions;
}
public static final class GossipTick extends Tick {}
public static final class GossipTick extends Tick {}
- public static final class GossipStatus extends BucketStoreMessages.ContainsBucketVersions implements Serializable{
+ public static final class GossipStatus extends ContainsBucketVersions implements Serializable{
private Address from;
public GossipStatus(Address from, Map<Address, Long> versions) {
private Address from;
public GossipStatus(Address from, Map<Address, Long> versions) {
- public static final class GossipEnvelope extends BucketStoreMessages.ContainsBuckets implements Serializable {
+ public static final class GossipEnvelope extends ContainsBuckets implements Serializable {
private final Address from;
private final Address to;
public GossipEnvelope(Address from, Address to, Map<Address, Bucket> buckets) {
super(buckets);
private final Address from;
private final Address to;
public GossipEnvelope(Address from, Address to, Map<Address, Bucket> buckets) {
super(buckets);
+ Preconditions.checkArgument(to != null, "Recipient of message must not be null");
this.to = to;
this.from = from;
}
this.to = to;
this.from = from;
}
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URI;
import java.net.URISyntaxException;
+import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.List;
import java.util.concurrent.TimeUnit;
-import static org.opendaylight.controller.remote.rpc.registry.RpcRegistry.Messages.AddOrUpdateRoute;
+import static org.opendaylight.controller.remote.rpc.registry.RpcRegistry.Messages.AddOrUpdateRoutes;
import static org.opendaylight.controller.remote.rpc.registry.RpcRegistry.Messages.FindRouters;
import static org.opendaylight.controller.remote.rpc.registry.RpcRegistry.Messages.FindRoutersReply;
import static org.opendaylight.controller.remote.rpc.registry.RpcRegistry.Messages.SetLocalRouter;
import static org.opendaylight.controller.remote.rpc.registry.RpcRegistry.Messages.FindRouters;
import static org.opendaylight.controller.remote.rpc.registry.RpcRegistry.Messages.FindRoutersReply;
import static org.opendaylight.controller.remote.rpc.registry.RpcRegistry.Messages.SetLocalRouter;
- private AddOrUpdateRoute getAddRouteMessage() throws URISyntaxException {
- return new AddOrUpdateRoute(createRouteId());
+ private AddOrUpdateRoutes getAddRouteMessage() throws URISyntaxException {
+ return new AddOrUpdateRoutes(createRouteIds());
+ }
+
+ private List<RpcRouter.RouteIdentifier<?,?,?>> createRouteIds() throws URISyntaxException {
+ QName type = new QName(new URI("/mockrpc"), "mockrpc");
+ List<RpcRouter.RouteIdentifier<?,?,?>> routeIds = new ArrayList<>();
+ routeIds.add(new RouteIdentifierImpl(null, type, null));
+ return routeIds;
}
private RpcRouter.RouteIdentifier<?,?,?> createRouteId() throws URISyntaxException {
}
private RpcRouter.RouteIdentifier<?,?,?> createRouteId() throws URISyntaxException {
verify(mockGossiper, times(0)).updateRemoteBuckets(anyMap());
}
verify(mockGossiper, times(0)).updateRemoteBuckets(anyMap());
}
- @Test
- public void testUpdateRemoteBuckets_WhenNoBucketShouldIgnore(){
-
- mockGossiper.updateRemoteBuckets(null);
- verify(mockGossiper, times(0)).getContext();
-
- Map<Address, Bucket> empty = Collections.emptyMap();
- mockGossiper.updateRemoteBuckets(empty);
- verify(mockGossiper, times(0)).getContext();
- }
-
/**
* Create Gossiper actor and return the underlying instance of Gossiper class.
*
/**
* Create Gossiper actor and return the underlying instance of Gossiper class.
*