Committed by
Brian O'Connor
Remove calls of IntentStore.batchWrite()
We are changing the write behavior to IntentStore, then calls of IntentStore.batchWrite will be replaced. Change-Id: Id9685d5631fea02f1d2ef30e12c503c7cf2c44ef
Showing
4 changed files
with
0 additions
and
91 deletions
... | @@ -15,11 +15,9 @@ | ... | @@ -15,11 +15,9 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.net.intent.impl; | 16 | package org.onosproject.net.intent.impl; |
17 | 17 | ||
18 | -import org.onosproject.net.intent.BatchWrite; | ||
19 | import org.onosproject.net.intent.Intent; | 18 | import org.onosproject.net.intent.Intent; |
20 | 19 | ||
21 | import static com.google.common.base.Preconditions.checkNotNull; | 20 | import static com.google.common.base.Preconditions.checkNotNull; |
22 | -import static org.onosproject.net.intent.IntentState.FAILED; | ||
23 | 21 | ||
24 | /** | 22 | /** |
25 | * A processing phase after compilation failure. | 23 | * A processing phase after compilation failure. |
... | @@ -36,10 +34,4 @@ class CompilingFailed implements CompletedIntentUpdate { | ... | @@ -36,10 +34,4 @@ class CompilingFailed implements CompletedIntentUpdate { |
36 | CompilingFailed(Intent intent) { | 34 | CompilingFailed(Intent intent) { |
37 | this.intent = checkNotNull(intent); | 35 | this.intent = checkNotNull(intent); |
38 | } | 36 | } |
39 | - | ||
40 | - @Override | ||
41 | - public void writeAfterExecution(BatchWrite batchWrite) { | ||
42 | - batchWrite.setState(intent, FAILED); | ||
43 | - batchWrite.removeInstalledIntents(intent.id()); | ||
44 | - } | ||
45 | } | 37 | } | ... | ... |
... | @@ -16,7 +16,6 @@ | ... | @@ -16,7 +16,6 @@ |
16 | package org.onosproject.net.intent.impl; | 16 | package org.onosproject.net.intent.impl; |
17 | 17 | ||
18 | import org.onosproject.net.flow.FlowRuleBatchOperation; | 18 | import org.onosproject.net.flow.FlowRuleBatchOperation; |
19 | -import org.onosproject.net.intent.BatchWrite; | ||
20 | import org.onosproject.net.intent.Intent; | 19 | import org.onosproject.net.intent.Intent; |
21 | 20 | ||
22 | import java.util.Collections; | 21 | import java.util.Collections; |
... | @@ -29,13 +28,6 @@ import java.util.Optional; | ... | @@ -29,13 +28,6 @@ import java.util.Optional; |
29 | interface CompletedIntentUpdate extends IntentUpdate { | 28 | interface CompletedIntentUpdate extends IntentUpdate { |
30 | 29 | ||
31 | /** | 30 | /** |
32 | - * Write data to the specified BatchWrite after execution() is called. | ||
33 | - * | ||
34 | - * @param batchWrite batchWrite | ||
35 | - */ | ||
36 | - default void writeAfterExecution(BatchWrite batchWrite) {} | ||
37 | - | ||
38 | - /** | ||
39 | * Moves forward with the contained current batch. | 31 | * Moves forward with the contained current batch. |
40 | * This method is invoked when the batch is successfully completed. | 32 | * This method is invoked when the batch is successfully completed. |
41 | */ | 33 | */ | ... | ... |
... | @@ -45,7 +45,6 @@ import org.onosproject.event.EventDeliveryService; | ... | @@ -45,7 +45,6 @@ import org.onosproject.event.EventDeliveryService; |
45 | import org.onosproject.net.flow.CompletedBatchOperation; | 45 | import org.onosproject.net.flow.CompletedBatchOperation; |
46 | import org.onosproject.net.flow.FlowRuleBatchOperation; | 46 | import org.onosproject.net.flow.FlowRuleBatchOperation; |
47 | import org.onosproject.net.flow.FlowRuleService; | 47 | import org.onosproject.net.flow.FlowRuleService; |
48 | -import org.onosproject.net.intent.BatchWrite; | ||
49 | import org.onosproject.net.intent.Intent; | 48 | import org.onosproject.net.intent.Intent; |
50 | import org.onosproject.net.intent.IntentBatchDelegate; | 49 | import org.onosproject.net.intent.IntentBatchDelegate; |
51 | import org.onosproject.net.intent.IntentCompiler; | 50 | import org.onosproject.net.intent.IntentCompiler; |
... | @@ -70,10 +69,8 @@ import static com.google.common.base.Preconditions.checkNotNull; | ... | @@ -70,10 +69,8 @@ import static com.google.common.base.Preconditions.checkNotNull; |
70 | import static java.util.concurrent.Executors.newFixedThreadPool; | 69 | import static java.util.concurrent.Executors.newFixedThreadPool; |
71 | import static org.onlab.util.Tools.namedThreads; | 70 | import static org.onlab.util.Tools.namedThreads; |
72 | import static org.onosproject.net.intent.IntentState.FAILED; | 71 | import static org.onosproject.net.intent.IntentState.FAILED; |
73 | -import static org.onosproject.net.intent.IntentState.INSTALLED; | ||
74 | import static org.onosproject.net.intent.IntentState.INSTALLING; | 72 | import static org.onosproject.net.intent.IntentState.INSTALLING; |
75 | import static org.onosproject.net.intent.IntentState.INSTALL_REQ; | 73 | import static org.onosproject.net.intent.IntentState.INSTALL_REQ; |
76 | -import static org.onosproject.net.intent.IntentState.WITHDRAWN; | ||
77 | import static org.onosproject.net.intent.IntentState.WITHDRAW_REQ; | 74 | import static org.onosproject.net.intent.IntentState.WITHDRAW_REQ; |
78 | import static org.slf4j.LoggerFactory.getLogger; | 75 | import static org.slf4j.LoggerFactory.getLogger; |
79 | 76 | ||
... | @@ -447,13 +444,6 @@ public class IntentManager | ... | @@ -447,13 +444,6 @@ public class IntentManager |
447 | } | 444 | } |
448 | 445 | ||
449 | @Override | 446 | @Override |
450 | - public void writeBeforeExecution(BatchWrite batchWrite) { | ||
451 | - // TODO consider only "creating" intent if it does not exist | ||
452 | - // Note: We need to set state to INSTALL_REQ regardless. | ||
453 | - batchWrite.createIntent(intent); | ||
454 | - } | ||
455 | - | ||
456 | - @Override | ||
457 | public Optional<IntentUpdate> execute() { | 447 | public Optional<IntentUpdate> execute() { |
458 | return Optional.of(new Compiling(intent)); //FIXME | 448 | return Optional.of(new Compiling(intent)); //FIXME |
459 | } | 449 | } |
... | @@ -470,11 +460,6 @@ public class IntentManager | ... | @@ -470,11 +460,6 @@ public class IntentManager |
470 | } | 460 | } |
471 | 461 | ||
472 | @Override | 462 | @Override |
473 | - public void writeBeforeExecution(BatchWrite batchWrite) { | ||
474 | - batchWrite.setState(intent, WITHDRAW_REQ); | ||
475 | - } | ||
476 | - | ||
477 | - @Override | ||
478 | public Optional<IntentUpdate> execute() { | 463 | public Optional<IntentUpdate> execute() { |
479 | return Optional.of(new Withdrawing(intent, currentState.installables())); //FIXME | 464 | return Optional.of(new Withdrawing(intent, currentState.installables())); //FIXME |
480 | } | 465 | } |
... | @@ -583,22 +568,6 @@ public class IntentManager | ... | @@ -583,22 +568,6 @@ public class IntentManager |
583 | } | 568 | } |
584 | 569 | ||
585 | @Override | 570 | @Override |
586 | - public void writeAfterExecution(BatchWrite batchWrite) { | ||
587 | - switch (intentState) { | ||
588 | - case INSTALLING: | ||
589 | - batchWrite.setState(intent, INSTALLED); | ||
590 | - batchWrite.setInstallableIntents(intent.id(), this.installables); | ||
591 | - break; | ||
592 | - case FAILED: | ||
593 | - batchWrite.setState(intent, FAILED); | ||
594 | - batchWrite.removeInstalledIntents(intent.id()); | ||
595 | - break; | ||
596 | - default: | ||
597 | - break; | ||
598 | - } | ||
599 | - } | ||
600 | - | ||
601 | - @Override | ||
602 | public FlowRuleBatchOperation currentBatch() { | 571 | public FlowRuleBatchOperation currentBatch() { |
603 | return currentBatch < batches.size() ? batches.get(currentBatch) : null; | 572 | return currentBatch < batches.size() ? batches.get(currentBatch) : null; |
604 | } | 573 | } |
... | @@ -640,13 +609,6 @@ public class IntentManager | ... | @@ -640,13 +609,6 @@ public class IntentManager |
640 | } | 609 | } |
641 | 610 | ||
642 | @Override | 611 | @Override |
643 | - public void writeAfterExecution(BatchWrite batchWrite) { | ||
644 | - batchWrite.setState(intent, WITHDRAWN); | ||
645 | - batchWrite.removeInstalledIntents(intent.id()); | ||
646 | - batchWrite.removeIntent(intent.id()); | ||
647 | - } | ||
648 | - | ||
649 | - @Override | ||
650 | public FlowRuleBatchOperation currentBatch() { | 612 | public FlowRuleBatchOperation currentBatch() { |
651 | return currentBatch < batches.size() ? batches.get(currentBatch) : null; | 613 | return currentBatch < batches.size() ? batches.get(currentBatch) : null; |
652 | } | 614 | } |
... | @@ -684,12 +646,6 @@ public class IntentManager | ... | @@ -684,12 +646,6 @@ public class IntentManager |
684 | } | 646 | } |
685 | 647 | ||
686 | @Override | 648 | @Override |
687 | - public void writeAfterExecution(BatchWrite batchWrite) { | ||
688 | - batchWrite.setState(intent, FAILED); | ||
689 | - batchWrite.removeInstalledIntents(intent.id()); | ||
690 | - } | ||
691 | - | ||
692 | - @Override | ||
693 | public FlowRuleBatchOperation currentBatch() { | 649 | public FlowRuleBatchOperation currentBatch() { |
694 | return currentBatch < batches.size() ? batches.get(currentBatch) : null; | 650 | return currentBatch < batches.size() ? batches.get(currentBatch) : null; |
695 | } | 651 | } |
... | @@ -736,10 +692,6 @@ public class IntentManager | ... | @@ -736,10 +692,6 @@ public class IntentManager |
736 | try { | 692 | try { |
737 | List<IntentUpdate> updates = createIntentUpdates(); | 693 | List<IntentUpdate> updates = createIntentUpdates(); |
738 | 694 | ||
739 | - // Write batch information | ||
740 | - BatchWrite batchWrite = createBatchWrite(updates); | ||
741 | - store.batchWrite(batchWrite); | ||
742 | - | ||
743 | new IntentBatchApplyFirst(ops, processIntentUpdates(updates), endTime, 0, null).run(); | 695 | new IntentBatchApplyFirst(ops, processIntentUpdates(updates), endTime, 0, null).run(); |
744 | } catch (Exception e) { | 696 | } catch (Exception e) { |
745 | log.error("Error submitting batches:", e); | 697 | log.error("Error submitting batches:", e); |
... | @@ -760,12 +712,6 @@ public class IntentManager | ... | @@ -760,12 +712,6 @@ public class IntentManager |
760 | .collect(Collectors.toList()); | 712 | .collect(Collectors.toList()); |
761 | } | 713 | } |
762 | 714 | ||
763 | - private BatchWrite createBatchWrite(List<IntentUpdate> updates) { | ||
764 | - BatchWrite batchWrite = BatchWrite.newInstance(); | ||
765 | - updates.forEach(update -> update.writeBeforeExecution(batchWrite)); | ||
766 | - return batchWrite; | ||
767 | - } | ||
768 | - | ||
769 | private List<CompletedIntentUpdate> processIntentUpdates(List<IntentUpdate> updates) { | 715 | private List<CompletedIntentUpdate> processIntentUpdates(List<IntentUpdate> updates) { |
770 | // start processing each Intents | 716 | // start processing each Intents |
771 | List<CompletedIntentUpdate> completed = new ArrayList<>(); | 717 | List<CompletedIntentUpdate> completed = new ArrayList<>(); |
... | @@ -821,10 +767,6 @@ public class IntentManager | ... | @@ -821,10 +767,6 @@ public class IntentManager |
821 | //FIXME apply batch might throw an exception | 767 | //FIXME apply batch might throw an exception |
822 | return flowRuleService.applyBatch(batch); | 768 | return flowRuleService.applyBatch(batch); |
823 | } else { | 769 | } else { |
824 | - // there are no flow rule batches; finalize the intent update | ||
825 | - BatchWrite batchWrite = createFinalizedBatchWrite(updates); | ||
826 | - | ||
827 | - store.batchWrite(batchWrite); | ||
828 | return null; | 770 | return null; |
829 | } | 771 | } |
830 | } | 772 | } |
... | @@ -840,14 +782,6 @@ public class IntentManager | ... | @@ -840,14 +782,6 @@ public class IntentManager |
840 | return batch; | 782 | return batch; |
841 | } | 783 | } |
842 | 784 | ||
843 | - private BatchWrite createFinalizedBatchWrite(List<CompletedIntentUpdate> intentUpdates) { | ||
844 | - BatchWrite batchWrite = BatchWrite.newInstance(); | ||
845 | - for (CompletedIntentUpdate update : intentUpdates) { | ||
846 | - update.writeAfterExecution(batchWrite); | ||
847 | - } | ||
848 | - return batchWrite; | ||
849 | - } | ||
850 | - | ||
851 | protected void abandonShip() { | 785 | protected void abandonShip() { |
852 | // the batch has failed | 786 | // the batch has failed |
853 | // TODO: maybe we should do more? | 787 | // TODO: maybe we should do more? | ... | ... |
... | @@ -15,8 +15,6 @@ | ... | @@ -15,8 +15,6 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.net.intent.impl; | 16 | package org.onosproject.net.intent.impl; |
17 | 17 | ||
18 | -import org.onosproject.net.intent.BatchWrite; | ||
19 | - | ||
20 | import java.util.Optional; | 18 | import java.util.Optional; |
21 | 19 | ||
22 | /** | 20 | /** |
... | @@ -31,11 +29,4 @@ interface IntentUpdate { | ... | @@ -31,11 +29,4 @@ interface IntentUpdate { |
31 | * @return next update | 29 | * @return next update |
32 | */ | 30 | */ |
33 | Optional<IntentUpdate> execute(); | 31 | Optional<IntentUpdate> execute(); |
34 | - | ||
35 | - /** | ||
36 | - * Write data to the specified BatchWrite before execution() is called. | ||
37 | - * | ||
38 | - * @param batchWrite batchWrite | ||
39 | - */ | ||
40 | - default void writeBeforeExecution(BatchWrite batchWrite) {} | ||
41 | } | 32 | } | ... | ... |
-
Please register or login to post a comment