Committed by
Gerrit Code Review
Fix NullPointerException with -s flag; add -s message
Change-Id: I6bc1e2326d0d260a0469e64b8d0ec2937694534c
Showing
1 changed file
with
13 additions
and
7 deletions
| ... | @@ -22,13 +22,14 @@ import org.onosproject.cli.AbstractShellCommand; | ... | @@ -22,13 +22,14 @@ import org.onosproject.cli.AbstractShellCommand; |
| 22 | import org.onosproject.core.ApplicationId; | 22 | import org.onosproject.core.ApplicationId; |
| 23 | import org.onosproject.core.CoreService; | 23 | import org.onosproject.core.CoreService; |
| 24 | import org.onosproject.net.intent.Intent; | 24 | import org.onosproject.net.intent.Intent; |
| 25 | -import org.onosproject.net.intent.IntentEvent; | ||
| 26 | -import org.onosproject.net.intent.IntentListener; | ||
| 27 | -import org.onosproject.net.intent.IntentService; | ||
| 28 | import org.onosproject.net.intent.IntentState; | 25 | import org.onosproject.net.intent.IntentState; |
| 26 | +import org.onosproject.net.intent.IntentService; | ||
| 27 | +import org.onosproject.net.intent.IntentListener; | ||
| 28 | +import org.onosproject.net.intent.IntentEvent; | ||
| 29 | import org.onosproject.net.intent.Key; | 29 | import org.onosproject.net.intent.Key; |
| 30 | 30 | ||
| 31 | import java.math.BigInteger; | 31 | import java.math.BigInteger; |
| 32 | +import java.util.EnumSet; | ||
| 32 | import java.util.Objects; | 33 | import java.util.Objects; |
| 33 | import java.util.concurrent.CountDownLatch; | 34 | import java.util.concurrent.CountDownLatch; |
| 34 | import java.util.concurrent.TimeUnit; | 35 | import java.util.concurrent.TimeUnit; |
| ... | @@ -64,11 +65,18 @@ public class IntentRemoveCommand extends AbstractShellCommand { | ... | @@ -64,11 +65,18 @@ public class IntentRemoveCommand extends AbstractShellCommand { |
| 64 | required = false, multiValued = false) | 65 | required = false, multiValued = false) |
| 65 | private boolean sync = false; | 66 | private boolean sync = false; |
| 66 | 67 | ||
| 68 | + private static final EnumSet<IntentState> CAN_PURGE = EnumSet.of(WITHDRAWN, FAILED); | ||
| 69 | + | ||
| 67 | @Override | 70 | @Override |
| 68 | protected void execute() { | 71 | protected void execute() { |
| 69 | IntentService intentService = get(IntentService.class); | 72 | IntentService intentService = get(IntentService.class); |
| 70 | CoreService coreService = get(CoreService.class); | 73 | CoreService coreService = get(CoreService.class); |
| 71 | 74 | ||
| 75 | + if (sync) { | ||
| 76 | + print("Use Sync to remove intents - this may take a while..."); | ||
| 77 | + print("Check \"summary\" to see remove progress."); | ||
| 78 | + } | ||
| 79 | + | ||
| 72 | ApplicationId appId = appId(); | 80 | ApplicationId appId = appId(); |
| 73 | if (!isNullOrEmpty(applicationIdString)) { | 81 | if (!isNullOrEmpty(applicationIdString)) { |
| 74 | appId = coreService.getAppId(applicationIdString); | 82 | appId = coreService.getAppId(applicationIdString); |
| ... | @@ -137,11 +145,8 @@ public class IntentRemoveCommand extends AbstractShellCommand { | ... | @@ -137,11 +145,8 @@ public class IntentRemoveCommand extends AbstractShellCommand { |
| 137 | } catch (InterruptedException e) { | 145 | } catch (InterruptedException e) { |
| 138 | print("Timed out waiting for intent {} withdraw", key); | 146 | print("Timed out waiting for intent {} withdraw", key); |
| 139 | } | 147 | } |
| 140 | - // double check the state | 148 | + if (purgeAfterRemove && CAN_PURGE.contains(intentService.getIntentState(key))) { |
| 141 | - IntentState state = intentService.getIntentState(key); | ||
| 142 | - if (purgeAfterRemove && (state == WITHDRAWN || state == FAILED)) { | ||
| 143 | intentService.purge(intent); | 149 | intentService.purge(intent); |
| 144 | - } | ||
| 145 | if (sync) { // wait for purge event | 150 | if (sync) { // wait for purge event |
| 146 | /* TODO | 151 | /* TODO |
| 147 | Technically, the event comes before map.remove() is called. | 152 | Technically, the event comes before map.remove() is called. |
| ... | @@ -155,6 +160,7 @@ public class IntentRemoveCommand extends AbstractShellCommand { | ... | @@ -155,6 +160,7 @@ public class IntentRemoveCommand extends AbstractShellCommand { |
| 155 | } | 160 | } |
| 156 | } | 161 | } |
| 157 | } | 162 | } |
| 163 | + } | ||
| 158 | 164 | ||
| 159 | if (listener != null) { | 165 | if (listener != null) { |
| 160 | // clean up the listener | 166 | // clean up the listener | ... | ... |
-
Please register or login to post a comment