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 | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 16 | package org.onlab.onos.net.intent.impl; |
| 17 | |
Yuta HIGUCHI | c2bf3d8 | 2014-11-28 18:50:41 -0800 | [diff] [blame] | 18 | import com.google.common.collect.ImmutableList; |
| 19 | import com.google.common.collect.ImmutableMap; |
| 20 | import com.google.common.collect.Lists; |
| 21 | import com.google.common.collect.Maps; |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 22 | import org.apache.felix.scr.annotations.Activate; |
| 23 | import org.apache.felix.scr.annotations.Component; |
| 24 | import org.apache.felix.scr.annotations.Deactivate; |
| 25 | import org.apache.felix.scr.annotations.Reference; |
| 26 | import org.apache.felix.scr.annotations.ReferenceCardinality; |
| 27 | import org.apache.felix.scr.annotations.Service; |
Brian O'Connor | 72a034c | 2014-11-26 18:24:23 -0800 | [diff] [blame] | 28 | import org.onlab.onos.core.ApplicationId; |
Brian O'Connor | 520c052 | 2014-11-23 23:50:47 -0800 | [diff] [blame] | 29 | import org.onlab.onos.core.CoreService; |
| 30 | import org.onlab.onos.core.IdGenerator; |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 31 | import org.onlab.onos.event.AbstractListenerRegistry; |
| 32 | import org.onlab.onos.event.EventDeliveryService; |
Brian O'Connor | cb900f4 | 2014-10-07 21:55:33 -0700 | [diff] [blame] | 33 | import org.onlab.onos.net.flow.CompletedBatchOperation; |
Brian O'Connor | f2dbde5 | 2014-10-10 16:20:24 -0700 | [diff] [blame] | 34 | import org.onlab.onos.net.flow.FlowRuleBatchOperation; |
| 35 | import org.onlab.onos.net.flow.FlowRuleService; |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 36 | import org.onlab.onos.net.intent.Intent; |
Brian O'Connor | fa81eae | 2014-10-30 13:20:05 -0700 | [diff] [blame] | 37 | import org.onlab.onos.net.intent.IntentBatchDelegate; |
| 38 | import org.onlab.onos.net.intent.IntentBatchService; |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 39 | import org.onlab.onos.net.intent.IntentCompiler; |
| 40 | import org.onlab.onos.net.intent.IntentEvent; |
Yuta HIGUCHI | c2bf3d8 | 2014-11-28 18:50:41 -0800 | [diff] [blame] | 41 | import org.onlab.onos.net.intent.IntentEvent.Type; |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 42 | import org.onlab.onos.net.intent.IntentException; |
| 43 | import org.onlab.onos.net.intent.IntentExtensionService; |
| 44 | import org.onlab.onos.net.intent.IntentId; |
| 45 | import org.onlab.onos.net.intent.IntentInstaller; |
| 46 | import org.onlab.onos.net.intent.IntentListener; |
Brian O'Connor | fa81eae | 2014-10-30 13:20:05 -0700 | [diff] [blame] | 47 | import org.onlab.onos.net.intent.IntentOperation; |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 48 | import org.onlab.onos.net.intent.IntentOperations; |
| 49 | import org.onlab.onos.net.intent.IntentService; |
| 50 | import org.onlab.onos.net.intent.IntentState; |
| 51 | import org.onlab.onos.net.intent.IntentStore; |
Yuta HIGUCHI | c2bf3d8 | 2014-11-28 18:50:41 -0800 | [diff] [blame] | 52 | import org.onlab.onos.net.intent.IntentStore.BatchWrite; |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 53 | import org.onlab.onos.net.intent.IntentStoreDelegate; |
| 54 | import org.slf4j.Logger; |
| 55 | |
Yuta HIGUCHI | c2bf3d8 | 2014-11-28 18:50:41 -0800 | [diff] [blame] | 56 | import java.util.ArrayList; |
| 57 | import java.util.Collections; |
| 58 | import java.util.EnumSet; |
| 59 | import java.util.List; |
| 60 | import java.util.Map; |
| 61 | import java.util.concurrent.ConcurrentHashMap; |
| 62 | import java.util.concurrent.ConcurrentMap; |
| 63 | import java.util.concurrent.ExecutionException; |
| 64 | import java.util.concurrent.ExecutorService; |
| 65 | import java.util.concurrent.Future; |
| 66 | import java.util.concurrent.TimeUnit; |
| 67 | import java.util.concurrent.TimeoutException; |
Brian O'Connor | fa81eae | 2014-10-30 13:20:05 -0700 | [diff] [blame] | 68 | |
| 69 | import static com.google.common.base.Preconditions.checkArgument; |
| 70 | import static com.google.common.base.Preconditions.checkNotNull; |
Yuta HIGUCHI | c2bf3d8 | 2014-11-28 18:50:41 -0800 | [diff] [blame] | 71 | import static java.util.concurrent.Executors.newFixedThreadPool; |
| 72 | import static org.onlab.onos.net.intent.IntentState.*; |
Brian O'Connor | fa81eae | 2014-10-30 13:20:05 -0700 | [diff] [blame] | 73 | import static org.onlab.util.Tools.namedThreads; |
| 74 | import static org.slf4j.LoggerFactory.getLogger; |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 75 | |
| 76 | /** |
| 77 | * An implementation of Intent Manager. |
| 78 | */ |
| 79 | @Component(immediate = true) |
| 80 | @Service |
| 81 | public class IntentManager |
| 82 | implements IntentService, IntentExtensionService { |
Sho SHIMIZU | 8b5051d | 2014-11-05 11:24:13 -0800 | [diff] [blame] | 83 | private static final Logger log = getLogger(IntentManager.class); |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 84 | |
| 85 | public static final String INTENT_NULL = "Intent cannot be null"; |
| 86 | public static final String INTENT_ID_NULL = "Intent ID cannot be null"; |
| 87 | |
Yuta HIGUCHI | c2bf3d8 | 2014-11-28 18:50:41 -0800 | [diff] [blame] | 88 | private static final int NUM_THREADS = 12; |
| 89 | |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 90 | // Collections for compiler, installer, and listener are ONOS instance local |
| 91 | private final ConcurrentMap<Class<? extends Intent>, |
| 92 | IntentCompiler<? extends Intent>> compilers = new ConcurrentHashMap<>(); |
Thomas Vachuska | b97cf28 | 2014-10-20 23:31:12 -0700 | [diff] [blame] | 93 | private final ConcurrentMap<Class<? extends Intent>, |
| 94 | IntentInstaller<? extends Intent>> installers = new ConcurrentHashMap<>(); |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 95 | |
| 96 | private final AbstractListenerRegistry<IntentEvent, IntentListener> |
tom | 95329eb | 2014-10-06 08:40:06 -0700 | [diff] [blame] | 97 | listenerRegistry = new AbstractListenerRegistry<>(); |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 98 | |
Brian O'Connor | 520c052 | 2014-11-23 23:50:47 -0800 | [diff] [blame] | 99 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 100 | protected CoreService coreService; |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 101 | |
| 102 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 103 | protected IntentStore store; |
| 104 | |
| 105 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
Brian O'Connor | fa81eae | 2014-10-30 13:20:05 -0700 | [diff] [blame] | 106 | protected IntentBatchService batchService; |
| 107 | |
| 108 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
tom | 85258ee | 2014-10-07 00:10:02 -0700 | [diff] [blame] | 109 | protected ObjectiveTrackerService trackerService; |
tom | 95329eb | 2014-10-06 08:40:06 -0700 | [diff] [blame] | 110 | |
| 111 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 112 | protected EventDeliveryService eventDispatcher; |
| 113 | |
Brian O'Connor | f2dbde5 | 2014-10-10 16:20:24 -0700 | [diff] [blame] | 114 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 115 | protected FlowRuleService flowRuleService; |
| 116 | |
Brian O'Connor | 520c052 | 2014-11-23 23:50:47 -0800 | [diff] [blame] | 117 | |
| 118 | private ExecutorService executor; |
Brian O'Connor | 520c052 | 2014-11-23 23:50:47 -0800 | [diff] [blame] | 119 | |
| 120 | private final IntentStoreDelegate delegate = new InternalStoreDelegate(); |
| 121 | private final TopologyChangeDelegate topoDelegate = new InternalTopoChangeDelegate(); |
| 122 | private final IntentBatchDelegate batchDelegate = new InternalBatchDelegate(); |
| 123 | private IdGenerator idGenerator; |
| 124 | |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 125 | @Activate |
| 126 | public void activate() { |
| 127 | store.setDelegate(delegate); |
tom | 95329eb | 2014-10-06 08:40:06 -0700 | [diff] [blame] | 128 | trackerService.setDelegate(topoDelegate); |
Brian O'Connor | fa81eae | 2014-10-30 13:20:05 -0700 | [diff] [blame] | 129 | batchService.setDelegate(batchDelegate); |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 130 | eventDispatcher.addSink(IntentEvent.class, listenerRegistry); |
alshabib | a9819bf | 2014-11-30 18:15:52 -0800 | [diff] [blame^] | 131 | executor = newFixedThreadPool(NUM_THREADS, namedThreads("onos-intent")); |
Brian O'Connor | 520c052 | 2014-11-23 23:50:47 -0800 | [diff] [blame] | 132 | idGenerator = coreService.getIdGenerator("intent-ids"); |
| 133 | Intent.bindIdGenerator(idGenerator); |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 134 | log.info("Started"); |
| 135 | } |
| 136 | |
| 137 | @Deactivate |
| 138 | public void deactivate() { |
| 139 | store.unsetDelegate(delegate); |
tom | 95329eb | 2014-10-06 08:40:06 -0700 | [diff] [blame] | 140 | trackerService.unsetDelegate(topoDelegate); |
Brian O'Connor | fa81eae | 2014-10-30 13:20:05 -0700 | [diff] [blame] | 141 | batchService.unsetDelegate(batchDelegate); |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 142 | eventDispatcher.removeSink(IntentEvent.class); |
Brian O'Connor | cb900f4 | 2014-10-07 21:55:33 -0700 | [diff] [blame] | 143 | executor.shutdown(); |
Brian O'Connor | 520c052 | 2014-11-23 23:50:47 -0800 | [diff] [blame] | 144 | Intent.unbindIdGenerator(idGenerator); |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 145 | log.info("Stopped"); |
| 146 | } |
| 147 | |
| 148 | @Override |
| 149 | public void submit(Intent intent) { |
| 150 | checkNotNull(intent, INTENT_NULL); |
Brian O'Connor | 72a034c | 2014-11-26 18:24:23 -0800 | [diff] [blame] | 151 | execute(IntentOperations.builder(intent.appId()) |
| 152 | .addSubmitOperation(intent).build()); |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 153 | } |
| 154 | |
| 155 | @Override |
| 156 | public void withdraw(Intent intent) { |
| 157 | checkNotNull(intent, INTENT_NULL); |
Brian O'Connor | 72a034c | 2014-11-26 18:24:23 -0800 | [diff] [blame] | 158 | execute(IntentOperations.builder(intent.appId()) |
| 159 | .addWithdrawOperation(intent.id()).build()); |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 160 | } |
| 161 | |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 162 | @Override |
Thomas Vachuska | 83e090e | 2014-10-22 14:25:35 -0700 | [diff] [blame] | 163 | public void replace(IntentId oldIntentId, Intent newIntent) { |
Brian O'Connor | fa81eae | 2014-10-30 13:20:05 -0700 | [diff] [blame] | 164 | checkNotNull(oldIntentId, INTENT_ID_NULL); |
| 165 | checkNotNull(newIntent, INTENT_NULL); |
Brian O'Connor | 72a034c | 2014-11-26 18:24:23 -0800 | [diff] [blame] | 166 | execute(IntentOperations.builder(newIntent.appId()) |
Ray Milkey | e97ede9 | 2014-11-20 10:43:12 -0800 | [diff] [blame] | 167 | .addReplaceOperation(oldIntentId, newIntent) |
| 168 | .build()); |
Thomas Vachuska | 83e090e | 2014-10-22 14:25:35 -0700 | [diff] [blame] | 169 | } |
| 170 | |
Thomas Vachuska | 83e090e | 2014-10-22 14:25:35 -0700 | [diff] [blame] | 171 | @Override |
Brian O'Connor | fa81eae | 2014-10-30 13:20:05 -0700 | [diff] [blame] | 172 | public void execute(IntentOperations operations) { |
Brian O'Connor | e2ff25a | 2014-11-18 19:25:43 -0800 | [diff] [blame] | 173 | if (operations.operations().isEmpty()) { |
| 174 | return; |
| 175 | } |
Brian O'Connor | fa81eae | 2014-10-30 13:20:05 -0700 | [diff] [blame] | 176 | batchService.addIntentOperations(operations); |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 177 | } |
| 178 | |
| 179 | @Override |
| 180 | public Iterable<Intent> getIntents() { |
| 181 | return store.getIntents(); |
| 182 | } |
| 183 | |
| 184 | @Override |
| 185 | public long getIntentCount() { |
| 186 | return store.getIntentCount(); |
| 187 | } |
| 188 | |
| 189 | @Override |
| 190 | public Intent getIntent(IntentId id) { |
| 191 | checkNotNull(id, INTENT_ID_NULL); |
| 192 | return store.getIntent(id); |
| 193 | } |
| 194 | |
| 195 | @Override |
| 196 | public IntentState getIntentState(IntentId id) { |
| 197 | checkNotNull(id, INTENT_ID_NULL); |
| 198 | return store.getIntentState(id); |
| 199 | } |
| 200 | |
| 201 | @Override |
Thomas Vachuska | 10d4abc | 2014-10-21 12:47:26 -0700 | [diff] [blame] | 202 | public List<Intent> getInstallableIntents(IntentId intentId) { |
| 203 | checkNotNull(intentId, INTENT_ID_NULL); |
| 204 | return store.getInstallableIntents(intentId); |
| 205 | } |
| 206 | |
| 207 | @Override |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 208 | public void addListener(IntentListener listener) { |
| 209 | listenerRegistry.addListener(listener); |
| 210 | } |
| 211 | |
| 212 | @Override |
| 213 | public void removeListener(IntentListener listener) { |
| 214 | listenerRegistry.removeListener(listener); |
| 215 | } |
| 216 | |
| 217 | @Override |
| 218 | public <T extends Intent> void registerCompiler(Class<T> cls, IntentCompiler<T> compiler) { |
| 219 | compilers.put(cls, compiler); |
| 220 | } |
| 221 | |
| 222 | @Override |
| 223 | public <T extends Intent> void unregisterCompiler(Class<T> cls) { |
| 224 | compilers.remove(cls); |
| 225 | } |
| 226 | |
| 227 | @Override |
| 228 | public Map<Class<? extends Intent>, IntentCompiler<? extends Intent>> getCompilers() { |
| 229 | return ImmutableMap.copyOf(compilers); |
| 230 | } |
| 231 | |
| 232 | @Override |
Thomas Vachuska | b97cf28 | 2014-10-20 23:31:12 -0700 | [diff] [blame] | 233 | public <T extends Intent> void registerInstaller(Class<T> cls, IntentInstaller<T> installer) { |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 234 | installers.put(cls, installer); |
| 235 | } |
| 236 | |
| 237 | @Override |
Thomas Vachuska | b97cf28 | 2014-10-20 23:31:12 -0700 | [diff] [blame] | 238 | public <T extends Intent> void unregisterInstaller(Class<T> cls) { |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 239 | installers.remove(cls); |
| 240 | } |
| 241 | |
| 242 | @Override |
Thomas Vachuska | b97cf28 | 2014-10-20 23:31:12 -0700 | [diff] [blame] | 243 | public Map<Class<? extends Intent>, IntentInstaller<? extends Intent>> getInstallers() { |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 244 | return ImmutableMap.copyOf(installers); |
| 245 | } |
| 246 | |
| 247 | /** |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 248 | * Returns the corresponding intent compiler to the specified intent. |
| 249 | * |
| 250 | * @param intent intent |
tom | 95329eb | 2014-10-06 08:40:06 -0700 | [diff] [blame] | 251 | * @param <T> the type of intent |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 252 | * @return intent compiler corresponding to the specified intent |
| 253 | */ |
| 254 | private <T extends Intent> IntentCompiler<T> getCompiler(T intent) { |
| 255 | @SuppressWarnings("unchecked") |
| 256 | IntentCompiler<T> compiler = (IntentCompiler<T>) compilers.get(intent.getClass()); |
| 257 | if (compiler == null) { |
| 258 | throw new IntentException("no compiler for class " + intent.getClass()); |
| 259 | } |
| 260 | return compiler; |
| 261 | } |
| 262 | |
| 263 | /** |
| 264 | * Returns the corresponding intent installer to the specified installable intent. |
tom | 95329eb | 2014-10-06 08:40:06 -0700 | [diff] [blame] | 265 | * |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 266 | * @param intent intent |
tom | 95329eb | 2014-10-06 08:40:06 -0700 | [diff] [blame] | 267 | * @param <T> the type of installable intent |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 268 | * @return intent installer corresponding to the specified installable intent |
| 269 | */ |
Thomas Vachuska | b97cf28 | 2014-10-20 23:31:12 -0700 | [diff] [blame] | 270 | private <T extends Intent> IntentInstaller<T> getInstaller(T intent) { |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 271 | @SuppressWarnings("unchecked") |
| 272 | IntentInstaller<T> installer = (IntentInstaller<T>) installers.get(intent.getClass()); |
| 273 | if (installer == null) { |
| 274 | throw new IntentException("no installer for class " + intent.getClass()); |
| 275 | } |
| 276 | return installer; |
| 277 | } |
| 278 | |
| 279 | /** |
tom | 85258ee | 2014-10-07 00:10:02 -0700 | [diff] [blame] | 280 | * Compiles the specified intent. |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 281 | * |
Brian O'Connor | fa81eae | 2014-10-30 13:20:05 -0700 | [diff] [blame] | 282 | * @param update intent update |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 283 | */ |
Brian O'Connor | fa81eae | 2014-10-30 13:20:05 -0700 | [diff] [blame] | 284 | private void executeCompilingPhase(IntentUpdate update) { |
| 285 | Intent intent = update.newIntent(); |
tom | 85258ee | 2014-10-07 00:10:02 -0700 | [diff] [blame] | 286 | // Indicate that the intent is entering the compiling phase. |
Yuta HIGUCHI | c2bf3d8 | 2014-11-28 18:50:41 -0800 | [diff] [blame] | 287 | update.setInflightState(intent, COMPILING); |
tom | 85258ee | 2014-10-07 00:10:02 -0700 | [diff] [blame] | 288 | |
| 289 | try { |
| 290 | // Compile the intent into installable derivatives. |
Brian O'Connor | fa81eae | 2014-10-30 13:20:05 -0700 | [diff] [blame] | 291 | List<Intent> installables = compileIntent(intent, update); |
tom | 85258ee | 2014-10-07 00:10:02 -0700 | [diff] [blame] | 292 | |
| 293 | // If all went well, associate the resulting list of installable |
| 294 | // intents with the top-level intent and proceed to install. |
Brian O'Connor | fa81eae | 2014-10-30 13:20:05 -0700 | [diff] [blame] | 295 | update.setInstallables(installables); |
| 296 | } catch (IntentException e) { |
Jonathan Hart | 1109640 | 2014-10-20 17:31:49 -0700 | [diff] [blame] | 297 | log.warn("Unable to compile intent {} due to:", intent.id(), e); |
tom | 53945d5 | 2014-10-07 11:01:36 -0700 | [diff] [blame] | 298 | |
tom | 85258ee | 2014-10-07 00:10:02 -0700 | [diff] [blame] | 299 | // If compilation failed, mark the intent as failed. |
Yuta HIGUCHI | c2bf3d8 | 2014-11-28 18:50:41 -0800 | [diff] [blame] | 300 | update.setInflightState(intent, FAILED); |
tom | 85258ee | 2014-10-07 00:10:02 -0700 | [diff] [blame] | 301 | } |
| 302 | } |
| 303 | |
Brian O'Connor | cb900f4 | 2014-10-07 21:55:33 -0700 | [diff] [blame] | 304 | /** |
| 305 | * Compiles an intent recursively. |
| 306 | * |
| 307 | * @param intent intent |
| 308 | * @return result of compilation |
| 309 | */ |
Brian O'Connor | fa81eae | 2014-10-30 13:20:05 -0700 | [diff] [blame] | 310 | private List<Intent> compileIntent(Intent intent, IntentUpdate update) { |
Thomas Vachuska | 4926c1b | 2014-10-21 00:44:10 -0700 | [diff] [blame] | 311 | if (intent.isInstallable()) { |
| 312 | return ImmutableList.of(intent); |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 313 | } |
Brian O'Connor | cb900f4 | 2014-10-07 21:55:33 -0700 | [diff] [blame] | 314 | |
Brian O'Connor | fa81eae | 2014-10-30 13:20:05 -0700 | [diff] [blame] | 315 | registerSubclassCompilerIfNeeded(intent); |
| 316 | List<Intent> previous = update.oldInstallables(); |
| 317 | // FIXME: get previous resources |
Thomas Vachuska | b97cf28 | 2014-10-20 23:31:12 -0700 | [diff] [blame] | 318 | List<Intent> installable = new ArrayList<>(); |
Brian O'Connor | fa81eae | 2014-10-30 13:20:05 -0700 | [diff] [blame] | 319 | for (Intent compiled : getCompiler(intent).compile(intent, previous, null)) { |
| 320 | installable.addAll(compileIntent(compiled, update)); |
Brian O'Connor | cb900f4 | 2014-10-07 21:55:33 -0700 | [diff] [blame] | 321 | } |
tom | 85258ee | 2014-10-07 00:10:02 -0700 | [diff] [blame] | 322 | return installable; |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 323 | } |
| 324 | |
| 325 | /** |
tom | 85258ee | 2014-10-07 00:10:02 -0700 | [diff] [blame] | 326 | * Installs all installable intents associated with the specified top-level |
| 327 | * intent. |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 328 | * |
Brian O'Connor | fa81eae | 2014-10-30 13:20:05 -0700 | [diff] [blame] | 329 | * @param update intent update |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 330 | */ |
Brian O'Connor | fa81eae | 2014-10-30 13:20:05 -0700 | [diff] [blame] | 331 | private void executeInstallingPhase(IntentUpdate update) { |
| 332 | if (update.newInstallables() == null) { |
| 333 | //no failed intents allowed past this point... |
| 334 | return; |
tom | 85258ee | 2014-10-07 00:10:02 -0700 | [diff] [blame] | 335 | } |
Brian O'Connor | fa81eae | 2014-10-30 13:20:05 -0700 | [diff] [blame] | 336 | // Indicate that the intent is entering the installing phase. |
Yuta HIGUCHI | c2bf3d8 | 2014-11-28 18:50:41 -0800 | [diff] [blame] | 337 | update.setInflightState(update.newIntent(), INSTALLING); |
Brian O'Connor | fa81eae | 2014-10-30 13:20:05 -0700 | [diff] [blame] | 338 | |
| 339 | List<FlowRuleBatchOperation> batches = Lists.newArrayList(); |
| 340 | for (Intent installable : update.newInstallables()) { |
| 341 | registerSubclassInstallerIfNeeded(installable); |
| 342 | trackerService.addTrackedResources(update.newIntent().id(), |
| 343 | installable.resources()); |
| 344 | try { |
| 345 | batches.addAll(getInstaller(installable).install(installable)); |
| 346 | } catch (IntentException e) { |
| 347 | log.warn("Unable to install intent {} due to:", update.newIntent().id(), e); |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 348 | trackerService.removeTrackedResources(update.newIntent().id(), |
| 349 | installable.resources()); |
Brian O'Connor | fa81eae | 2014-10-30 13:20:05 -0700 | [diff] [blame] | 350 | //FIXME we failed... intent should be recompiled |
Brian O'Connor | fa81eae | 2014-10-30 13:20:05 -0700 | [diff] [blame] | 351 | } |
| 352 | } |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 353 | update.addBatches(batches); |
Brian O'Connor | fa81eae | 2014-10-30 13:20:05 -0700 | [diff] [blame] | 354 | } |
| 355 | |
| 356 | /** |
| 357 | * Uninstalls the specified intent by uninstalling all of its associated |
| 358 | * installable derivatives. |
| 359 | * |
| 360 | * @param update intent update |
| 361 | */ |
| 362 | private void executeWithdrawingPhase(IntentUpdate update) { |
| 363 | if (!update.oldIntent().equals(update.newIntent())) { |
Yuta HIGUCHI | c2bf3d8 | 2014-11-28 18:50:41 -0800 | [diff] [blame] | 364 | update.setInflightState(update.oldIntent(), WITHDRAWING); |
Brian O'Connor | fa81eae | 2014-10-30 13:20:05 -0700 | [diff] [blame] | 365 | } // else newIntent is FAILED |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 366 | update.addBatches(uninstallIntent(update.oldIntent(), update.oldInstallables())); |
Brian O'Connor | fa81eae | 2014-10-30 13:20:05 -0700 | [diff] [blame] | 367 | } |
| 368 | |
| 369 | /** |
| 370 | * Uninstalls all installable intents associated with the given intent. |
| 371 | * |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 372 | * @param intent intent |
| 373 | * @param installables installable intents |
| 374 | * @return list of batches to uninstall intent |
Brian O'Connor | fa81eae | 2014-10-30 13:20:05 -0700 | [diff] [blame] | 375 | */ |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 376 | private List<FlowRuleBatchOperation> uninstallIntent(Intent intent, List<Intent> installables) { |
| 377 | if (installables == null) { |
| 378 | return Collections.emptyList(); |
Brian O'Connor | fa81eae | 2014-10-30 13:20:05 -0700 | [diff] [blame] | 379 | } |
| 380 | List<FlowRuleBatchOperation> batches = Lists.newArrayList(); |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 381 | for (Intent installable : installables) { |
| 382 | trackerService.removeTrackedResources(intent.id(), |
Brian O'Connor | fa81eae | 2014-10-30 13:20:05 -0700 | [diff] [blame] | 383 | installable.resources()); |
| 384 | try { |
| 385 | batches.addAll(getInstaller(installable).uninstall(installable)); |
| 386 | } catch (IntentException e) { |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 387 | log.warn("Unable to uninstall intent {} due to:", intent.id(), e); |
Brian O'Connor | fa81eae | 2014-10-30 13:20:05 -0700 | [diff] [blame] | 388 | // TODO: this should never happen. but what if it does? |
| 389 | } |
| 390 | } |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 391 | return batches; |
tom | 85258ee | 2014-10-07 00:10:02 -0700 | [diff] [blame] | 392 | } |
| 393 | |
| 394 | /** |
Brian O'Connor | fa81eae | 2014-10-30 13:20:05 -0700 | [diff] [blame] | 395 | * Withdraws the old intent and installs the new intent as one operation. |
tom | 85258ee | 2014-10-07 00:10:02 -0700 | [diff] [blame] | 396 | * |
Brian O'Connor | fa81eae | 2014-10-30 13:20:05 -0700 | [diff] [blame] | 397 | * @param update intent update |
tom | 85258ee | 2014-10-07 00:10:02 -0700 | [diff] [blame] | 398 | */ |
Brian O'Connor | fa81eae | 2014-10-30 13:20:05 -0700 | [diff] [blame] | 399 | private void executeReplacementPhase(IntentUpdate update) { |
| 400 | checkArgument(update.oldInstallables().size() == update.newInstallables().size(), |
| 401 | "Old and New Intent must have equivalent installable intents."); |
| 402 | if (!update.oldIntent().equals(update.newIntent())) { |
| 403 | // only set the old intent's state if it is different |
Yuta HIGUCHI | c2bf3d8 | 2014-11-28 18:50:41 -0800 | [diff] [blame] | 404 | update.setInflightState(update.oldIntent(), WITHDRAWING); |
tom | 53945d5 | 2014-10-07 11:01:36 -0700 | [diff] [blame] | 405 | } |
Yuta HIGUCHI | c2bf3d8 | 2014-11-28 18:50:41 -0800 | [diff] [blame] | 406 | update.setInflightState(update.newIntent(), INSTALLING); |
Brian O'Connor | fa81eae | 2014-10-30 13:20:05 -0700 | [diff] [blame] | 407 | |
| 408 | List<FlowRuleBatchOperation> batches = Lists.newArrayList(); |
| 409 | for (int i = 0; i < update.oldInstallables().size(); i++) { |
| 410 | Intent oldInstallable = update.oldInstallables().get(i); |
| 411 | Intent newInstallable = update.newInstallables().get(i); |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 412 | //FIXME revisit this |
| 413 | // if (oldInstallable.equals(newInstallable)) { |
| 414 | // continue; |
| 415 | // } |
Brian O'Connor | fa81eae | 2014-10-30 13:20:05 -0700 | [diff] [blame] | 416 | checkArgument(oldInstallable.getClass().equals(newInstallable.getClass()), |
| 417 | "Installable Intent type mismatch."); |
| 418 | trackerService.removeTrackedResources(update.oldIntent().id(), oldInstallable.resources()); |
| 419 | trackerService.addTrackedResources(update.newIntent().id(), newInstallable.resources()); |
| 420 | try { |
| 421 | batches.addAll(getInstaller(newInstallable).replace(oldInstallable, newInstallable)); |
| 422 | } catch (IntentException e) { |
| 423 | log.warn("Unable to update intent {} due to:", update.oldIntent().id(), e); |
| 424 | //FIXME... we failed. need to uninstall (if same) or revert (if different) |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 425 | trackerService.removeTrackedResources(update.newIntent().id(), newInstallable.resources()); |
Yuta HIGUCHI | c2bf3d8 | 2014-11-28 18:50:41 -0800 | [diff] [blame] | 426 | update.setInflightState(update.newIntent(), FAILED); |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 427 | batches = uninstallIntent(update.oldIntent(), update.oldInstallables()); |
Brian O'Connor | fa81eae | 2014-10-30 13:20:05 -0700 | [diff] [blame] | 428 | } |
| 429 | } |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 430 | update.addBatches(batches); |
tom | 53945d5 | 2014-10-07 11:01:36 -0700 | [diff] [blame] | 431 | } |
| 432 | |
| 433 | /** |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 434 | * Registers an intent compiler of the specified intent if an intent compiler |
| 435 | * for the intent is not registered. This method traverses the class hierarchy of |
| 436 | * the intent. Once an intent compiler for a parent type is found, this method |
| 437 | * registers the found intent compiler. |
| 438 | * |
| 439 | * @param intent intent |
| 440 | */ |
| 441 | private void registerSubclassCompilerIfNeeded(Intent intent) { |
| 442 | if (!compilers.containsKey(intent.getClass())) { |
| 443 | Class<?> cls = intent.getClass(); |
| 444 | while (cls != Object.class) { |
| 445 | // As long as we're within the Intent class descendants |
| 446 | if (Intent.class.isAssignableFrom(cls)) { |
| 447 | IntentCompiler<?> compiler = compilers.get(cls); |
| 448 | if (compiler != null) { |
| 449 | compilers.put(intent.getClass(), compiler); |
| 450 | return; |
| 451 | } |
| 452 | } |
| 453 | cls = cls.getSuperclass(); |
| 454 | } |
| 455 | } |
| 456 | } |
| 457 | |
| 458 | /** |
| 459 | * Registers an intent installer of the specified intent if an intent installer |
| 460 | * for the intent is not registered. This method traverses the class hierarchy of |
| 461 | * the intent. Once an intent installer for a parent type is found, this method |
| 462 | * registers the found intent installer. |
| 463 | * |
| 464 | * @param intent intent |
| 465 | */ |
Thomas Vachuska | b97cf28 | 2014-10-20 23:31:12 -0700 | [diff] [blame] | 466 | private void registerSubclassInstallerIfNeeded(Intent intent) { |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 467 | if (!installers.containsKey(intent.getClass())) { |
| 468 | Class<?> cls = intent.getClass(); |
| 469 | while (cls != Object.class) { |
Thomas Vachuska | b97cf28 | 2014-10-20 23:31:12 -0700 | [diff] [blame] | 470 | // As long as we're within the Intent class descendants |
| 471 | if (Intent.class.isAssignableFrom(cls)) { |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 472 | IntentInstaller<?> installer = installers.get(cls); |
| 473 | if (installer != null) { |
| 474 | installers.put(intent.getClass(), installer); |
| 475 | return; |
| 476 | } |
| 477 | } |
| 478 | cls = cls.getSuperclass(); |
| 479 | } |
| 480 | } |
| 481 | } |
| 482 | |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 483 | // Store delegate to re-post events emitted from the store. |
| 484 | private class InternalStoreDelegate implements IntentStoreDelegate { |
| 485 | @Override |
| 486 | public void notify(IntentEvent event) { |
tom | 85258ee | 2014-10-07 00:10:02 -0700 | [diff] [blame] | 487 | eventDispatcher.post(event); |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 488 | } |
| 489 | } |
| 490 | |
Brian O'Connor | 72a034c | 2014-11-26 18:24:23 -0800 | [diff] [blame] | 491 | private void buildAndSubmitBatches(Iterable<IntentId> intentIds, |
| 492 | boolean compileAllFailed) { |
| 493 | Map<ApplicationId, IntentOperations.Builder> batches = Maps.newHashMap(); |
| 494 | // Attempt recompilation of the specified intents first. |
| 495 | for (IntentId id : intentIds) { |
| 496 | Intent intent = store.getIntent(id); |
| 497 | if (intent == null) { |
| 498 | continue; |
| 499 | } |
| 500 | IntentOperations.Builder builder = batches.get(intent.appId()); |
| 501 | if (builder == null) { |
| 502 | builder = IntentOperations.builder(intent.appId()); |
| 503 | batches.put(intent.appId(), builder); |
| 504 | } |
| 505 | builder.addUpdateOperation(id); |
| 506 | } |
| 507 | |
| 508 | if (compileAllFailed) { |
| 509 | // If required, compile all currently failed intents. |
| 510 | for (Intent intent : getIntents()) { |
| 511 | if (getIntentState(intent.id()) == FAILED) { |
| 512 | IntentOperations.Builder builder = batches.get(intent.appId()); |
| 513 | if (builder == null) { |
| 514 | builder = IntentOperations.builder(intent.appId()); |
| 515 | batches.put(intent.appId(), builder); |
| 516 | } |
| 517 | builder.addUpdateOperation(intent.id()); |
| 518 | } |
| 519 | } |
| 520 | } |
| 521 | |
| 522 | for (ApplicationId appId : batches.keySet()) { |
| 523 | if (batchService.isLocalLeader(appId)) { |
| 524 | execute(batches.get(appId).build()); |
| 525 | } |
| 526 | } |
| 527 | } |
| 528 | |
tom | 95329eb | 2014-10-06 08:40:06 -0700 | [diff] [blame] | 529 | // Topology change delegate |
| 530 | private class InternalTopoChangeDelegate implements TopologyChangeDelegate { |
| 531 | @Override |
tom | 85258ee | 2014-10-07 00:10:02 -0700 | [diff] [blame] | 532 | public void triggerCompile(Iterable<IntentId> intentIds, |
| 533 | boolean compileAllFailed) { |
Brian O'Connor | 72a034c | 2014-11-26 18:24:23 -0800 | [diff] [blame] | 534 | buildAndSubmitBatches(intentIds, compileAllFailed); |
tom | 95329eb | 2014-10-06 08:40:06 -0700 | [diff] [blame] | 535 | } |
tom | 95329eb | 2014-10-06 08:40:06 -0700 | [diff] [blame] | 536 | } |
tom | 85258ee | 2014-10-07 00:10:02 -0700 | [diff] [blame] | 537 | |
Yuta HIGUCHI | c2bf3d8 | 2014-11-28 18:50:41 -0800 | [diff] [blame] | 538 | // TODO move this inside IntentUpdate? |
Brian O'Connor | fa81eae | 2014-10-30 13:20:05 -0700 | [diff] [blame] | 539 | /** |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 540 | * TODO. rename this... |
| 541 | * @param update intent update |
Brian O'Connor | fa81eae | 2014-10-30 13:20:05 -0700 | [diff] [blame] | 542 | */ |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 543 | private void processIntentUpdate(IntentUpdate update) { |
Brian O'Connor | fa81eae | 2014-10-30 13:20:05 -0700 | [diff] [blame] | 544 | |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 545 | // check to see if the intent needs to be compiled or recompiled |
Brian O'Connor | fa81eae | 2014-10-30 13:20:05 -0700 | [diff] [blame] | 546 | if (update.newIntent() != null) { |
| 547 | executeCompilingPhase(update); |
| 548 | } |
| 549 | |
| 550 | if (update.oldInstallables() != null && update.newInstallables() != null) { |
| 551 | executeReplacementPhase(update); |
| 552 | } else if (update.newInstallables() != null) { |
| 553 | executeInstallingPhase(update); |
| 554 | } else if (update.oldInstallables() != null) { |
| 555 | executeWithdrawingPhase(update); |
| 556 | } else { |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 557 | if (update.oldIntent() != null && |
Yuta HIGUCHI | c2bf3d8 | 2014-11-28 18:50:41 -0800 | [diff] [blame] | 558 | !update.oldIntent().equals(update.newIntent())) { |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 559 | // removing failed intent |
Yuta HIGUCHI | c2bf3d8 | 2014-11-28 18:50:41 -0800 | [diff] [blame] | 560 | update.setInflightState(update.oldIntent(), WITHDRAWING); |
Brian O'Connor | fa81eae | 2014-10-30 13:20:05 -0700 | [diff] [blame] | 561 | } |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 562 | // if (update.newIntent() != null) { |
| 563 | // // TODO assert that next state is failed |
| 564 | // } |
Brian O'Connor | fa81eae | 2014-10-30 13:20:05 -0700 | [diff] [blame] | 565 | } |
Brian O'Connor | fa81eae | 2014-10-30 13:20:05 -0700 | [diff] [blame] | 566 | } |
| 567 | |
| 568 | // TODO comments... |
| 569 | private class IntentUpdate { |
Brian O'Connor | fa81eae | 2014-10-30 13:20:05 -0700 | [diff] [blame] | 570 | private final Intent oldIntent; |
| 571 | private final Intent newIntent; |
| 572 | private final Map<Intent, IntentState> stateMap = Maps.newHashMap(); |
| 573 | |
| 574 | private final List<Intent> oldInstallables; |
| 575 | private List<Intent> newInstallables; |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 576 | private final List<FlowRuleBatchOperation> batches = Lists.newLinkedList(); |
| 577 | private int currentBatch = 0; // TODO: maybe replace with an iterator |
Brian O'Connor | fa81eae | 2014-10-30 13:20:05 -0700 | [diff] [blame] | 578 | |
| 579 | IntentUpdate(IntentOperation op) { |
Brian O'Connor | fa81eae | 2014-10-30 13:20:05 -0700 | [diff] [blame] | 580 | switch (op.type()) { |
| 581 | case SUBMIT: |
| 582 | newIntent = op.intent(); |
| 583 | oldIntent = null; |
| 584 | break; |
| 585 | case WITHDRAW: |
| 586 | newIntent = null; |
| 587 | oldIntent = store.getIntent(op.intentId()); |
| 588 | break; |
| 589 | case REPLACE: |
| 590 | newIntent = op.intent(); |
| 591 | oldIntent = store.getIntent(op.intentId()); |
| 592 | break; |
| 593 | case UPDATE: |
| 594 | oldIntent = store.getIntent(op.intentId()); |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 595 | newIntent = oldIntent; |
Brian O'Connor | fa81eae | 2014-10-30 13:20:05 -0700 | [diff] [blame] | 596 | break; |
| 597 | default: |
| 598 | oldIntent = null; |
| 599 | newIntent = null; |
| 600 | break; |
| 601 | } |
Brian O'Connor | fa81eae | 2014-10-30 13:20:05 -0700 | [diff] [blame] | 602 | // fetch the old intent's installables from the store |
| 603 | if (oldIntent != null) { |
| 604 | oldInstallables = store.getInstallableIntents(oldIntent.id()); |
Brian O'Connor | fa81eae | 2014-10-30 13:20:05 -0700 | [diff] [blame] | 605 | } else { |
| 606 | oldInstallables = null; |
| 607 | } |
| 608 | } |
| 609 | |
Yuta HIGUCHI | c2bf3d8 | 2014-11-28 18:50:41 -0800 | [diff] [blame] | 610 | void init(BatchWrite batchWrite) { |
| 611 | // add new intent to store (if required) |
| 612 | if (newIntent != null) { |
| 613 | batchWrite.createIntent(newIntent); |
| 614 | } |
| 615 | } |
| 616 | |
Brian O'Connor | fa81eae | 2014-10-30 13:20:05 -0700 | [diff] [blame] | 617 | Intent oldIntent() { |
| 618 | return oldIntent; |
| 619 | } |
| 620 | |
| 621 | Intent newIntent() { |
| 622 | return newIntent; |
| 623 | } |
| 624 | |
| 625 | List<Intent> oldInstallables() { |
| 626 | return oldInstallables; |
| 627 | } |
| 628 | |
| 629 | List<Intent> newInstallables() { |
| 630 | return newInstallables; |
| 631 | } |
| 632 | |
| 633 | void setInstallables(List<Intent> installables) { |
| 634 | newInstallables = installables; |
Yuta HIGUCHI | c2bf3d8 | 2014-11-28 18:50:41 -0800 | [diff] [blame] | 635 | //FIXME batch this |
| 636 | |
| 637 | //store.setInstallableIntents(newIntent.id(), installables); |
| 638 | |
Brian O'Connor | fa81eae | 2014-10-30 13:20:05 -0700 | [diff] [blame] | 639 | } |
| 640 | |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 641 | boolean isComplete() { |
| 642 | return currentBatch >= batches.size(); |
| 643 | } |
| 644 | |
| 645 | FlowRuleBatchOperation currentBatch() { |
| 646 | return !isComplete() ? batches.get(currentBatch) : null; |
| 647 | } |
| 648 | |
alshabib | a9819bf | 2014-11-30 18:15:52 -0800 | [diff] [blame^] | 649 | void batchSuccess(BatchWrite batchWrite) { |
Yuta HIGUCHI | c2bf3d8 | 2014-11-28 18:50:41 -0800 | [diff] [blame] | 650 | // move on to next Batch |
| 651 | if (++currentBatch == batches.size()) { |
alshabib | a9819bf | 2014-11-30 18:15:52 -0800 | [diff] [blame^] | 652 | finalizeStates(batchWrite); |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 653 | } |
Yuta HIGUCHI | c2bf3d8 | 2014-11-28 18:50:41 -0800 | [diff] [blame] | 654 | } |
| 655 | |
| 656 | void batchFailed() { |
| 657 | |
| 658 | // the current batch has failed, so recompile |
| 659 | // remove the current batch and all remaining |
| 660 | for (int i = currentBatch; i < batches.size(); i++) { |
| 661 | batches.remove(i); |
| 662 | } |
| 663 | if (oldIntent != null) { |
| 664 | executeWithdrawingPhase(this); // remove the old intent |
| 665 | } |
| 666 | if (newIntent != null) { |
| 667 | setInflightState(newIntent, FAILED); |
| 668 | batches.addAll(uninstallIntent(newIntent, newInstallables())); |
| 669 | } |
| 670 | |
| 671 | // FIXME: should we try to recompile? |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 672 | } |
| 673 | |
| 674 | // FIXME make sure this is called!!! |
alshabib | a9819bf | 2014-11-30 18:15:52 -0800 | [diff] [blame^] | 675 | private void finalizeStates(BatchWrite batchWrite) { |
Yuta HIGUCHI | c2bf3d8 | 2014-11-28 18:50:41 -0800 | [diff] [blame] | 676 | // events to be triggered on successful write |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 677 | for (Intent intent : stateMap.keySet()) { |
Yuta HIGUCHI | c2bf3d8 | 2014-11-28 18:50:41 -0800 | [diff] [blame] | 678 | switch (getInflightState(intent)) { |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 679 | case INSTALLING: |
Yuta HIGUCHI | c2bf3d8 | 2014-11-28 18:50:41 -0800 | [diff] [blame] | 680 | batchWrite.setState(intent, INSTALLED); |
| 681 | batchWrite.setInstallableIntents(newIntent.id(), newInstallables); |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 682 | break; |
| 683 | case WITHDRAWING: |
Yuta HIGUCHI | c2bf3d8 | 2014-11-28 18:50:41 -0800 | [diff] [blame] | 684 | batchWrite.setState(intent, WITHDRAWN); |
Yuta HIGUCHI | c2bf3d8 | 2014-11-28 18:50:41 -0800 | [diff] [blame] | 685 | batchWrite.removeInstalledIntents(intent.id()); |
| 686 | batchWrite.removeIntent(intent.id()); |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 687 | break; |
| 688 | case FAILED: |
Yuta HIGUCHI | c2bf3d8 | 2014-11-28 18:50:41 -0800 | [diff] [blame] | 689 | batchWrite.removeInstalledIntents(intent.id()); |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 690 | break; |
| 691 | |
| 692 | // FALLTHROUGH to default from here |
| 693 | case SUBMITTED: |
| 694 | case COMPILING: |
| 695 | case RECOMPILING: |
| 696 | case WITHDRAWN: |
| 697 | case INSTALLED: |
| 698 | default: |
| 699 | //FIXME clean this up (we shouldn't ever get here) |
Yuta HIGUCHI | c2bf3d8 | 2014-11-28 18:50:41 -0800 | [diff] [blame] | 700 | log.warn("Bad state: {} for {}", getInflightState(intent), intent); |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 701 | break; |
| 702 | } |
| 703 | } |
| 704 | } |
| 705 | |
Brian O'Connor | fa81eae | 2014-10-30 13:20:05 -0700 | [diff] [blame] | 706 | List<FlowRuleBatchOperation> batches() { |
| 707 | return batches; |
| 708 | } |
| 709 | |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 710 | void addBatches(List<FlowRuleBatchOperation> batches) { |
| 711 | this.batches.addAll(batches); |
Brian O'Connor | fa81eae | 2014-10-30 13:20:05 -0700 | [diff] [blame] | 712 | } |
| 713 | |
Yuta HIGUCHI | c2bf3d8 | 2014-11-28 18:50:41 -0800 | [diff] [blame] | 714 | IntentState getInflightState(Intent intent) { |
Brian O'Connor | fa81eae | 2014-10-30 13:20:05 -0700 | [diff] [blame] | 715 | return stateMap.get(intent); |
| 716 | } |
| 717 | |
Yuta HIGUCHI | c2bf3d8 | 2014-11-28 18:50:41 -0800 | [diff] [blame] | 718 | |
| 719 | // set transient state during intent update process |
| 720 | void setInflightState(Intent intent, IntentState newState) { |
| 721 | // This method should be called for |
| 722 | // transition to non-parking or Failed only |
| 723 | EnumSet<IntentState> nonParkingOrFailed |
| 724 | = EnumSet.complementOf(EnumSet.of(SUBMITTED, INSTALLED, WITHDRAWN)); |
| 725 | if (!nonParkingOrFailed.contains(newState)) { |
| 726 | log.error("Unexpected transition to {}", newState); |
| 727 | } |
| 728 | |
Brian O'Connor | fa81eae | 2014-10-30 13:20:05 -0700 | [diff] [blame] | 729 | // TODO: clean this up, or set to debug |
| 730 | IntentState oldState = stateMap.get(intent); |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 731 | log.debug("intent id: {}, old state: {}, new state: {}", |
Ray Milkey | e97ede9 | 2014-11-20 10:43:12 -0800 | [diff] [blame] | 732 | intent.id(), oldState, newState); |
Brian O'Connor | fa81eae | 2014-10-30 13:20:05 -0700 | [diff] [blame] | 733 | |
| 734 | stateMap.put(intent, newState); |
alshabib | a9819bf | 2014-11-30 18:15:52 -0800 | [diff] [blame^] | 735 | // IntentEvent event = store.setState(intent, newState); |
| 736 | // if (event != null) { |
| 737 | // eventDispatcher.post(event); |
| 738 | // } |
Brian O'Connor | fa81eae | 2014-10-30 13:20:05 -0700 | [diff] [blame] | 739 | } |
| 740 | |
| 741 | Map<Intent, IntentState> stateMap() { |
| 742 | return stateMap; |
| 743 | } |
| 744 | } |
| 745 | |
Brian O'Connor | cb900f4 | 2014-10-07 21:55:33 -0700 | [diff] [blame] | 746 | private class IntentInstallMonitor implements Runnable { |
| 747 | |
Yuta HIGUCHI | 82e5326 | 2014-11-27 10:28:51 -0800 | [diff] [blame] | 748 | // TODO make this configurable |
| 749 | private static final int TIMEOUT_PER_OP = 500; // ms |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 750 | private static final int MAX_ATTEMPTS = 3; |
Brian O'Connor | cb900f4 | 2014-10-07 21:55:33 -0700 | [diff] [blame] | 751 | |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 752 | private final IntentOperations ops; |
| 753 | private final List<IntentUpdate> intentUpdates = Lists.newArrayList(); |
| 754 | |
Yuta HIGUCHI | c2bf3d8 | 2014-11-28 18:50:41 -0800 | [diff] [blame] | 755 | // future holding current FlowRuleBatch installation result |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 756 | private Future<CompletedBatchOperation> future; |
| 757 | private long startTime = System.currentTimeMillis(); |
Yuta HIGUCHI | 82e5326 | 2014-11-27 10:28:51 -0800 | [diff] [blame] | 758 | private long endTime; |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 759 | private int installAttempt; |
| 760 | |
| 761 | public IntentInstallMonitor(IntentOperations ops) { |
Brian O'Connor | fa81eae | 2014-10-30 13:20:05 -0700 | [diff] [blame] | 762 | this.ops = ops; |
Yuta HIGUCHI | 82e5326 | 2014-11-27 10:28:51 -0800 | [diff] [blame] | 763 | resetTimeoutLimit(); |
| 764 | } |
| 765 | |
| 766 | private void resetTimeoutLimit() { |
| 767 | // FIXME compute reasonable timeouts |
| 768 | this.endTime = System.currentTimeMillis() |
| 769 | + ops.operations().size() * TIMEOUT_PER_OP; |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 770 | } |
| 771 | |
| 772 | private void buildIntentUpdates() { |
Yuta HIGUCHI | c2bf3d8 | 2014-11-28 18:50:41 -0800 | [diff] [blame] | 773 | BatchWrite batchWrite = store.newBatchWrite(); |
| 774 | |
| 775 | // create context and record new request to store |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 776 | for (IntentOperation op : ops.operations()) { |
| 777 | IntentUpdate update = new IntentUpdate(op); |
Yuta HIGUCHI | c2bf3d8 | 2014-11-28 18:50:41 -0800 | [diff] [blame] | 778 | update.init(batchWrite); |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 779 | intentUpdates.add(update); |
Yuta HIGUCHI | c2bf3d8 | 2014-11-28 18:50:41 -0800 | [diff] [blame] | 780 | } |
| 781 | |
| 782 | if (!batchWrite.isEmpty()) { |
| 783 | store.batchWrite(batchWrite); |
| 784 | } |
| 785 | |
| 786 | // start processing each Intents |
| 787 | for (IntentUpdate update : intentUpdates) { |
| 788 | if (update.newIntent() != null) { |
| 789 | IntentState state = store.getIntentState(update.newIntent().id()); |
| 790 | if (state == SUBMITTED) { |
| 791 | eventDispatcher.post(new IntentEvent(Type.SUBMITTED, update.newIntent)); |
| 792 | } |
| 793 | } |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 794 | processIntentUpdate(update); |
| 795 | } |
Brian O'Connor | fa81eae | 2014-10-30 13:20:05 -0700 | [diff] [blame] | 796 | future = applyNextBatch(); |
Brian O'Connor | cb900f4 | 2014-10-07 21:55:33 -0700 | [diff] [blame] | 797 | } |
| 798 | |
Brian O'Connor | f2dbde5 | 2014-10-10 16:20:24 -0700 | [diff] [blame] | 799 | /** |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 800 | * Builds and applies the next batch, and returns the future. |
Brian O'Connor | fa81eae | 2014-10-30 13:20:05 -0700 | [diff] [blame] | 801 | * |
| 802 | * @return Future for next batch |
Brian O'Connor | f2dbde5 | 2014-10-10 16:20:24 -0700 | [diff] [blame] | 803 | */ |
| 804 | private Future<CompletedBatchOperation> applyNextBatch() { |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 805 | //TODO test this. (also, maybe save this batch) |
| 806 | FlowRuleBatchOperation batch = new FlowRuleBatchOperation(Collections.emptyList()); |
| 807 | for (IntentUpdate update : intentUpdates) { |
| 808 | if (!update.isComplete()) { |
| 809 | batch.addAll(update.currentBatch()); |
| 810 | } |
Brian O'Connor | f2dbde5 | 2014-10-10 16:20:24 -0700 | [diff] [blame] | 811 | } |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 812 | return (batch.size() > 0) ? flowRuleService.applyBatch(batch) : null; |
Brian O'Connor | f2dbde5 | 2014-10-10 16:20:24 -0700 | [diff] [blame] | 813 | } |
| 814 | |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 815 | private void updateBatches(CompletedBatchOperation completed) { |
| 816 | if (completed.isSuccess()) { |
Yuta HIGUCHI | c2bf3d8 | 2014-11-28 18:50:41 -0800 | [diff] [blame] | 817 | BatchWrite batchWrite = store.newBatchWrite(); |
| 818 | List<IntentEvent> events = new ArrayList<>(); |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 819 | for (IntentUpdate update : intentUpdates) { |
alshabib | a9819bf | 2014-11-30 18:15:52 -0800 | [diff] [blame^] | 820 | update.batchSuccess(batchWrite); |
Yuta HIGUCHI | c2bf3d8 | 2014-11-28 18:50:41 -0800 | [diff] [blame] | 821 | } |
| 822 | if (!batchWrite.isEmpty()) { |
| 823 | store.batchWrite(batchWrite); |
| 824 | for (IntentEvent event : events) { |
| 825 | eventDispatcher.post(event); |
| 826 | } |
Brian O'Connor | fa81eae | 2014-10-30 13:20:05 -0700 | [diff] [blame] | 827 | } |
Brian O'Connor | fa81eae | 2014-10-30 13:20:05 -0700 | [diff] [blame] | 828 | } else { |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 829 | // entire batch has been reverted... |
| 830 | log.warn("Failed items: {}", completed.failedItems()); |
| 831 | |
| 832 | for (Long id : completed.failedIds()) { |
| 833 | IntentId targetId = IntentId.valueOf(id); |
| 834 | for (IntentUpdate update : intentUpdates) { |
| 835 | List<Intent> installables = Lists.newArrayList(update.newInstallables()); |
| 836 | installables.addAll(update.oldInstallables()); |
| 837 | for (Intent intent : installables) { |
| 838 | if (intent.id().equals(targetId)) { |
Yuta HIGUCHI | c2bf3d8 | 2014-11-28 18:50:41 -0800 | [diff] [blame] | 839 | update.batchFailed(); |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 840 | break; |
| 841 | } |
| 842 | } |
| 843 | } |
| 844 | // don't increment the non-failed items, as they have been reverted. |
| 845 | } |
| 846 | } |
Brian O'Connor | fa81eae | 2014-10-30 13:20:05 -0700 | [diff] [blame] | 847 | } |
| 848 | |
| 849 | /** |
Brian O'Connor | f2dbde5 | 2014-10-10 16:20:24 -0700 | [diff] [blame] | 850 | * Iterate through the pending futures, and remove them when they have completed. |
| 851 | */ |
| 852 | private void processFutures() { |
Brian O'Connor | fa81eae | 2014-10-30 13:20:05 -0700 | [diff] [blame] | 853 | if (future == null) { |
Yuta HIGUCHI | 82e5326 | 2014-11-27 10:28:51 -0800 | [diff] [blame] | 854 | log.warn("I have no Future."); |
Brian O'Connor | fa81eae | 2014-10-30 13:20:05 -0700 | [diff] [blame] | 855 | return; //FIXME look at this |
Brian O'Connor | cb900f4 | 2014-10-07 21:55:33 -0700 | [diff] [blame] | 856 | } |
Brian O'Connor | fa81eae | 2014-10-30 13:20:05 -0700 | [diff] [blame] | 857 | try { |
| 858 | CompletedBatchOperation completed = future.get(100, TimeUnit.NANOSECONDS); |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 859 | updateBatches(completed); |
| 860 | future = applyNextBatch(); |
Brian O'Connor | fa81eae | 2014-10-30 13:20:05 -0700 | [diff] [blame] | 861 | } catch (TimeoutException | InterruptedException | ExecutionException te) { |
| 862 | //TODO look into error message |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 863 | log.debug("Installation of intents are still pending: {}", ops); |
Brian O'Connor | fa81eae | 2014-10-30 13:20:05 -0700 | [diff] [blame] | 864 | } |
Brian O'Connor | f2dbde5 | 2014-10-10 16:20:24 -0700 | [diff] [blame] | 865 | } |
| 866 | |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 867 | private void retry() { |
Yuta HIGUCHI | 82e5326 | 2014-11-27 10:28:51 -0800 | [diff] [blame] | 868 | log.debug("Execution timed out, retrying."); |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 869 | if (future.cancel(true)) { // cancel success; batch is reverted |
| 870 | // reset the timer |
Yuta HIGUCHI | 82e5326 | 2014-11-27 10:28:51 -0800 | [diff] [blame] | 871 | resetTimeoutLimit(); |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 872 | if (installAttempt++ >= MAX_ATTEMPTS) { |
| 873 | log.warn("Install request timed out: {}", ops); |
| 874 | for (IntentUpdate update : intentUpdates) { |
Yuta HIGUCHI | c2bf3d8 | 2014-11-28 18:50:41 -0800 | [diff] [blame] | 875 | update.batchFailed(); |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 876 | } |
| 877 | } // else just resubmit the work |
| 878 | future = applyNextBatch(); |
Yuta HIGUCHI | c2bf3d8 | 2014-11-28 18:50:41 -0800 | [diff] [blame] | 879 | executor.submit(this); |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 880 | } else { |
Yuta HIGUCHI | c2bf3d8 | 2014-11-28 18:50:41 -0800 | [diff] [blame] | 881 | log.error("Cancelling FlowRuleBatch failed."); |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 882 | // FIXME |
| 883 | // cancel failed... batch is broken; shouldn't happen! |
| 884 | // we could manually reverse everything |
| 885 | // ... or just core dump and send email to Ali |
| 886 | batchService.removeIntentOperations(ops); |
| 887 | } |
| 888 | } |
| 889 | |
| 890 | boolean isComplete() { |
| 891 | // TODO: actually check with the intent update? |
| 892 | return future == null; |
| 893 | } |
| 894 | |
Brian O'Connor | f2dbde5 | 2014-10-10 16:20:24 -0700 | [diff] [blame] | 895 | @Override |
| 896 | public void run() { |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 897 | try { |
| 898 | if (intentUpdates.isEmpty()) { |
| 899 | // this should only be called on the first iteration |
| 900 | // note: this a "expensive", so it is not done in the constructor |
Yuta HIGUCHI | c2bf3d8 | 2014-11-28 18:50:41 -0800 | [diff] [blame] | 901 | |
| 902 | // - creates per Intent installation context (IntentUpdate) |
| 903 | // - write Intents to store |
| 904 | // - process (compile, install, etc.) each Intents |
| 905 | // - generate FlowRuleBatch for this phase |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 906 | buildIntentUpdates(); |
| 907 | } |
Yuta HIGUCHI | c2bf3d8 | 2014-11-28 18:50:41 -0800 | [diff] [blame] | 908 | |
| 909 | // - peek if current FlowRuleBatch is complete |
| 910 | // -- If complete OK: |
| 911 | // step each IntentUpdate forward |
| 912 | // If phase left: generate next FlowRuleBatch |
| 913 | // If no more phase: write parking states |
| 914 | // -- If complete FAIL: |
| 915 | // Intent which failed: transition Intent to FAILED |
| 916 | // Other Intents: resubmit same FlowRuleBatch for this phase |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 917 | processFutures(); |
| 918 | if (isComplete()) { |
| 919 | // there are no outstanding batches; we are done |
| 920 | batchService.removeIntentOperations(ops); |
| 921 | } else if (endTime < System.currentTimeMillis()) { |
Yuta HIGUCHI | c2bf3d8 | 2014-11-28 18:50:41 -0800 | [diff] [blame] | 922 | // - cancel current FlowRuleBatch and resubmit again |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 923 | retry(); |
| 924 | } else { |
| 925 | // we are not done yet, yield the thread by resubmitting ourselves |
Yuta HIGUCHI | c2bf3d8 | 2014-11-28 18:50:41 -0800 | [diff] [blame] | 926 | executor.submit(this); |
Brian O'Connor | 427a176 | 2014-11-19 18:40:32 -0800 | [diff] [blame] | 927 | } |
| 928 | } catch (Exception e) { |
| 929 | log.error("Error submitting batches:", e); |
Yuta HIGUCHI | c2bf3d8 | 2014-11-28 18:50:41 -0800 | [diff] [blame] | 930 | // FIXME incomplete Intents should be cleaned up |
| 931 | // (transition to FAILED, etc.) |
Brian O'Connor | cb900f4 | 2014-10-07 21:55:33 -0700 | [diff] [blame] | 932 | } |
| 933 | } |
| 934 | } |
Brian O'Connor | fa81eae | 2014-10-30 13:20:05 -0700 | [diff] [blame] | 935 | |
| 936 | private class InternalBatchDelegate implements IntentBatchDelegate { |
| 937 | @Override |
| 938 | public void execute(IntentOperations operations) { |
Yuta HIGUCHI | fe4367a | 2014-11-24 19:19:09 -0800 | [diff] [blame] | 939 | log.info("Execute {} operation(s).", operations.operations().size()); |
| 940 | log.debug("Execute operations: {}", operations.operations()); |
Brian O'Connor | fa81eae | 2014-10-30 13:20:05 -0700 | [diff] [blame] | 941 | //FIXME: perhaps we want to track this task so that we can cancel it. |
Yuta HIGUCHI | c2bf3d8 | 2014-11-28 18:50:41 -0800 | [diff] [blame] | 942 | executor.execute(new IntentInstallMonitor(operations)); |
Brian O'Connor | fa81eae | 2014-10-30 13:20:05 -0700 | [diff] [blame] | 943 | } |
| 944 | |
| 945 | @Override |
| 946 | public void cancel(IntentOperations operations) { |
| 947 | //FIXME: implement this |
| 948 | log.warn("NOT IMPLEMENTED -- Cancel operations: {}", operations); |
| 949 | } |
| 950 | } |
Ray Milkey | e97ede9 | 2014-11-20 10:43:12 -0800 | [diff] [blame] | 951 | |
Brian O'Connor | 66630c8 | 2014-10-02 21:08:19 -0700 | [diff] [blame] | 952 | } |