blob: 8f4683394fda038df70c25ddf899e4a907d289d7 [file] [log] [blame]
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07001/*
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'Connorabafb502014-12-02 22:26:20 -080016package org.onosproject.net.intent.impl;
Brian O'Connor66630c82014-10-02 21:08:19 -070017
Brian O'Connor64a0369d2015-02-20 22:02:59 -080018import com.google.common.collect.ImmutableList;
Brian O'Connor66630c82014-10-02 21:08:19 -070019import org.apache.felix.scr.annotations.Activate;
20import org.apache.felix.scr.annotations.Component;
21import org.apache.felix.scr.annotations.Deactivate;
22import org.apache.felix.scr.annotations.Reference;
23import org.apache.felix.scr.annotations.ReferenceCardinality;
24import org.apache.felix.scr.annotations.Service;
Brian O'Connorabafb502014-12-02 22:26:20 -080025import org.onosproject.core.CoreService;
26import org.onosproject.core.IdGenerator;
27import org.onosproject.event.AbstractListenerRegistry;
28import org.onosproject.event.EventDeliveryService;
Brian O'Connor0e271dc2015-02-04 18:20:25 -080029import org.onosproject.net.flow.FlowRuleOperations;
Brian O'Connorabafb502014-12-02 22:26:20 -080030import org.onosproject.net.flow.FlowRuleService;
31import org.onosproject.net.intent.Intent;
32import org.onosproject.net.intent.IntentBatchDelegate;
Brian O'Connorabafb502014-12-02 22:26:20 -080033import org.onosproject.net.intent.IntentCompiler;
Brian O'Connorcff03322015-02-03 15:28:59 -080034import org.onosproject.net.intent.IntentData;
Brian O'Connorabafb502014-12-02 22:26:20 -080035import org.onosproject.net.intent.IntentEvent;
Brian O'Connorabafb502014-12-02 22:26:20 -080036import org.onosproject.net.intent.IntentExtensionService;
Brian O'Connorabafb502014-12-02 22:26:20 -080037import org.onosproject.net.intent.IntentInstaller;
38import org.onosproject.net.intent.IntentListener;
Brian O'Connorabafb502014-12-02 22:26:20 -080039import org.onosproject.net.intent.IntentService;
40import org.onosproject.net.intent.IntentState;
41import org.onosproject.net.intent.IntentStore;
Brian O'Connorabafb502014-12-02 22:26:20 -080042import org.onosproject.net.intent.IntentStoreDelegate;
Ray Milkeyf9af43c2015-02-09 16:45:48 -080043import org.onosproject.net.intent.Key;
Sho SHIMIZU36a8a6e2015-02-13 15:38:45 -080044import org.onosproject.net.intent.impl.phase.FinalIntentProcessPhase;
Sho SHIMIZUce49b602015-02-23 19:15:49 -080045import org.onosproject.net.intent.impl.phase.IntentProcessPhase;
Sho SHIMIZU662c3db2015-02-23 16:59:01 -080046import org.onosproject.net.intent.impl.phase.IntentWorker;
Brian O'Connor66630c82014-10-02 21:08:19 -070047import org.slf4j.Logger;
48
Brian O'Connor64a0369d2015-02-20 22:02:59 -080049import java.util.Collection;
Brian O'Connor64a0369d2015-02-20 22:02:59 -080050import java.util.EnumSet;
Brian O'Connor64a0369d2015-02-20 22:02:59 -080051import java.util.List;
52import java.util.Map;
Brian O'Connor64a0369d2015-02-20 22:02:59 -080053import java.util.concurrent.ExecutionException;
54import java.util.concurrent.ExecutorService;
55import java.util.concurrent.Future;
56import java.util.stream.Collectors;
Brian O'Connorfa81eae2014-10-30 13:20:05 -070057
Brian O'Connorfa81eae2014-10-30 13:20:05 -070058import static com.google.common.base.Preconditions.checkNotNull;
Yuta HIGUCHIc2bf3d82014-11-28 18:50:41 -080059import static java.util.concurrent.Executors.newFixedThreadPool;
Brian O'Connordb15b042015-02-04 14:59:28 -080060import static java.util.concurrent.Executors.newSingleThreadExecutor;
Brian O'Connorbdc7f002015-02-18 20:49:41 -080061import static org.onlab.util.Tools.groupedThreads;
Sho SHIMIZUb0a47d42015-02-19 13:26:30 -080062import static org.onosproject.net.intent.IntentState.FAILED;
63import static org.onosproject.net.intent.IntentState.INSTALL_REQ;
Sho SHIMIZUb0a47d42015-02-19 13:26:30 -080064import static org.onosproject.net.intent.IntentState.WITHDRAW_REQ;
Sho SHIMIZUce49b602015-02-23 19:15:49 -080065import static org.onosproject.net.intent.impl.phase.IntentProcessPhase.newInitialPhase;
Brian O'Connorfa81eae2014-10-30 13:20:05 -070066import static org.slf4j.LoggerFactory.getLogger;
Brian O'Connor66630c82014-10-02 21:08:19 -070067
68/**
69 * An implementation of Intent Manager.
70 */
71@Component(immediate = true)
72@Service
73public class IntentManager
74 implements IntentService, IntentExtensionService {
Sho SHIMIZU8b5051d2014-11-05 11:24:13 -080075 private static final Logger log = getLogger(IntentManager.class);
Brian O'Connor66630c82014-10-02 21:08:19 -070076
77 public static final String INTENT_NULL = "Intent cannot be null";
Ray Milkeyf9af43c2015-02-09 16:45:48 -080078 public static final String INTENT_ID_NULL = "Intent key cannot be null";
Brian O'Connor66630c82014-10-02 21:08:19 -070079
Yuta HIGUCHIc2bf3d82014-11-28 18:50:41 -080080 private static final int NUM_THREADS = 12;
81
Brian O'Connor7a71d5d2014-12-02 00:12:27 -080082 private static final EnumSet<IntentState> RECOMPILE
83 = EnumSet.of(INSTALL_REQ, FAILED, WITHDRAW_REQ);
Brian O'Connor7a71d5d2014-12-02 00:12:27 -080084
Brian O'Connor66630c82014-10-02 21:08:19 -070085 private final AbstractListenerRegistry<IntentEvent, IntentListener>
tom95329eb2014-10-06 08:40:06 -070086 listenerRegistry = new AbstractListenerRegistry<>();
Brian O'Connor66630c82014-10-02 21:08:19 -070087
Brian O'Connor520c0522014-11-23 23:50:47 -080088 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
89 protected CoreService coreService;
Brian O'Connor66630c82014-10-02 21:08:19 -070090
91 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
92 protected IntentStore store;
93
94 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
tom85258ee2014-10-07 00:10:02 -070095 protected ObjectiveTrackerService trackerService;
tom95329eb2014-10-06 08:40:06 -070096
97 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
Brian O'Connor66630c82014-10-02 21:08:19 -070098 protected EventDeliveryService eventDispatcher;
99
Sho SHIMIZU36a8a6e2015-02-13 15:38:45 -0800100 // TODO: make this protected due to short term hack for ONOS-1051
Brian O'Connorf2dbde52014-10-10 16:20:24 -0700101 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
Sho SHIMIZU36a8a6e2015-02-13 15:38:45 -0800102 public FlowRuleService flowRuleService;
Brian O'Connorf2dbde52014-10-10 16:20:24 -0700103
Brian O'Connor520c0522014-11-23 23:50:47 -0800104
Brian O'Connordb15b042015-02-04 14:59:28 -0800105 private ExecutorService batchExecutor;
106 private ExecutorService workerExecutor;
Brian O'Connor520c0522014-11-23 23:50:47 -0800107
Sho SHIMIZUb0a47d42015-02-19 13:26:30 -0800108 private final CompilerRegistry compilerRegistry = new CompilerRegistry();
109 private final InstallerRegistry installerRegistry = new InstallerRegistry();
110 private final InternalIntentProcessor processor = new InternalIntentProcessor();
Brian O'Connor520c0522014-11-23 23:50:47 -0800111 private final IntentStoreDelegate delegate = new InternalStoreDelegate();
112 private final TopologyChangeDelegate topoDelegate = new InternalTopoChangeDelegate();
113 private final IntentBatchDelegate batchDelegate = new InternalBatchDelegate();
114 private IdGenerator idGenerator;
115
Brian O'Connorb499b352015-02-03 16:46:15 -0800116 private final IntentAccumulator accumulator = new IntentAccumulator(batchDelegate);
Brian O'Connorcff03322015-02-03 15:28:59 -0800117
Brian O'Connor66630c82014-10-02 21:08:19 -0700118 @Activate
119 public void activate() {
120 store.setDelegate(delegate);
tom95329eb2014-10-06 08:40:06 -0700121 trackerService.setDelegate(topoDelegate);
Brian O'Connor66630c82014-10-02 21:08:19 -0700122 eventDispatcher.addSink(IntentEvent.class, listenerRegistry);
Brian O'Connorbdc7f002015-02-18 20:49:41 -0800123 batchExecutor = newSingleThreadExecutor(groupedThreads("onos/intent", "batch"));
124 workerExecutor = newFixedThreadPool(NUM_THREADS, groupedThreads("onos/intent", "worker-%d"));
Brian O'Connor520c0522014-11-23 23:50:47 -0800125 idGenerator = coreService.getIdGenerator("intent-ids");
126 Intent.bindIdGenerator(idGenerator);
Brian O'Connor66630c82014-10-02 21:08:19 -0700127 log.info("Started");
128 }
129
130 @Deactivate
131 public void deactivate() {
132 store.unsetDelegate(delegate);
tom95329eb2014-10-06 08:40:06 -0700133 trackerService.unsetDelegate(topoDelegate);
Brian O'Connor66630c82014-10-02 21:08:19 -0700134 eventDispatcher.removeSink(IntentEvent.class);
Brian O'Connordb15b042015-02-04 14:59:28 -0800135 batchExecutor.shutdown();
Brian O'Connor520c0522014-11-23 23:50:47 -0800136 Intent.unbindIdGenerator(idGenerator);
Brian O'Connor66630c82014-10-02 21:08:19 -0700137 log.info("Stopped");
138 }
139
140 @Override
141 public void submit(Intent intent) {
142 checkNotNull(intent, INTENT_NULL);
Brian O'Connorcff03322015-02-03 15:28:59 -0800143 IntentData data = new IntentData(intent, IntentState.INSTALL_REQ, null);
Brian O'Connorcff03322015-02-03 15:28:59 -0800144 store.addPending(data);
Brian O'Connor66630c82014-10-02 21:08:19 -0700145 }
146
147 @Override
148 public void withdraw(Intent intent) {
149 checkNotNull(intent, INTENT_NULL);
Brian O'Connorcff03322015-02-03 15:28:59 -0800150 IntentData data = new IntentData(intent, IntentState.WITHDRAW_REQ, null);
Brian O'Connorcff03322015-02-03 15:28:59 -0800151 store.addPending(data);
Brian O'Connor66630c82014-10-02 21:08:19 -0700152 }
153
Brian O'Connor66630c82014-10-02 21:08:19 -0700154 @Override
Ray Milkeyf9af43c2015-02-09 16:45:48 -0800155 public Intent getIntent(Key key) {
156 return store.getIntent(key);
157 }
158
159 @Override
Brian O'Connor66630c82014-10-02 21:08:19 -0700160 public Iterable<Intent> getIntents() {
161 return store.getIntents();
162 }
163
164 @Override
165 public long getIntentCount() {
166 return store.getIntentCount();
167 }
168
169 @Override
Ray Milkeyf9af43c2015-02-09 16:45:48 -0800170 public IntentState getIntentState(Key intentKey) {
171 checkNotNull(intentKey, INTENT_ID_NULL);
172 return store.getIntentState(intentKey);
Brian O'Connor66630c82014-10-02 21:08:19 -0700173 }
174
175 @Override
Ray Milkeyf9af43c2015-02-09 16:45:48 -0800176 public List<Intent> getInstallableIntents(Key intentKey) {
177 checkNotNull(intentKey, INTENT_ID_NULL);
178 return store.getInstallableIntents(intentKey);
Thomas Vachuska10d4abc2014-10-21 12:47:26 -0700179 }
180
181 @Override
Brian O'Connorbe28a872015-02-19 21:44:37 -0800182 public boolean isLocal(Key intentKey) {
183 return store.isMaster(intentKey);
184 }
185
186 @Override
Brian O'Connor66630c82014-10-02 21:08:19 -0700187 public void addListener(IntentListener listener) {
188 listenerRegistry.addListener(listener);
189 }
190
191 @Override
192 public void removeListener(IntentListener listener) {
193 listenerRegistry.removeListener(listener);
194 }
195
196 @Override
197 public <T extends Intent> void registerCompiler(Class<T> cls, IntentCompiler<T> compiler) {
Sho SHIMIZUb0a47d42015-02-19 13:26:30 -0800198 compilerRegistry.registerCompiler(cls, compiler);
Brian O'Connor66630c82014-10-02 21:08:19 -0700199 }
200
201 @Override
202 public <T extends Intent> void unregisterCompiler(Class<T> cls) {
Sho SHIMIZUb0a47d42015-02-19 13:26:30 -0800203 compilerRegistry.unregisterCompiler(cls);
Brian O'Connor66630c82014-10-02 21:08:19 -0700204 }
205
206 @Override
207 public Map<Class<? extends Intent>, IntentCompiler<? extends Intent>> getCompilers() {
Sho SHIMIZUb0a47d42015-02-19 13:26:30 -0800208 return compilerRegistry.getCompilers();
Brian O'Connor66630c82014-10-02 21:08:19 -0700209 }
210
211 @Override
Thomas Vachuskab97cf282014-10-20 23:31:12 -0700212 public <T extends Intent> void registerInstaller(Class<T> cls, IntentInstaller<T> installer) {
Sho SHIMIZUb0a47d42015-02-19 13:26:30 -0800213 installerRegistry.registerInstaller(cls, installer);
Brian O'Connor66630c82014-10-02 21:08:19 -0700214 }
215
216 @Override
Thomas Vachuskab97cf282014-10-20 23:31:12 -0700217 public <T extends Intent> void unregisterInstaller(Class<T> cls) {
Sho SHIMIZUb0a47d42015-02-19 13:26:30 -0800218 installerRegistry.unregisterInstaller(cls);
Brian O'Connor66630c82014-10-02 21:08:19 -0700219 }
220
221 @Override
Thomas Vachuskab97cf282014-10-20 23:31:12 -0700222 public Map<Class<? extends Intent>, IntentInstaller<? extends Intent>> getInstallers() {
Sho SHIMIZUb0a47d42015-02-19 13:26:30 -0800223 return installerRegistry.getInstallers();
Brian O'Connor66630c82014-10-02 21:08:19 -0700224 }
225
Brian O'Connor66630c82014-10-02 21:08:19 -0700226 // Store delegate to re-post events emitted from the store.
227 private class InternalStoreDelegate implements IntentStoreDelegate {
228 @Override
229 public void notify(IntentEvent event) {
tom85258ee2014-10-07 00:10:02 -0700230 eventDispatcher.post(event);
Brian O'Connor66630c82014-10-02 21:08:19 -0700231 }
Brian O'Connorea4d7d12015-01-28 16:37:46 -0800232
233 @Override
Brian O'Connorcff03322015-02-03 15:28:59 -0800234 public void process(IntentData data) {
235 accumulator.add(data);
Brian O'Connorea4d7d12015-01-28 16:37:46 -0800236 }
Brian O'Connor66630c82014-10-02 21:08:19 -0700237 }
238
Ray Milkeyf9af43c2015-02-09 16:45:48 -0800239 private void buildAndSubmitBatches(Iterable<Key> intentKeys,
Brian O'Connor72a034c2014-11-26 18:24:23 -0800240 boolean compileAllFailed) {
Brian O'Connor72a034c2014-11-26 18:24:23 -0800241 // Attempt recompilation of the specified intents first.
Ray Milkeyf9af43c2015-02-09 16:45:48 -0800242 for (Key key : intentKeys) {
243 Intent intent = store.getIntent(key);
Brian O'Connor72a034c2014-11-26 18:24:23 -0800244 if (intent == null) {
245 continue;
246 }
Brian O'Connor03406a42015-02-03 17:28:57 -0800247 submit(intent);
Brian O'Connor72a034c2014-11-26 18:24:23 -0800248 }
249
250 if (compileAllFailed) {
251 // If required, compile all currently failed intents.
252 for (Intent intent : getIntents()) {
Ray Milkeyf9af43c2015-02-09 16:45:48 -0800253 IntentState state = getIntentState(intent.key());
Brian O'Connor7a71d5d2014-12-02 00:12:27 -0800254 if (RECOMPILE.contains(state)) {
Brian O'Connor7a71d5d2014-12-02 00:12:27 -0800255 if (state == WITHDRAW_REQ) {
Brian O'Connor03406a42015-02-03 17:28:57 -0800256 withdraw(intent);
Brian O'Connor7a71d5d2014-12-02 00:12:27 -0800257 } else {
Brian O'Connor03406a42015-02-03 17:28:57 -0800258 submit(intent);
Brian O'Connor7a71d5d2014-12-02 00:12:27 -0800259 }
Brian O'Connor72a034c2014-11-26 18:24:23 -0800260 }
261 }
262 }
263
Brian O'Connorb499b352015-02-03 16:46:15 -0800264 //FIXME
265// for (ApplicationId appId : batches.keySet()) {
266// if (batchService.isLocalLeader(appId)) {
267// execute(batches.get(appId).build());
268// }
269// }
Brian O'Connor72a034c2014-11-26 18:24:23 -0800270 }
271
tom95329eb2014-10-06 08:40:06 -0700272 // Topology change delegate
273 private class InternalTopoChangeDelegate implements TopologyChangeDelegate {
274 @Override
Ray Milkeyf9af43c2015-02-09 16:45:48 -0800275 public void triggerCompile(Iterable<Key> intentKeys,
tom85258ee2014-10-07 00:10:02 -0700276 boolean compileAllFailed) {
Ray Milkeyf9af43c2015-02-09 16:45:48 -0800277 buildAndSubmitBatches(intentKeys, compileAllFailed);
tom95329eb2014-10-06 08:40:06 -0700278 }
tom95329eb2014-10-06 08:40:06 -0700279 }
tom85258ee2014-10-07 00:10:02 -0700280
Sho SHIMIZU36a8a6e2015-02-13 15:38:45 -0800281 private Future<FinalIntentProcessPhase> submitIntentData(IntentData data) {
Sho SHIMIZU0cb6fe62015-02-23 16:39:57 -0800282 IntentData current = store.getIntentData(data.key());
Sho SHIMIZUce49b602015-02-23 19:15:49 -0800283 IntentProcessPhase initial = newInitialPhase(processor, data, current);
284 return workerExecutor.submit(new IntentWorker(initial));
Sho SHIMIZU8d9d1362015-02-04 12:28:15 -0800285 }
286
Sho SHIMIZUadf8c482014-12-12 18:23:29 -0800287 private class IntentBatchPreprocess implements Runnable {
288
289 // TODO make this configurable
290 private static final int TIMEOUT_PER_OP = 500; // ms
291 protected static final int MAX_ATTEMPTS = 3;
292
Sho SHIMIZU5f281a42015-02-04 15:29:11 -0800293 protected final Collection<IntentData> data;
Sho SHIMIZUadf8c482014-12-12 18:23:29 -0800294
295 // future holding current FlowRuleBatch installation result
296 protected final long startTime = System.currentTimeMillis();
297 protected final long endTime;
298
Sho SHIMIZU5f281a42015-02-04 15:29:11 -0800299 private IntentBatchPreprocess(Collection<IntentData> data, long endTime) {
300 this.data = checkNotNull(data);
Sho SHIMIZUadf8c482014-12-12 18:23:29 -0800301 this.endTime = endTime;
302 }
303
Sho SHIMIZU5f281a42015-02-04 15:29:11 -0800304 public IntentBatchPreprocess(Collection<IntentData> data) {
305 this(data, System.currentTimeMillis() + data.size() * TIMEOUT_PER_OP);
Sho SHIMIZUadf8c482014-12-12 18:23:29 -0800306 }
307
308 // FIXME compute reasonable timeouts
309 protected long calculateTimeoutLimit() {
Sho SHIMIZU5f281a42015-02-04 15:29:11 -0800310 return System.currentTimeMillis() + data.size() * TIMEOUT_PER_OP;
Sho SHIMIZUadf8c482014-12-12 18:23:29 -0800311 }
312
313 @Override
314 public void run() {
315 try {
Brian O'Connor0e271dc2015-02-04 18:20:25 -0800316 /*
317 1. wrap each intentdata in a runnable and submit
318 2. wait for completion of all the work
319 3. accumulate results and submit batch write of IntentData to store
320 (we can also try to update these individually)
321 */
322 submitUpdates(waitForFutures(createIntentUpdates()));
Sho SHIMIZUadf8c482014-12-12 18:23:29 -0800323 } catch (Exception e) {
324 log.error("Error submitting batches:", e);
325 // FIXME incomplete Intents should be cleaned up
326 // (transition to FAILED, etc.)
327
Sho SHIMIZUadf8c482014-12-12 18:23:29 -0800328 // the batch has failed
329 // TODO: maybe we should do more?
330 log.error("Walk the plank, matey...");
Brian O'Connorb499b352015-02-03 16:46:15 -0800331 //FIXME
Sho SHIMIZU5f281a42015-02-04 15:29:11 -0800332// batchService.removeIntentOperations(data);
Sho SHIMIZUadf8c482014-12-12 18:23:29 -0800333 }
334 }
335
Sho SHIMIZU36a8a6e2015-02-13 15:38:45 -0800336 private List<Future<FinalIntentProcessPhase>> createIntentUpdates() {
Sho SHIMIZU5f281a42015-02-04 15:29:11 -0800337 return data.stream()
Brian O'Connor0e271dc2015-02-04 18:20:25 -0800338 .map(IntentManager.this::submitIntentData)
339 .collect(Collectors.toList());
340 }
341
Sho SHIMIZU36a8a6e2015-02-13 15:38:45 -0800342 private List<FinalIntentProcessPhase> waitForFutures(List<Future<FinalIntentProcessPhase>> futures) {
343 ImmutableList.Builder<FinalIntentProcessPhase> updateBuilder = ImmutableList.builder();
344 for (Future<FinalIntentProcessPhase> future : futures) {
Brian O'Connor0e271dc2015-02-04 18:20:25 -0800345 try {
346 updateBuilder.add(future.get());
347 } catch (InterruptedException | ExecutionException e) {
348 //FIXME
349 log.warn("Future failed: {}", e);
350 }
351 }
352 return updateBuilder.build();
353 }
354
Sho SHIMIZU36a8a6e2015-02-13 15:38:45 -0800355 private void submitUpdates(List<FinalIntentProcessPhase> updates) {
Brian O'Connor0e271dc2015-02-04 18:20:25 -0800356 store.batchWrite(updates.stream()
Sho SHIMIZU36a8a6e2015-02-13 15:38:45 -0800357 .map(FinalIntentProcessPhase::data)
Brian O'Connor0e271dc2015-02-04 18:20:25 -0800358 .collect(Collectors.toList()));
Sho SHIMIZUadf8c482014-12-12 18:23:29 -0800359 }
Sho SHIMIZUadf8c482014-12-12 18:23:29 -0800360 }
Yuta HIGUCHIc2bf3d82014-11-28 18:50:41 -0800361
Brian O'Connorfa81eae2014-10-30 13:20:05 -0700362 private class InternalBatchDelegate implements IntentBatchDelegate {
363 @Override
Brian O'Connorb499b352015-02-03 16:46:15 -0800364 public void execute(Collection<IntentData> operations) {
Brian O'Connorab8ef822015-02-17 18:08:54 -0800365 log.debug("Execute {} operation(s).", operations.size());
366 log.trace("Execute operations: {}", operations);
Brian O'Connordb15b042015-02-04 14:59:28 -0800367 batchExecutor.execute(new IntentBatchPreprocess(operations));
368 // TODO ensure that only one batch is in flight at a time
Brian O'Connorfa81eae2014-10-30 13:20:05 -0700369 }
Brian O'Connorfa81eae2014-10-30 13:20:05 -0700370 }
Sho SHIMIZUb0a47d42015-02-19 13:26:30 -0800371
372 private class InternalIntentProcessor implements IntentProcessor {
373 @Override
374 public List<Intent> compile(Intent intent, List<Intent> previousInstallables) {
375 return compilerRegistry.compile(intent, previousInstallables);
376 }
377
378 @Override
379 public FlowRuleOperations coordinate(IntentData current, IntentData pending) {
380 return installerRegistry.coordinate(current, pending, store, trackerService);
381 }
382
383 @Override
384 public FlowRuleOperations uninstallCoordinate(IntentData current, IntentData pending) {
385 return installerRegistry.uninstallCoordinate(current, pending, store, trackerService);
386 }
387
388 @Override
389 public void applyFlowRules(FlowRuleOperations flowRules) {
390 flowRuleService.apply(flowRules);
391 }
392 }
Brian O'Connor66630c82014-10-02 21:08:19 -0700393}