[ONOS-6510] Fix Intent perf aplication logic
Change-Id: Ib43cc062c413d8d7b92f21dd6794ebf67b077172
(cherry picked from commit 356d1250def0f1f23eb6af282fa8aca91c24c62f)
diff --git a/apps/test/intent-perf/src/main/java/org/onosproject/intentperf/IntentPerfInstaller.java b/apps/test/intent-perf/src/main/java/org/onosproject/intentperf/IntentPerfInstaller.java
index e68c13c..8e1ad06 100644
--- a/apps/test/intent-perf/src/main/java/org/onosproject/intentperf/IntentPerfInstaller.java
+++ b/apps/test/intent-perf/src/main/java/org/onosproject/intentperf/IntentPerfInstaller.java
@@ -389,6 +389,9 @@
return Sets.newHashSet(intents.values());
}
+ final Set<Intent> submitted = Sets.newConcurrentHashSet();
+ final Set<Intent> withdrawn = Sets.newConcurrentHashSet();
+
// Submits intent operations.
final class Submitter implements Runnable {
@@ -396,8 +399,7 @@
private int lastCount;
private Set<Intent> intents = Sets.newHashSet();
- private Set<Intent> submitted = Sets.newHashSet();
- private Set<Intent> withdrawn = Sets.newHashSet();
+
private Submitter(Set<Intent> intents) {
this.intents = intents;
@@ -421,20 +423,18 @@
private Iterable<Intent> subset(Set<Intent> intents) {
List<Intent> subset = Lists.newArrayList(intents);
Collections.shuffle(subset);
- return subset.subList(0, Math.min(intents.size(), lastCount));
+ return subset.subList(0, Math.min(subset.size(), lastCount));
}
// Submits the specified intent.
private void submit(Intent intent) {
intentService.submit(intent);
- submitted.add(intent);
withdrawn.remove(intent); //TODO could check result here...
}
// Withdraws the specified intent.
private void withdraw(Intent intent) {
intentService.withdraw(intent);
- withdrawn.add(intent);
submitted.remove(intent); //TODO could check result here...
}
@@ -533,6 +533,12 @@
@Override
public void event(IntentEvent event) {
if (event.subject().appId().equals(appId)) {
+ if (event.type() == INSTALLED) {
+ submitted.add(event.subject());
+ }
+ if (event.type() == WITHDRAWN) {
+ withdrawn.add(event.subject());
+ }
counters.get(event.type()).add(1);
}
}