Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2014 Open Networking Laboratory |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
tom | be98831 | 2014-09-19 18:38:47 -0700 | [diff] [blame] | 16 | package org.onlab.onos.net.flow.impl; |
alshabib | 57044ba | 2014-09-16 15:58:01 -0700 | [diff] [blame] | 17 | |
Thomas Vachuska | 9b2da21 | 2014-11-10 19:30:25 -0800 | [diff] [blame] | 18 | import com.google.common.collect.ArrayListMultimap; |
| 19 | import com.google.common.collect.Iterables; |
| 20 | import com.google.common.collect.Lists; |
| 21 | import com.google.common.collect.Maps; |
| 22 | import com.google.common.collect.Multimap; |
| 23 | import com.google.common.collect.Sets; |
Yuta HIGUCHI | f1ccee8 | 2014-11-11 20:39:58 -0800 | [diff] [blame] | 24 | |
alshabib | 57044ba | 2014-09-16 15:58:01 -0700 | [diff] [blame] | 25 | import org.apache.felix.scr.annotations.Activate; |
| 26 | import org.apache.felix.scr.annotations.Component; |
| 27 | import org.apache.felix.scr.annotations.Deactivate; |
| 28 | import org.apache.felix.scr.annotations.Reference; |
| 29 | import org.apache.felix.scr.annotations.ReferenceCardinality; |
| 30 | import org.apache.felix.scr.annotations.Service; |
Thomas Vachuska | e0f804a | 2014-10-27 23:40:48 -0700 | [diff] [blame] | 31 | import org.onlab.onos.core.ApplicationId; |
alshabib | 57044ba | 2014-09-16 15:58:01 -0700 | [diff] [blame] | 32 | import org.onlab.onos.event.AbstractListenerRegistry; |
| 33 | import org.onlab.onos.event.EventDeliveryService; |
| 34 | import org.onlab.onos.net.Device; |
| 35 | import org.onlab.onos.net.DeviceId; |
| 36 | import org.onlab.onos.net.device.DeviceService; |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 37 | import org.onlab.onos.net.flow.CompletedBatchOperation; |
alshabib | cf36991 | 2014-10-13 14:16:42 -0700 | [diff] [blame] | 38 | import org.onlab.onos.net.flow.DefaultFlowEntry; |
alshabib | 1c319ff | 2014-10-04 20:29:09 -0700 | [diff] [blame] | 39 | import org.onlab.onos.net.flow.FlowEntry; |
alshabib | 57044ba | 2014-09-16 15:58:01 -0700 | [diff] [blame] | 40 | import org.onlab.onos.net.flow.FlowRule; |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 41 | import org.onlab.onos.net.flow.FlowRuleBatchEntry; |
alshabib | 193525b | 2014-10-08 18:58:03 -0700 | [diff] [blame] | 42 | import org.onlab.onos.net.flow.FlowRuleBatchEntry.FlowRuleOperation; |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 43 | import org.onlab.onos.net.flow.FlowRuleBatchEvent; |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 44 | import org.onlab.onos.net.flow.FlowRuleBatchOperation; |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 45 | import org.onlab.onos.net.flow.FlowRuleBatchRequest; |
alshabib | 57044ba | 2014-09-16 15:58:01 -0700 | [diff] [blame] | 46 | import org.onlab.onos.net.flow.FlowRuleEvent; |
| 47 | import org.onlab.onos.net.flow.FlowRuleListener; |
| 48 | import org.onlab.onos.net.flow.FlowRuleProvider; |
| 49 | import org.onlab.onos.net.flow.FlowRuleProviderRegistry; |
| 50 | import org.onlab.onos.net.flow.FlowRuleProviderService; |
| 51 | import org.onlab.onos.net.flow.FlowRuleService; |
tom | be98831 | 2014-09-19 18:38:47 -0700 | [diff] [blame] | 52 | import org.onlab.onos.net.flow.FlowRuleStore; |
tom | c78acee | 2014-09-24 15:16:55 -0700 | [diff] [blame] | 53 | import org.onlab.onos.net.flow.FlowRuleStoreDelegate; |
alshabib | 57044ba | 2014-09-16 15:58:01 -0700 | [diff] [blame] | 54 | import org.onlab.onos.net.provider.AbstractProviderRegistry; |
| 55 | import org.onlab.onos.net.provider.AbstractProviderService; |
| 56 | import org.slf4j.Logger; |
| 57 | |
Yuta HIGUCHI | f1ccee8 | 2014-11-11 20:39:58 -0800 | [diff] [blame] | 58 | import java.util.HashSet; |
Thomas Vachuska | 9b2da21 | 2014-11-10 19:30:25 -0800 | [diff] [blame] | 59 | import java.util.List; |
| 60 | import java.util.Map; |
| 61 | import java.util.Set; |
| 62 | import java.util.concurrent.CancellationException; |
| 63 | import java.util.concurrent.ExecutionException; |
| 64 | import java.util.concurrent.ExecutorService; |
| 65 | import java.util.concurrent.Executors; |
| 66 | import java.util.concurrent.Future; |
| 67 | import java.util.concurrent.TimeUnit; |
| 68 | import java.util.concurrent.TimeoutException; |
| 69 | import java.util.concurrent.atomic.AtomicReference; |
| 70 | |
| 71 | import static com.google.common.base.Preconditions.checkNotNull; |
| 72 | import static org.onlab.util.Tools.namedThreads; |
| 73 | import static org.slf4j.LoggerFactory.getLogger; |
alshabib | a7f7ca8 | 2014-09-22 11:41:23 -0700 | [diff] [blame] | 74 | |
tom | e472987 | 2014-09-23 00:37:37 -0700 | [diff] [blame] | 75 | /** |
| 76 | * Provides implementation of the flow NB & SB APIs. |
| 77 | */ |
alshabib | 57044ba | 2014-09-16 15:58:01 -0700 | [diff] [blame] | 78 | @Component(immediate = true) |
| 79 | @Service |
tom | 202175a | 2014-09-19 19:00:11 -0700 | [diff] [blame] | 80 | public class FlowRuleManager |
tom | 9b4030d | 2014-10-06 10:39:03 -0700 | [diff] [blame] | 81 | extends AbstractProviderRegistry<FlowRuleProvider, FlowRuleProviderService> |
| 82 | implements FlowRuleService, FlowRuleProviderRegistry { |
alshabib | 57044ba | 2014-09-16 15:58:01 -0700 | [diff] [blame] | 83 | |
alshabib | 193525b | 2014-10-08 18:58:03 -0700 | [diff] [blame] | 84 | enum BatchState { STARTED, FINISHED, CANCELLED }; |
| 85 | |
Ayaka Koshibe | 08eabaa | 2014-09-17 14:59:25 -0700 | [diff] [blame] | 86 | public static final String FLOW_RULE_NULL = "FlowRule cannot be null"; |
alshabib | 57044ba | 2014-09-16 15:58:01 -0700 | [diff] [blame] | 87 | private final Logger log = getLogger(getClass()); |
| 88 | |
| 89 | private final AbstractListenerRegistry<FlowRuleEvent, FlowRuleListener> |
tom | 9b4030d | 2014-10-06 10:39:03 -0700 | [diff] [blame] | 90 | listenerRegistry = new AbstractListenerRegistry<>(); |
alshabib | 57044ba | 2014-09-16 15:58:01 -0700 | [diff] [blame] | 91 | |
alshabib | bb42cad | 2014-09-25 11:43:05 -0700 | [diff] [blame] | 92 | private final FlowRuleStoreDelegate delegate = new InternalStoreDelegate(); |
tom | c78acee | 2014-09-24 15:16:55 -0700 | [diff] [blame] | 93 | |
Thomas Vachuska | 9b2da21 | 2014-11-10 19:30:25 -0800 | [diff] [blame] | 94 | private ExecutorService futureService; |
Yuta HIGUCHI | 9def047 | 2014-10-23 15:51:10 -0700 | [diff] [blame] | 95 | |
tom | be98831 | 2014-09-19 18:38:47 -0700 | [diff] [blame] | 96 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 97 | protected FlowRuleStore store; |
Ayaka Koshibe | 08eabaa | 2014-09-17 14:59:25 -0700 | [diff] [blame] | 98 | |
alshabib | 57044ba | 2014-09-16 15:58:01 -0700 | [diff] [blame] | 99 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
Ayaka Koshibe | b55524f | 2014-09-18 09:59:24 -0700 | [diff] [blame] | 100 | protected EventDeliveryService eventDispatcher; |
alshabib | 57044ba | 2014-09-16 15:58:01 -0700 | [diff] [blame] | 101 | |
| 102 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
Ayaka Koshibe | b55524f | 2014-09-18 09:59:24 -0700 | [diff] [blame] | 103 | protected DeviceService deviceService; |
alshabib | 57044ba | 2014-09-16 15:58:01 -0700 | [diff] [blame] | 104 | |
| 105 | @Activate |
| 106 | public void activate() { |
Thomas Vachuska | 9b2da21 | 2014-11-10 19:30:25 -0800 | [diff] [blame] | 107 | futureService = Executors.newCachedThreadPool(namedThreads("provider-future-listeners")); |
tom | c78acee | 2014-09-24 15:16:55 -0700 | [diff] [blame] | 108 | store.setDelegate(delegate); |
alshabib | 57044ba | 2014-09-16 15:58:01 -0700 | [diff] [blame] | 109 | eventDispatcher.addSink(FlowRuleEvent.class, listenerRegistry); |
| 110 | log.info("Started"); |
| 111 | } |
| 112 | |
| 113 | @Deactivate |
| 114 | public void deactivate() { |
Thomas Vachuska | 9b2da21 | 2014-11-10 19:30:25 -0800 | [diff] [blame] | 115 | futureService.shutdownNow(); |
Yuta HIGUCHI | 9def047 | 2014-10-23 15:51:10 -0700 | [diff] [blame] | 116 | |
tom | c78acee | 2014-09-24 15:16:55 -0700 | [diff] [blame] | 117 | store.unsetDelegate(delegate); |
alshabib | 57044ba | 2014-09-16 15:58:01 -0700 | [diff] [blame] | 118 | eventDispatcher.removeSink(FlowRuleEvent.class); |
| 119 | log.info("Stopped"); |
| 120 | } |
| 121 | |
| 122 | @Override |
tom | 9b4030d | 2014-10-06 10:39:03 -0700 | [diff] [blame] | 123 | public int getFlowRuleCount() { |
| 124 | return store.getFlowRuleCount(); |
| 125 | } |
| 126 | |
| 127 | @Override |
alshabib | 1c319ff | 2014-10-04 20:29:09 -0700 | [diff] [blame] | 128 | public Iterable<FlowEntry> getFlowEntries(DeviceId deviceId) { |
Ayaka Koshibe | 08eabaa | 2014-09-17 14:59:25 -0700 | [diff] [blame] | 129 | return store.getFlowEntries(deviceId); |
alshabib | 57044ba | 2014-09-16 15:58:01 -0700 | [diff] [blame] | 130 | } |
| 131 | |
| 132 | @Override |
alshabib | 219ebaa | 2014-09-22 15:41:24 -0700 | [diff] [blame] | 133 | public void applyFlowRules(FlowRule... flowRules) { |
Madan Jampani | 6a45616 | 2014-10-24 11:36:17 -0700 | [diff] [blame] | 134 | Set<FlowRuleBatchEntry> toAddBatchEntries = Sets.newHashSet(); |
alshabib | 57044ba | 2014-09-16 15:58:01 -0700 | [diff] [blame] | 135 | for (int i = 0; i < flowRules.length; i++) { |
Madan Jampani | 6a45616 | 2014-10-24 11:36:17 -0700 | [diff] [blame] | 136 | toAddBatchEntries.add(new FlowRuleBatchEntry(FlowRuleOperation.ADD, flowRules[i])); |
Yuta HIGUCHI | f3d51bd | 2014-10-21 01:05:33 -0700 | [diff] [blame] | 137 | } |
Madan Jampani | 6a45616 | 2014-10-24 11:36:17 -0700 | [diff] [blame] | 138 | applyBatch(new FlowRuleBatchOperation(toAddBatchEntries)); |
alshabib | 57044ba | 2014-09-16 15:58:01 -0700 | [diff] [blame] | 139 | } |
| 140 | |
| 141 | @Override |
| 142 | public void removeFlowRules(FlowRule... flowRules) { |
Madan Jampani | 6a45616 | 2014-10-24 11:36:17 -0700 | [diff] [blame] | 143 | Set<FlowRuleBatchEntry> toRemoveBatchEntries = Sets.newHashSet(); |
alshabib | 57044ba | 2014-09-16 15:58:01 -0700 | [diff] [blame] | 144 | for (int i = 0; i < flowRules.length; i++) { |
Madan Jampani | 6a45616 | 2014-10-24 11:36:17 -0700 | [diff] [blame] | 145 | toRemoveBatchEntries.add(new FlowRuleBatchEntry(FlowRuleOperation.REMOVE, flowRules[i])); |
Yuta HIGUCHI | f3d51bd | 2014-10-21 01:05:33 -0700 | [diff] [blame] | 146 | } |
Madan Jampani | 6a45616 | 2014-10-24 11:36:17 -0700 | [diff] [blame] | 147 | applyBatch(new FlowRuleBatchOperation(toRemoveBatchEntries)); |
alshabib | a68eb96 | 2014-09-24 20:34:13 -0700 | [diff] [blame] | 148 | } |
alshabib | 57044ba | 2014-09-16 15:58:01 -0700 | [diff] [blame] | 149 | |
alshabib | a68eb96 | 2014-09-24 20:34:13 -0700 | [diff] [blame] | 150 | @Override |
| 151 | public void removeFlowRulesById(ApplicationId id) { |
Madan Jampani | 6a45616 | 2014-10-24 11:36:17 -0700 | [diff] [blame] | 152 | removeFlowRules(Iterables.toArray(getFlowRulesById(id), FlowRule.class)); |
alshabib | a68eb96 | 2014-09-24 20:34:13 -0700 | [diff] [blame] | 153 | } |
| 154 | |
| 155 | @Override |
| 156 | public Iterable<FlowRule> getFlowRulesById(ApplicationId id) { |
Madan Jampani | 6a45616 | 2014-10-24 11:36:17 -0700 | [diff] [blame] | 157 | Set<FlowRule> flowEntries = Sets.newHashSet(); |
| 158 | for (Device d : deviceService.getDevices()) { |
| 159 | for (FlowEntry flowEntry : store.getFlowEntries(d.id())) { |
| 160 | if (flowEntry.appId() == id.id()) { |
| 161 | flowEntries.add(flowEntry); |
| 162 | } |
| 163 | } |
| 164 | } |
| 165 | return flowEntries; |
alshabib | 57044ba | 2014-09-16 15:58:01 -0700 | [diff] [blame] | 166 | } |
| 167 | |
| 168 | @Override |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 169 | public Future<CompletedBatchOperation> applyBatch( |
| 170 | FlowRuleBatchOperation batch) { |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 171 | Multimap<DeviceId, FlowRuleBatchEntry> perDeviceBatches = |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 172 | ArrayListMultimap.create(); |
alshabib | 193525b | 2014-10-08 18:58:03 -0700 | [diff] [blame] | 173 | List<Future<CompletedBatchOperation>> futures = Lists.newArrayList(); |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 174 | for (FlowRuleBatchEntry fbe : batch.getOperations()) { |
| 175 | final FlowRule f = fbe.getTarget(); |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 176 | perDeviceBatches.put(f.deviceId(), fbe); |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 177 | } |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 178 | |
| 179 | for (DeviceId deviceId : perDeviceBatches.keySet()) { |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 180 | FlowRuleBatchOperation b = |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 181 | new FlowRuleBatchOperation(perDeviceBatches.get(deviceId)); |
| 182 | Future<CompletedBatchOperation> future = store.storeBatch(b); |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 183 | futures.add(future); |
| 184 | } |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 185 | return new FlowRuleBatchFuture(futures, perDeviceBatches); |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 186 | } |
| 187 | |
| 188 | @Override |
alshabib | 57044ba | 2014-09-16 15:58:01 -0700 | [diff] [blame] | 189 | public void addListener(FlowRuleListener listener) { |
| 190 | listenerRegistry.addListener(listener); |
| 191 | } |
| 192 | |
| 193 | @Override |
| 194 | public void removeListener(FlowRuleListener listener) { |
| 195 | listenerRegistry.removeListener(listener); |
| 196 | } |
| 197 | |
| 198 | @Override |
| 199 | protected FlowRuleProviderService createProviderService( |
| 200 | FlowRuleProvider provider) { |
| 201 | return new InternalFlowRuleProviderService(provider); |
| 202 | } |
| 203 | |
| 204 | private class InternalFlowRuleProviderService |
tom | 9b4030d | 2014-10-06 10:39:03 -0700 | [diff] [blame] | 205 | extends AbstractProviderService<FlowRuleProvider> |
| 206 | implements FlowRuleProviderService { |
alshabib | 57044ba | 2014-09-16 15:58:01 -0700 | [diff] [blame] | 207 | |
Yuta HIGUCHI | f6f50a6 | 2014-10-19 15:58:49 -0700 | [diff] [blame] | 208 | final Map<FlowEntry, Long> lastSeen = Maps.newConcurrentMap(); |
| 209 | |
alshabib | 57044ba | 2014-09-16 15:58:01 -0700 | [diff] [blame] | 210 | protected InternalFlowRuleProviderService(FlowRuleProvider provider) { |
| 211 | super(provider); |
| 212 | } |
| 213 | |
| 214 | @Override |
alshabib | 1c319ff | 2014-10-04 20:29:09 -0700 | [diff] [blame] | 215 | public void flowRemoved(FlowEntry flowEntry) { |
| 216 | checkNotNull(flowEntry, FLOW_RULE_NULL); |
Ayaka Koshibe | 08eabaa | 2014-09-17 14:59:25 -0700 | [diff] [blame] | 217 | checkValidity(); |
Yuta HIGUCHI | f6f50a6 | 2014-10-19 15:58:49 -0700 | [diff] [blame] | 218 | lastSeen.remove(flowEntry); |
alshabib | 1c319ff | 2014-10-04 20:29:09 -0700 | [diff] [blame] | 219 | FlowEntry stored = store.getFlowEntry(flowEntry); |
alshabib | a68eb96 | 2014-09-24 20:34:13 -0700 | [diff] [blame] | 220 | if (stored == null) { |
alshabib | 1c319ff | 2014-10-04 20:29:09 -0700 | [diff] [blame] | 221 | log.info("Rule already evicted from store: {}", flowEntry); |
alshabib | a68eb96 | 2014-09-24 20:34:13 -0700 | [diff] [blame] | 222 | return; |
| 223 | } |
alshabib | 1c319ff | 2014-10-04 20:29:09 -0700 | [diff] [blame] | 224 | Device device = deviceService.getDevice(flowEntry.deviceId()); |
alshabib | a68eb96 | 2014-09-24 20:34:13 -0700 | [diff] [blame] | 225 | FlowRuleProvider frp = getProvider(device.providerId()); |
| 226 | FlowRuleEvent event = null; |
| 227 | switch (stored.state()) { |
tom | 9b4030d | 2014-10-06 10:39:03 -0700 | [diff] [blame] | 228 | case ADDED: |
| 229 | case PENDING_ADD: |
alshabib | 6eb438a | 2014-10-01 16:39:37 -0700 | [diff] [blame] | 230 | frp.applyFlowRule(stored); |
tom | 9b4030d | 2014-10-06 10:39:03 -0700 | [diff] [blame] | 231 | break; |
| 232 | case PENDING_REMOVE: |
| 233 | case REMOVED: |
| 234 | event = store.removeFlowRule(stored); |
| 235 | break; |
| 236 | default: |
| 237 | break; |
alshabib | 57044ba | 2014-09-16 15:58:01 -0700 | [diff] [blame] | 238 | |
alshabib | a68eb96 | 2014-09-24 20:34:13 -0700 | [diff] [blame] | 239 | } |
Ayaka Koshibe | 08eabaa | 2014-09-17 14:59:25 -0700 | [diff] [blame] | 240 | if (event != null) { |
alshabib | 1c319ff | 2014-10-04 20:29:09 -0700 | [diff] [blame] | 241 | log.debug("Flow {} removed", flowEntry); |
Ayaka Koshibe | 08eabaa | 2014-09-17 14:59:25 -0700 | [diff] [blame] | 242 | post(event); |
| 243 | } |
alshabib | 57044ba | 2014-09-16 15:58:01 -0700 | [diff] [blame] | 244 | } |
| 245 | |
alshabib | ba5ac48 | 2014-10-02 17:15:20 -0700 | [diff] [blame] | 246 | |
alshabib | 1c319ff | 2014-10-04 20:29:09 -0700 | [diff] [blame] | 247 | private void flowMissing(FlowEntry flowRule) { |
Ayaka Koshibe | 08eabaa | 2014-09-17 14:59:25 -0700 | [diff] [blame] | 248 | checkNotNull(flowRule, FLOW_RULE_NULL); |
| 249 | checkValidity(); |
alshabib | a68eb96 | 2014-09-24 20:34:13 -0700 | [diff] [blame] | 250 | Device device = deviceService.getDevice(flowRule.deviceId()); |
| 251 | FlowRuleProvider frp = getProvider(device.providerId()); |
alshabib | bb42cad | 2014-09-25 11:43:05 -0700 | [diff] [blame] | 252 | FlowRuleEvent event = null; |
alshabib | a68eb96 | 2014-09-24 20:34:13 -0700 | [diff] [blame] | 253 | switch (flowRule.state()) { |
tom | 9b4030d | 2014-10-06 10:39:03 -0700 | [diff] [blame] | 254 | case PENDING_REMOVE: |
| 255 | case REMOVED: |
| 256 | event = store.removeFlowRule(flowRule); |
| 257 | frp.removeFlowRule(flowRule); |
| 258 | break; |
| 259 | case ADDED: |
| 260 | case PENDING_ADD: |
| 261 | frp.applyFlowRule(flowRule); |
| 262 | break; |
| 263 | default: |
| 264 | log.debug("Flow {} has not been installed.", flowRule); |
alshabib | a68eb96 | 2014-09-24 20:34:13 -0700 | [diff] [blame] | 265 | } |
| 266 | |
alshabib | bb42cad | 2014-09-25 11:43:05 -0700 | [diff] [blame] | 267 | if (event != null) { |
| 268 | log.debug("Flow {} removed", flowRule); |
| 269 | post(event); |
| 270 | } |
alshabib | 57044ba | 2014-09-16 15:58:01 -0700 | [diff] [blame] | 271 | |
| 272 | } |
| 273 | |
alshabib | ba5ac48 | 2014-10-02 17:15:20 -0700 | [diff] [blame] | 274 | |
| 275 | private void extraneousFlow(FlowRule flowRule) { |
alshabib | 219ebaa | 2014-09-22 15:41:24 -0700 | [diff] [blame] | 276 | checkNotNull(flowRule, FLOW_RULE_NULL); |
| 277 | checkValidity(); |
alshabib | 2374fc9 | 2014-10-22 11:03:23 -0700 | [diff] [blame] | 278 | FlowRuleProvider frp = getProvider(flowRule.deviceId()); |
| 279 | frp.removeFlowRule(flowRule); |
alshabib | 54ce589 | 2014-09-23 17:50:51 -0700 | [diff] [blame] | 280 | log.debug("Flow {} is on switch but not in store.", flowRule); |
alshabib | 219ebaa | 2014-09-22 15:41:24 -0700 | [diff] [blame] | 281 | } |
| 282 | |
alshabib | ba5ac48 | 2014-10-02 17:15:20 -0700 | [diff] [blame] | 283 | |
alshabib | 1c319ff | 2014-10-04 20:29:09 -0700 | [diff] [blame] | 284 | private void flowAdded(FlowEntry flowEntry) { |
| 285 | checkNotNull(flowEntry, FLOW_RULE_NULL); |
Ayaka Koshibe | 08eabaa | 2014-09-17 14:59:25 -0700 | [diff] [blame] | 286 | checkValidity(); |
alshabib | 57044ba | 2014-09-16 15:58:01 -0700 | [diff] [blame] | 287 | |
alshabib | 1c319ff | 2014-10-04 20:29:09 -0700 | [diff] [blame] | 288 | if (checkRuleLiveness(flowEntry, store.getFlowEntry(flowEntry))) { |
alshabib | ba5ac48 | 2014-10-02 17:15:20 -0700 | [diff] [blame] | 289 | |
alshabib | 1c319ff | 2014-10-04 20:29:09 -0700 | [diff] [blame] | 290 | FlowRuleEvent event = store.addOrUpdateFlowRule(flowEntry); |
alshabib | ba5ac48 | 2014-10-02 17:15:20 -0700 | [diff] [blame] | 291 | if (event == null) { |
| 292 | log.debug("No flow store event generated."); |
| 293 | } else { |
alshabib | 1c319ff | 2014-10-04 20:29:09 -0700 | [diff] [blame] | 294 | log.debug("Flow {} {}", flowEntry, event.type()); |
alshabib | ba5ac48 | 2014-10-02 17:15:20 -0700 | [diff] [blame] | 295 | post(event); |
| 296 | } |
Ayaka Koshibe | 08eabaa | 2014-09-17 14:59:25 -0700 | [diff] [blame] | 297 | } else { |
Thomas Vachuska | 4830d39 | 2014-11-09 17:09:56 -0800 | [diff] [blame] | 298 | log.debug("Removing flow rules...."); |
alshabib | 1c319ff | 2014-10-04 20:29:09 -0700 | [diff] [blame] | 299 | removeFlowRules(flowEntry); |
Ayaka Koshibe | 08eabaa | 2014-09-17 14:59:25 -0700 | [diff] [blame] | 300 | } |
alshabib | 219ebaa | 2014-09-22 15:41:24 -0700 | [diff] [blame] | 301 | |
alshabib | 57044ba | 2014-09-16 15:58:01 -0700 | [diff] [blame] | 302 | } |
| 303 | |
alshabib | 1c319ff | 2014-10-04 20:29:09 -0700 | [diff] [blame] | 304 | private boolean checkRuleLiveness(FlowEntry swRule, FlowEntry storedRule) { |
| 305 | if (storedRule == null) { |
| 306 | return false; |
| 307 | } |
Jonathan Hart | bc4a793 | 2014-10-21 11:46:00 -0700 | [diff] [blame] | 308 | if (storedRule.isPermanent()) { |
| 309 | return true; |
| 310 | } |
| 311 | |
Yuta HIGUCHI | f6f50a6 | 2014-10-19 15:58:49 -0700 | [diff] [blame] | 312 | final long timeout = storedRule.timeout() * 1000; |
| 313 | final long currentTime = System.currentTimeMillis(); |
alshabib | 85c4197 | 2014-10-03 13:48:39 -0700 | [diff] [blame] | 314 | if (storedRule.packets() != swRule.packets()) { |
Yuta HIGUCHI | f6f50a6 | 2014-10-19 15:58:49 -0700 | [diff] [blame] | 315 | lastSeen.put(storedRule, currentTime); |
alshabib | 85c4197 | 2014-10-03 13:48:39 -0700 | [diff] [blame] | 316 | return true; |
| 317 | } |
Yuta HIGUCHI | f6f50a6 | 2014-10-19 15:58:49 -0700 | [diff] [blame] | 318 | if (!lastSeen.containsKey(storedRule)) { |
| 319 | // checking for the first time |
| 320 | lastSeen.put(storedRule, storedRule.lastSeen()); |
| 321 | // Use following if lastSeen attr. was removed. |
| 322 | //lastSeen.put(storedRule, currentTime); |
| 323 | } |
| 324 | Long last = lastSeen.get(storedRule); |
| 325 | if (last == null) { |
| 326 | // concurrently removed? let the liveness check fail |
| 327 | return false; |
| 328 | } |
alshabib | 85c4197 | 2014-10-03 13:48:39 -0700 | [diff] [blame] | 329 | |
Yuta HIGUCHI | f6f50a6 | 2014-10-19 15:58:49 -0700 | [diff] [blame] | 330 | if ((currentTime - last) <= timeout) { |
alshabib | c274c90 | 2014-10-03 14:58:27 -0700 | [diff] [blame] | 331 | return true; |
| 332 | } |
| 333 | return false; |
alshabib | ba5ac48 | 2014-10-02 17:15:20 -0700 | [diff] [blame] | 334 | } |
| 335 | |
Ayaka Koshibe | 08eabaa | 2014-09-17 14:59:25 -0700 | [diff] [blame] | 336 | // Posts the specified event to the local event dispatcher. |
| 337 | private void post(FlowRuleEvent event) { |
| 338 | if (event != null) { |
| 339 | eventDispatcher.post(event); |
| 340 | } |
| 341 | } |
alshabib | 5c370ff | 2014-09-18 10:12:14 -0700 | [diff] [blame] | 342 | |
| 343 | @Override |
alshabib | 1c319ff | 2014-10-04 20:29:09 -0700 | [diff] [blame] | 344 | public void pushFlowMetrics(DeviceId deviceId, Iterable<FlowEntry> flowEntries) { |
| 345 | List<FlowEntry> storedRules = Lists.newLinkedList(store.getFlowEntries(deviceId)); |
alshabib | bb8b128 | 2014-09-22 17:00:18 -0700 | [diff] [blame] | 346 | |
Yuta HIGUCHI | f6f50a6 | 2014-10-19 15:58:49 -0700 | [diff] [blame] | 347 | for (FlowEntry rule : flowEntries) { |
alshabib | a7f7ca8 | 2014-09-22 11:41:23 -0700 | [diff] [blame] | 348 | if (storedRules.remove(rule)) { |
alshabib | 219ebaa | 2014-09-22 15:41:24 -0700 | [diff] [blame] | 349 | // we both have the rule, let's update some info then. |
alshabib | a7f7ca8 | 2014-09-22 11:41:23 -0700 | [diff] [blame] | 350 | flowAdded(rule); |
| 351 | } else { |
alshabib | 219ebaa | 2014-09-22 15:41:24 -0700 | [diff] [blame] | 352 | // the device has a rule the store does not have |
| 353 | extraneousFlow(rule); |
alshabib | a7f7ca8 | 2014-09-22 11:41:23 -0700 | [diff] [blame] | 354 | } |
| 355 | } |
alshabib | 1c319ff | 2014-10-04 20:29:09 -0700 | [diff] [blame] | 356 | for (FlowEntry rule : storedRules) { |
alshabib | a7f7ca8 | 2014-09-22 11:41:23 -0700 | [diff] [blame] | 357 | // there are rules in the store that aren't on the switch |
| 358 | flowMissing(rule); |
alshabib | 54ce589 | 2014-09-23 17:50:51 -0700 | [diff] [blame] | 359 | |
alshabib | a7f7ca8 | 2014-09-22 11:41:23 -0700 | [diff] [blame] | 360 | } |
alshabib | 5c370ff | 2014-09-18 10:12:14 -0700 | [diff] [blame] | 361 | } |
alshabib | 57044ba | 2014-09-16 15:58:01 -0700 | [diff] [blame] | 362 | } |
| 363 | |
tom | c78acee | 2014-09-24 15:16:55 -0700 | [diff] [blame] | 364 | // Store delegate to re-post events emitted from the store. |
| 365 | private class InternalStoreDelegate implements FlowRuleStoreDelegate { |
Thomas Vachuska | 9b2da21 | 2014-11-10 19:30:25 -0800 | [diff] [blame] | 366 | |
| 367 | private static final int TIMEOUT = 5000; // ms |
| 368 | |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 369 | // TODO: Right now we only dispatch events at individual flowEntry level. |
| 370 | // It may be more efficient for also dispatch events as a batch. |
tom | c78acee | 2014-09-24 15:16:55 -0700 | [diff] [blame] | 371 | @Override |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 372 | public void notify(FlowRuleBatchEvent event) { |
| 373 | final FlowRuleBatchRequest request = event.subject(); |
Yuta HIGUCHI | f3d51bd | 2014-10-21 01:05:33 -0700 | [diff] [blame] | 374 | switch (event.type()) { |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 375 | case BATCH_OPERATION_REQUESTED: |
Yuta HIGUCHI | 2fcb40c | 2014-11-03 14:39:10 -0800 | [diff] [blame] | 376 | // Request has been forwarded to MASTER Node, and was |
| 377 | for (FlowRule entry : request.toAdd()) { |
Madan Jampani | 31961c1 | 2014-10-23 12:06:58 -0700 | [diff] [blame] | 378 | eventDispatcher.post(new FlowRuleEvent(FlowRuleEvent.Type.RULE_ADD_REQUESTED, entry)); |
| 379 | } |
Yuta HIGUCHI | 2fcb40c | 2014-11-03 14:39:10 -0800 | [diff] [blame] | 380 | for (FlowRule entry : request.toRemove()) { |
Madan Jampani | 31961c1 | 2014-10-23 12:06:58 -0700 | [diff] [blame] | 381 | eventDispatcher.post(new FlowRuleEvent(FlowRuleEvent.Type.RULE_REMOVE_REQUESTED, entry)); |
| 382 | } |
| 383 | // FIXME: what about op.equals(FlowRuleOperation.MODIFY) ? |
Yuta HIGUCHI | f3d51bd | 2014-10-21 01:05:33 -0700 | [diff] [blame] | 384 | |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 385 | FlowRuleBatchOperation batchOperation = request.asBatchOperation(); |
Yuta HIGUCHI | f3d51bd | 2014-10-21 01:05:33 -0700 | [diff] [blame] | 386 | |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 387 | FlowRuleProvider flowRuleProvider = |
| 388 | getProvider(batchOperation.getOperations().get(0).getTarget().deviceId()); |
Thomas Vachuska | 9b2da21 | 2014-11-10 19:30:25 -0800 | [diff] [blame] | 389 | final Future<CompletedBatchOperation> result = |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 390 | flowRuleProvider.executeBatch(batchOperation); |
Thomas Vachuska | 9b2da21 | 2014-11-10 19:30:25 -0800 | [diff] [blame] | 391 | futureService.submit(new Runnable() { |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 392 | @Override |
| 393 | public void run() { |
Yuta HIGUCHI | f1ccee8 | 2014-11-11 20:39:58 -0800 | [diff] [blame] | 394 | CompletedBatchOperation res; |
Thomas Vachuska | 9b2da21 | 2014-11-10 19:30:25 -0800 | [diff] [blame] | 395 | try { |
| 396 | res = result.get(TIMEOUT, TimeUnit.MILLISECONDS); |
Yuta HIGUCHI | f1ccee8 | 2014-11-11 20:39:58 -0800 | [diff] [blame] | 397 | store.batchOperationComplete(FlowRuleBatchEvent.completed(request, res)); |
Thomas Vachuska | 9b2da21 | 2014-11-10 19:30:25 -0800 | [diff] [blame] | 398 | } catch (TimeoutException | InterruptedException | ExecutionException e) { |
| 399 | log.warn("Something went wrong with the batch operation {}", |
Yuta HIGUCHI | f1ccee8 | 2014-11-11 20:39:58 -0800 | [diff] [blame] | 400 | request.batchId(), e); |
| 401 | |
| 402 | Set<FlowRule> failures = new HashSet<>(batchOperation.size()); |
| 403 | for (FlowRuleBatchEntry op : batchOperation.getOperations()) { |
| 404 | failures.add(op.getTarget()); |
| 405 | } |
| 406 | res = new CompletedBatchOperation(false, failures); |
| 407 | store.batchOperationComplete(FlowRuleBatchEvent.completed(request, res)); |
Thomas Vachuska | 9b2da21 | 2014-11-10 19:30:25 -0800 | [diff] [blame] | 408 | } |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 409 | } |
Thomas Vachuska | 9b2da21 | 2014-11-10 19:30:25 -0800 | [diff] [blame] | 410 | }); |
Yuta HIGUCHI | 2fcb40c | 2014-11-03 14:39:10 -0800 | [diff] [blame] | 411 | break; |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 412 | |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 413 | case BATCH_OPERATION_COMPLETED: |
Yuta HIGUCHI | 2fcb40c | 2014-11-03 14:39:10 -0800 | [diff] [blame] | 414 | // MASTER Node has pushed the batch down to the Device |
| 415 | |
| 416 | // Note: RULE_ADDED will be posted |
| 417 | // when Flow was actually confirmed by stats reply. |
Yuta HIGUCHI | f3d51bd | 2014-10-21 01:05:33 -0700 | [diff] [blame] | 418 | break; |
Yuta HIGUCHI | 2fcb40c | 2014-11-03 14:39:10 -0800 | [diff] [blame] | 419 | |
Yuta HIGUCHI | f3d51bd | 2014-10-21 01:05:33 -0700 | [diff] [blame] | 420 | default: |
| 421 | break; |
| 422 | } |
tom | c78acee | 2014-09-24 15:16:55 -0700 | [diff] [blame] | 423 | } |
| 424 | } |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 425 | |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 426 | private class FlowRuleBatchFuture implements Future<CompletedBatchOperation> { |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 427 | |
alshabib | 193525b | 2014-10-08 18:58:03 -0700 | [diff] [blame] | 428 | private final List<Future<CompletedBatchOperation>> futures; |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 429 | private final Multimap<DeviceId, FlowRuleBatchEntry> batches; |
alshabib | 193525b | 2014-10-08 18:58:03 -0700 | [diff] [blame] | 430 | private final AtomicReference<BatchState> state; |
| 431 | private CompletedBatchOperation overall; |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 432 | |
alshabib | 193525b | 2014-10-08 18:58:03 -0700 | [diff] [blame] | 433 | public FlowRuleBatchFuture(List<Future<CompletedBatchOperation>> futures, |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 434 | Multimap<DeviceId, FlowRuleBatchEntry> batches) { |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 435 | this.futures = futures; |
alshabib | 193525b | 2014-10-08 18:58:03 -0700 | [diff] [blame] | 436 | this.batches = batches; |
| 437 | state = new AtomicReference<FlowRuleManager.BatchState>(); |
| 438 | state.set(BatchState.STARTED); |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 439 | } |
| 440 | |
| 441 | @Override |
| 442 | public boolean cancel(boolean mayInterruptIfRunning) { |
alshabib | 193525b | 2014-10-08 18:58:03 -0700 | [diff] [blame] | 443 | if (state.get() == BatchState.FINISHED) { |
| 444 | return false; |
| 445 | } |
| 446 | if (!state.compareAndSet(BatchState.STARTED, BatchState.CANCELLED)) { |
| 447 | return false; |
| 448 | } |
| 449 | cleanUpBatch(); |
| 450 | for (Future<CompletedBatchOperation> f : futures) { |
| 451 | f.cancel(mayInterruptIfRunning); |
| 452 | } |
| 453 | return true; |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 454 | } |
| 455 | |
| 456 | @Override |
| 457 | public boolean isCancelled() { |
alshabib | 193525b | 2014-10-08 18:58:03 -0700 | [diff] [blame] | 458 | return state.get() == BatchState.CANCELLED; |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 459 | } |
| 460 | |
| 461 | @Override |
| 462 | public boolean isDone() { |
alshabib | 193525b | 2014-10-08 18:58:03 -0700 | [diff] [blame] | 463 | return state.get() == BatchState.FINISHED; |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 464 | } |
| 465 | |
alshabib | 193525b | 2014-10-08 18:58:03 -0700 | [diff] [blame] | 466 | |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 467 | @Override |
| 468 | public CompletedBatchOperation get() throws InterruptedException, |
alshabib | 193525b | 2014-10-08 18:58:03 -0700 | [diff] [blame] | 469 | ExecutionException { |
| 470 | |
| 471 | if (isDone()) { |
| 472 | return overall; |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 473 | } |
alshabib | 193525b | 2014-10-08 18:58:03 -0700 | [diff] [blame] | 474 | |
| 475 | boolean success = true; |
Yuta HIGUCHI | 4b52444 | 2014-10-28 22:23:57 -0700 | [diff] [blame] | 476 | Set<FlowRule> failed = Sets.newHashSet(); |
alshabib | 193525b | 2014-10-08 18:58:03 -0700 | [diff] [blame] | 477 | CompletedBatchOperation completed; |
| 478 | for (Future<CompletedBatchOperation> future : futures) { |
| 479 | completed = future.get(); |
alshabib | 3effd04 | 2014-10-17 12:00:31 -0700 | [diff] [blame] | 480 | success = validateBatchOperation(failed, completed); |
alshabib | 193525b | 2014-10-08 18:58:03 -0700 | [diff] [blame] | 481 | } |
| 482 | |
| 483 | return finalizeBatchOperation(success, failed); |
| 484 | |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 485 | } |
| 486 | |
| 487 | @Override |
| 488 | public CompletedBatchOperation get(long timeout, TimeUnit unit) |
| 489 | throws InterruptedException, ExecutionException, |
| 490 | TimeoutException { |
alshabib | 193525b | 2014-10-08 18:58:03 -0700 | [diff] [blame] | 491 | |
| 492 | if (isDone()) { |
| 493 | return overall; |
| 494 | } |
| 495 | boolean success = true; |
Yuta HIGUCHI | 4b52444 | 2014-10-28 22:23:57 -0700 | [diff] [blame] | 496 | Set<FlowRule> failed = Sets.newHashSet(); |
alshabib | 193525b | 2014-10-08 18:58:03 -0700 | [diff] [blame] | 497 | CompletedBatchOperation completed; |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 498 | long start = System.nanoTime(); |
| 499 | long end = start + unit.toNanos(timeout); |
alshabib | 193525b | 2014-10-08 18:58:03 -0700 | [diff] [blame] | 500 | |
| 501 | for (Future<CompletedBatchOperation> future : futures) { |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 502 | long now = System.nanoTime(); |
| 503 | long thisTimeout = end - now; |
alshabib | 193525b | 2014-10-08 18:58:03 -0700 | [diff] [blame] | 504 | completed = future.get(thisTimeout, TimeUnit.NANOSECONDS); |
alshabib | 3effd04 | 2014-10-17 12:00:31 -0700 | [diff] [blame] | 505 | success = validateBatchOperation(failed, completed); |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 506 | } |
alshabib | 193525b | 2014-10-08 18:58:03 -0700 | [diff] [blame] | 507 | return finalizeBatchOperation(success, failed); |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 508 | } |
| 509 | |
Yuta HIGUCHI | 4b52444 | 2014-10-28 22:23:57 -0700 | [diff] [blame] | 510 | private boolean validateBatchOperation(Set<FlowRule> failed, |
alshabib | 3effd04 | 2014-10-17 12:00:31 -0700 | [diff] [blame] | 511 | CompletedBatchOperation completed) { |
alshabib | 193525b | 2014-10-08 18:58:03 -0700 | [diff] [blame] | 512 | |
| 513 | if (isCancelled()) { |
| 514 | throw new CancellationException(); |
| 515 | } |
| 516 | if (!completed.isSuccess()) { |
| 517 | failed.addAll(completed.failedItems()); |
| 518 | cleanUpBatch(); |
| 519 | cancelAllSubBatches(); |
| 520 | return false; |
| 521 | } |
| 522 | return true; |
| 523 | } |
| 524 | |
| 525 | private void cancelAllSubBatches() { |
| 526 | for (Future<CompletedBatchOperation> f : futures) { |
| 527 | f.cancel(true); |
| 528 | } |
| 529 | } |
| 530 | |
| 531 | private CompletedBatchOperation finalizeBatchOperation(boolean success, |
Yuta HIGUCHI | 4b52444 | 2014-10-28 22:23:57 -0700 | [diff] [blame] | 532 | Set<FlowRule> failed) { |
alshabib | 2683458 | 2014-10-08 20:15:46 -0700 | [diff] [blame] | 533 | synchronized (this) { |
alshabib | 193525b | 2014-10-08 18:58:03 -0700 | [diff] [blame] | 534 | if (!state.compareAndSet(BatchState.STARTED, BatchState.FINISHED)) { |
| 535 | if (state.get() == BatchState.FINISHED) { |
| 536 | return overall; |
| 537 | } |
| 538 | throw new CancellationException(); |
| 539 | } |
| 540 | overall = new CompletedBatchOperation(success, failed); |
| 541 | return overall; |
| 542 | } |
| 543 | } |
| 544 | |
| 545 | private void cleanUpBatch() { |
| 546 | for (FlowRuleBatchEntry fbe : batches.values()) { |
| 547 | if (fbe.getOperator() == FlowRuleOperation.ADD || |
| 548 | fbe.getOperator() == FlowRuleOperation.MODIFY) { |
| 549 | store.deleteFlowRule(fbe.getTarget()); |
| 550 | } else if (fbe.getOperator() == FlowRuleOperation.REMOVE) { |
alshabib | cf36991 | 2014-10-13 14:16:42 -0700 | [diff] [blame] | 551 | store.removeFlowRule(new DefaultFlowEntry(fbe.getTarget())); |
alshabib | 193525b | 2014-10-08 18:58:03 -0700 | [diff] [blame] | 552 | store.storeFlowRule(fbe.getTarget()); |
| 553 | } |
| 554 | } |
alshabib | 193525b | 2014-10-08 18:58:03 -0700 | [diff] [blame] | 555 | } |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 556 | } |
alshabib | 57044ba | 2014-09-16 15:58:01 -0700 | [diff] [blame] | 557 | } |