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; ...@@ -29,6 +29,8 @@ import org.apache.felix.scr.annotations.Deactivate;
29 import org.apache.felix.scr.annotations.Reference; 29 import org.apache.felix.scr.annotations.Reference;
30 import org.apache.felix.scr.annotations.ReferenceCardinality; 30 import org.apache.felix.scr.annotations.ReferenceCardinality;
31 import org.onlab.packet.Ethernet; 31 import org.onlab.packet.Ethernet;
32 +import org.onlab.packet.Ip4Address;
33 +import org.onlab.packet.Ip6Address;
32 import org.onlab.packet.IpAddress; 34 import org.onlab.packet.IpAddress;
33 import org.onlab.packet.IpPrefix; 35 import org.onlab.packet.IpPrefix;
34 import org.onlab.packet.MacAddress; 36 import org.onlab.packet.MacAddress;
...@@ -145,10 +147,14 @@ public class BgpRouter { ...@@ -145,10 +147,14 @@ public class BgpRouter {
145 147
146 private InternalTableHandler provisionStaticTables = new InternalTableHandler(); 148 private InternalTableHandler provisionStaticTables = new InternalTableHandler();
147 149
148 - private KryoNamespace.Builder appKryo = new KryoNamespace.Builder() 150 + private KryoNamespace appKryo = new KryoNamespace.Builder()
149 .register(IpAddress.Version.class) 151 .register(IpAddress.Version.class)
150 .register(IpAddress.class) 152 .register(IpAddress.class)
151 - .register(NextHopGroupKey.class); 153 + .register(Ip4Address.class)
154 + .register(Ip6Address.class)
155 + .register(byte[].class)
156 + .register(NextHopGroupKey.class)
157 + .build();
152 158
153 @Activate 159 @Activate
154 protected void activate() { 160 protected void activate() {
...@@ -219,7 +225,7 @@ public class BgpRouter { ...@@ -219,7 +225,7 @@ public class BgpRouter {
219 NextHop nextHop = nextHops.get(entry.nextHopIp()); 225 NextHop nextHop = nextHops.get(entry.nextHopIp());
220 group = groupService.getGroup(deviceId, 226 group = groupService.getGroup(deviceId,
221 new DefaultGroupKey( 227 new DefaultGroupKey(
222 - appKryo.build().serialize(nextHop.group()))); 228 + appKryo.serialize(nextHop.group())));
223 229
224 if (group == null) { 230 if (group == null) {
225 log.debug("Adding pending flow {}", update.entry()); 231 log.debug("Adding pending flow {}", update.entry());
...@@ -317,8 +323,8 @@ public class BgpRouter { ...@@ -317,8 +323,8 @@ public class BgpRouter {
317 = new DefaultGroupDescription(deviceId, 323 = new DefaultGroupDescription(deviceId,
318 GroupDescription.Type.INDIRECT, 324 GroupDescription.Type.INDIRECT,
319 new GroupBuckets(Collections 325 new GroupBuckets(Collections
320 - .singletonList(bucket)), 326 + .singletonList(bucket)),
321 - new DefaultGroupKey(appKryo.build().serialize(groupKey)), 327 + new DefaultGroupKey(appKryo.serialize(groupKey)),
322 appId); 328 appId);
323 329
324 groupService.addGroup(groupDescription); 330 groupService.addGroup(groupDescription);
...@@ -340,7 +346,6 @@ public class BgpRouter { ...@@ -340,7 +346,6 @@ public class BgpRouter {
340 346
341 Group group = groupService.getGroup(deviceId, 347 Group group = groupService.getGroup(deviceId,
342 new DefaultGroupKey(appKryo. 348 new DefaultGroupKey(appKryo.
343 - build().
344 serialize(nextHop.group()))); 349 serialize(nextHop.group())));
345 350
346 // FIXME disabling group deletes for now until we verify the logic is OK 351 // FIXME disabling group deletes for now until we verify the logic is OK
...@@ -714,7 +719,7 @@ public class BgpRouter { ...@@ -714,7 +719,7 @@ public class BgpRouter {
714 synchronized (pendingUpdates) { 719 synchronized (pendingUpdates) {
715 720
716 NextHopGroupKey nhGroupKey = 721 NextHopGroupKey nhGroupKey =
717 - appKryo.build().deserialize(group.appCookie().key()); 722 + appKryo.deserialize(group.appCookie().key());
718 Map<FibEntry, Group> entriesToInstall = 723 Map<FibEntry, Group> entriesToInstall =
719 pendingUpdates.removeAll(nhGroupKey) 724 pendingUpdates.removeAll(nhGroupKey)
720 .stream() 725 .stream()
......
...@@ -15,14 +15,21 @@ ...@@ -15,14 +15,21 @@
15 */ 15 */
16 package org.onosproject.routing.impl; 16 package org.onosproject.routing.impl;
17 17
18 -import com.google.common.collect.HashMultimap; 18 +import static com.google.common.base.Preconditions.checkNotNull;
19 -import com.google.common.collect.Multimaps; 19 +
20 -import com.google.common.collect.SetMultimap; 20 +import java.util.Collection;
21 -import com.google.common.util.concurrent.ThreadFactoryBuilder; 21 +import java.util.Collections;
22 -import com.googlecode.concurrenttrees.common.KeyValuePair; 22 +import java.util.Iterator;
23 -import com.googlecode.concurrenttrees.radix.node.concrete.DefaultByteArrayNodeFactory; 23 +import java.util.LinkedList;
24 -import com.googlecode.concurrenttrees.radixinverted.ConcurrentInvertedRadixTree; 24 +import java.util.List;
25 -import com.googlecode.concurrenttrees.radixinverted.InvertedRadixTree; 25 +import java.util.Map;
26 +import java.util.Set;
27 +import java.util.concurrent.BlockingQueue;
28 +import java.util.concurrent.ConcurrentHashMap;
29 +import java.util.concurrent.ExecutorService;
30 +import java.util.concurrent.Executors;
31 +import java.util.concurrent.LinkedBlockingQueue;
32 +
26 import org.apache.felix.scr.annotations.Activate; 33 import org.apache.felix.scr.annotations.Activate;
27 import org.apache.felix.scr.annotations.Component; 34 import org.apache.felix.scr.annotations.Component;
28 import org.apache.felix.scr.annotations.Deactivate; 35 import org.apache.felix.scr.annotations.Deactivate;
...@@ -47,20 +54,14 @@ import org.onosproject.routing.RoutingService; ...@@ -47,20 +54,14 @@ import org.onosproject.routing.RoutingService;
47 import org.slf4j.Logger; 54 import org.slf4j.Logger;
48 import org.slf4j.LoggerFactory; 55 import org.slf4j.LoggerFactory;
49 56
50 -import java.util.Collection; 57 +import com.google.common.collect.HashMultimap;
51 -import java.util.Collections; 58 +import com.google.common.collect.Multimaps;
52 -import java.util.Iterator; 59 +import com.google.common.collect.SetMultimap;
53 -import java.util.LinkedList; 60 +import com.google.common.util.concurrent.ThreadFactoryBuilder;
54 -import java.util.List; 61 +import com.googlecode.concurrenttrees.common.KeyValuePair;
55 -import java.util.Map; 62 +import com.googlecode.concurrenttrees.radix.node.concrete.DefaultByteArrayNodeFactory;
56 -import java.util.Set; 63 +import com.googlecode.concurrenttrees.radixinverted.ConcurrentInvertedRadixTree;
57 -import java.util.concurrent.BlockingQueue; 64 +import com.googlecode.concurrenttrees.radixinverted.InvertedRadixTree;
58 -import java.util.concurrent.ConcurrentHashMap;
59 -import java.util.concurrent.ExecutorService;
60 -import java.util.concurrent.Executors;
61 -import java.util.concurrent.LinkedBlockingQueue;
62 -
63 -import static com.google.common.base.Preconditions.checkNotNull;
64 65
65 /** 66 /**
66 * This class processes route updates and maintains a Routing Information Base 67 * This class processes route updates and maintains a Routing Information Base
...@@ -163,7 +164,7 @@ public class Router implements RoutingService { ...@@ -163,7 +164,7 @@ public class Router implements RoutingService {
163 try { 164 try {
164 routeUpdatesQueue.put(routeUpdates); 165 routeUpdatesQueue.put(routeUpdates);
165 } catch (InterruptedException e) { 166 } catch (InterruptedException e) {
166 - log.debug("Interrupted while putting on routeUpdatesQueue", e); 167 + log.error("Interrupted while putting on routeUpdatesQueue", e);
167 Thread.currentThread().interrupt(); 168 Thread.currentThread().interrupt();
168 } 169 }
169 } 170 }
...@@ -180,10 +181,10 @@ public class Router implements RoutingService { ...@@ -180,10 +181,10 @@ public class Router implements RoutingService {
180 routeUpdatesQueue.take(); 181 routeUpdatesQueue.take();
181 processRouteUpdates(routeUpdates); 182 processRouteUpdates(routeUpdates);
182 } catch (InterruptedException e) { 183 } catch (InterruptedException e) {
183 - log.debug("Interrupted while taking from updates queue", e); 184 + log.error("Interrupted while taking from updates queue", e);
184 interrupted = true; 185 interrupted = true;
185 } catch (Exception e) { 186 } catch (Exception e) {
186 - log.debug("exception", e); 187 + log.error("exception", e);
187 } 188 }
188 } 189 }
189 } finally { 190 } finally {
...@@ -198,6 +199,7 @@ public class Router implements RoutingService { ...@@ -198,6 +199,7 @@ public class Router implements RoutingService {
198 * 199 *
199 * @return all IPv4 routes from the RIB 200 * @return all IPv4 routes from the RIB
200 */ 201 */
202 + @Override
201 public Collection<RouteEntry> getRoutes4() { 203 public Collection<RouteEntry> getRoutes4() {
202 Iterator<KeyValuePair<RouteEntry>> it = 204 Iterator<KeyValuePair<RouteEntry>> it =
203 ribTable4.getKeyValuePairsForKeysStartingWith("").iterator(); 205 ribTable4.getKeyValuePairsForKeysStartingWith("").iterator();
...@@ -217,6 +219,7 @@ public class Router implements RoutingService { ...@@ -217,6 +219,7 @@ public class Router implements RoutingService {
217 * 219 *
218 * @return all IPv6 routes from the RIB 220 * @return all IPv6 routes from the RIB
219 */ 221 */
222 + @Override
220 public Collection<RouteEntry> getRoutes6() { 223 public Collection<RouteEntry> getRoutes6() {
221 Iterator<KeyValuePair<RouteEntry>> it = 224 Iterator<KeyValuePair<RouteEntry>> it =
222 ribTable6.getKeyValuePairsForKeysStartingWith("").iterator(); 225 ribTable6.getKeyValuePairsForKeysStartingWith("").iterator();
......