Committed by
Gerrit Code Review
Move IntentUpdate subclasses to the dedicated package
Resolve ONOS-1051 - Create package "phase" under intent.impl - Rename IntentUpdate and CompletedIntentUpdate - IntentUpdate -> IntentProcessPhase - CompletedIntentUpdate -> FinalIntentProcessPhase - Loosen method/field visibility as short term hack Change-Id: Idc0fd9a74aadd227d62006d00fee473c63b1fc05
Showing
16 changed files
with
79 additions
and
62 deletions
... | @@ -47,6 +47,12 @@ import org.onosproject.net.intent.IntentState; | ... | @@ -47,6 +47,12 @@ import org.onosproject.net.intent.IntentState; |
47 | import org.onosproject.net.intent.IntentStore; | 47 | import org.onosproject.net.intent.IntentStore; |
48 | import org.onosproject.net.intent.IntentStoreDelegate; | 48 | import org.onosproject.net.intent.IntentStoreDelegate; |
49 | import org.onosproject.net.intent.Key; | 49 | import org.onosproject.net.intent.Key; |
50 | +import org.onosproject.net.intent.impl.phase.CompilingFailed; | ||
51 | +import org.onosproject.net.intent.impl.phase.FinalIntentProcessPhase; | ||
52 | +import org.onosproject.net.intent.impl.phase.InstallRequest; | ||
53 | +import org.onosproject.net.intent.impl.phase.IntentProcessPhase; | ||
54 | +import org.onosproject.net.intent.impl.phase.WithdrawRequest; | ||
55 | +import org.onosproject.net.intent.impl.phase.Withdrawn; | ||
50 | import org.slf4j.Logger; | 56 | import org.slf4j.Logger; |
51 | 57 | ||
52 | import java.util.ArrayList; | 58 | import java.util.ArrayList; |
... | @@ -112,8 +118,9 @@ public class IntentManager | ... | @@ -112,8 +118,9 @@ public class IntentManager |
112 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | 118 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
113 | protected EventDeliveryService eventDispatcher; | 119 | protected EventDeliveryService eventDispatcher; |
114 | 120 | ||
121 | + // TODO: make this protected due to short term hack for ONOS-1051 | ||
115 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | 122 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
116 | - protected FlowRuleService flowRuleService; | 123 | + public FlowRuleService flowRuleService; |
117 | 124 | ||
118 | 125 | ||
119 | private ExecutorService batchExecutor; | 126 | private ExecutorService batchExecutor; |
... | @@ -268,7 +275,8 @@ public class IntentManager | ... | @@ -268,7 +275,8 @@ public class IntentManager |
268 | * @param previousInstallables previous intent installables | 275 | * @param previousInstallables previous intent installables |
269 | * @return result of compilation | 276 | * @return result of compilation |
270 | */ | 277 | */ |
271 | - List<Intent> compileIntent(Intent intent, List<Intent> previousInstallables) { | 278 | + // TODO: make this non-public due to short term hack for ONOS-1051 |
279 | + public List<Intent> compileIntent(Intent intent, List<Intent> previousInstallables) { | ||
272 | if (intent.isInstallable()) { | 280 | if (intent.isInstallable()) { |
273 | return ImmutableList.of(intent); | 281 | return ImmutableList.of(intent); |
274 | } | 282 | } |
... | @@ -284,7 +292,8 @@ public class IntentManager | ... | @@ -284,7 +292,8 @@ public class IntentManager |
284 | 292 | ||
285 | //TODO javadoc | 293 | //TODO javadoc |
286 | //FIXME | 294 | //FIXME |
287 | - FlowRuleOperations coordinate(IntentData current, IntentData pending) { | 295 | + // TODO: make this non-public due to short term hack for ONOS-1051 |
296 | + public FlowRuleOperations coordinate(IntentData current, IntentData pending) { | ||
288 | List<Intent> oldInstallables = (current != null) ? current.installables() : null; | 297 | List<Intent> oldInstallables = (current != null) ? current.installables() : null; |
289 | List<Intent> newInstallables = pending.installables(); | 298 | List<Intent> newInstallables = pending.installables(); |
290 | 299 | ||
... | @@ -347,7 +356,8 @@ public class IntentManager | ... | @@ -347,7 +356,8 @@ public class IntentManager |
347 | * @param current intent data stored in the store | 356 | * @param current intent data stored in the store |
348 | * @return flow rule operations | 357 | * @return flow rule operations |
349 | */ | 358 | */ |
350 | - FlowRuleOperations uninstallCoordinate(IntentData current, IntentData pending) { | 359 | + // TODO: make this non-public due to short term hack for ONOS-1051 |
360 | + public FlowRuleOperations uninstallCoordinate(IntentData current, IntentData pending) { | ||
351 | List<Intent> installables = current.installables(); | 361 | List<Intent> installables = current.installables(); |
352 | List<List<FlowRuleBatchOperation>> plans = new ArrayList<>(); | 362 | List<List<FlowRuleBatchOperation>> plans = new ArrayList<>(); |
353 | for (Intent installable : installables) { | 363 | for (Intent installable : installables) { |
... | @@ -520,7 +530,7 @@ public class IntentManager | ... | @@ -520,7 +530,7 @@ public class IntentManager |
520 | } | 530 | } |
521 | } | 531 | } |
522 | 532 | ||
523 | - private IntentUpdate createIntentUpdate(IntentData intentData) { | 533 | + private IntentProcessPhase createIntentUpdate(IntentData intentData) { |
524 | IntentData current = store.getIntentData(intentData.key()); | 534 | IntentData current = store.getIntentData(intentData.key()); |
525 | switch (intentData.state()) { | 535 | switch (intentData.state()) { |
526 | case INSTALL_REQ: | 536 | case INSTALL_REQ: |
... | @@ -537,7 +547,7 @@ public class IntentManager | ... | @@ -537,7 +547,7 @@ public class IntentManager |
537 | } | 547 | } |
538 | } | 548 | } |
539 | 549 | ||
540 | - private Future<CompletedIntentUpdate> submitIntentData(IntentData data) { | 550 | + private Future<FinalIntentProcessPhase> submitIntentData(IntentData data) { |
541 | return workerExecutor.submit(new IntentWorker(data)); | 551 | return workerExecutor.submit(new IntentWorker(data)); |
542 | } | 552 | } |
543 | 553 | ||
... | @@ -590,15 +600,15 @@ public class IntentManager | ... | @@ -590,15 +600,15 @@ public class IntentManager |
590 | } | 600 | } |
591 | } | 601 | } |
592 | 602 | ||
593 | - private List<Future<CompletedIntentUpdate>> createIntentUpdates() { | 603 | + private List<Future<FinalIntentProcessPhase>> createIntentUpdates() { |
594 | return data.stream() | 604 | return data.stream() |
595 | .map(IntentManager.this::submitIntentData) | 605 | .map(IntentManager.this::submitIntentData) |
596 | .collect(Collectors.toList()); | 606 | .collect(Collectors.toList()); |
597 | } | 607 | } |
598 | 608 | ||
599 | - private List<CompletedIntentUpdate> waitForFutures(List<Future<CompletedIntentUpdate>> futures) { | 609 | + private List<FinalIntentProcessPhase> waitForFutures(List<Future<FinalIntentProcessPhase>> futures) { |
600 | - ImmutableList.Builder<CompletedIntentUpdate> updateBuilder = ImmutableList.builder(); | 610 | + ImmutableList.Builder<FinalIntentProcessPhase> updateBuilder = ImmutableList.builder(); |
601 | - for (Future<CompletedIntentUpdate> future : futures) { | 611 | + for (Future<FinalIntentProcessPhase> future : futures) { |
602 | try { | 612 | try { |
603 | updateBuilder.add(future.get()); | 613 | updateBuilder.add(future.get()); |
604 | } catch (InterruptedException | ExecutionException e) { | 614 | } catch (InterruptedException | ExecutionException e) { |
... | @@ -609,14 +619,14 @@ public class IntentManager | ... | @@ -609,14 +619,14 @@ public class IntentManager |
609 | return updateBuilder.build(); | 619 | return updateBuilder.build(); |
610 | } | 620 | } |
611 | 621 | ||
612 | - private void submitUpdates(List<CompletedIntentUpdate> updates) { | 622 | + private void submitUpdates(List<FinalIntentProcessPhase> updates) { |
613 | store.batchWrite(updates.stream() | 623 | store.batchWrite(updates.stream() |
614 | - .map(CompletedIntentUpdate::data) | 624 | + .map(FinalIntentProcessPhase::data) |
615 | .collect(Collectors.toList())); | 625 | .collect(Collectors.toList())); |
616 | } | 626 | } |
617 | } | 627 | } |
618 | 628 | ||
619 | - private final class IntentWorker implements Callable<CompletedIntentUpdate> { | 629 | + private final class IntentWorker implements Callable<FinalIntentProcessPhase> { |
620 | 630 | ||
621 | private final IntentData data; | 631 | private final IntentData data; |
622 | 632 | ||
... | @@ -625,16 +635,16 @@ public class IntentManager | ... | @@ -625,16 +635,16 @@ public class IntentManager |
625 | } | 635 | } |
626 | 636 | ||
627 | @Override | 637 | @Override |
628 | - public CompletedIntentUpdate call() throws Exception { | 638 | + public FinalIntentProcessPhase call() throws Exception { |
629 | - IntentUpdate update = createIntentUpdate(data); | 639 | + IntentProcessPhase update = createIntentUpdate(data); |
630 | - Optional<IntentUpdate> currentPhase = Optional.of(update); | 640 | + Optional<IntentProcessPhase> currentPhase = Optional.of(update); |
631 | - IntentUpdate previousPhase = update; | 641 | + IntentProcessPhase previousPhase = update; |
632 | 642 | ||
633 | while (currentPhase.isPresent()) { | 643 | while (currentPhase.isPresent()) { |
634 | previousPhase = currentPhase.get(); | 644 | previousPhase = currentPhase.get(); |
635 | currentPhase = previousPhase.execute(); | 645 | currentPhase = previousPhase.execute(); |
636 | } | 646 | } |
637 | - return (CompletedIntentUpdate) previousPhase; | 647 | + return (FinalIntentProcessPhase) previousPhase; |
638 | } | 648 | } |
639 | } | 649 | } |
640 | 650 | ... | ... |
... | @@ -13,7 +13,7 @@ | ... | @@ -13,7 +13,7 @@ |
13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | -package org.onosproject.net.intent.impl; | 16 | +package org.onosproject.net.intent.impl.phase; |
17 | 17 | ||
18 | import org.onosproject.net.intent.IntentData; | 18 | import org.onosproject.net.intent.IntentData; |
19 | 19 | ||
... | @@ -24,7 +24,7 @@ import static org.onosproject.net.intent.IntentState.FAILED; | ... | @@ -24,7 +24,7 @@ import static org.onosproject.net.intent.IntentState.FAILED; |
24 | * A common parent class of a class representing failure | 24 | * A common parent class of a class representing failure |
25 | * as IntentUpdate subclass. | 25 | * as IntentUpdate subclass. |
26 | */ | 26 | */ |
27 | -abstract class AbstractFailed extends CompletedIntentUpdate { | 27 | +abstract class AbstractFailed extends FinalIntentProcessPhase { |
28 | 28 | ||
29 | private final IntentData intentData; | 29 | private final IntentData intentData; |
30 | 30 | ... | ... |
... | @@ -13,11 +13,12 @@ | ... | @@ -13,11 +13,12 @@ |
13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | -package org.onosproject.net.intent.impl; | 16 | +package org.onosproject.net.intent.impl.phase; |
17 | 17 | ||
18 | import org.onosproject.net.intent.Intent; | 18 | import org.onosproject.net.intent.Intent; |
19 | import org.onosproject.net.intent.IntentData; | 19 | import org.onosproject.net.intent.IntentData; |
20 | import org.onosproject.net.intent.IntentException; | 20 | import org.onosproject.net.intent.IntentException; |
21 | +import org.onosproject.net.intent.impl.IntentManager; | ||
21 | import org.slf4j.Logger; | 22 | import org.slf4j.Logger; |
22 | import org.slf4j.LoggerFactory; | 23 | import org.slf4j.LoggerFactory; |
23 | 24 | ||
... | @@ -29,7 +30,7 @@ import static com.google.common.base.Preconditions.checkNotNull; | ... | @@ -29,7 +30,7 @@ import static com.google.common.base.Preconditions.checkNotNull; |
29 | /** | 30 | /** |
30 | * Represents a phase where an intent is being compiled. | 31 | * Represents a phase where an intent is being compiled. |
31 | */ | 32 | */ |
32 | -class Compiling implements IntentUpdate { | 33 | +final class Compiling implements IntentProcessPhase { |
33 | 34 | ||
34 | private static final Logger log = LoggerFactory.getLogger(Compiling.class); | 35 | private static final Logger log = LoggerFactory.getLogger(Compiling.class); |
35 | 36 | ||
... | @@ -45,7 +46,7 @@ class Compiling implements IntentUpdate { | ... | @@ -45,7 +46,7 @@ class Compiling implements IntentUpdate { |
45 | } | 46 | } |
46 | 47 | ||
47 | @Override | 48 | @Override |
48 | - public Optional<IntentUpdate> execute() { | 49 | + public Optional<IntentProcessPhase> execute() { |
49 | try { | 50 | try { |
50 | List<Intent> installables = (current != null) ? current.installables() : null; | 51 | List<Intent> installables = (current != null) ? current.installables() : null; |
51 | pending.setInstallables(intentManager.compileIntent(pending.intent(), installables)); | 52 | pending.setInstallables(intentManager.compileIntent(pending.intent(), installables)); | ... | ... |
... | @@ -13,21 +13,21 @@ | ... | @@ -13,21 +13,21 @@ |
13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | -package org.onosproject.net.intent.impl; | 16 | +package org.onosproject.net.intent.impl.phase; |
17 | 17 | ||
18 | import org.onosproject.net.intent.IntentData; | 18 | import org.onosproject.net.intent.IntentData; |
19 | 19 | ||
20 | /** | 20 | /** |
21 | * Represents a phase where the compile has failed. | 21 | * Represents a phase where the compile has failed. |
22 | */ | 22 | */ |
23 | -class CompilingFailed extends AbstractFailed { | 23 | +public class CompilingFailed extends AbstractFailed { |
24 | 24 | ||
25 | /** | 25 | /** |
26 | * Create an instance with the specified data. | 26 | * Create an instance with the specified data. |
27 | * | 27 | * |
28 | * @param intentData intentData | 28 | * @param intentData intentData |
29 | */ | 29 | */ |
30 | - CompilingFailed(IntentData intentData) { | 30 | + public CompilingFailed(IntentData intentData) { |
31 | super(intentData); | 31 | super(intentData); |
32 | } | 32 | } |
33 | } | 33 | } | ... | ... |
... | @@ -13,19 +13,19 @@ | ... | @@ -13,19 +13,19 @@ |
13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | -package org.onosproject.net.intent.impl; | 16 | +package org.onosproject.net.intent.impl.phase; |
17 | 17 | ||
18 | import org.onosproject.net.intent.IntentData; | 18 | import org.onosproject.net.intent.IntentData; |
19 | 19 | ||
20 | import java.util.Optional; | 20 | import java.util.Optional; |
21 | 21 | ||
22 | /** | 22 | /** |
23 | - * Represents a completed phase of processing an intent. | 23 | + * Represents a final phase of processing an intent. |
24 | */ | 24 | */ |
25 | -abstract class CompletedIntentUpdate implements IntentUpdate { | 25 | +public abstract class FinalIntentProcessPhase implements IntentProcessPhase { |
26 | 26 | ||
27 | @Override | 27 | @Override |
28 | - public final Optional<IntentUpdate> execute() { | 28 | + public final Optional<IntentProcessPhase> execute() { |
29 | return Optional.empty(); | 29 | return Optional.empty(); |
30 | } | 30 | } |
31 | 31 | ... | ... |
... | @@ -13,11 +13,12 @@ | ... | @@ -13,11 +13,12 @@ |
13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | -package org.onosproject.net.intent.impl; | 16 | +package org.onosproject.net.intent.impl.phase; |
17 | 17 | ||
18 | import org.onosproject.net.flow.FlowRuleOperations; | 18 | import org.onosproject.net.flow.FlowRuleOperations; |
19 | import org.onosproject.net.intent.IntentData; | 19 | import org.onosproject.net.intent.IntentData; |
20 | import org.onosproject.net.intent.IntentException; | 20 | import org.onosproject.net.intent.IntentException; |
21 | +import org.onosproject.net.intent.impl.IntentManager; | ||
21 | import org.slf4j.Logger; | 22 | import org.slf4j.Logger; |
22 | import org.slf4j.LoggerFactory; | 23 | import org.slf4j.LoggerFactory; |
23 | 24 | ||
... | @@ -29,7 +30,7 @@ import static com.google.common.base.Preconditions.checkNotNull; | ... | @@ -29,7 +30,7 @@ import static com.google.common.base.Preconditions.checkNotNull; |
29 | * Represents a phase to create a {@link FlowRuleOperations} instance | 30 | * Represents a phase to create a {@link FlowRuleOperations} instance |
30 | * with using registered intent installers. | 31 | * with using registered intent installers. |
31 | */ | 32 | */ |
32 | -class InstallCoordinating implements IntentUpdate { | 33 | +final class InstallCoordinating implements IntentProcessPhase { |
33 | 34 | ||
34 | private static final Logger log = LoggerFactory.getLogger(InstallCoordinating.class); | 35 | private static final Logger log = LoggerFactory.getLogger(InstallCoordinating.class); |
35 | 36 | ||
... | @@ -45,7 +46,7 @@ class InstallCoordinating implements IntentUpdate { | ... | @@ -45,7 +46,7 @@ class InstallCoordinating implements IntentUpdate { |
45 | } | 46 | } |
46 | 47 | ||
47 | @Override | 48 | @Override |
48 | - public Optional<IntentUpdate> execute() { | 49 | + public Optional<IntentProcessPhase> execute() { |
49 | try { | 50 | try { |
50 | //FIXME we orphan flow rules that are currently on the data plane | 51 | //FIXME we orphan flow rules that are currently on the data plane |
51 | // ... should either reuse them or remove them | 52 | // ... should either reuse them or remove them | ... | ... |
... | @@ -13,9 +13,10 @@ | ... | @@ -13,9 +13,10 @@ |
13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | -package org.onosproject.net.intent.impl; | 16 | +package org.onosproject.net.intent.impl.phase; |
17 | 17 | ||
18 | import org.onosproject.net.intent.IntentData; | 18 | import org.onosproject.net.intent.IntentData; |
19 | +import org.onosproject.net.intent.impl.IntentManager; | ||
19 | 20 | ||
20 | import java.util.Optional; | 21 | import java.util.Optional; |
21 | 22 | ||
... | @@ -24,21 +25,21 @@ import static com.google.common.base.Preconditions.checkNotNull; | ... | @@ -24,21 +25,21 @@ import static com.google.common.base.Preconditions.checkNotNull; |
24 | /** | 25 | /** |
25 | * Represents a phase where intent installation has been requested. | 26 | * Represents a phase where intent installation has been requested. |
26 | */ | 27 | */ |
27 | -class InstallRequest implements IntentUpdate { | 28 | +public final class InstallRequest implements IntentProcessPhase { |
28 | 29 | ||
29 | // TODO: define an interface and use it, instead of IntentManager | 30 | // TODO: define an interface and use it, instead of IntentManager |
30 | private final IntentManager intentManager; | 31 | private final IntentManager intentManager; |
31 | private final IntentData pending; | 32 | private final IntentData pending; |
32 | private final Optional<IntentData> current; | 33 | private final Optional<IntentData> current; |
33 | 34 | ||
34 | - InstallRequest(IntentManager intentManager, IntentData intentData, Optional<IntentData> current) { | 35 | + public InstallRequest(IntentManager intentManager, IntentData intentData, Optional<IntentData> current) { |
35 | this.intentManager = checkNotNull(intentManager); | 36 | this.intentManager = checkNotNull(intentManager); |
36 | this.pending = checkNotNull(intentData); | 37 | this.pending = checkNotNull(intentData); |
37 | this.current = checkNotNull(current); | 38 | this.current = checkNotNull(current); |
38 | } | 39 | } |
39 | 40 | ||
40 | @Override | 41 | @Override |
41 | - public Optional<IntentUpdate> execute() { | 42 | + public Optional<IntentProcessPhase> execute() { |
42 | return Optional.of(new Compiling(intentManager, pending, current.orElse(null))); | 43 | return Optional.of(new Compiling(intentManager, pending, current.orElse(null))); |
43 | } | 44 | } |
44 | } | 45 | } | ... | ... |
... | @@ -13,7 +13,7 @@ | ... | @@ -13,7 +13,7 @@ |
13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | -package org.onosproject.net.intent.impl; | 16 | +package org.onosproject.net.intent.impl.phase; |
17 | 17 | ||
18 | import org.onosproject.net.intent.IntentData; | 18 | import org.onosproject.net.intent.IntentData; |
19 | 19 | ||
... | @@ -23,7 +23,7 @@ import static org.onosproject.net.intent.IntentState.INSTALLING; | ... | @@ -23,7 +23,7 @@ import static org.onosproject.net.intent.IntentState.INSTALLING; |
23 | /** | 23 | /** |
24 | * Represent a phase where an intent has been installed. | 24 | * Represent a phase where an intent has been installed. |
25 | */ | 25 | */ |
26 | -class Installed extends CompletedIntentUpdate { | 26 | +class Installed extends FinalIntentProcessPhase { |
27 | 27 | ||
28 | private final IntentData intentData; | 28 | private final IntentData intentData; |
29 | 29 | ... | ... |
... | @@ -13,11 +13,12 @@ | ... | @@ -13,11 +13,12 @@ |
13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | -package org.onosproject.net.intent.impl; | 16 | +package org.onosproject.net.intent.impl.phase; |
17 | 17 | ||
18 | import org.onosproject.net.flow.FlowRuleOperations; | 18 | import org.onosproject.net.flow.FlowRuleOperations; |
19 | import org.onosproject.net.intent.IntentData; | 19 | import org.onosproject.net.intent.IntentData; |
20 | import org.onosproject.net.intent.IntentException; | 20 | import org.onosproject.net.intent.IntentException; |
21 | +import org.onosproject.net.intent.impl.IntentManager; | ||
21 | import org.slf4j.Logger; | 22 | import org.slf4j.Logger; |
22 | import org.slf4j.LoggerFactory; | 23 | import org.slf4j.LoggerFactory; |
23 | 24 | ||
... | @@ -29,7 +30,7 @@ import static com.google.common.base.Preconditions.checkNotNull; | ... | @@ -29,7 +30,7 @@ import static com.google.common.base.Preconditions.checkNotNull; |
29 | * Represents a phase of installing an intent with calling | 30 | * Represents a phase of installing an intent with calling |
30 | * {@link org.onosproject.net.flow.FlowRuleService}. | 31 | * {@link org.onosproject.net.flow.FlowRuleService}. |
31 | */ | 32 | */ |
32 | -class Installing implements IntentUpdate { | 33 | +final class Installing implements IntentProcessPhase { |
33 | 34 | ||
34 | private static final Logger log = LoggerFactory.getLogger(Installing.class); | 35 | private static final Logger log = LoggerFactory.getLogger(Installing.class); |
35 | 36 | ||
... | @@ -45,7 +46,7 @@ class Installing implements IntentUpdate { | ... | @@ -45,7 +46,7 @@ class Installing implements IntentUpdate { |
45 | } | 46 | } |
46 | 47 | ||
47 | @Override | 48 | @Override |
48 | - public Optional<IntentUpdate> execute() { | 49 | + public Optional<IntentProcessPhase> execute() { |
49 | try { | 50 | try { |
50 | intentManager.flowRuleService.apply(flowRules); // FIXME we need to provide a context | 51 | intentManager.flowRuleService.apply(flowRules); // FIXME we need to provide a context |
51 | return Optional.of(new Installed(pending)); | 52 | return Optional.of(new Installed(pending)); | ... | ... |
... | @@ -13,7 +13,7 @@ | ... | @@ -13,7 +13,7 @@ |
13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | -package org.onosproject.net.intent.impl; | 16 | +package org.onosproject.net.intent.impl.phase; |
17 | 17 | ||
18 | import org.onosproject.net.intent.IntentData; | 18 | import org.onosproject.net.intent.IntentData; |
19 | 19 | ... | ... |
... | @@ -13,14 +13,14 @@ | ... | @@ -13,14 +13,14 @@ |
13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | -package org.onosproject.net.intent.impl; | 16 | +package org.onosproject.net.intent.impl.phase; |
17 | 17 | ||
18 | import java.util.Optional; | 18 | import java.util.Optional; |
19 | 19 | ||
20 | /** | 20 | /** |
21 | * Represents a phase of processing an intent. | 21 | * Represents a phase of processing an intent. |
22 | */ | 22 | */ |
23 | -interface IntentUpdate { | 23 | +public interface IntentProcessPhase { |
24 | 24 | ||
25 | /** | 25 | /** |
26 | * Execute the procedure represented by the instance | 26 | * Execute the procedure represented by the instance |
... | @@ -28,5 +28,5 @@ interface IntentUpdate { | ... | @@ -28,5 +28,5 @@ interface IntentUpdate { |
28 | * | 28 | * |
29 | * @return next update | 29 | * @return next update |
30 | */ | 30 | */ |
31 | - Optional<IntentUpdate> execute(); | 31 | + Optional<IntentProcessPhase> execute(); |
32 | } | 32 | } | ... | ... |
... | @@ -13,11 +13,12 @@ | ... | @@ -13,11 +13,12 @@ |
13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | -package org.onosproject.net.intent.impl; | 16 | +package org.onosproject.net.intent.impl.phase; |
17 | 17 | ||
18 | import org.onosproject.net.flow.FlowRuleOperations; | 18 | import org.onosproject.net.flow.FlowRuleOperations; |
19 | import org.onosproject.net.intent.IntentData; | 19 | import org.onosproject.net.intent.IntentData; |
20 | import org.onosproject.net.intent.IntentException; | 20 | import org.onosproject.net.intent.IntentException; |
21 | +import org.onosproject.net.intent.impl.IntentManager; | ||
21 | import org.slf4j.Logger; | 22 | import org.slf4j.Logger; |
22 | import org.slf4j.LoggerFactory; | 23 | import org.slf4j.LoggerFactory; |
23 | 24 | ||
... | @@ -29,7 +30,7 @@ import static com.google.common.base.Preconditions.checkNotNull; | ... | @@ -29,7 +30,7 @@ import static com.google.common.base.Preconditions.checkNotNull; |
29 | * Represents a phase to create a {@link FlowRuleOperations} instance | 30 | * Represents a phase to create a {@link FlowRuleOperations} instance |
30 | * with using registered intent installers. | 31 | * with using registered intent installers. |
31 | */ | 32 | */ |
32 | -class WithdrawCoordinating implements IntentUpdate { | 33 | +final class WithdrawCoordinating implements IntentProcessPhase { |
33 | 34 | ||
34 | private static final Logger log = LoggerFactory.getLogger(WithdrawCoordinating.class); | 35 | private static final Logger log = LoggerFactory.getLogger(WithdrawCoordinating.class); |
35 | 36 | ||
... | @@ -45,7 +46,7 @@ class WithdrawCoordinating implements IntentUpdate { | ... | @@ -45,7 +46,7 @@ class WithdrawCoordinating implements IntentUpdate { |
45 | } | 46 | } |
46 | 47 | ||
47 | @Override | 48 | @Override |
48 | - public Optional<IntentUpdate> execute() { | 49 | + public Optional<IntentProcessPhase> execute() { |
49 | try { | 50 | try { |
50 | // Note: current.installables() are not null or empty due to createIntentUpdate check | 51 | // Note: current.installables() are not null or empty due to createIntentUpdate check |
51 | FlowRuleOperations flowRules = intentManager.uninstallCoordinate(current, pending); | 52 | FlowRuleOperations flowRules = intentManager.uninstallCoordinate(current, pending); | ... | ... |
... | @@ -13,9 +13,10 @@ | ... | @@ -13,9 +13,10 @@ |
13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | -package org.onosproject.net.intent.impl; | 16 | +package org.onosproject.net.intent.impl.phase; |
17 | 17 | ||
18 | import org.onosproject.net.intent.IntentData; | 18 | import org.onosproject.net.intent.IntentData; |
19 | +import org.onosproject.net.intent.impl.IntentManager; | ||
19 | 20 | ||
20 | import java.util.Optional; | 21 | import java.util.Optional; |
21 | 22 | ||
... | @@ -24,21 +25,21 @@ import static com.google.common.base.Preconditions.checkNotNull; | ... | @@ -24,21 +25,21 @@ import static com.google.common.base.Preconditions.checkNotNull; |
24 | /** | 25 | /** |
25 | * Represents a phase of requesting a withdraw of an intent. | 26 | * Represents a phase of requesting a withdraw of an intent. |
26 | */ | 27 | */ |
27 | -class WithdrawRequest implements IntentUpdate { | 28 | +public final class WithdrawRequest implements IntentProcessPhase { |
28 | 29 | ||
29 | // TODO: define an interface and use it, instead of IntentManager | 30 | // TODO: define an interface and use it, instead of IntentManager |
30 | private final IntentManager intentManager; | 31 | private final IntentManager intentManager; |
31 | private final IntentData pending; | 32 | private final IntentData pending; |
32 | private final IntentData current; | 33 | private final IntentData current; |
33 | 34 | ||
34 | - WithdrawRequest(IntentManager intentManager, IntentData intentData, IntentData current) { | 35 | + public WithdrawRequest(IntentManager intentManager, IntentData intentData, IntentData current) { |
35 | this.intentManager = checkNotNull(intentManager); | 36 | this.intentManager = checkNotNull(intentManager); |
36 | this.pending = checkNotNull(intentData); | 37 | this.pending = checkNotNull(intentData); |
37 | this.current = checkNotNull(current); | 38 | this.current = checkNotNull(current); |
38 | } | 39 | } |
39 | 40 | ||
40 | @Override | 41 | @Override |
41 | - public Optional<IntentUpdate> execute() { | 42 | + public Optional<IntentProcessPhase> execute() { |
42 | //TODO perhaps we want to validate that the pending and current are the | 43 | //TODO perhaps we want to validate that the pending and current are the |
43 | // same version i.e. they are the same | 44 | // same version i.e. they are the same |
44 | // Note: this call is not just the symmetric version of submit | 45 | // Note: this call is not just the symmetric version of submit | ... | ... |
... | @@ -13,10 +13,11 @@ | ... | @@ -13,10 +13,11 @@ |
13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | -package org.onosproject.net.intent.impl; | 16 | +package org.onosproject.net.intent.impl.phase; |
17 | 17 | ||
18 | import org.onosproject.net.flow.FlowRuleOperations; | 18 | import org.onosproject.net.flow.FlowRuleOperations; |
19 | import org.onosproject.net.intent.IntentData; | 19 | import org.onosproject.net.intent.IntentData; |
20 | +import org.onosproject.net.intent.impl.IntentManager; | ||
20 | 21 | ||
21 | import java.util.Optional; | 22 | import java.util.Optional; |
22 | 23 | ||
... | @@ -26,7 +27,7 @@ import static com.google.common.base.Preconditions.checkNotNull; | ... | @@ -26,7 +27,7 @@ import static com.google.common.base.Preconditions.checkNotNull; |
26 | * Represents a phase of withdrawing an intent with calling | 27 | * Represents a phase of withdrawing an intent with calling |
27 | * {@link org.onosproject.net.flow.FlowRuleService}. | 28 | * {@link org.onosproject.net.flow.FlowRuleService}. |
28 | */ | 29 | */ |
29 | -class Withdrawing implements IntentUpdate { | 30 | +class Withdrawing implements IntentProcessPhase { |
30 | 31 | ||
31 | // TODO: define an interface and use it, instead of IntentManager | 32 | // TODO: define an interface and use it, instead of IntentManager |
32 | private final IntentManager intentManager; | 33 | private final IntentManager intentManager; |
... | @@ -40,7 +41,7 @@ class Withdrawing implements IntentUpdate { | ... | @@ -40,7 +41,7 @@ class Withdrawing implements IntentUpdate { |
40 | } | 41 | } |
41 | 42 | ||
42 | @Override | 43 | @Override |
43 | - public Optional<IntentUpdate> execute() { | 44 | + public Optional<IntentProcessPhase> execute() { |
44 | intentManager.flowRuleService.apply(flowRules); | 45 | intentManager.flowRuleService.apply(flowRules); |
45 | return Optional.of(new Withdrawn(pending)); | 46 | return Optional.of(new Withdrawn(pending)); |
46 | } | 47 | } | ... | ... |
... | @@ -13,14 +13,14 @@ | ... | @@ -13,14 +13,14 @@ |
13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | -package org.onosproject.net.intent.impl; | 16 | +package org.onosproject.net.intent.impl.phase; |
17 | 17 | ||
18 | import org.onosproject.net.intent.IntentData; | 18 | import org.onosproject.net.intent.IntentData; |
19 | 19 | ||
20 | /** | 20 | /** |
21 | * Represents a phase where the withdraw has failed. | 21 | * Represents a phase where the withdraw has failed. |
22 | */ | 22 | */ |
23 | -class WithdrawingFailed extends AbstractFailed { | 23 | +final class WithdrawingFailed extends AbstractFailed { |
24 | 24 | ||
25 | /** | 25 | /** |
26 | * Create an instance with the specified data. | 26 | * Create an instance with the specified data. | ... | ... |
... | @@ -13,7 +13,7 @@ | ... | @@ -13,7 +13,7 @@ |
13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | -package org.onosproject.net.intent.impl; | 16 | +package org.onosproject.net.intent.impl.phase; |
17 | 17 | ||
18 | import org.onosproject.net.intent.IntentData; | 18 | import org.onosproject.net.intent.IntentData; |
19 | import org.onosproject.net.intent.IntentState; | 19 | import org.onosproject.net.intent.IntentState; |
... | @@ -24,15 +24,15 @@ import static org.onosproject.net.intent.IntentState.WITHDRAWING; | ... | @@ -24,15 +24,15 @@ import static org.onosproject.net.intent.IntentState.WITHDRAWING; |
24 | /** | 24 | /** |
25 | * Represents a phase where an intent has been withdrawn. | 25 | * Represents a phase where an intent has been withdrawn. |
26 | */ | 26 | */ |
27 | -class Withdrawn extends CompletedIntentUpdate { | 27 | +public final class Withdrawn extends FinalIntentProcessPhase { |
28 | 28 | ||
29 | private final IntentData intentData; | 29 | private final IntentData intentData; |
30 | 30 | ||
31 | - Withdrawn(IntentData intentData) { | 31 | + public Withdrawn(IntentData intentData) { |
32 | this(intentData, WITHDRAWING); | 32 | this(intentData, WITHDRAWING); |
33 | } | 33 | } |
34 | 34 | ||
35 | - Withdrawn(IntentData intentData, IntentState newState) { | 35 | + public Withdrawn(IntentData intentData, IntentState newState) { |
36 | this.intentData = checkNotNull(intentData); | 36 | this.intentData = checkNotNull(intentData); |
37 | this.intentData.setState(newState); | 37 | this.intentData.setState(newState); |
38 | } | 38 | } | ... | ... |
-
Please register or login to post a comment