Modify test app usages of Property annotations for new OSGi implementation
Change-Id: Ie16cc4c41541f9e199c0c9e5f1338ee617097942
diff --git a/apps/test/flow-perf/src/main/java/org/onosproject/flowperf/FlowPerfApp.java b/apps/test/flow-perf/src/main/java/org/onosproject/flowperf/FlowPerfApp.java
index 9ee3559..9a6e3a7 100644
--- a/apps/test/flow-perf/src/main/java/org/onosproject/flowperf/FlowPerfApp.java
+++ b/apps/test/flow-perf/src/main/java/org/onosproject/flowperf/FlowPerfApp.java
@@ -54,6 +54,12 @@
import static com.google.common.base.Strings.isNullOrEmpty;
import static org.onlab.util.Tools.get;
+import static org.onosproject.flowperf.OsgiPropertyConstants.BATCH_SIZE;
+import static org.onosproject.flowperf.OsgiPropertyConstants.BATCH_SIZE_DEFAULT;
+import static org.onosproject.flowperf.OsgiPropertyConstants.TOTAL_FLOWS;
+import static org.onosproject.flowperf.OsgiPropertyConstants.TOTAL_FLOWS_DEFAULT;
+import static org.onosproject.flowperf.OsgiPropertyConstants.TOTAL_THREADS;
+import static org.onosproject.flowperf.OsgiPropertyConstants.TOTAL_THREADS_DEFAULT;
import static org.osgi.service.component.annotations.ReferenceCardinality.MANDATORY;
import static org.slf4j.LoggerFactory.getLogger;
@@ -63,7 +69,15 @@
* This application installs a bunch of flows, validates that all those flows have
* been successfully added and immediately proceeds to remove all the added flows.
*/
-@Component(immediate = true, service = FlowPerfApp.class)
+@Component(
+ immediate = true,
+ service = FlowPerfApp.class,
+ property = {
+ TOTAL_FLOWS + ":Integer=" + TOTAL_FLOWS_DEFAULT,
+ BATCH_SIZE + ":Integer=" + BATCH_SIZE_DEFAULT,
+ TOTAL_THREADS + ":Integer=" + TOTAL_THREADS_DEFAULT
+ }
+)
public class FlowPerfApp {
private final Logger log = getLogger(getClass());
@@ -81,9 +95,6 @@
protected ApplicationId appId;
- private static final int DEFAULT_BATCH_SIZE = 200;
- private static final int DEFAULT_TOTAL_THREADS = 1;
- private static final int DEFAULT_TOTAL_FLOWS = 100000;
private AtomicInteger pendingBatchCount;
private CountDownLatch installationLatch;
private CountDownLatch uninstallationLatch;
@@ -92,17 +103,14 @@
List<FlowRule> addedRules = Lists.newArrayList();
- //@Property(name = "totalFlows", intValue = DEFAULT_TOTAL_FLOWS,
- // label = "Total number of flows")
- protected int totalFlows = DEFAULT_TOTAL_FLOWS;
+ /** Total number of flows. */
+ private int totalFlows = TOTAL_FLOWS_DEFAULT;
- //@Property(name = "batchSize", intValue = DEFAULT_BATCH_SIZE,
- // label = "Number of flows per batch")
- protected int batchSize = DEFAULT_BATCH_SIZE;
+ /** Number of flows per batch. */
+ private int batchSize = BATCH_SIZE_DEFAULT;
- //@Property(name = "totalThreads", intValue = DEFAULT_TOTAL_THREADS,
- // label = "Number of installer threads")
- protected int totalThreads = DEFAULT_TOTAL_THREADS;
+ /** Number of installer threads. */
+ private int totalThreads = TOTAL_THREADS_DEFAULT;
private ExecutorService installer;
private ExecutorService testRunner =
@@ -219,9 +227,9 @@
@Modified
public void modified(ComponentContext context) {
if (context == null) {
- totalFlows = DEFAULT_TOTAL_FLOWS;
- batchSize = DEFAULT_BATCH_SIZE;
- totalThreads = DEFAULT_TOTAL_THREADS;
+ totalFlows = TOTAL_FLOWS_DEFAULT;
+ batchSize = BATCH_SIZE_DEFAULT;
+ totalThreads = TOTAL_THREADS_DEFAULT;
return;
}
@@ -231,15 +239,15 @@
int newBatchSize = batchSize;
int newTotalThreads = totalThreads;
try {
- String s = get(properties, "batchSize");
+ String s = get(properties, TOTAL_FLOWS);
newTotalFlows = isNullOrEmpty(s)
? totalFlows : Integer.parseInt(s.trim());
- s = get(properties, "batchSize");
+ s = get(properties, BATCH_SIZE);
newBatchSize = isNullOrEmpty(s)
? batchSize : Integer.parseInt(s.trim());
- s = get(properties, "totalThreads");
+ s = get(properties, TOTAL_THREADS);
newTotalThreads = isNullOrEmpty(s)
? totalThreads : Integer.parseInt(s.trim());
@@ -263,4 +271,4 @@
installer = Executors.newFixedThreadPool(totalThreads, Tools.groupedThreads("flow-perf-worker", "%d"));
}
}
-}
\ No newline at end of file
+}