Srikanth Vavilapalli
Committed by Ray Milkey

ONOS-1400: Fixing BgpRouter functionality break due to distributed group store changes

Change-Id: I7e0dd3bb32333a19ab234ad66b84fd22a06fc341
......@@ -29,6 +29,8 @@ import org.apache.felix.scr.annotations.Deactivate;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.onlab.packet.Ethernet;
import org.onlab.packet.Ip4Address;
import org.onlab.packet.Ip6Address;
import org.onlab.packet.IpAddress;
import org.onlab.packet.IpPrefix;
import org.onlab.packet.MacAddress;
......@@ -145,10 +147,14 @@ public class BgpRouter {
private InternalTableHandler provisionStaticTables = new InternalTableHandler();
private KryoNamespace.Builder appKryo = new KryoNamespace.Builder()
private KryoNamespace appKryo = new KryoNamespace.Builder()
.register(IpAddress.Version.class)
.register(IpAddress.class)
.register(NextHopGroupKey.class);
.register(Ip4Address.class)
.register(Ip6Address.class)
.register(byte[].class)
.register(NextHopGroupKey.class)
.build();
@Activate
protected void activate() {
......@@ -219,7 +225,7 @@ public class BgpRouter {
NextHop nextHop = nextHops.get(entry.nextHopIp());
group = groupService.getGroup(deviceId,
new DefaultGroupKey(
appKryo.build().serialize(nextHop.group())));
appKryo.serialize(nextHop.group())));
if (group == null) {
log.debug("Adding pending flow {}", update.entry());
......@@ -317,8 +323,8 @@ public class BgpRouter {
= new DefaultGroupDescription(deviceId,
GroupDescription.Type.INDIRECT,
new GroupBuckets(Collections
.singletonList(bucket)),
new DefaultGroupKey(appKryo.build().serialize(groupKey)),
.singletonList(bucket)),
new DefaultGroupKey(appKryo.serialize(groupKey)),
appId);
groupService.addGroup(groupDescription);
......@@ -340,7 +346,6 @@ public class BgpRouter {
Group group = groupService.getGroup(deviceId,
new DefaultGroupKey(appKryo.
build().
serialize(nextHop.group())));
// FIXME disabling group deletes for now until we verify the logic is OK
......@@ -714,7 +719,7 @@ public class BgpRouter {
synchronized (pendingUpdates) {
NextHopGroupKey nhGroupKey =
appKryo.build().deserialize(group.appCookie().key());
appKryo.deserialize(group.appCookie().key());
Map<FibEntry, Group> entriesToInstall =
pendingUpdates.removeAll(nhGroupKey)
.stream()
......
......@@ -15,14 +15,21 @@
*/
package org.onosproject.routing.impl;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimaps;
import com.google.common.collect.SetMultimap;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import com.googlecode.concurrenttrees.common.KeyValuePair;
import com.googlecode.concurrenttrees.radix.node.concrete.DefaultByteArrayNodeFactory;
import com.googlecode.concurrenttrees.radixinverted.ConcurrentInvertedRadixTree;
import com.googlecode.concurrenttrees.radixinverted.InvertedRadixTree;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
......@@ -47,20 +54,14 @@ import org.onosproject.routing.RoutingService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimaps;
import com.google.common.collect.SetMultimap;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import com.googlecode.concurrenttrees.common.KeyValuePair;
import com.googlecode.concurrenttrees.radix.node.concrete.DefaultByteArrayNodeFactory;
import com.googlecode.concurrenttrees.radixinverted.ConcurrentInvertedRadixTree;
import com.googlecode.concurrenttrees.radixinverted.InvertedRadixTree;
/**
* This class processes route updates and maintains a Routing Information Base
......@@ -163,7 +164,7 @@ public class Router implements RoutingService {
try {
routeUpdatesQueue.put(routeUpdates);
} catch (InterruptedException e) {
log.debug("Interrupted while putting on routeUpdatesQueue", e);
log.error("Interrupted while putting on routeUpdatesQueue", e);
Thread.currentThread().interrupt();
}
}
......@@ -180,10 +181,10 @@ public class Router implements RoutingService {
routeUpdatesQueue.take();
processRouteUpdates(routeUpdates);
} catch (InterruptedException e) {
log.debug("Interrupted while taking from updates queue", e);
log.error("Interrupted while taking from updates queue", e);
interrupted = true;
} catch (Exception e) {
log.debug("exception", e);
log.error("exception", e);
}
}
} finally {
......@@ -198,6 +199,7 @@ public class Router implements RoutingService {
*
* @return all IPv4 routes from the RIB
*/
@Override
public Collection<RouteEntry> getRoutes4() {
Iterator<KeyValuePair<RouteEntry>> it =
ribTable4.getKeyValuePairsForKeysStartingWith("").iterator();
......@@ -217,6 +219,7 @@ public class Router implements RoutingService {
*
* @return all IPv6 routes from the RIB
*/
@Override
public Collection<RouteEntry> getRoutes6() {
Iterator<KeyValuePair<RouteEntry>> it =
ribTable6.getKeyValuePairsForKeysStartingWith("").iterator();
......