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 | */ |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 16 | package org.onosproject.store.flow.impl; |
alshabib | 339a3d9 | 2014-09-26 17:54:32 -0700 | [diff] [blame] | 17 | |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 18 | import com.google.common.cache.CacheBuilder; |
| 19 | import com.google.common.cache.CacheLoader; |
| 20 | import com.google.common.cache.LoadingCache; |
| 21 | import com.google.common.collect.ImmutableList; |
| 22 | import com.google.common.collect.Iterables; |
| 23 | import com.google.common.collect.Maps; |
| 24 | import com.google.common.collect.Sets; |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 25 | import com.hazelcast.core.IMap; |
alshabib | 339a3d9 | 2014-09-26 17:54:32 -0700 | [diff] [blame] | 26 | import org.apache.felix.scr.annotations.Activate; |
| 27 | import org.apache.felix.scr.annotations.Component; |
| 28 | import org.apache.felix.scr.annotations.Deactivate; |
Madan Jampani | 38b250d | 2014-10-17 11:02:38 -0700 | [diff] [blame] | 29 | import org.apache.felix.scr.annotations.Reference; |
| 30 | import org.apache.felix.scr.annotations.ReferenceCardinality; |
alshabib | 339a3d9 | 2014-09-26 17:54:32 -0700 | [diff] [blame] | 31 | import org.apache.felix.scr.annotations.Service; |
Brian O'Connor | 5eb77c8 | 2015-03-02 18:09:39 -0800 | [diff] [blame^] | 32 | import org.onlab.util.BoundedThreadPool; |
Jonathan Hart | 4fb5cde | 2014-12-22 12:09:07 -0800 | [diff] [blame] | 33 | import org.onlab.util.KryoNamespace; |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 34 | import org.onlab.util.NewConcurrentHashMap; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 35 | import org.onosproject.cluster.ClusterService; |
| 36 | import org.onosproject.cluster.NodeId; |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 37 | import org.onosproject.core.CoreService; |
| 38 | import org.onosproject.core.IdGenerator; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 39 | import org.onosproject.net.Device; |
| 40 | import org.onosproject.net.DeviceId; |
| 41 | import org.onosproject.net.device.DeviceService; |
| 42 | import org.onosproject.net.flow.CompletedBatchOperation; |
| 43 | import org.onosproject.net.flow.DefaultFlowEntry; |
| 44 | import org.onosproject.net.flow.FlowEntry; |
| 45 | import org.onosproject.net.flow.FlowEntry.FlowEntryState; |
| 46 | import org.onosproject.net.flow.FlowId; |
| 47 | import org.onosproject.net.flow.FlowRule; |
| 48 | import org.onosproject.net.flow.FlowRuleBatchEntry; |
Jonathan Hart | 4fb5cde | 2014-12-22 12:09:07 -0800 | [diff] [blame] | 49 | import org.onosproject.net.flow.FlowRuleBatchEntry.FlowRuleOperation; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 50 | import org.onosproject.net.flow.FlowRuleBatchEvent; |
| 51 | import org.onosproject.net.flow.FlowRuleBatchOperation; |
| 52 | import org.onosproject.net.flow.FlowRuleBatchRequest; |
| 53 | import org.onosproject.net.flow.FlowRuleEvent; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 54 | import org.onosproject.net.flow.FlowRuleEvent.Type; |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 55 | import org.onosproject.net.flow.FlowRuleService; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 56 | import org.onosproject.net.flow.FlowRuleStore; |
| 57 | import org.onosproject.net.flow.FlowRuleStoreDelegate; |
| 58 | import org.onosproject.net.flow.StoredFlowEntry; |
| 59 | import org.onosproject.store.cluster.messaging.ClusterCommunicationService; |
| 60 | import org.onosproject.store.cluster.messaging.ClusterMessage; |
| 61 | import org.onosproject.store.cluster.messaging.ClusterMessageHandler; |
| 62 | import org.onosproject.store.flow.ReplicaInfo; |
| 63 | import org.onosproject.store.flow.ReplicaInfoEvent; |
| 64 | import org.onosproject.store.flow.ReplicaInfoEventListener; |
| 65 | import org.onosproject.store.flow.ReplicaInfoService; |
| 66 | import org.onosproject.store.hz.AbstractHazelcastStore; |
| 67 | import org.onosproject.store.hz.SMap; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 68 | import org.onosproject.store.serializers.KryoSerializer; |
| 69 | import org.onosproject.store.serializers.StoreSerializer; |
| 70 | import org.onosproject.store.serializers.impl.DistributedStoreSerializers; |
alshabib | 339a3d9 | 2014-09-26 17:54:32 -0700 | [diff] [blame] | 71 | import org.slf4j.Logger; |
| 72 | |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 73 | import java.io.IOException; |
| 74 | import java.util.ArrayList; |
| 75 | import java.util.Arrays; |
| 76 | import java.util.Collections; |
| 77 | import java.util.HashSet; |
| 78 | import java.util.List; |
| 79 | import java.util.Map; |
| 80 | import java.util.Map.Entry; |
| 81 | import java.util.Set; |
| 82 | import java.util.concurrent.ConcurrentHashMap; |
| 83 | import java.util.concurrent.ConcurrentMap; |
| 84 | import java.util.concurrent.CopyOnWriteArraySet; |
| 85 | import java.util.concurrent.ExecutionException; |
| 86 | import java.util.concurrent.ExecutorService; |
| 87 | import java.util.concurrent.Executors; |
| 88 | import java.util.concurrent.Future; |
| 89 | import java.util.concurrent.TimeUnit; |
| 90 | import java.util.concurrent.TimeoutException; |
| 91 | import java.util.stream.Collectors; |
| 92 | |
| 93 | import static com.google.common.base.Preconditions.checkNotNull; |
| 94 | import static org.apache.commons.lang3.concurrent.ConcurrentUtils.createIfAbsentUnchecked; |
Thomas Vachuska | 6f94ded | 2015-02-21 14:02:38 -0800 | [diff] [blame] | 95 | import static org.onlab.util.Tools.groupedThreads; |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 96 | import static org.onosproject.net.flow.FlowRuleEvent.Type.RULE_REMOVED; |
| 97 | import static org.onosproject.store.flow.impl.FlowStoreMessageSubjects.*; |
| 98 | import static org.slf4j.LoggerFactory.getLogger; |
alshabib | 339a3d9 | 2014-09-26 17:54:32 -0700 | [diff] [blame] | 99 | |
| 100 | /** |
Madan Jampani | 38b250d | 2014-10-17 11:02:38 -0700 | [diff] [blame] | 101 | * Manages inventory of flow rules using a distributed state management protocol. |
alshabib | 339a3d9 | 2014-09-26 17:54:32 -0700 | [diff] [blame] | 102 | */ |
alshabib | 339a3d9 | 2014-09-26 17:54:32 -0700 | [diff] [blame] | 103 | @Component(immediate = true) |
| 104 | @Service |
| 105 | public class DistributedFlowRuleStore |
Yuta HIGUCHI | 92891d1 | 2014-10-27 20:04:38 -0700 | [diff] [blame] | 106 | extends AbstractHazelcastStore<FlowRuleBatchEvent, FlowRuleStoreDelegate> |
alshabib | 1c319ff | 2014-10-04 20:29:09 -0700 | [diff] [blame] | 107 | implements FlowRuleStore { |
alshabib | 339a3d9 | 2014-09-26 17:54:32 -0700 | [diff] [blame] | 108 | |
| 109 | private final Logger log = getLogger(getClass()); |
| 110 | |
Madan Jampani | 2af244a | 2015-02-22 13:12:01 -0800 | [diff] [blame] | 111 | // TODO: Make configurable. |
| 112 | private static final int MESSAGE_HANDLER_THREAD_POOL_SIZE = 8; |
| 113 | |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 114 | private InternalFlowTable flowTable = new InternalFlowTable(); |
| 115 | |
| 116 | /*private final ConcurrentMap<DeviceId, ConcurrentMap<FlowId, Set<StoredFlowEntry>>> |
| 117 | flowEntries = new ConcurrentHashMap<>();*/ |
alshabib | 339a3d9 | 2014-09-26 17:54:32 -0700 | [diff] [blame] | 118 | |
Madan Jampani | 38b250d | 2014-10-17 11:02:38 -0700 | [diff] [blame] | 119 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
Yuta HIGUCHI | 9def047 | 2014-10-23 15:51:10 -0700 | [diff] [blame] | 120 | protected ReplicaInfoService replicaInfoManager; |
Madan Jampani | 38b250d | 2014-10-17 11:02:38 -0700 | [diff] [blame] | 121 | |
| 122 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
Yuta HIGUCHI | 9def047 | 2014-10-23 15:51:10 -0700 | [diff] [blame] | 123 | protected ClusterCommunicationService clusterCommunicator; |
Madan Jampani | 38b250d | 2014-10-17 11:02:38 -0700 | [diff] [blame] | 124 | |
| 125 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
Yuta HIGUCHI | 9def047 | 2014-10-23 15:51:10 -0700 | [diff] [blame] | 126 | protected ClusterService clusterService; |
| 127 | |
| 128 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 129 | protected DeviceService deviceService; |
| 130 | |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 131 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 132 | protected CoreService coreService; |
Yuta HIGUCHI | 9def047 | 2014-10-23 15:51:10 -0700 | [diff] [blame] | 133 | |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 134 | private Map<Long, NodeId> pendingResponses = Maps.newConcurrentMap(); |
Yuta HIGUCHI | bf89c74 | 2014-10-27 15:10:02 -0700 | [diff] [blame] | 135 | |
Yuta HIGUCHI | e9b2b00 | 2014-11-04 12:25:47 -0800 | [diff] [blame] | 136 | // Cache of SMaps used for backup data. each SMap contain device flow table |
Yuta HIGUCHI | 92891d1 | 2014-10-27 20:04:38 -0700 | [diff] [blame] | 137 | private LoadingCache<DeviceId, SMap<FlowId, ImmutableList<StoredFlowEntry>>> smaps; |
| 138 | |
Madan Jampani | 2af244a | 2015-02-22 13:12:01 -0800 | [diff] [blame] | 139 | private ExecutorService messageHandlingExecutor; |
Yuta HIGUCHI | 9def047 | 2014-10-23 15:51:10 -0700 | [diff] [blame] | 140 | |
Yuta HIGUCHI | 92891d1 | 2014-10-27 20:04:38 -0700 | [diff] [blame] | 141 | private final ExecutorService backupExecutors = |
Brian O'Connor | 5eb77c8 | 2015-03-02 18:09:39 -0800 | [diff] [blame^] | 142 | BoundedThreadPool.newSingleThreadExecutor(groupedThreads("onos/flow", "async-backups")); |
| 143 | //Executors.newSingleThreadExecutor(groupedThreads("onos/flow", "async-backups")); |
Yuta HIGUCHI | 92891d1 | 2014-10-27 20:04:38 -0700 | [diff] [blame] | 144 | |
Yuta HIGUCHI | 92891d1 | 2014-10-27 20:04:38 -0700 | [diff] [blame] | 145 | private boolean syncBackup = false; |
Madan Jampani | 38b250d | 2014-10-17 11:02:38 -0700 | [diff] [blame] | 146 | |
Yuta HIGUCHI | ea15015 | 2014-10-28 22:55:14 -0700 | [diff] [blame] | 147 | protected static final StoreSerializer SERIALIZER = new KryoSerializer() { |
Madan Jampani | 38b250d | 2014-10-17 11:02:38 -0700 | [diff] [blame] | 148 | @Override |
| 149 | protected void setupKryoPool() { |
Yuta HIGUCHI | 8d143d2 | 2014-10-19 23:15:09 -0700 | [diff] [blame] | 150 | serializerPool = KryoNamespace.newBuilder() |
Yuta HIGUCHI | 91768e3 | 2014-11-22 05:06:35 -0800 | [diff] [blame] | 151 | .register(DistributedStoreSerializers.STORE_COMMON) |
| 152 | .nextId(DistributedStoreSerializers.STORE_CUSTOM_BEGIN) |
Yuta HIGUCHI | 2f15833 | 2014-11-25 13:32:06 -0800 | [diff] [blame] | 153 | .register(FlowRuleEvent.class) |
Jonathan Hart | 4fb5cde | 2014-12-22 12:09:07 -0800 | [diff] [blame] | 154 | .register(FlowRuleEvent.Type.class) |
Yuta HIGUCHI | 91768e3 | 2014-11-22 05:06:35 -0800 | [diff] [blame] | 155 | .build(); |
Madan Jampani | 38b250d | 2014-10-17 11:02:38 -0700 | [diff] [blame] | 156 | } |
| 157 | }; |
| 158 | |
Yuta HIGUCHI | f3d51bd | 2014-10-21 01:05:33 -0700 | [diff] [blame] | 159 | private static final long FLOW_RULE_STORE_TIMEOUT_MILLIS = 5000; |
Madan Jampani | 38b250d | 2014-10-17 11:02:38 -0700 | [diff] [blame] | 160 | |
Yuta HIGUCHI | 92891d1 | 2014-10-27 20:04:38 -0700 | [diff] [blame] | 161 | private ReplicaInfoEventListener replicaInfoEventListener; |
| 162 | |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 163 | private IdGenerator idGenerator; |
| 164 | |
Yuta HIGUCHI | 92891d1 | 2014-10-27 20:04:38 -0700 | [diff] [blame] | 165 | @Override |
alshabib | 339a3d9 | 2014-09-26 17:54:32 -0700 | [diff] [blame] | 166 | @Activate |
| 167 | public void activate() { |
Yuta HIGUCHI | 92891d1 | 2014-10-27 20:04:38 -0700 | [diff] [blame] | 168 | |
| 169 | super.serializer = SERIALIZER; |
| 170 | super.theInstance = storeService.getHazelcastInstance(); |
| 171 | |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 172 | idGenerator = coreService.getIdGenerator(FlowRuleService.FLOW_OP_TOPIC); |
| 173 | |
Yuta HIGUCHI | 92891d1 | 2014-10-27 20:04:38 -0700 | [diff] [blame] | 174 | // Cache to create SMap on demand |
| 175 | smaps = CacheBuilder.newBuilder() |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 176 | .softValues() |
| 177 | .build(new SMapLoader()); |
Yuta HIGUCHI | 92891d1 | 2014-10-27 20:04:38 -0700 | [diff] [blame] | 178 | |
Yuta HIGUCHI | 4b52444 | 2014-10-28 22:23:57 -0700 | [diff] [blame] | 179 | final NodeId local = clusterService.getLocalNode().id(); |
| 180 | |
Madan Jampani | 2af244a | 2015-02-22 13:12:01 -0800 | [diff] [blame] | 181 | messageHandlingExecutor = Executors.newFixedThreadPool( |
| 182 | MESSAGE_HANDLER_THREAD_POOL_SIZE, |
Madan Jampani | 6b5b717 | 2015-02-23 13:02:26 -0800 | [diff] [blame] | 183 | groupedThreads("onos/store/flow", "message-handlers")); |
Madan Jampani | 2af244a | 2015-02-22 13:12:01 -0800 | [diff] [blame] | 184 | |
| 185 | clusterCommunicator.addSubscriber(APPLY_BATCH_FLOWS, new OnStoreBatch(local), messageHandlingExecutor); |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 186 | |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 187 | clusterCommunicator.addSubscriber(REMOTE_APPLY_COMPLETED, new ClusterMessageHandler() { |
| 188 | @Override |
| 189 | public void handle(ClusterMessage message) { |
| 190 | FlowRuleBatchEvent event = SERIALIZER.decode(message.payload()); |
| 191 | log.trace("received completed notification for {}", event); |
| 192 | notifyDelegate(event); |
| 193 | } |
Madan Jampani | 2af244a | 2015-02-22 13:12:01 -0800 | [diff] [blame] | 194 | }, messageHandlingExecutor); |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 195 | |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 196 | clusterCommunicator.addSubscriber(GET_FLOW_ENTRY, new ClusterMessageHandler() { |
| 197 | |
| 198 | @Override |
| 199 | public void handle(ClusterMessage message) { |
| 200 | FlowRule rule = SERIALIZER.decode(message.payload()); |
Yuta HIGUCHI | faf9e1c | 2014-11-20 00:31:29 -0800 | [diff] [blame] | 201 | log.trace("received get flow entry request for {}", rule); |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 202 | FlowEntry flowEntry = flowTable.getFlowEntry(rule); //getFlowEntryInternal(rule); |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 203 | try { |
| 204 | message.respond(SERIALIZER.encode(flowEntry)); |
| 205 | } catch (IOException e) { |
| 206 | log.error("Failed to respond back", e); |
| 207 | } |
| 208 | } |
Madan Jampani | 2af244a | 2015-02-22 13:12:01 -0800 | [diff] [blame] | 209 | }, messageHandlingExecutor); |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 210 | |
Madan Jampani | f5fdef0 | 2014-10-23 21:58:10 -0700 | [diff] [blame] | 211 | clusterCommunicator.addSubscriber(GET_DEVICE_FLOW_ENTRIES, new ClusterMessageHandler() { |
| 212 | |
| 213 | @Override |
| 214 | public void handle(ClusterMessage message) { |
| 215 | DeviceId deviceId = SERIALIZER.decode(message.payload()); |
Yuta HIGUCHI | faf9e1c | 2014-11-20 00:31:29 -0800 | [diff] [blame] | 216 | log.trace("Received get flow entries request for {} from {}", deviceId, message.sender()); |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 217 | Set<FlowEntry> flowEntries = flowTable.getFlowEntries(deviceId); |
Madan Jampani | f5fdef0 | 2014-10-23 21:58:10 -0700 | [diff] [blame] | 218 | try { |
| 219 | message.respond(SERIALIZER.encode(flowEntries)); |
| 220 | } catch (IOException e) { |
| 221 | log.error("Failed to respond to peer's getFlowEntries request", e); |
| 222 | } |
| 223 | } |
Madan Jampani | 2af244a | 2015-02-22 13:12:01 -0800 | [diff] [blame] | 224 | }, messageHandlingExecutor); |
Madan Jampani | f5fdef0 | 2014-10-23 21:58:10 -0700 | [diff] [blame] | 225 | |
Yuta HIGUCHI | dfa45c1 | 2014-11-24 18:38:53 -0800 | [diff] [blame] | 226 | clusterCommunicator.addSubscriber(REMOVE_FLOW_ENTRY, new ClusterMessageHandler() { |
| 227 | |
| 228 | @Override |
| 229 | public void handle(ClusterMessage message) { |
| 230 | FlowEntry rule = SERIALIZER.decode(message.payload()); |
| 231 | log.trace("received get flow entry request for {}", rule); |
| 232 | FlowRuleEvent event = removeFlowRuleInternal(rule); |
| 233 | try { |
| 234 | message.respond(SERIALIZER.encode(event)); |
| 235 | } catch (IOException e) { |
| 236 | log.error("Failed to respond back", e); |
| 237 | } |
| 238 | } |
Madan Jampani | 2af244a | 2015-02-22 13:12:01 -0800 | [diff] [blame] | 239 | }, messageHandlingExecutor); |
Yuta HIGUCHI | dfa45c1 | 2014-11-24 18:38:53 -0800 | [diff] [blame] | 240 | |
Yuta HIGUCHI | 92891d1 | 2014-10-27 20:04:38 -0700 | [diff] [blame] | 241 | replicaInfoEventListener = new InternalReplicaInfoEventListener(); |
| 242 | |
| 243 | replicaInfoManager.addListener(replicaInfoEventListener); |
| 244 | |
alshabib | 339a3d9 | 2014-09-26 17:54:32 -0700 | [diff] [blame] | 245 | log.info("Started"); |
| 246 | } |
| 247 | |
| 248 | @Deactivate |
| 249 | public void deactivate() { |
Yuta HIGUCHI | dfa45c1 | 2014-11-24 18:38:53 -0800 | [diff] [blame] | 250 | clusterCommunicator.removeSubscriber(REMOVE_FLOW_ENTRY); |
| 251 | clusterCommunicator.removeSubscriber(GET_DEVICE_FLOW_ENTRIES); |
| 252 | clusterCommunicator.removeSubscriber(GET_FLOW_ENTRY); |
| 253 | clusterCommunicator.removeSubscriber(APPLY_BATCH_FLOWS); |
alshabib | 371abe8 | 2015-02-13 10:44:17 -0800 | [diff] [blame] | 254 | clusterCommunicator.removeSubscriber(REMOTE_APPLY_COMPLETED); |
Madan Jampani | 2af244a | 2015-02-22 13:12:01 -0800 | [diff] [blame] | 255 | messageHandlingExecutor.shutdown(); |
Yuta HIGUCHI | 92891d1 | 2014-10-27 20:04:38 -0700 | [diff] [blame] | 256 | replicaInfoManager.removeListener(replicaInfoEventListener); |
alshabib | 339a3d9 | 2014-09-26 17:54:32 -0700 | [diff] [blame] | 257 | log.info("Stopped"); |
| 258 | } |
| 259 | |
| 260 | |
Brian O'Connor | 4400853 | 2014-12-04 16:41:36 -0800 | [diff] [blame] | 261 | // This is not a efficient operation on a distributed sharded |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 262 | // flow store. We need to revisit the need for this operation or at least |
| 263 | // make it device specific. |
alshabib | 339a3d9 | 2014-09-26 17:54:32 -0700 | [diff] [blame] | 264 | @Override |
tom | 9b4030d | 2014-10-06 10:39:03 -0700 | [diff] [blame] | 265 | public int getFlowRuleCount() { |
Yuta HIGUCHI | 9def047 | 2014-10-23 15:51:10 -0700 | [diff] [blame] | 266 | // implementing in-efficient operation for debugging purpose. |
| 267 | int sum = 0; |
| 268 | for (Device device : deviceService.getDevices()) { |
| 269 | final DeviceId did = device.id(); |
| 270 | sum += Iterables.size(getFlowEntries(did)); |
| 271 | } |
| 272 | return sum; |
tom | 9b4030d | 2014-10-06 10:39:03 -0700 | [diff] [blame] | 273 | } |
| 274 | |
| 275 | @Override |
Yuta HIGUCHI | 885868f | 2014-11-13 19:12:07 -0800 | [diff] [blame] | 276 | public FlowEntry getFlowEntry(FlowRule rule) { |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 277 | ReplicaInfo replicaInfo = replicaInfoManager.getReplicaInfoFor(rule.deviceId()); |
Yuta HIGUCHI | 4b52444 | 2014-10-28 22:23:57 -0700 | [diff] [blame] | 278 | |
| 279 | if (!replicaInfo.master().isPresent()) { |
Yuta HIGUCHI | 6b98ab6 | 2014-12-03 16:08:08 -0800 | [diff] [blame] | 280 | log.warn("Failed to getFlowEntry: No master for {}", rule.deviceId()); |
Yuta HIGUCHI | 885868f | 2014-11-13 19:12:07 -0800 | [diff] [blame] | 281 | return null; |
Yuta HIGUCHI | 4b52444 | 2014-10-28 22:23:57 -0700 | [diff] [blame] | 282 | } |
| 283 | |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 284 | if (replicaInfo.master().get().equals(clusterService.getLocalNode().id())) { |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 285 | return flowTable.getFlowEntry(rule); |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 286 | } |
| 287 | |
Yuta HIGUCHI | faf9e1c | 2014-11-20 00:31:29 -0800 | [diff] [blame] | 288 | log.trace("Forwarding getFlowEntry to {}, which is the primary (master) for device {}", |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 289 | replicaInfo.master().orNull(), rule.deviceId()); |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 290 | |
| 291 | ClusterMessage message = new ClusterMessage( |
| 292 | clusterService.getLocalNode().id(), |
| 293 | FlowStoreMessageSubjects.GET_FLOW_ENTRY, |
| 294 | SERIALIZER.encode(rule)); |
| 295 | |
| 296 | try { |
Madan Jampani | 24f9efb | 2014-10-24 18:56:23 -0700 | [diff] [blame] | 297 | Future<byte[]> responseFuture = clusterCommunicator.sendAndReceive(message, replicaInfo.master().get()); |
| 298 | return SERIALIZER.decode(responseFuture.get(FLOW_RULE_STORE_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS)); |
| 299 | } catch (IOException | TimeoutException | ExecutionException | InterruptedException e) { |
Brian O'Connor | 4400853 | 2014-12-04 16:41:36 -0800 | [diff] [blame] | 300 | log.warn("Unable to fetch flow store contents from {}", replicaInfo.master().get()); |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 301 | } |
Brian O'Connor | 4400853 | 2014-12-04 16:41:36 -0800 | [diff] [blame] | 302 | return null; |
Yuta HIGUCHI | f6f50a6 | 2014-10-19 15:58:49 -0700 | [diff] [blame] | 303 | } |
| 304 | |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 305 | |
alshabib | 339a3d9 | 2014-09-26 17:54:32 -0700 | [diff] [blame] | 306 | |
| 307 | @Override |
Yuta HIGUCHI | 885868f | 2014-11-13 19:12:07 -0800 | [diff] [blame] | 308 | public Iterable<FlowEntry> getFlowEntries(DeviceId deviceId) { |
Madan Jampani | f5fdef0 | 2014-10-23 21:58:10 -0700 | [diff] [blame] | 309 | |
| 310 | ReplicaInfo replicaInfo = replicaInfoManager.getReplicaInfoFor(deviceId); |
Yuta HIGUCHI | 4b52444 | 2014-10-28 22:23:57 -0700 | [diff] [blame] | 311 | |
| 312 | if (!replicaInfo.master().isPresent()) { |
Yuta HIGUCHI | 6b98ab6 | 2014-12-03 16:08:08 -0800 | [diff] [blame] | 313 | log.warn("Failed to getFlowEntries: No master for {}", deviceId); |
Yuta HIGUCHI | 2c1d847 | 2014-10-31 14:13:38 -0700 | [diff] [blame] | 314 | return Collections.emptyList(); |
Yuta HIGUCHI | 4b52444 | 2014-10-28 22:23:57 -0700 | [diff] [blame] | 315 | } |
| 316 | |
Madan Jampani | f5fdef0 | 2014-10-23 21:58:10 -0700 | [diff] [blame] | 317 | if (replicaInfo.master().get().equals(clusterService.getLocalNode().id())) { |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 318 | return flowTable.getFlowEntries(deviceId); |
Madan Jampani | f5fdef0 | 2014-10-23 21:58:10 -0700 | [diff] [blame] | 319 | } |
| 320 | |
Yuta HIGUCHI | faf9e1c | 2014-11-20 00:31:29 -0800 | [diff] [blame] | 321 | log.trace("Forwarding getFlowEntries to {}, which is the primary (master) for device {}", |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 322 | replicaInfo.master().orNull(), deviceId); |
Madan Jampani | f5fdef0 | 2014-10-23 21:58:10 -0700 | [diff] [blame] | 323 | |
| 324 | ClusterMessage message = new ClusterMessage( |
| 325 | clusterService.getLocalNode().id(), |
| 326 | GET_DEVICE_FLOW_ENTRIES, |
| 327 | SERIALIZER.encode(deviceId)); |
| 328 | |
| 329 | try { |
Madan Jampani | 24f9efb | 2014-10-24 18:56:23 -0700 | [diff] [blame] | 330 | Future<byte[]> responseFuture = clusterCommunicator.sendAndReceive(message, replicaInfo.master().get()); |
| 331 | return SERIALIZER.decode(responseFuture.get(FLOW_RULE_STORE_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS)); |
| 332 | } catch (IOException | TimeoutException | ExecutionException | InterruptedException e) { |
Brian O'Connor | 4400853 | 2014-12-04 16:41:36 -0800 | [diff] [blame] | 333 | log.warn("Unable to fetch flow store contents from {}", replicaInfo.master().get()); |
Madan Jampani | f5fdef0 | 2014-10-23 21:58:10 -0700 | [diff] [blame] | 334 | } |
Yuta HIGUCHI | 24f79eb | 2014-12-12 15:46:43 -0800 | [diff] [blame] | 335 | return Collections.emptyList(); |
Madan Jampani | f5fdef0 | 2014-10-23 21:58:10 -0700 | [diff] [blame] | 336 | } |
| 337 | |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 338 | |
alshabib | 339a3d9 | 2014-09-26 17:54:32 -0700 | [diff] [blame] | 339 | |
| 340 | @Override |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 341 | public void storeFlowRule(FlowRule rule) { |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 342 | storeBatch(new FlowRuleBatchOperation( |
| 343 | Arrays.asList(new FlowRuleBatchEntry(FlowRuleOperation.ADD, rule)), |
| 344 | rule.deviceId(), idGenerator.getNewId())); |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 345 | } |
| 346 | |
Yuta HIGUCHI | 9def047 | 2014-10-23 15:51:10 -0700 | [diff] [blame] | 347 | @Override |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 348 | public void storeBatch(FlowRuleBatchOperation operation) { |
| 349 | |
Yuta HIGUCHI | 92891d1 | 2014-10-27 20:04:38 -0700 | [diff] [blame] | 350 | |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 351 | if (operation.getOperations().isEmpty()) { |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 352 | |
| 353 | notifyDelegate(FlowRuleBatchEvent.completed( |
| 354 | new FlowRuleBatchRequest(operation.id(), Collections.emptySet()), |
| 355 | new CompletedBatchOperation(true, Collections.emptySet(), |
| 356 | operation.deviceId()))); |
| 357 | return; |
alshabib | 339a3d9 | 2014-09-26 17:54:32 -0700 | [diff] [blame] | 358 | } |
Madan Jampani | 38b250d | 2014-10-17 11:02:38 -0700 | [diff] [blame] | 359 | |
alshabib | 371abe8 | 2015-02-13 10:44:17 -0800 | [diff] [blame] | 360 | DeviceId deviceId = operation.deviceId(); |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 361 | |
| 362 | ReplicaInfo replicaInfo = replicaInfoManager.getReplicaInfoFor(deviceId); |
| 363 | |
Yuta HIGUCHI | 4b52444 | 2014-10-28 22:23:57 -0700 | [diff] [blame] | 364 | if (!replicaInfo.master().isPresent()) { |
alshabib | 371abe8 | 2015-02-13 10:44:17 -0800 | [diff] [blame] | 365 | log.warn("No master for {} : flows will be marked for removal", deviceId); |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 366 | |
alshabib | 371abe8 | 2015-02-13 10:44:17 -0800 | [diff] [blame] | 367 | updateStoreInternal(operation); |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 368 | |
| 369 | notifyDelegate(FlowRuleBatchEvent.completed( |
| 370 | new FlowRuleBatchRequest(operation.id(), Collections.emptySet()), |
alshabib | 371abe8 | 2015-02-13 10:44:17 -0800 | [diff] [blame] | 371 | new CompletedBatchOperation(true, Collections.emptySet(), operation.deviceId()))); |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 372 | return; |
Yuta HIGUCHI | 4b52444 | 2014-10-28 22:23:57 -0700 | [diff] [blame] | 373 | } |
| 374 | |
| 375 | final NodeId local = clusterService.getLocalNode().id(); |
| 376 | if (replicaInfo.master().get().equals(local)) { |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 377 | storeBatchInternal(operation); |
| 378 | return; |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 379 | } |
| 380 | |
Yuta HIGUCHI | faf9e1c | 2014-11-20 00:31:29 -0800 | [diff] [blame] | 381 | log.trace("Forwarding storeBatch to {}, which is the primary (master) for device {}", |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 382 | replicaInfo.master().orNull(), deviceId); |
Yuta HIGUCHI | f3d51bd | 2014-10-21 01:05:33 -0700 | [diff] [blame] | 383 | |
Madan Jampani | 38b250d | 2014-10-17 11:02:38 -0700 | [diff] [blame] | 384 | ClusterMessage message = new ClusterMessage( |
Yuta HIGUCHI | 4b52444 | 2014-10-28 22:23:57 -0700 | [diff] [blame] | 385 | local, |
Yuta HIGUCHI | 9def047 | 2014-10-23 15:51:10 -0700 | [diff] [blame] | 386 | APPLY_BATCH_FLOWS, |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 387 | SERIALIZER.encode(operation)); |
Madan Jampani | 38b250d | 2014-10-17 11:02:38 -0700 | [diff] [blame] | 388 | |
alshabib | 371abe8 | 2015-02-13 10:44:17 -0800 | [diff] [blame] | 389 | |
Brian O'Connor | 5eb77c8 | 2015-03-02 18:09:39 -0800 | [diff] [blame^] | 390 | if (!clusterCommunicator.unicast(message, replicaInfo.master().get())) { |
| 391 | log.warn("Failed to storeBatch: {} to {}", message, replicaInfo.master()); |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 392 | |
| 393 | Set<FlowRule> allFailures = operation.getOperations().stream() |
Ray Milkey | f7329c7 | 2015-02-17 11:37:01 -0800 | [diff] [blame] | 394 | .map(op -> op.target()) |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 395 | .collect(Collectors.toSet()); |
| 396 | |
| 397 | notifyDelegate(FlowRuleBatchEvent.completed( |
| 398 | new FlowRuleBatchRequest(operation.id(), Collections.emptySet()), |
| 399 | new CompletedBatchOperation(false, allFailures, deviceId))); |
| 400 | return; |
Madan Jampani | 38b250d | 2014-10-17 11:02:38 -0700 | [diff] [blame] | 401 | } |
| 402 | } |
| 403 | |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 404 | private void storeBatchInternal(FlowRuleBatchOperation operation) { |
Yuta HIGUCHI | e9b2b00 | 2014-11-04 12:25:47 -0800 | [diff] [blame] | 405 | |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 406 | final DeviceId did = operation.deviceId(); |
| 407 | //final Collection<FlowEntry> ft = flowTable.getFlowEntries(did); |
alshabib | 371abe8 | 2015-02-13 10:44:17 -0800 | [diff] [blame] | 408 | Set<FlowRuleBatchEntry> currentOps = updateStoreInternal(operation); |
| 409 | if (currentOps.isEmpty()) { |
| 410 | batchOperationComplete(FlowRuleBatchEvent.completed( |
| 411 | new FlowRuleBatchRequest(operation.id(), Collections.emptySet()), |
| 412 | new CompletedBatchOperation(true, Collections.emptySet(), did))); |
| 413 | return; |
| 414 | } |
| 415 | updateBackup(did, currentOps); |
Yuta HIGUCHI | 92891d1 | 2014-10-27 20:04:38 -0700 | [diff] [blame] | 416 | |
alshabib | 371abe8 | 2015-02-13 10:44:17 -0800 | [diff] [blame] | 417 | notifyDelegate(FlowRuleBatchEvent.requested(new |
| 418 | FlowRuleBatchRequest(operation.id(), |
| 419 | currentOps), operation.deviceId())); |
Yuta HIGUCHI | 9def047 | 2014-10-23 15:51:10 -0700 | [diff] [blame] | 420 | |
alshabib | 371abe8 | 2015-02-13 10:44:17 -0800 | [diff] [blame] | 421 | } |
| 422 | |
| 423 | private Set<FlowRuleBatchEntry> updateStoreInternal(FlowRuleBatchOperation operation) { |
| 424 | return operation.getOperations().stream().map( |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 425 | op -> { |
| 426 | StoredFlowEntry entry; |
Ray Milkey | f7329c7 | 2015-02-17 11:37:01 -0800 | [diff] [blame] | 427 | switch (op.operator()) { |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 428 | case ADD: |
Ray Milkey | f7329c7 | 2015-02-17 11:37:01 -0800 | [diff] [blame] | 429 | entry = new DefaultFlowEntry(op.target()); |
Madan Jampani | 2af244a | 2015-02-22 13:12:01 -0800 | [diff] [blame] | 430 | // always add requested FlowRule |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 431 | // Note: 2 equal FlowEntry may have different treatment |
| 432 | flowTable.remove(entry.deviceId(), entry); |
| 433 | flowTable.add(entry); |
| 434 | |
| 435 | return op; |
| 436 | case REMOVE: |
| 437 | entry = flowTable.getFlowEntry(op.target()); |
| 438 | if (entry != null) { |
| 439 | entry.setState(FlowEntryState.PENDING_REMOVE); |
| 440 | return op; |
| 441 | } |
| 442 | break; |
| 443 | case MODIFY: |
| 444 | //TODO: figure this out at some point |
| 445 | break; |
| 446 | default: |
Ray Milkey | f7329c7 | 2015-02-17 11:37:01 -0800 | [diff] [blame] | 447 | log.warn("Unknown flow operation operator: {}", op.operator()); |
Yuta HIGUCHI | 885868f | 2014-11-13 19:12:07 -0800 | [diff] [blame] | 448 | } |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 449 | return null; |
Yuta HIGUCHI | 885868f | 2014-11-13 19:12:07 -0800 | [diff] [blame] | 450 | } |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 451 | ).filter(op -> op != null).collect(Collectors.toSet()); |
alshabib | 339a3d9 | 2014-09-26 17:54:32 -0700 | [diff] [blame] | 452 | } |
| 453 | |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 454 | private void updateBackup(DeviceId deviceId, final Set<FlowRuleBatchEntry> entries) { |
| 455 | Future<?> backup = backupExecutors.submit(new UpdateBackup(deviceId, entries)); |
Yuta HIGUCHI | 92891d1 | 2014-10-27 20:04:38 -0700 | [diff] [blame] | 456 | |
| 457 | if (syncBackup) { |
| 458 | // wait for backup to complete |
| 459 | try { |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 460 | backup.get(); |
Yuta HIGUCHI | 92891d1 | 2014-10-27 20:04:38 -0700 | [diff] [blame] | 461 | } catch (InterruptedException | ExecutionException e) { |
| 462 | log.error("Failed to create backups", e); |
| 463 | } |
| 464 | } |
| 465 | } |
| 466 | |
alshabib | 339a3d9 | 2014-09-26 17:54:32 -0700 | [diff] [blame] | 467 | @Override |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 468 | public void deleteFlowRule(FlowRule rule) { |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 469 | storeBatch( |
| 470 | new FlowRuleBatchOperation( |
| 471 | Arrays.asList( |
| 472 | new FlowRuleBatchEntry( |
| 473 | FlowRuleOperation.REMOVE, |
| 474 | rule)), rule.deviceId(), idGenerator.getNewId())); |
alshabib | 339a3d9 | 2014-09-26 17:54:32 -0700 | [diff] [blame] | 475 | } |
| 476 | |
| 477 | @Override |
Madan Jampani | 38b250d | 2014-10-17 11:02:38 -0700 | [diff] [blame] | 478 | public FlowRuleEvent addOrUpdateFlowRule(FlowEntry rule) { |
| 479 | ReplicaInfo replicaInfo = replicaInfoManager.getReplicaInfoFor(rule.deviceId()); |
Yuta HIGUCHI | 4b52444 | 2014-10-28 22:23:57 -0700 | [diff] [blame] | 480 | final NodeId localId = clusterService.getLocalNode().id(); |
| 481 | if (localId.equals(replicaInfo.master().orNull())) { |
Madan Jampani | 38b250d | 2014-10-17 11:02:38 -0700 | [diff] [blame] | 482 | return addOrUpdateFlowRuleInternal(rule); |
| 483 | } |
| 484 | |
Yuta HIGUCHI | faf9e1c | 2014-11-20 00:31:29 -0800 | [diff] [blame] | 485 | log.warn("Tried to update FlowRule {} state," |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 486 | + " while the Node was not the master.", rule); |
Yuta HIGUCHI | 9def047 | 2014-10-23 15:51:10 -0700 | [diff] [blame] | 487 | return null; |
Madan Jampani | 38b250d | 2014-10-17 11:02:38 -0700 | [diff] [blame] | 488 | } |
| 489 | |
Yuta HIGUCHI | 885868f | 2014-11-13 19:12:07 -0800 | [diff] [blame] | 490 | private FlowRuleEvent addOrUpdateFlowRuleInternal(FlowEntry rule) { |
Yuta HIGUCHI | 92891d1 | 2014-10-27 20:04:38 -0700 | [diff] [blame] | 491 | final DeviceId did = rule.deviceId(); |
alshabib | 339a3d9 | 2014-09-26 17:54:32 -0700 | [diff] [blame] | 492 | |
alshabib | 339a3d9 | 2014-09-26 17:54:32 -0700 | [diff] [blame] | 493 | |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 494 | // check if this new rule is an update to an existing entry |
| 495 | StoredFlowEntry stored = flowTable.getFlowEntry(rule); |
| 496 | if (stored != null) { |
| 497 | stored.setBytes(rule.bytes()); |
| 498 | stored.setLife(rule.life()); |
| 499 | stored.setPackets(rule.packets()); |
| 500 | if (stored.state() == FlowEntryState.PENDING_ADD) { |
| 501 | stored.setState(FlowEntryState.ADDED); |
| 502 | FlowRuleBatchEntry entry = |
| 503 | new FlowRuleBatchEntry(FlowRuleOperation.ADD, stored); |
| 504 | updateBackup(did, Sets.newHashSet(entry)); |
| 505 | return new FlowRuleEvent(Type.RULE_ADDED, rule); |
| 506 | } |
| 507 | return new FlowRuleEvent(Type.RULE_UPDATED, rule); |
Yuta HIGUCHI | 885868f | 2014-11-13 19:12:07 -0800 | [diff] [blame] | 508 | } |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 509 | |
| 510 | // TODO: Confirm if this behavior is correct. See SimpleFlowRuleStore |
| 511 | // TODO: also update backup if the behavior is correct. |
| 512 | flowTable.add(rule); |
| 513 | |
| 514 | |
alshabib | 1c319ff | 2014-10-04 20:29:09 -0700 | [diff] [blame] | 515 | return null; |
Madan Jampani | 38b250d | 2014-10-17 11:02:38 -0700 | [diff] [blame] | 516 | |
alshabib | 339a3d9 | 2014-09-26 17:54:32 -0700 | [diff] [blame] | 517 | } |
| 518 | |
| 519 | @Override |
Madan Jampani | 38b250d | 2014-10-17 11:02:38 -0700 | [diff] [blame] | 520 | public FlowRuleEvent removeFlowRule(FlowEntry rule) { |
Yuta HIGUCHI | b6eb914 | 2014-11-26 16:18:13 -0800 | [diff] [blame] | 521 | final DeviceId deviceId = rule.deviceId(); |
| 522 | ReplicaInfo replicaInfo = replicaInfoManager.getReplicaInfoFor(deviceId); |
Yuta HIGUCHI | 4b52444 | 2014-10-28 22:23:57 -0700 | [diff] [blame] | 523 | |
| 524 | final NodeId localId = clusterService.getLocalNode().id(); |
| 525 | if (localId.equals(replicaInfo.master().orNull())) { |
Madan Jampani | 38b250d | 2014-10-17 11:02:38 -0700 | [diff] [blame] | 526 | // bypass and handle it locally |
| 527 | return removeFlowRuleInternal(rule); |
| 528 | } |
| 529 | |
Yuta HIGUCHI | b6eb914 | 2014-11-26 16:18:13 -0800 | [diff] [blame] | 530 | if (!replicaInfo.master().isPresent()) { |
Yuta HIGUCHI | 6b98ab6 | 2014-12-03 16:08:08 -0800 | [diff] [blame] | 531 | log.warn("Failed to removeFlowRule: No master for {}", deviceId); |
Yuta HIGUCHI | b6eb914 | 2014-11-26 16:18:13 -0800 | [diff] [blame] | 532 | // TODO: revisit if this should be null (="no-op") or Exception |
| 533 | return null; |
| 534 | } |
| 535 | |
Yuta HIGUCHI | dfa45c1 | 2014-11-24 18:38:53 -0800 | [diff] [blame] | 536 | log.trace("Forwarding removeFlowRule to {}, which is the primary (master) for device {}", |
Yuta HIGUCHI | b6eb914 | 2014-11-26 16:18:13 -0800 | [diff] [blame] | 537 | replicaInfo.master().orNull(), deviceId); |
Yuta HIGUCHI | dfa45c1 | 2014-11-24 18:38:53 -0800 | [diff] [blame] | 538 | |
| 539 | ClusterMessage message = new ClusterMessage( |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 540 | clusterService.getLocalNode().id(), |
| 541 | REMOVE_FLOW_ENTRY, |
| 542 | SERIALIZER.encode(rule)); |
Yuta HIGUCHI | dfa45c1 | 2014-11-24 18:38:53 -0800 | [diff] [blame] | 543 | |
| 544 | try { |
| 545 | Future<byte[]> responseFuture = clusterCommunicator.sendAndReceive(message, replicaInfo.master().get()); |
| 546 | return SERIALIZER.decode(responseFuture.get(FLOW_RULE_STORE_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS)); |
| 547 | } catch (IOException | TimeoutException | ExecutionException | InterruptedException e) { |
Yuta HIGUCHI | 6593489 | 2014-12-04 17:47:44 -0800 | [diff] [blame] | 548 | // TODO: Retry against latest master or throw a FlowStoreException |
Yuta HIGUCHI | dfa45c1 | 2014-11-24 18:38:53 -0800 | [diff] [blame] | 549 | throw new RuntimeException(e); |
| 550 | } |
Madan Jampani | 38b250d | 2014-10-17 11:02:38 -0700 | [diff] [blame] | 551 | } |
| 552 | |
Yuta HIGUCHI | 885868f | 2014-11-13 19:12:07 -0800 | [diff] [blame] | 553 | private FlowRuleEvent removeFlowRuleInternal(FlowEntry rule) { |
Yuta HIGUCHI | 92891d1 | 2014-10-27 20:04:38 -0700 | [diff] [blame] | 554 | final DeviceId deviceId = rule.deviceId(); |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 555 | // This is where one could mark a rule as removed and still keep it in the store. |
| 556 | final boolean removed = flowTable.remove(deviceId, rule); //flowEntries.remove(deviceId, rule); |
| 557 | FlowRuleBatchEntry entry = |
| 558 | new FlowRuleBatchEntry(FlowRuleOperation.REMOVE, rule); |
| 559 | updateBackup(deviceId, Sets.newHashSet(entry)); |
| 560 | if (removed) { |
| 561 | return new FlowRuleEvent(RULE_REMOVED, rule); |
| 562 | } else { |
| 563 | return null; |
alshabib | 339a3d9 | 2014-09-26 17:54:32 -0700 | [diff] [blame] | 564 | } |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 565 | |
alshabib | 339a3d9 | 2014-09-26 17:54:32 -0700 | [diff] [blame] | 566 | } |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 567 | |
| 568 | @Override |
| 569 | public void batchOperationComplete(FlowRuleBatchEvent event) { |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 570 | //FIXME: need a per device pending response |
| 571 | |
| 572 | NodeId nodeId = pendingResponses.remove(event.subject().batchId()); |
| 573 | if (nodeId == null) { |
| 574 | notifyDelegate(event); |
| 575 | } else { |
Brian O'Connor | 5eb77c8 | 2015-03-02 18:09:39 -0800 | [diff] [blame^] | 576 | ClusterMessage message = new ClusterMessage( |
| 577 | clusterService.getLocalNode().id(), |
| 578 | REMOTE_APPLY_COMPLETED, |
| 579 | SERIALIZER.encode(event)); |
| 580 | // TODO check unicast return value |
| 581 | clusterCommunicator.unicast(message, nodeId); |
| 582 | //error log: log.warn("Failed to respond to peer for batch operation result"); |
Yuta HIGUCHI | 9def047 | 2014-10-23 15:51:10 -0700 | [diff] [blame] | 583 | } |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 584 | } |
Yuta HIGUCHI | 92891d1 | 2014-10-27 20:04:38 -0700 | [diff] [blame] | 585 | |
Yuta HIGUCHI | 885868f | 2014-11-13 19:12:07 -0800 | [diff] [blame] | 586 | private void loadFromBackup(final DeviceId did) { |
Yuta HIGUCHI | 92891d1 | 2014-10-27 20:04:38 -0700 | [diff] [blame] | 587 | |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 588 | |
Yuta HIGUCHI | 92891d1 | 2014-10-27 20:04:38 -0700 | [diff] [blame] | 589 | try { |
Yuta HIGUCHI | faf9e1c | 2014-11-20 00:31:29 -0800 | [diff] [blame] | 590 | log.debug("Loading FlowRules for {} from backups", did); |
Yuta HIGUCHI | 92891d1 | 2014-10-27 20:04:38 -0700 | [diff] [blame] | 591 | SMap<FlowId, ImmutableList<StoredFlowEntry>> backupFlowTable = smaps.get(did); |
| 592 | for (Entry<FlowId, ImmutableList<StoredFlowEntry>> e |
| 593 | : backupFlowTable.entrySet()) { |
| 594 | |
Yuta HIGUCHI | faf9e1c | 2014-11-20 00:31:29 -0800 | [diff] [blame] | 595 | log.trace("loading {}", e.getValue()); |
Yuta HIGUCHI | 92891d1 | 2014-10-27 20:04:38 -0700 | [diff] [blame] | 596 | for (StoredFlowEntry entry : e.getValue()) { |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 597 | flowTable.getFlowEntriesById(entry).remove(entry); |
| 598 | flowTable.getFlowEntriesById(entry).add(entry); |
| 599 | |
| 600 | |
Yuta HIGUCHI | 92891d1 | 2014-10-27 20:04:38 -0700 | [diff] [blame] | 601 | } |
| 602 | } |
| 603 | } catch (ExecutionException e) { |
| 604 | log.error("Failed to load backup flowtable for {}", did, e); |
| 605 | } |
| 606 | } |
| 607 | |
Yuta HIGUCHI | 885868f | 2014-11-13 19:12:07 -0800 | [diff] [blame] | 608 | private void removeFromPrimary(final DeviceId did) { |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 609 | flowTable.clearDevice(did); |
Yuta HIGUCHI | 92891d1 | 2014-10-27 20:04:38 -0700 | [diff] [blame] | 610 | } |
| 611 | |
Yuta HIGUCHI | f1ccee8 | 2014-11-11 20:39:58 -0800 | [diff] [blame] | 612 | |
Yuta HIGUCHI | ea15015 | 2014-10-28 22:55:14 -0700 | [diff] [blame] | 613 | private final class OnStoreBatch implements ClusterMessageHandler { |
| 614 | private final NodeId local; |
| 615 | |
| 616 | private OnStoreBatch(NodeId local) { |
| 617 | this.local = local; |
| 618 | } |
| 619 | |
| 620 | @Override |
| 621 | public void handle(final ClusterMessage message) { |
| 622 | FlowRuleBatchOperation operation = SERIALIZER.decode(message.payload()); |
Yuta HIGUCHI | faf9e1c | 2014-11-20 00:31:29 -0800 | [diff] [blame] | 623 | log.debug("received batch request {}", operation); |
Yuta HIGUCHI | ea15015 | 2014-10-28 22:55:14 -0700 | [diff] [blame] | 624 | |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 625 | final DeviceId deviceId = operation.deviceId(); |
Yuta HIGUCHI | ea15015 | 2014-10-28 22:55:14 -0700 | [diff] [blame] | 626 | ReplicaInfo replicaInfo = replicaInfoManager.getReplicaInfoFor(deviceId); |
| 627 | if (!local.equals(replicaInfo.master().orNull())) { |
| 628 | |
| 629 | Set<FlowRule> failures = new HashSet<>(operation.size()); |
| 630 | for (FlowRuleBatchEntry op : operation.getOperations()) { |
Sho SHIMIZU | aba9d00 | 2015-01-29 14:51:04 -0800 | [diff] [blame] | 631 | failures.add(op.target()); |
Yuta HIGUCHI | ea15015 | 2014-10-28 22:55:14 -0700 | [diff] [blame] | 632 | } |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 633 | CompletedBatchOperation allFailed = new CompletedBatchOperation(false, failures, deviceId); |
Yuta HIGUCHI | ea15015 | 2014-10-28 22:55:14 -0700 | [diff] [blame] | 634 | // This node is no longer the master, respond as all failed. |
| 635 | // TODO: we might want to wrap response in envelope |
| 636 | // to distinguish sw programming failure and hand over |
| 637 | // it make sense in the latter case to retry immediately. |
| 638 | try { |
| 639 | message.respond(SERIALIZER.encode(allFailed)); |
| 640 | } catch (IOException e) { |
| 641 | log.error("Failed to respond back", e); |
| 642 | } |
| 643 | return; |
| 644 | } |
| 645 | |
Yuta HIGUCHI | ea15015 | 2014-10-28 22:55:14 -0700 | [diff] [blame] | 646 | |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 647 | pendingResponses.put(operation.id(), message.sender()); |
| 648 | storeBatchInternal(operation); |
Yuta HIGUCHI | ea15015 | 2014-10-28 22:55:14 -0700 | [diff] [blame] | 649 | |
Yuta HIGUCHI | ea15015 | 2014-10-28 22:55:14 -0700 | [diff] [blame] | 650 | } |
| 651 | } |
| 652 | |
Yuta HIGUCHI | 92891d1 | 2014-10-27 20:04:38 -0700 | [diff] [blame] | 653 | private final class SMapLoader |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 654 | extends CacheLoader<DeviceId, SMap<FlowId, ImmutableList<StoredFlowEntry>>> { |
Yuta HIGUCHI | 92891d1 | 2014-10-27 20:04:38 -0700 | [diff] [blame] | 655 | |
| 656 | @Override |
| 657 | public SMap<FlowId, ImmutableList<StoredFlowEntry>> load(DeviceId id) |
| 658 | throws Exception { |
| 659 | IMap<byte[], byte[]> map = theInstance.getMap("flowtable_" + id.toString()); |
| 660 | return new SMap<FlowId, ImmutableList<StoredFlowEntry>>(map, SERIALIZER); |
| 661 | } |
| 662 | } |
| 663 | |
| 664 | private final class InternalReplicaInfoEventListener |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 665 | implements ReplicaInfoEventListener { |
Yuta HIGUCHI | 92891d1 | 2014-10-27 20:04:38 -0700 | [diff] [blame] | 666 | |
| 667 | @Override |
| 668 | public void event(ReplicaInfoEvent event) { |
| 669 | final NodeId local = clusterService.getLocalNode().id(); |
| 670 | final DeviceId did = event.subject(); |
| 671 | final ReplicaInfo rInfo = event.replicaInfo(); |
| 672 | |
| 673 | switch (event.type()) { |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 674 | case MASTER_CHANGED: |
| 675 | if (local.equals(rInfo.master().orNull())) { |
| 676 | // This node is the new master, populate local structure |
| 677 | // from backup |
| 678 | loadFromBackup(did); |
alshabib | 93cb57f | 2015-02-12 17:43:26 -0800 | [diff] [blame] | 679 | } |
| 680 | //else { |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 681 | // This node is no longer the master holder, |
| 682 | // clean local structure |
alshabib | 93cb57f | 2015-02-12 17:43:26 -0800 | [diff] [blame] | 683 | //removeFromPrimary(did); |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 684 | // TODO: probably should stop pending backup activities in |
| 685 | // executors to avoid overwriting with old value |
alshabib | 93cb57f | 2015-02-12 17:43:26 -0800 | [diff] [blame] | 686 | //} |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 687 | break; |
| 688 | default: |
| 689 | break; |
Yuta HIGUCHI | 92891d1 | 2014-10-27 20:04:38 -0700 | [diff] [blame] | 690 | |
| 691 | } |
| 692 | } |
| 693 | } |
| 694 | |
| 695 | // Task to update FlowEntries in backup HZ store |
| 696 | private final class UpdateBackup implements Runnable { |
| 697 | |
| 698 | private final DeviceId deviceId; |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 699 | private final Set<FlowRuleBatchEntry> ops; |
| 700 | |
Yuta HIGUCHI | 92891d1 | 2014-10-27 20:04:38 -0700 | [diff] [blame] | 701 | |
| 702 | public UpdateBackup(DeviceId deviceId, |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 703 | Set<FlowRuleBatchEntry> ops) { |
Yuta HIGUCHI | 92891d1 | 2014-10-27 20:04:38 -0700 | [diff] [blame] | 704 | this.deviceId = checkNotNull(deviceId); |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 705 | this.ops = checkNotNull(ops); |
| 706 | |
Yuta HIGUCHI | 92891d1 | 2014-10-27 20:04:38 -0700 | [diff] [blame] | 707 | } |
| 708 | |
| 709 | @Override |
| 710 | public void run() { |
| 711 | try { |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 712 | log.trace("update backup {} {}", deviceId, ops |
| 713 | ); |
Yuta HIGUCHI | 92891d1 | 2014-10-27 20:04:38 -0700 | [diff] [blame] | 714 | final SMap<FlowId, ImmutableList<StoredFlowEntry>> backupFlowTable = smaps.get(deviceId); |
Yuta HIGUCHI | 92891d1 | 2014-10-27 20:04:38 -0700 | [diff] [blame] | 715 | |
Yuta HIGUCHI | 92891d1 | 2014-10-27 20:04:38 -0700 | [diff] [blame] | 716 | |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 717 | ops.stream().forEach( |
| 718 | op -> { |
Ray Milkey | f7329c7 | 2015-02-17 11:37:01 -0800 | [diff] [blame] | 719 | final FlowRule entry = op.target(); |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 720 | final FlowId id = entry.id(); |
| 721 | ImmutableList<StoredFlowEntry> original = backupFlowTable.get(id); |
| 722 | List<StoredFlowEntry> list = new ArrayList<>(); |
| 723 | if (original != null) { |
| 724 | list.addAll(original); |
| 725 | } |
Ray Milkey | f7329c7 | 2015-02-17 11:37:01 -0800 | [diff] [blame] | 726 | list.remove(op.target()); |
| 727 | if (op.operator() == FlowRuleOperation.ADD) { |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 728 | list.add((StoredFlowEntry) entry); |
| 729 | } |
Yuta HIGUCHI | 92891d1 | 2014-10-27 20:04:38 -0700 | [diff] [blame] | 730 | |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 731 | ImmutableList<StoredFlowEntry> newValue = ImmutableList.copyOf(list); |
| 732 | boolean success; |
| 733 | if (original == null) { |
| 734 | success = (backupFlowTable.putIfAbsent(id, newValue) == null); |
| 735 | } else { |
| 736 | success = backupFlowTable.replace(id, original, newValue); |
| 737 | } |
| 738 | if (!success) { |
| 739 | log.error("Updating backup failed."); |
| 740 | } |
Yuta HIGUCHI | 92891d1 | 2014-10-27 20:04:38 -0700 | [diff] [blame] | 741 | |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 742 | } |
| 743 | ); |
Yuta HIGUCHI | 92891d1 | 2014-10-27 20:04:38 -0700 | [diff] [blame] | 744 | } catch (ExecutionException e) { |
| 745 | log.error("Failed to write to backups", e); |
| 746 | } |
| 747 | |
| 748 | } |
| 749 | } |
Brian O'Connor | 72cb19a | 2015-01-16 16:14:41 -0800 | [diff] [blame] | 750 | |
| 751 | private class InternalFlowTable { |
| 752 | |
| 753 | /* |
| 754 | TODO: This needs to be cleaned up. Perhaps using the eventually consistent |
| 755 | map when it supports distributed to a sequence of instances. |
| 756 | */ |
| 757 | |
| 758 | |
| 759 | private final ConcurrentMap<DeviceId, ConcurrentMap<FlowId, Set<StoredFlowEntry>>> |
| 760 | flowEntries = new ConcurrentHashMap<>(); |
| 761 | |
| 762 | |
| 763 | private NewConcurrentHashMap<FlowId, Set<StoredFlowEntry>> lazyEmptyFlowTable() { |
| 764 | return NewConcurrentHashMap.<FlowId, Set<StoredFlowEntry>>ifNeeded(); |
| 765 | } |
| 766 | |
| 767 | /** |
| 768 | * Returns the flow table for specified device. |
| 769 | * |
| 770 | * @param deviceId identifier of the device |
| 771 | * @return Map representing Flow Table of given device. |
| 772 | */ |
| 773 | private ConcurrentMap<FlowId, Set<StoredFlowEntry>> getFlowTable(DeviceId deviceId) { |
| 774 | return createIfAbsentUnchecked(flowEntries, |
| 775 | deviceId, lazyEmptyFlowTable()); |
| 776 | } |
| 777 | |
| 778 | private Set<StoredFlowEntry> getFlowEntriesInternal(DeviceId deviceId, FlowId flowId) { |
| 779 | final ConcurrentMap<FlowId, Set<StoredFlowEntry>> flowTable = getFlowTable(deviceId); |
| 780 | Set<StoredFlowEntry> r = flowTable.get(flowId); |
| 781 | if (r == null) { |
| 782 | final Set<StoredFlowEntry> concurrentlyAdded; |
| 783 | r = new CopyOnWriteArraySet<>(); |
| 784 | concurrentlyAdded = flowTable.putIfAbsent(flowId, r); |
| 785 | if (concurrentlyAdded != null) { |
| 786 | return concurrentlyAdded; |
| 787 | } |
| 788 | } |
| 789 | return r; |
| 790 | } |
| 791 | |
| 792 | private StoredFlowEntry getFlowEntryInternal(FlowRule rule) { |
| 793 | for (StoredFlowEntry f : getFlowEntriesInternal(rule.deviceId(), rule.id())) { |
| 794 | if (f.equals(rule)) { |
| 795 | return f; |
| 796 | } |
| 797 | } |
| 798 | return null; |
| 799 | } |
| 800 | |
| 801 | private Set<FlowEntry> getFlowEntriesInternal(DeviceId deviceId) { |
| 802 | return getFlowTable(deviceId).values().stream() |
| 803 | .flatMap((list -> list.stream())).collect(Collectors.toSet()); |
| 804 | |
| 805 | } |
| 806 | |
| 807 | |
| 808 | public StoredFlowEntry getFlowEntry(FlowRule rule) { |
| 809 | return getFlowEntryInternal(rule); |
| 810 | } |
| 811 | |
| 812 | public Set<FlowEntry> getFlowEntries(DeviceId deviceId) { |
| 813 | return getFlowEntriesInternal(deviceId); |
| 814 | } |
| 815 | |
| 816 | public Set<StoredFlowEntry> getFlowEntriesById(FlowEntry entry) { |
| 817 | return getFlowEntriesInternal(entry.deviceId(), entry.id()); |
| 818 | } |
| 819 | |
| 820 | public void add(FlowEntry rule) { |
| 821 | ((CopyOnWriteArraySet) |
| 822 | getFlowEntriesInternal(rule.deviceId(), rule.id())).add(rule); |
| 823 | } |
| 824 | |
| 825 | public boolean remove(DeviceId deviceId, FlowEntry rule) { |
| 826 | return ((CopyOnWriteArraySet) |
| 827 | getFlowEntriesInternal(deviceId, rule.id())).remove(rule); |
| 828 | //return flowEntries.remove(deviceId, rule); |
| 829 | } |
| 830 | |
| 831 | public void clearDevice(DeviceId did) { |
| 832 | flowEntries.remove(did); |
| 833 | } |
| 834 | } |
| 835 | |
| 836 | |
alshabib | 339a3d9 | 2014-09-26 17:54:32 -0700 | [diff] [blame] | 837 | } |