Committed by
Brian O'Connor
Avoid unnecessary state transition
Change state from WithdrawRequest to Withdrawn directly when there is nothing in the store with the key Change-Id: Ia38d02bcff8df7aad35fbb975843c6741ff540f4
Showing
2 changed files
with
5 additions
and
5 deletions
... | @@ -17,7 +17,6 @@ package org.onosproject.net.intent.impl; | ... | @@ -17,7 +17,6 @@ package org.onosproject.net.intent.impl; |
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.IntentState; | ||
21 | 20 | ||
22 | import java.util.Optional; | 21 | import java.util.Optional; |
23 | 22 | ||
... | @@ -37,14 +36,11 @@ class WithdrawCoordinating implements IntentUpdate { | ... | @@ -37,14 +36,11 @@ class WithdrawCoordinating implements IntentUpdate { |
37 | WithdrawCoordinating(IntentManager intentManager, IntentData pending, IntentData current) { | 36 | WithdrawCoordinating(IntentManager intentManager, IntentData pending, IntentData current) { |
38 | this.intentManager = checkNotNull(intentManager); | 37 | this.intentManager = checkNotNull(intentManager); |
39 | this.pending = checkNotNull(pending); | 38 | this.pending = checkNotNull(pending); |
40 | - this.current = current; | 39 | + this.current = checkNotNull(current); |
41 | } | 40 | } |
42 | 41 | ||
43 | @Override | 42 | @Override |
44 | public Optional<IntentUpdate> execute() { | 43 | public Optional<IntentUpdate> execute() { |
45 | - if (current == null) { // there's nothing in the store with this key | ||
46 | - return Optional.of(new Withdrawn(pending, IntentState.WITHDRAWN)); | ||
47 | - } | ||
48 | FlowRuleOperations flowRules = intentManager.uninstallCoordinate(current, pending); | 44 | FlowRuleOperations flowRules = intentManager.uninstallCoordinate(current, pending); |
49 | pending.setInstallables(current.installables()); | 45 | pending.setInstallables(current.installables()); |
50 | return Optional.of(new Withdrawing(intentManager, pending, flowRules)); | 46 | return Optional.of(new Withdrawing(intentManager, pending, flowRules)); | ... | ... |
... | @@ -20,6 +20,7 @@ import org.onosproject.net.intent.IntentData; | ... | @@ -20,6 +20,7 @@ import org.onosproject.net.intent.IntentData; |
20 | import java.util.Optional; | 20 | import java.util.Optional; |
21 | 21 | ||
22 | import static com.google.common.base.Preconditions.checkNotNull; | 22 | import static com.google.common.base.Preconditions.checkNotNull; |
23 | +import static org.onosproject.net.intent.IntentState.WITHDRAWN; | ||
23 | 24 | ||
24 | /** | 25 | /** |
25 | * Represents a phase of requesting a withdraw of an intent. | 26 | * Represents a phase of requesting a withdraw of an intent. |
... | @@ -39,6 +40,9 @@ class WithdrawRequest implements IntentUpdate { | ... | @@ -39,6 +40,9 @@ class WithdrawRequest implements IntentUpdate { |
39 | public Optional<IntentUpdate> execute() { | 40 | public Optional<IntentUpdate> execute() { |
40 | //FIXME need store interface | 41 | //FIXME need store interface |
41 | IntentData current = intentManager.store.getIntentData(pending.key()); | 42 | IntentData current = intentManager.store.getIntentData(pending.key()); |
43 | + if (current == null) { | ||
44 | + return Optional.of(new Withdrawn(pending, WITHDRAWN)); | ||
45 | + } | ||
42 | //TODO perhaps we want to validate that the pending and current are the | 46 | //TODO perhaps we want to validate that the pending and current are the |
43 | // same version i.e. they are the same | 47 | // same version i.e. they are the same |
44 | // Note: this call is not just the symmetric version of submit | 48 | // Note: this call is not just the symmetric version of submit | ... | ... |
-
Please register or login to post a comment