Thomas Vachuska | 781d18b | 2014-10-27 10:31:25 -0700 | [diff] [blame] | 1 | /* |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 2 | * Copyright 2014 Open Networking Laboratory |
Thomas Vachuska | 781d18b | 2014-10-27 10:31:25 -0700 | [diff] [blame] | 3 | * |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 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 |
Thomas Vachuska | 781d18b | 2014-10-27 10:31:25 -0700 | [diff] [blame] | 7 | * |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 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. |
Thomas Vachuska | 781d18b | 2014-10-27 10:31:25 -0700 | [diff] [blame] | 15 | */ |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 16 | package org.onosproject.provider.of.flow.impl; |
alshabib | 1cc04f7 | 2014-09-16 16:09:58 -0700 | [diff] [blame] | 17 | |
Jonathan Hart | 2ffcd10 | 2015-01-16 16:47:50 -0800 | [diff] [blame] | 18 | import static com.google.common.base.Preconditions.checkState; |
| 19 | import static org.slf4j.LoggerFactory.getLogger; |
| 20 | |
| 21 | import java.util.Collections; |
| 22 | import java.util.HashMap; |
| 23 | import java.util.List; |
| 24 | import java.util.Map; |
| 25 | import java.util.Optional; |
| 26 | import java.util.Set; |
| 27 | import java.util.concurrent.ConcurrentHashMap; |
| 28 | import java.util.concurrent.CountDownLatch; |
| 29 | import java.util.concurrent.ExecutionException; |
| 30 | import java.util.concurrent.Future; |
| 31 | import java.util.concurrent.TimeUnit; |
| 32 | import java.util.concurrent.TimeoutException; |
| 33 | import java.util.concurrent.atomic.AtomicBoolean; |
| 34 | import java.util.concurrent.atomic.AtomicLong; |
| 35 | import java.util.stream.Collectors; |
Yuta HIGUCHI | 82e5326 | 2014-11-27 10:28:51 -0800 | [diff] [blame] | 36 | |
alshabib | 1cc04f7 | 2014-09-16 16:09:58 -0700 | [diff] [blame] | 37 | import org.apache.felix.scr.annotations.Activate; |
| 38 | import org.apache.felix.scr.annotations.Component; |
| 39 | import org.apache.felix.scr.annotations.Deactivate; |
| 40 | import org.apache.felix.scr.annotations.Reference; |
| 41 | import org.apache.felix.scr.annotations.ReferenceCardinality; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 42 | import org.onosproject.core.ApplicationId; |
| 43 | import org.onosproject.net.DeviceId; |
| 44 | import org.onosproject.net.flow.BatchOperation; |
| 45 | import org.onosproject.net.flow.CompletedBatchOperation; |
| 46 | import org.onosproject.net.flow.DefaultFlowEntry; |
| 47 | import org.onosproject.net.flow.FlowEntry; |
| 48 | import org.onosproject.net.flow.FlowRule; |
| 49 | import org.onosproject.net.flow.FlowRuleBatchEntry; |
| 50 | import org.onosproject.net.flow.FlowRuleBatchEntry.FlowRuleOperation; |
| 51 | import org.onosproject.net.flow.FlowRuleProvider; |
| 52 | import org.onosproject.net.flow.FlowRuleProviderRegistry; |
| 53 | import org.onosproject.net.flow.FlowRuleProviderService; |
| 54 | import org.onosproject.net.provider.AbstractProvider; |
| 55 | import org.onosproject.net.provider.ProviderId; |
| 56 | import org.onosproject.net.topology.TopologyService; |
| 57 | import org.onosproject.openflow.controller.Dpid; |
| 58 | import org.onosproject.openflow.controller.OpenFlowController; |
| 59 | import org.onosproject.openflow.controller.OpenFlowEventListener; |
| 60 | import org.onosproject.openflow.controller.OpenFlowSwitch; |
| 61 | import org.onosproject.openflow.controller.OpenFlowSwitchListener; |
| 62 | import org.onosproject.openflow.controller.RoleState; |
alshabib | 19fdc12 | 2014-10-03 11:38:19 -0700 | [diff] [blame] | 63 | import org.projectfloodlight.openflow.protocol.OFActionType; |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 64 | import org.projectfloodlight.openflow.protocol.OFBarrierRequest; |
| 65 | import org.projectfloodlight.openflow.protocol.OFErrorMsg; |
alshabib | 193525b | 2014-10-08 18:58:03 -0700 | [diff] [blame] | 66 | import org.projectfloodlight.openflow.protocol.OFFlowMod; |
alshabib | 8f1cf4a | 2014-09-17 14:44:48 -0700 | [diff] [blame] | 67 | import org.projectfloodlight.openflow.protocol.OFFlowRemoved; |
alshabib | 5c370ff | 2014-09-18 10:12:14 -0700 | [diff] [blame] | 68 | import org.projectfloodlight.openflow.protocol.OFFlowStatsEntry; |
| 69 | import org.projectfloodlight.openflow.protocol.OFFlowStatsReply; |
alshabib | 19fdc12 | 2014-10-03 11:38:19 -0700 | [diff] [blame] | 70 | import org.projectfloodlight.openflow.protocol.OFInstructionType; |
alshabib | 8f1cf4a | 2014-09-17 14:44:48 -0700 | [diff] [blame] | 71 | import org.projectfloodlight.openflow.protocol.OFMessage; |
| 72 | import org.projectfloodlight.openflow.protocol.OFPortStatus; |
alshabib | 5c370ff | 2014-09-18 10:12:14 -0700 | [diff] [blame] | 73 | import org.projectfloodlight.openflow.protocol.OFStatsReply; |
alshabib | 19fdc12 | 2014-10-03 11:38:19 -0700 | [diff] [blame] | 74 | import org.projectfloodlight.openflow.protocol.OFVersion; |
| 75 | import org.projectfloodlight.openflow.protocol.action.OFAction; |
| 76 | import org.projectfloodlight.openflow.protocol.action.OFActionOutput; |
alshabib | 193525b | 2014-10-08 18:58:03 -0700 | [diff] [blame] | 77 | import org.projectfloodlight.openflow.protocol.errormsg.OFBadActionErrorMsg; |
| 78 | import org.projectfloodlight.openflow.protocol.errormsg.OFBadInstructionErrorMsg; |
| 79 | import org.projectfloodlight.openflow.protocol.errormsg.OFBadMatchErrorMsg; |
| 80 | import org.projectfloodlight.openflow.protocol.errormsg.OFBadRequestErrorMsg; |
| 81 | import org.projectfloodlight.openflow.protocol.errormsg.OFFlowModFailedErrorMsg; |
alshabib | 19fdc12 | 2014-10-03 11:38:19 -0700 | [diff] [blame] | 82 | import org.projectfloodlight.openflow.protocol.instruction.OFInstruction; |
| 83 | import org.projectfloodlight.openflow.protocol.instruction.OFInstructionApplyActions; |
| 84 | import org.projectfloodlight.openflow.types.OFPort; |
alshabib | 1cc04f7 | 2014-09-16 16:09:58 -0700 | [diff] [blame] | 85 | import org.slf4j.Logger; |
| 86 | |
Jonathan Hart | 2ffcd10 | 2015-01-16 16:47:50 -0800 | [diff] [blame] | 87 | import com.google.common.base.MoreObjects; |
| 88 | import com.google.common.collect.ArrayListMultimap; |
| 89 | import com.google.common.collect.Maps; |
| 90 | import com.google.common.collect.Multimap; |
| 91 | import com.google.common.collect.Sets; |
alshabib | eec3a06 | 2014-09-17 18:01:26 -0700 | [diff] [blame] | 92 | |
alshabib | 1cc04f7 | 2014-09-16 16:09:58 -0700 | [diff] [blame] | 93 | /** |
| 94 | * Provider which uses an OpenFlow controller to detect network |
| 95 | * end-station hosts. |
| 96 | */ |
| 97 | @Component(immediate = true) |
| 98 | public class OpenFlowRuleProvider extends AbstractProvider implements FlowRuleProvider { |
| 99 | |
Sho SHIMIZU | fce9d4c | 2015-01-20 19:20:13 -0800 | [diff] [blame] | 100 | enum BatchState { STARTED, FINISHED, CANCELLED } |
alshabib | 193525b | 2014-10-08 18:58:03 -0700 | [diff] [blame] | 101 | |
Jonathan Hart | 2ffcd10 | 2015-01-16 16:47:50 -0800 | [diff] [blame] | 102 | private static final int LOWEST_PRIORITY = 0; |
| 103 | |
alshabib | 1cc04f7 | 2014-09-16 16:09:58 -0700 | [diff] [blame] | 104 | private final Logger log = getLogger(getClass()); |
| 105 | |
| 106 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 107 | protected FlowRuleProviderRegistry providerRegistry; |
| 108 | |
| 109 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 110 | protected OpenFlowController controller; |
| 111 | |
| 112 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 113 | protected TopologyService topologyService; |
| 114 | |
| 115 | private FlowRuleProviderService providerService; |
| 116 | |
alshabib | eec3a06 | 2014-09-17 18:01:26 -0700 | [diff] [blame] | 117 | private final InternalFlowProvider listener = new InternalFlowProvider(); |
| 118 | |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 119 | // FIXME: This should be an expiring map to ensure futures that don't have |
| 120 | // a future eventually get garbage collected. |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 121 | private final Map<Long, InstallationFuture> pendingFutures = |
| 122 | new ConcurrentHashMap<Long, InstallationFuture>(); |
| 123 | |
alshabib | 193525b | 2014-10-08 18:58:03 -0700 | [diff] [blame] | 124 | private final Map<Long, InstallationFuture> pendingFMs = |
| 125 | new ConcurrentHashMap<Long, InstallationFuture>(); |
| 126 | |
alshabib | 3d643ec | 2014-10-22 18:33:00 -0700 | [diff] [blame] | 127 | private final Map<Dpid, FlowStatsCollector> collectors = Maps.newHashMap(); |
| 128 | |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 129 | private final AtomicLong xidCounter = new AtomicLong(1); |
Thomas Vachuska | 9b2da21 | 2014-11-10 19:30:25 -0800 | [diff] [blame] | 130 | |
alshabib | 1cc04f7 | 2014-09-16 16:09:58 -0700 | [diff] [blame] | 131 | /** |
| 132 | * Creates an OpenFlow host provider. |
| 133 | */ |
| 134 | public OpenFlowRuleProvider() { |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 135 | super(new ProviderId("of", "org.onosproject.provider.openflow")); |
alshabib | 1cc04f7 | 2014-09-16 16:09:58 -0700 | [diff] [blame] | 136 | } |
| 137 | |
| 138 | @Activate |
| 139 | public void activate() { |
| 140 | providerService = providerRegistry.register(this); |
alshabib | eec3a06 | 2014-09-17 18:01:26 -0700 | [diff] [blame] | 141 | controller.addListener(listener); |
| 142 | controller.addEventListener(listener); |
alshabib | 3d643ec | 2014-10-22 18:33:00 -0700 | [diff] [blame] | 143 | |
| 144 | for (OpenFlowSwitch sw : controller.getSwitches()) { |
| 145 | FlowStatsCollector fsc = new FlowStatsCollector(sw, POLL_INTERVAL); |
| 146 | fsc.start(); |
| 147 | collectors.put(new Dpid(sw.getId()), fsc); |
| 148 | } |
| 149 | |
| 150 | |
alshabib | 1cc04f7 | 2014-09-16 16:09:58 -0700 | [diff] [blame] | 151 | log.info("Started"); |
| 152 | } |
| 153 | |
| 154 | @Deactivate |
| 155 | public void deactivate() { |
| 156 | providerRegistry.unregister(this); |
| 157 | providerService = null; |
| 158 | |
| 159 | log.info("Stopped"); |
| 160 | } |
Thomas Vachuska | 9b2da21 | 2014-11-10 19:30:25 -0800 | [diff] [blame] | 161 | |
alshabib | 1cc04f7 | 2014-09-16 16:09:58 -0700 | [diff] [blame] | 162 | @Override |
| 163 | public void applyFlowRule(FlowRule... flowRules) { |
alshabib | 35edb1a | 2014-09-16 17:44:44 -0700 | [diff] [blame] | 164 | for (int i = 0; i < flowRules.length; i++) { |
| 165 | applyRule(flowRules[i]); |
| 166 | } |
alshabib | 1cc04f7 | 2014-09-16 16:09:58 -0700 | [diff] [blame] | 167 | } |
| 168 | |
alshabib | 35edb1a | 2014-09-16 17:44:44 -0700 | [diff] [blame] | 169 | private void applyRule(FlowRule flowRule) { |
| 170 | OpenFlowSwitch sw = controller.getSwitch(Dpid.dpid(flowRule.deviceId().uri())); |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 171 | sw.sendMsg(FlowModBuilder.builder(flowRule, sw.factory(), |
| 172 | Optional.empty()).buildFlowAdd()); |
alshabib | 35edb1a | 2014-09-16 17:44:44 -0700 | [diff] [blame] | 173 | } |
| 174 | |
alshabib | 35edb1a | 2014-09-16 17:44:44 -0700 | [diff] [blame] | 175 | |
alshabib | 1cc04f7 | 2014-09-16 16:09:58 -0700 | [diff] [blame] | 176 | @Override |
| 177 | public void removeFlowRule(FlowRule... flowRules) { |
alshabib | 219ebaa | 2014-09-22 15:41:24 -0700 | [diff] [blame] | 178 | for (int i = 0; i < flowRules.length; i++) { |
| 179 | removeRule(flowRules[i]); |
| 180 | } |
alshabib | 1cc04f7 | 2014-09-16 16:09:58 -0700 | [diff] [blame] | 181 | |
| 182 | } |
| 183 | |
alshabib | 219ebaa | 2014-09-22 15:41:24 -0700 | [diff] [blame] | 184 | private void removeRule(FlowRule flowRule) { |
| 185 | OpenFlowSwitch sw = controller.getSwitch(Dpid.dpid(flowRule.deviceId().uri())); |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 186 | sw.sendMsg(FlowModBuilder.builder(flowRule, sw.factory(), |
| 187 | Optional.empty()).buildFlowDel()); |
alshabib | 219ebaa | 2014-09-22 15:41:24 -0700 | [diff] [blame] | 188 | } |
| 189 | |
alshabib | a68eb96 | 2014-09-24 20:34:13 -0700 | [diff] [blame] | 190 | @Override |
| 191 | public void removeRulesById(ApplicationId id, FlowRule... flowRules) { |
| 192 | // TODO: optimize using the ApplicationId |
| 193 | removeFlowRule(flowRules); |
| 194 | } |
| 195 | |
alshabib | 193525b | 2014-10-08 18:58:03 -0700 | [diff] [blame] | 196 | @Override |
Thomas Vachuska | 9b2da21 | 2014-11-10 19:30:25 -0800 | [diff] [blame] | 197 | public Future<CompletedBatchOperation> executeBatch(BatchOperation<FlowRuleBatchEntry> batch) { |
Yuta HIGUCHI | 82e5326 | 2014-11-27 10:28:51 -0800 | [diff] [blame] | 198 | final Set<Dpid> sws = Sets.newConcurrentHashSet(); |
| 199 | final Map<Long, FlowRuleBatchEntry> fmXids = new HashMap<>(); |
Thomas Vachuska | 9b2da21 | 2014-11-10 19:30:25 -0800 | [diff] [blame] | 200 | /* |
| 201 | * Use identity hash map for reference equality as we could have equal |
| 202 | * flow mods for different switches. |
| 203 | */ |
| 204 | Map<OFFlowMod, OpenFlowSwitch> mods = Maps.newIdentityHashMap(); |
alshabib | 193525b | 2014-10-08 18:58:03 -0700 | [diff] [blame] | 205 | for (FlowRuleBatchEntry fbe : batch.getOperations()) { |
| 206 | FlowRule flowRule = fbe.getTarget(); |
Yuta HIGUCHI | 82e5326 | 2014-11-27 10:28:51 -0800 | [diff] [blame] | 207 | final Dpid dpid = Dpid.dpid(flowRule.deviceId().uri()); |
| 208 | OpenFlowSwitch sw = controller.getSwitch(dpid); |
alshabib | 7911a05 | 2014-10-16 17:49:37 -0700 | [diff] [blame] | 209 | if (sw == null) { |
alshabib | 3effd04 | 2014-10-17 12:00:31 -0700 | [diff] [blame] | 210 | /* |
| 211 | * if a switch we are supposed to install to is gone then |
| 212 | * cancel (ie. rollback) the work that has been done so far |
| 213 | * and return the associated future. |
| 214 | */ |
| 215 | InstallationFuture failed = new InstallationFuture(sws, fmXids); |
| 216 | failed.cancel(true); |
| 217 | return failed; |
alshabib | 7911a05 | 2014-10-16 17:49:37 -0700 | [diff] [blame] | 218 | } |
Yuta HIGUCHI | 82e5326 | 2014-11-27 10:28:51 -0800 | [diff] [blame] | 219 | sws.add(dpid); |
| 220 | final Long flowModXid = xidCounter.getAndIncrement(); |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 221 | FlowModBuilder builder = |
| 222 | FlowModBuilder.builder(flowRule, sw.factory(), |
| 223 | Optional.of(flowModXid)); |
Thomas Vachuska | 9b2da21 | 2014-11-10 19:30:25 -0800 | [diff] [blame] | 224 | OFFlowMod mod = null; |
alshabib | 193525b | 2014-10-08 18:58:03 -0700 | [diff] [blame] | 225 | switch (fbe.getOperator()) { |
| 226 | case ADD: |
| 227 | mod = builder.buildFlowAdd(); |
| 228 | break; |
| 229 | case REMOVE: |
| 230 | mod = builder.buildFlowDel(); |
| 231 | break; |
| 232 | case MODIFY: |
| 233 | mod = builder.buildFlowMod(); |
| 234 | break; |
| 235 | default: |
| 236 | log.error("Unsupported batch operation {}", fbe.getOperator()); |
| 237 | } |
| 238 | if (mod != null) { |
Thomas Vachuska | 9b2da21 | 2014-11-10 19:30:25 -0800 | [diff] [blame] | 239 | mods.put(mod, sw); |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 240 | fmXids.put(flowModXid, fbe); |
alshabib | 193525b | 2014-10-08 18:58:03 -0700 | [diff] [blame] | 241 | } else { |
| 242 | log.error("Conversion of flowrule {} failed.", flowRule); |
| 243 | } |
alshabib | 193525b | 2014-10-08 18:58:03 -0700 | [diff] [blame] | 244 | } |
| 245 | InstallationFuture installation = new InstallationFuture(sws, fmXids); |
| 246 | for (Long xid : fmXids.keySet()) { |
| 247 | pendingFMs.put(xid, installation); |
| 248 | } |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 249 | |
Thomas Vachuska | 9b2da21 | 2014-11-10 19:30:25 -0800 | [diff] [blame] | 250 | pendingFutures.put(installation.xid(), installation); |
| 251 | for (Map.Entry<OFFlowMod, OpenFlowSwitch> entry : mods.entrySet()) { |
| 252 | OpenFlowSwitch sw = entry.getValue(); |
| 253 | OFFlowMod mod = entry.getKey(); |
| 254 | sw.sendMsg(mod); |
| 255 | } |
| 256 | installation.verify(); |
alshabib | 193525b | 2014-10-08 18:58:03 -0700 | [diff] [blame] | 257 | return installation; |
| 258 | } |
| 259 | |
| 260 | |
alshabib | 8f1cf4a | 2014-09-17 14:44:48 -0700 | [diff] [blame] | 261 | private class InternalFlowProvider |
Thomas Vachuska | 9b2da21 | 2014-11-10 19:30:25 -0800 | [diff] [blame] | 262 | implements OpenFlowSwitchListener, OpenFlowEventListener { |
alshabib | 8f1cf4a | 2014-09-17 14:44:48 -0700 | [diff] [blame] | 263 | |
alshabib | 3d643ec | 2014-10-22 18:33:00 -0700 | [diff] [blame] | 264 | |
alshabib | 1c319ff | 2014-10-04 20:29:09 -0700 | [diff] [blame] | 265 | private final Multimap<DeviceId, FlowEntry> completeEntries = |
alshabib | 54ce589 | 2014-09-23 17:50:51 -0700 | [diff] [blame] | 266 | ArrayListMultimap.create(); |
alshabib | 8f1cf4a | 2014-09-17 14:44:48 -0700 | [diff] [blame] | 267 | |
| 268 | @Override |
| 269 | public void switchAdded(Dpid dpid) { |
alshabib | ba5ac48 | 2014-10-02 17:15:20 -0700 | [diff] [blame] | 270 | FlowStatsCollector fsc = new FlowStatsCollector(controller.getSwitch(dpid), POLL_INTERVAL); |
alshabib | eec3a06 | 2014-09-17 18:01:26 -0700 | [diff] [blame] | 271 | fsc.start(); |
| 272 | collectors.put(dpid, fsc); |
alshabib | 8f1cf4a | 2014-09-17 14:44:48 -0700 | [diff] [blame] | 273 | } |
| 274 | |
| 275 | @Override |
| 276 | public void switchRemoved(Dpid dpid) { |
alshabib | dfc7afb | 2014-10-21 20:13:27 -0700 | [diff] [blame] | 277 | FlowStatsCollector collector = collectors.remove(dpid); |
| 278 | if (collector != null) { |
| 279 | collector.stop(); |
| 280 | } |
alshabib | 8f1cf4a | 2014-09-17 14:44:48 -0700 | [diff] [blame] | 281 | } |
| 282 | |
| 283 | @Override |
Ayaka Koshibe | 38594c2 | 2014-10-22 13:36:12 -0700 | [diff] [blame] | 284 | public void switchChanged(Dpid dpid) { |
| 285 | } |
| 286 | |
| 287 | @Override |
alshabib | 8f1cf4a | 2014-09-17 14:44:48 -0700 | [diff] [blame] | 288 | public void portChanged(Dpid dpid, OFPortStatus status) { |
| 289 | //TODO: Decide whether to evict flows internal store. |
| 290 | } |
| 291 | |
| 292 | @Override |
| 293 | public void handleMessage(Dpid dpid, OFMessage msg) { |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 294 | InstallationFuture future = null; |
alshabib | 8f1cf4a | 2014-09-17 14:44:48 -0700 | [diff] [blame] | 295 | switch (msg.getType()) { |
Thomas Vachuska | 9b2da21 | 2014-11-10 19:30:25 -0800 | [diff] [blame] | 296 | case FLOW_REMOVED: |
| 297 | OFFlowRemoved removed = (OFFlowRemoved) msg; |
alshabib | 6b5cfec | 2014-09-18 17:42:18 -0700 | [diff] [blame] | 298 | |
Thomas Vachuska | 9b2da21 | 2014-11-10 19:30:25 -0800 | [diff] [blame] | 299 | FlowEntry fr = new FlowEntryBuilder(dpid, removed).build(); |
| 300 | providerService.flowRemoved(fr); |
| 301 | break; |
| 302 | case STATS_REPLY: |
| 303 | pushFlowMetrics(dpid, (OFStatsReply) msg); |
| 304 | break; |
| 305 | case BARRIER_REPLY: |
| 306 | future = pendingFutures.get(msg.getXid()); |
| 307 | if (future != null) { |
| 308 | future.satisfyRequirement(dpid); |
Yuta HIGUCHI | 82e5326 | 2014-11-27 10:28:51 -0800 | [diff] [blame] | 309 | } else { |
| 310 | log.warn("Received unknown Barrier Reply: {}", msg.getXid()); |
Thomas Vachuska | 9b2da21 | 2014-11-10 19:30:25 -0800 | [diff] [blame] | 311 | } |
| 312 | break; |
| 313 | case ERROR: |
Yuta HIGUCHI | 82e5326 | 2014-11-27 10:28:51 -0800 | [diff] [blame] | 314 | log.warn("received Error message {} from {}", msg, dpid); |
Thomas Vachuska | 9b2da21 | 2014-11-10 19:30:25 -0800 | [diff] [blame] | 315 | future = pendingFMs.get(msg.getXid()); |
| 316 | if (future != null) { |
| 317 | future.fail((OFErrorMsg) msg, dpid); |
Yuta HIGUCHI | 82e5326 | 2014-11-27 10:28:51 -0800 | [diff] [blame] | 318 | } else { |
| 319 | log.warn("Received unknown Error Reply: {} {}", msg.getXid(), msg); |
Thomas Vachuska | 9b2da21 | 2014-11-10 19:30:25 -0800 | [diff] [blame] | 320 | } |
| 321 | break; |
| 322 | default: |
| 323 | log.debug("Unhandled message type: {}", msg.getType()); |
alshabib | 8f1cf4a | 2014-09-17 14:44:48 -0700 | [diff] [blame] | 324 | } |
| 325 | |
| 326 | } |
| 327 | |
Ayaka Koshibe | ab91cc4 | 2014-09-25 10:20:52 -0700 | [diff] [blame] | 328 | @Override |
Ayaka Koshibe | 3ef2b0d | 2014-10-31 13:58:27 -0700 | [diff] [blame] | 329 | public void receivedRoleReply(Dpid dpid, RoleState requested, |
Thomas Vachuska | 9b2da21 | 2014-11-10 19:30:25 -0800 | [diff] [blame] | 330 | RoleState response) { |
Ayaka Koshibe | 3ef2b0d | 2014-10-31 13:58:27 -0700 | [diff] [blame] | 331 | // Do nothing here for now. |
| 332 | } |
Ayaka Koshibe | ab91cc4 | 2014-09-25 10:20:52 -0700 | [diff] [blame] | 333 | |
Pavlin Radoslavov | 369c643 | 2014-12-03 16:25:14 -0800 | [diff] [blame] | 334 | private void pushFlowMetrics(Dpid dpid, OFStatsReply stats) { |
alshabib | 64def64 | 2014-12-02 23:27:37 -0800 | [diff] [blame] | 335 | |
alshabib | 54ce589 | 2014-09-23 17:50:51 -0700 | [diff] [blame] | 336 | DeviceId did = DeviceId.deviceId(Dpid.uri(dpid)); |
alshabib | 5c370ff | 2014-09-18 10:12:14 -0700 | [diff] [blame] | 337 | final OFFlowStatsReply replies = (OFFlowStatsReply) stats; |
alshabib | 54ce589 | 2014-09-23 17:50:51 -0700 | [diff] [blame] | 338 | |
alshabib | 64def64 | 2014-12-02 23:27:37 -0800 | [diff] [blame] | 339 | List<FlowEntry> flowEntries = replies.getEntries().stream() |
| 340 | .filter(entry -> !tableMissRule(dpid, entry)) |
| 341 | .map(entry -> new FlowEntryBuilder(dpid, entry).build()) |
| 342 | .collect(Collectors.toList()); |
alshabib | 54ce589 | 2014-09-23 17:50:51 -0700 | [diff] [blame] | 343 | |
alshabib | 64def64 | 2014-12-02 23:27:37 -0800 | [diff] [blame] | 344 | providerService.pushFlowMetrics(did, flowEntries); |
| 345 | |
alshabib | 5c370ff | 2014-09-18 10:12:14 -0700 | [diff] [blame] | 346 | } |
| 347 | |
alshabib | 19fdc12 | 2014-10-03 11:38:19 -0700 | [diff] [blame] | 348 | private boolean tableMissRule(Dpid dpid, OFFlowStatsEntry reply) { |
Jonathan Hart | 2ffcd10 | 2015-01-16 16:47:50 -0800 | [diff] [blame] | 349 | if (reply.getMatch().getMatchFields().iterator().hasNext()) { |
alshabib | 19fdc12 | 2014-10-03 11:38:19 -0700 | [diff] [blame] | 350 | return false; |
| 351 | } |
Jonathan Hart | 2ffcd10 | 2015-01-16 16:47:50 -0800 | [diff] [blame] | 352 | if (reply.getVersion().equals(OFVersion.OF_10)) { |
| 353 | return reply.getPriority() == LOWEST_PRIORITY |
| 354 | && reply.getActions().isEmpty(); |
| 355 | } |
alshabib | 19fdc12 | 2014-10-03 11:38:19 -0700 | [diff] [blame] | 356 | for (OFInstruction ins : reply.getInstructions()) { |
| 357 | if (ins.getType() == OFInstructionType.APPLY_ACTIONS) { |
| 358 | OFInstructionApplyActions apply = (OFInstructionApplyActions) ins; |
| 359 | List<OFAction> acts = apply.getActions(); |
| 360 | for (OFAction act : acts) { |
| 361 | if (act.getType() == OFActionType.OUTPUT) { |
| 362 | OFActionOutput out = (OFActionOutput) act; |
| 363 | if (out.getPort() == OFPort.CONTROLLER) { |
| 364 | return true; |
| 365 | } |
| 366 | } |
| 367 | } |
| 368 | } |
| 369 | } |
| 370 | return false; |
| 371 | } |
Ayaka Koshibe | 38594c2 | 2014-10-22 13:36:12 -0700 | [diff] [blame] | 372 | |
alshabib | 8f1cf4a | 2014-09-17 14:44:48 -0700 | [diff] [blame] | 373 | } |
alshabib | 1cc04f7 | 2014-09-16 16:09:58 -0700 | [diff] [blame] | 374 | |
Thomas Vachuska | 9b2da21 | 2014-11-10 19:30:25 -0800 | [diff] [blame] | 375 | private class InstallationFuture implements Future<CompletedBatchOperation> { |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 376 | |
Yuta HIGUCHI | 82e5326 | 2014-11-27 10:28:51 -0800 | [diff] [blame] | 377 | // barrier xid |
Thomas Vachuska | 9b2da21 | 2014-11-10 19:30:25 -0800 | [diff] [blame] | 378 | private final Long xid; |
Yuta HIGUCHI | 82e5326 | 2014-11-27 10:28:51 -0800 | [diff] [blame] | 379 | // waiting for barrier reply from... |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 380 | private final Set<Dpid> sws; |
| 381 | private final AtomicBoolean ok = new AtomicBoolean(true); |
Yuta HIGUCHI | 82e5326 | 2014-11-27 10:28:51 -0800 | [diff] [blame] | 382 | // FlowMod xid -> |
alshabib | 193525b | 2014-10-08 18:58:03 -0700 | [diff] [blame] | 383 | private final Map<Long, FlowRuleBatchEntry> fms; |
| 384 | |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 385 | |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 386 | private final Set<FlowEntry> offendingFlowMods = Sets.newHashSet(); |
Yuta HIGUCHI | 82e5326 | 2014-11-27 10:28:51 -0800 | [diff] [blame] | 387 | // Failed batch operation id |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 388 | private Long failedId; |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 389 | |
| 390 | private final CountDownLatch countDownLatch; |
alshabib | 193525b | 2014-10-08 18:58:03 -0700 | [diff] [blame] | 391 | private BatchState state; |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 392 | |
alshabib | 193525b | 2014-10-08 18:58:03 -0700 | [diff] [blame] | 393 | public InstallationFuture(Set<Dpid> sws, Map<Long, FlowRuleBatchEntry> fmXids) { |
Thomas Vachuska | 9b2da21 | 2014-11-10 19:30:25 -0800 | [diff] [blame] | 394 | this.xid = xidCounter.getAndIncrement(); |
alshabib | 193525b | 2014-10-08 18:58:03 -0700 | [diff] [blame] | 395 | this.state = BatchState.STARTED; |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 396 | this.sws = sws; |
alshabib | 193525b | 2014-10-08 18:58:03 -0700 | [diff] [blame] | 397 | this.fms = fmXids; |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 398 | countDownLatch = new CountDownLatch(sws.size()); |
| 399 | } |
| 400 | |
Thomas Vachuska | 9b2da21 | 2014-11-10 19:30:25 -0800 | [diff] [blame] | 401 | public Long xid() { |
| 402 | return xid; |
| 403 | } |
| 404 | |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 405 | public void fail(OFErrorMsg msg, Dpid dpid) { |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 406 | |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 407 | ok.set(false); |
alshabib | 193525b | 2014-10-08 18:58:03 -0700 | [diff] [blame] | 408 | FlowEntry fe = null; |
| 409 | FlowRuleBatchEntry fbe = fms.get(msg.getXid()); |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 410 | failedId = fbe.id(); |
alshabib | 193525b | 2014-10-08 18:58:03 -0700 | [diff] [blame] | 411 | FlowRule offending = fbe.getTarget(); |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 412 | //TODO handle specific error msgs |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 413 | switch (msg.getErrType()) { |
| 414 | case BAD_ACTION: |
alshabib | 193525b | 2014-10-08 18:58:03 -0700 | [diff] [blame] | 415 | OFBadActionErrorMsg bad = (OFBadActionErrorMsg) msg; |
| 416 | fe = new DefaultFlowEntry(offending, bad.getErrType().ordinal(), |
Thomas Vachuska | 9b2da21 | 2014-11-10 19:30:25 -0800 | [diff] [blame] | 417 | bad.getCode().ordinal()); |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 418 | break; |
| 419 | case BAD_INSTRUCTION: |
alshabib | 193525b | 2014-10-08 18:58:03 -0700 | [diff] [blame] | 420 | OFBadInstructionErrorMsg badins = (OFBadInstructionErrorMsg) msg; |
| 421 | fe = new DefaultFlowEntry(offending, badins.getErrType().ordinal(), |
Thomas Vachuska | 9b2da21 | 2014-11-10 19:30:25 -0800 | [diff] [blame] | 422 | badins.getCode().ordinal()); |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 423 | break; |
| 424 | case BAD_MATCH: |
alshabib | 193525b | 2014-10-08 18:58:03 -0700 | [diff] [blame] | 425 | OFBadMatchErrorMsg badMatch = (OFBadMatchErrorMsg) msg; |
| 426 | fe = new DefaultFlowEntry(offending, badMatch.getErrType().ordinal(), |
Thomas Vachuska | 9b2da21 | 2014-11-10 19:30:25 -0800 | [diff] [blame] | 427 | badMatch.getCode().ordinal()); |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 428 | break; |
| 429 | case BAD_REQUEST: |
alshabib | 193525b | 2014-10-08 18:58:03 -0700 | [diff] [blame] | 430 | OFBadRequestErrorMsg badReq = (OFBadRequestErrorMsg) msg; |
| 431 | fe = new DefaultFlowEntry(offending, badReq.getErrType().ordinal(), |
Thomas Vachuska | 9b2da21 | 2014-11-10 19:30:25 -0800 | [diff] [blame] | 432 | badReq.getCode().ordinal()); |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 433 | break; |
| 434 | case FLOW_MOD_FAILED: |
alshabib | 193525b | 2014-10-08 18:58:03 -0700 | [diff] [blame] | 435 | OFFlowModFailedErrorMsg fmFail = (OFFlowModFailedErrorMsg) msg; |
| 436 | fe = new DefaultFlowEntry(offending, fmFail.getErrType().ordinal(), |
Thomas Vachuska | 9b2da21 | 2014-11-10 19:30:25 -0800 | [diff] [blame] | 437 | fmFail.getCode().ordinal()); |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 438 | break; |
alshabib | 193525b | 2014-10-08 18:58:03 -0700 | [diff] [blame] | 439 | case EXPERIMENTER: |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 440 | case GROUP_MOD_FAILED: |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 441 | case HELLO_FAILED: |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 442 | case METER_MOD_FAILED: |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 443 | case PORT_MOD_FAILED: |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 444 | case QUEUE_OP_FAILED: |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 445 | case ROLE_REQUEST_FAILED: |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 446 | case SWITCH_CONFIG_FAILED: |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 447 | case TABLE_FEATURES_FAILED: |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 448 | case TABLE_MOD_FAILED: |
alshabib | 193525b | 2014-10-08 18:58:03 -0700 | [diff] [blame] | 449 | fe = new DefaultFlowEntry(offending, msg.getErrType().ordinal(), 0); |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 450 | break; |
| 451 | default: |
alshabib | 193525b | 2014-10-08 18:58:03 -0700 | [diff] [blame] | 452 | log.error("Unknown error type {}", msg.getErrType()); |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 453 | |
| 454 | } |
alshabib | 193525b | 2014-10-08 18:58:03 -0700 | [diff] [blame] | 455 | offendingFlowMods.add(fe); |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 456 | |
Yuta HIGUCHI | 804a4bb | 2014-11-27 09:37:34 -0800 | [diff] [blame] | 457 | removeRequirement(dpid); |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 458 | } |
| 459 | |
alshabib | 193525b | 2014-10-08 18:58:03 -0700 | [diff] [blame] | 460 | |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 461 | public void satisfyRequirement(Dpid dpid) { |
alshabib | 3effd04 | 2014-10-17 12:00:31 -0700 | [diff] [blame] | 462 | log.debug("Satisfaction from switch {}", dpid); |
alshabib | 7911a05 | 2014-10-16 17:49:37 -0700 | [diff] [blame] | 463 | removeRequirement(dpid); |
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 | |
Thomas Vachuska | 9b2da21 | 2014-11-10 19:30:25 -0800 | [diff] [blame] | 467 | public void verify() { |
Yuta HIGUCHI | 82e5326 | 2014-11-27 10:28:51 -0800 | [diff] [blame] | 468 | checkState(!sws.isEmpty()); |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 469 | for (Dpid dpid : sws) { |
| 470 | OpenFlowSwitch sw = controller.getSwitch(dpid); |
| 471 | OFBarrierRequest.Builder builder = sw.factory() |
| 472 | .buildBarrierRequest() |
Thomas Vachuska | 9b2da21 | 2014-11-10 19:30:25 -0800 | [diff] [blame] | 473 | .setXid(xid); |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 474 | sw.sendMsg(builder.build()); |
| 475 | } |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 476 | } |
| 477 | |
| 478 | @Override |
| 479 | public boolean cancel(boolean mayInterruptIfRunning) { |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 480 | if (isDone()) { |
| 481 | return false; |
| 482 | } |
alshabib | 7911a05 | 2014-10-16 17:49:37 -0700 | [diff] [blame] | 483 | ok.set(false); |
alshabib | 193525b | 2014-10-08 18:58:03 -0700 | [diff] [blame] | 484 | this.state = BatchState.CANCELLED; |
| 485 | cleanUp(); |
| 486 | for (FlowRuleBatchEntry fbe : fms.values()) { |
| 487 | if (fbe.getOperator() == FlowRuleOperation.ADD || |
| 488 | fbe.getOperator() == FlowRuleOperation.MODIFY) { |
| 489 | removeFlowRule(fbe.getTarget()); |
| 490 | } else if (fbe.getOperator() == FlowRuleOperation.REMOVE) { |
| 491 | applyRule(fbe.getTarget()); |
| 492 | } |
| 493 | |
| 494 | } |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 495 | return true; |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 496 | } |
| 497 | |
| 498 | @Override |
| 499 | public boolean isCancelled() { |
alshabib | 193525b | 2014-10-08 18:58:03 -0700 | [diff] [blame] | 500 | return this.state == BatchState.CANCELLED; |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 501 | } |
| 502 | |
| 503 | @Override |
| 504 | public boolean isDone() { |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 505 | return this.state == BatchState.FINISHED || isCancelled(); |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 506 | } |
| 507 | |
| 508 | @Override |
alshabib | 193525b | 2014-10-08 18:58:03 -0700 | [diff] [blame] | 509 | public CompletedBatchOperation get() throws InterruptedException, ExecutionException { |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 510 | countDownLatch.await(); |
alshabib | 193525b | 2014-10-08 18:58:03 -0700 | [diff] [blame] | 511 | this.state = BatchState.FINISHED; |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 512 | Set<Long> failedIds = (failedId != null) ? Sets.newHashSet(failedId) : Collections.emptySet(); |
| 513 | CompletedBatchOperation result = |
| 514 | new CompletedBatchOperation(ok.get(), offendingFlowMods, failedIds); |
| 515 | //FIXME do cleanup here (moved by BOC) |
| 516 | cleanUp(); |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 517 | return result; |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 518 | } |
| 519 | |
| 520 | @Override |
alshabib | 193525b | 2014-10-08 18:58:03 -0700 | [diff] [blame] | 521 | public CompletedBatchOperation get(long timeout, TimeUnit unit) |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 522 | throws InterruptedException, ExecutionException, |
| 523 | TimeoutException { |
alshabib | 2683458 | 2014-10-08 20:15:46 -0700 | [diff] [blame] | 524 | if (countDownLatch.await(timeout, unit)) { |
| 525 | this.state = BatchState.FINISHED; |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 526 | Set<Long> failedIds = (failedId != null) ? Sets.newHashSet(failedId) : Collections.emptySet(); |
| 527 | CompletedBatchOperation result = |
| 528 | new CompletedBatchOperation(ok.get(), offendingFlowMods, failedIds); |
| 529 | // FIXME do cleanup here (moved by BOC) |
| 530 | cleanUp(); |
Madan Jampani | 117aaae | 2014-10-23 10:04:05 -0700 | [diff] [blame] | 531 | return result; |
alshabib | 2683458 | 2014-10-08 20:15:46 -0700 | [diff] [blame] | 532 | } |
Yuta HIGUCHI | 82e5326 | 2014-11-27 10:28:51 -0800 | [diff] [blame] | 533 | throw new TimeoutException(this.toString()); |
alshabib | 193525b | 2014-10-08 18:58:03 -0700 | [diff] [blame] | 534 | } |
| 535 | |
| 536 | private void cleanUp() { |
alshabib | 7911a05 | 2014-10-16 17:49:37 -0700 | [diff] [blame] | 537 | if (isDone() || isCancelled()) { |
Thomas Vachuska | 9b2da21 | 2014-11-10 19:30:25 -0800 | [diff] [blame] | 538 | pendingFutures.remove(xid); |
alshabib | 193525b | 2014-10-08 18:58:03 -0700 | [diff] [blame] | 539 | for (Long xid : fms.keySet()) { |
| 540 | pendingFMs.remove(xid); |
| 541 | } |
| 542 | } |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 543 | } |
| 544 | |
alshabib | 7911a05 | 2014-10-16 17:49:37 -0700 | [diff] [blame] | 545 | private void removeRequirement(Dpid dpid) { |
| 546 | countDownLatch.countDown(); |
| 547 | sws.remove(dpid); |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 548 | //FIXME don't do cleanup here (moved by BOC) |
| 549 | //cleanUp(); |
alshabib | 7911a05 | 2014-10-16 17:49:37 -0700 | [diff] [blame] | 550 | } |
Yuta HIGUCHI | 82e5326 | 2014-11-27 10:28:51 -0800 | [diff] [blame] | 551 | |
| 552 | @Override |
| 553 | public String toString() { |
| 554 | return MoreObjects.toStringHelper(getClass()) |
| 555 | .add("xid", xid) |
| 556 | .add("pending devices", sws) |
| 557 | .add("devices in batch", |
| 558 | fms.values().stream() |
| 559 | .map((fbe) -> fbe.getTarget().deviceId()) |
| 560 | .distinct().collect(Collectors.toList())) |
| 561 | .add("failedId", failedId) |
| 562 | .add("latchCount", countDownLatch.getCount()) |
| 563 | .add("state", state) |
| 564 | .add("no error?", ok.get()) |
| 565 | .toString(); |
| 566 | } |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 567 | } |
alshabib | a68eb96 | 2014-09-24 20:34:13 -0700 | [diff] [blame] | 568 | |
alshabib | 1cc04f7 | 2014-09-16 16:09:58 -0700 | [diff] [blame] | 569 | } |