alshabib
Committed by Gerrit Code Review

partial fix for default flows. Need to redesign packet requests

Change-Id: Ia68412c3843ecd7da3e7ae9f4f52750874fb1409
...@@ -15,14 +15,6 @@ ...@@ -15,14 +15,6 @@
15 */ 15 */
16 package org.onosproject.net.packet.impl; 16 package org.onosproject.net.packet.impl;
17 17
18 -import static com.google.common.base.Preconditions.checkNotNull;
19 -import static org.slf4j.LoggerFactory.getLogger;
20 -
21 -import java.util.Collections;
22 -import java.util.Map;
23 -import java.util.Set;
24 -import java.util.concurrent.ConcurrentHashMap;
25 -
26 import org.apache.felix.scr.annotations.Activate; 18 import org.apache.felix.scr.annotations.Activate;
27 import org.apache.felix.scr.annotations.Component; 19 import org.apache.felix.scr.annotations.Component;
28 import org.apache.felix.scr.annotations.Deactivate; 20 import org.apache.felix.scr.annotations.Deactivate;
...@@ -31,6 +23,7 @@ import org.apache.felix.scr.annotations.ReferenceCardinality; ...@@ -31,6 +23,7 @@ import org.apache.felix.scr.annotations.ReferenceCardinality;
31 import org.apache.felix.scr.annotations.Service; 23 import org.apache.felix.scr.annotations.Service;
32 import org.onosproject.core.ApplicationId; 24 import org.onosproject.core.ApplicationId;
33 import org.onosproject.net.Device; 25 import org.onosproject.net.Device;
26 +import org.onosproject.net.MastershipRole;
34 import org.onosproject.net.device.DeviceEvent; 27 import org.onosproject.net.device.DeviceEvent;
35 import org.onosproject.net.device.DeviceListener; 28 import org.onosproject.net.device.DeviceListener;
36 import org.onosproject.net.device.DeviceService; 29 import org.onosproject.net.device.DeviceService;
...@@ -55,6 +48,14 @@ import org.onosproject.net.provider.AbstractProviderRegistry; ...@@ -55,6 +48,14 @@ import org.onosproject.net.provider.AbstractProviderRegistry;
55 import org.onosproject.net.provider.AbstractProviderService; 48 import org.onosproject.net.provider.AbstractProviderService;
56 import org.slf4j.Logger; 49 import org.slf4j.Logger;
57 50
51 +import java.util.Collections;
52 +import java.util.Map;
53 +import java.util.Set;
54 +import java.util.concurrent.ConcurrentHashMap;
55 +
56 +import static com.google.common.base.Preconditions.checkNotNull;
57 +import static org.slf4j.LoggerFactory.getLogger;
58 +
58 /** 59 /**
59 * Provides a basic implementation of the packet SB & NB APIs. 60 * Provides a basic implementation of the packet SB & NB APIs.
60 */ 61 */
...@@ -193,8 +194,9 @@ implements PacketService, PacketProviderRegistry { ...@@ -193,8 +194,9 @@ implements PacketService, PacketProviderRegistry {
193 PacketRequest request = 194 PacketRequest request =
194 new PacketRequest(selector, priority, appId, tableType); 195 new PacketRequest(selector, priority, appId, tableType);
195 196
196 - packetRequests.add(request); 197 + if (packetRequests.add(request)) {
197 - pushToAllDevices(request); 198 + pushToAllDevices(request);
199 + }
198 } 200 }
199 201
200 /** 202 /**
...@@ -204,7 +206,9 @@ implements PacketService, PacketProviderRegistry { ...@@ -204,7 +206,9 @@ implements PacketService, PacketProviderRegistry {
204 */ 206 */
205 private void pushToAllDevices(PacketRequest request) { 207 private void pushToAllDevices(PacketRequest request) {
206 for (Device device : deviceService.getDevices()) { 208 for (Device device : deviceService.getDevices()) {
207 - pushRule(device, request); 209 + if (deviceService.getRole(device.id()) == MastershipRole.MASTER) {
210 + pushRule(device, request);
211 + }
208 } 212 }
209 } 213 }
210 214
......