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