Modify test app usages of Property annotations for new OSGi implementation
Change-Id: Ie16cc4c41541f9e199c0c9e5f1338ee617097942
diff --git a/apps/segmentrouting/app/src/main/java/org/onosproject/segmentrouting/SegmentRoutingManager.java b/apps/segmentrouting/app/src/main/java/org/onosproject/segmentrouting/SegmentRoutingManager.java
index a21e12b..17e733c 100644
--- a/apps/segmentrouting/app/src/main/java/org/onosproject/segmentrouting/SegmentRoutingManager.java
+++ b/apps/segmentrouting/app/src/main/java/org/onosproject/segmentrouting/SegmentRoutingManager.java
@@ -618,14 +618,14 @@
return;
}
- String strActiveProbing = Tools.get(properties, "activeProbing");
+ String strActiveProbing = Tools.get(properties, PROP_ACTIVE_PROBING);
boolean expectActiveProbing = Boolean.parseBoolean(strActiveProbing);
if (expectActiveProbing != activeProbing) {
activeProbing = expectActiveProbing;
log.info("{} active probing", activeProbing ? "Enabling" : "Disabling");
}
- String strSingleHomedDown = Tools.get(properties, "singleHomedDown");
+ String strSingleHomedDown = Tools.get(properties, PROP_SINGLE_HOMED_DOWN);
boolean expectSingleHomedDown = Boolean.parseBoolean(strSingleHomedDown);
if (expectSingleHomedDown != singleHomedDown) {
singleHomedDown = expectSingleHomedDown;
@@ -644,14 +644,14 @@
}
}
- String strRespondToUnknownHosts = Tools.get(properties, "respondToUnknownHosts");
+ String strRespondToUnknownHosts = Tools.get(properties, PROP_RESPOND_TO_UNKNOWN_HOSTS);
boolean expectRespondToUnknownHosts = Boolean.parseBoolean(strRespondToUnknownHosts);
if (expectRespondToUnknownHosts != respondToUnknownHosts) {
respondToUnknownHosts = expectRespondToUnknownHosts;
log.info("{} responding to ARPs/NDPs from unknown hosts", respondToUnknownHosts ? "Enabling" : "Disabling");
}
- String strRouteDoubleTaggedHosts = Tools.get(properties, "routeDoubleTaggedHosts");
+ String strRouteDoubleTaggedHosts = Tools.get(properties, PROP_ROUTE_DOUBLE_TAGGED_HOSTS);
boolean expectRouteDoubleTaggedHosts = Boolean.parseBoolean(strRouteDoubleTaggedHosts);
if (expectRouteDoubleTaggedHosts != routeDoubleTaggedHosts) {
routeDoubleTaggedHosts = expectRouteDoubleTaggedHosts;
@@ -664,7 +664,7 @@
}
}
- String strDefaultInternalVlan = Tools.get(properties, "defaultInternalVlan");
+ String strDefaultInternalVlan = Tools.get(properties, PROP_DEFAULT_INTERNAL_VLAN);
int defIntVlan = Integer.parseInt(strDefaultInternalVlan);
if (defIntVlan != defaultInternalVlan) {
if (canUseVlanId(defIntVlan)) {
@@ -682,7 +682,7 @@
}
}
- String strPwTxpVlan = Tools.get(properties, "pwTransportVlan");
+ String strPwTxpVlan = Tools.get(properties, PROP_PW_TRANSPORT_VLAN);
int pwTxpVlan = Integer.parseInt(strPwTxpVlan);
if (pwTxpVlan != pwTransportVlan) {
if (canUseVlanId(pwTxpVlan)) {
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
+}
diff --git a/apps/test/flow-perf/src/main/java/org/onosproject/flowperf/OsgiPropertyConstants.java b/apps/test/flow-perf/src/main/java/org/onosproject/flowperf/OsgiPropertyConstants.java
new file mode 100644
index 0000000..5eef804
--- /dev/null
+++ b/apps/test/flow-perf/src/main/java/org/onosproject/flowperf/OsgiPropertyConstants.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.flowperf;
+
+/**
+ * Name/Value constants for properties.
+ */
+public final class OsgiPropertyConstants {
+ private OsgiPropertyConstants() {
+ }
+
+ public static final String TOTAL_FLOWS = "totalFlows";
+ public static final int TOTAL_FLOWS_DEFAULT = 100000;
+
+ public static final String BATCH_SIZE = "batchSize";
+ public static final int BATCH_SIZE_DEFAULT = 200;
+
+ public static final String TOTAL_THREADS = "totalThreads";
+ public static final int TOTAL_THREADS_DEFAULT = 1;
+}
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 b956539..0b509f4 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
@@ -77,6 +77,14 @@
import static org.onlab.util.Tools.delay;
import static org.onlab.util.Tools.get;
import static org.onlab.util.Tools.groupedThreads;
+import static org.onosproject.intentperf.OsgiPropertyConstants.CYCLE_PERIOD;
+import static org.onosproject.intentperf.OsgiPropertyConstants.CYCLE_PERIOD_DEFAULT;
+import static org.onosproject.intentperf.OsgiPropertyConstants.NUM_KEYS;
+import static org.onosproject.intentperf.OsgiPropertyConstants.NUM_KEYS_DEFAULT;
+import static org.onosproject.intentperf.OsgiPropertyConstants.NUM_NEIGHBORS;
+import static org.onosproject.intentperf.OsgiPropertyConstants.NUM_NEIGHBORS_DEFAULT;
+import static org.onosproject.intentperf.OsgiPropertyConstants.NUM_WORKERS;
+import static org.onosproject.intentperf.OsgiPropertyConstants.NUM_WORKERS_DEFAULT;
import static org.onosproject.net.intent.IntentEvent.Type.INSTALLED;
import static org.onosproject.net.intent.IntentEvent.Type.INSTALL_REQ;
import static org.onosproject.net.intent.IntentEvent.Type.WITHDRAWN;
@@ -87,18 +95,20 @@
/**
* Application to test sustained intent throughput.
*/
-@Component(immediate = true, service = IntentPerfInstaller.class)
+@Component(
+ immediate = true,
+ service = IntentPerfInstaller.class,
+ property = {
+ NUM_KEYS + ":Integer=" + NUM_KEYS_DEFAULT,
+ NUM_WORKERS + ":Integer=" + NUM_WORKERS_DEFAULT,
+ CYCLE_PERIOD + ":Integer=" + CYCLE_PERIOD_DEFAULT,
+ NUM_NEIGHBORS + ":Integer=" + NUM_NEIGHBORS_DEFAULT,
+ }
+)
public class IntentPerfInstaller {
private final Logger log = getLogger(getClass());
- private static final int DEFAULT_NUM_WORKERS = 1;
-
- private static final int DEFAULT_NUM_KEYS = 40000;
- private static final int DEFAULT_GOAL_CYCLE_PERIOD = 1000; //ms
-
- private static final int DEFAULT_NUM_NEIGHBORS = 0;
-
private static final int START_DELAY = 5_000; // ms
private static final int REPORT_PERIOD = 1_000; //ms
@@ -108,22 +118,17 @@
//FIXME add path length
- //@Property(name = "numKeys", intValue = DEFAULT_NUM_KEYS,
- // label = "Number of keys (i.e. unique intents) to generate per instance")
- private int numKeys = DEFAULT_NUM_KEYS;
+ /** Number of keys (i.e. unique intents) to generate per instance. */
+ private int numKeys = NUM_KEYS_DEFAULT;
- //TODO implement numWorkers property
-// @Property(name = "numThreads", intValue = DEFAULT_NUM_WORKERS,
-// label = "Number of installer threads per instance")
-// private int numWokers = DEFAULT_NUM_WORKERS;
+ /** Number of installer threads per instance. */
+ private int numWorkers = NUM_WORKERS_DEFAULT;
- //@Property(name = "cyclePeriod", intValue = DEFAULT_GOAL_CYCLE_PERIOD,
- // label = "Goal for cycle period (in ms)")
- private int cyclePeriod = DEFAULT_GOAL_CYCLE_PERIOD;
+ /** Goal for cycle period (in ms). */
+ private int cyclePeriod = CYCLE_PERIOD_DEFAULT;
- //@Property(name = "numNeighbors", intValue = DEFAULT_NUM_NEIGHBORS,
- // label = "Number of neighbors to generate intents for")
- private int numNeighbors = DEFAULT_NUM_NEIGHBORS;
+ /** Number of neighbors to generate intents for. */
+ private int numNeighbors = NUM_NEIGHBORS_DEFAULT;
@Reference(cardinality = MANDATORY)
protected CoreService coreService;
@@ -177,7 +182,7 @@
// TODO: replace with shared timer
reportTimer = new Timer("onos-intent-perf-reporter");
- workers = Executors.newFixedThreadPool(DEFAULT_NUM_WORKERS, groupedThreads("onos/intent-perf", "worker-%d"));
+ workers = Executors.newFixedThreadPool(numWorkers, groupedThreads("onos/intent-perf", "worker-%d"));
// TODO: replace with shared executor
messageHandlingExecutor = Executors.newSingleThreadExecutor(
@@ -217,28 +222,33 @@
}
Dictionary<?, ?> properties = context.getProperties();
- int newNumKeys, newCyclePeriod, newNumNeighbors;
+ int newNumKeys, newCyclePeriod, newNumNeighbors, newNumWorkers;
try {
- String s = get(properties, "numKeys");
+ String s = get(properties, NUM_KEYS);
newNumKeys = isNullOrEmpty(s) ? numKeys : Integer.parseInt(s.trim());
- s = get(properties, "cyclePeriod");
+ s = get(properties, CYCLE_PERIOD);
newCyclePeriod = isNullOrEmpty(s) ? cyclePeriod : Integer.parseInt(s.trim());
- s = get(properties, "numNeighbors");
+ s = get(properties, NUM_NEIGHBORS);
newNumNeighbors = isNullOrEmpty(s) ? numNeighbors : Integer.parseInt(s.trim());
+ s = get(properties, NUM_WORKERS);
+ newNumWorkers = isNullOrEmpty(s) ? numWorkers : Integer.parseInt(s.trim());
+
} catch (NumberFormatException | ClassCastException e) {
log.warn("Malformed configuration detected; using defaults", e);
- newNumKeys = DEFAULT_NUM_KEYS;
- newCyclePeriod = DEFAULT_GOAL_CYCLE_PERIOD;
- newNumNeighbors = DEFAULT_NUM_NEIGHBORS;
+ newNumKeys = NUM_KEYS_DEFAULT;
+ newCyclePeriod = CYCLE_PERIOD_DEFAULT;
+ newNumNeighbors = NUM_NEIGHBORS_DEFAULT;
+ newNumWorkers = NUM_WORKERS_DEFAULT;
}
if (newNumKeys != numKeys || newCyclePeriod != cyclePeriod || newNumNeighbors != numNeighbors) {
numKeys = newNumKeys;
cyclePeriod = newCyclePeriod;
numNeighbors = newNumNeighbors;
+ numWorkers = newNumWorkers;
logConfig("Reconfigured");
}
}
@@ -277,7 +287,7 @@
// Submit workers
stopped = false;
- for (int i = 0; i < DEFAULT_NUM_WORKERS; i++) {
+ for (int i = 0; i < numWorkers; i++) {
workers.submit(new Submitter(createIntents(numKeys, /*FIXME*/ 2, lastKey)));
}
log.info("Started test run");
diff --git a/apps/test/intent-perf/src/main/java/org/onosproject/intentperf/OsgiPropertyConstants.java b/apps/test/intent-perf/src/main/java/org/onosproject/intentperf/OsgiPropertyConstants.java
new file mode 100644
index 0000000..aed36a7
--- /dev/null
+++ b/apps/test/intent-perf/src/main/java/org/onosproject/intentperf/OsgiPropertyConstants.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.intentperf;
+
+/**
+ * Name/Value constants for properties.
+ */
+public final class OsgiPropertyConstants {
+ private OsgiPropertyConstants() {
+ }
+
+ public static final String NUM_KEYS = "numKeys";
+ public static final int NUM_KEYS_DEFAULT = 40000;
+
+ public static final String NUM_WORKERS = "numWorkers";
+ public static final int NUM_WORKERS_DEFAULT = 1;
+
+ public static final String CYCLE_PERIOD = "cyclePeriod";
+ public static final int CYCLE_PERIOD_DEFAULT = 1000; //ms
+
+ public static final String NUM_NEIGHBORS = "numNeighbors";
+ public static final int NUM_NEIGHBORS_DEFAULT = 0;
+}
diff --git a/apps/test/loadtest/src/main/java/org/onosproject/loadtest/DistributedConsensusLoadTest.java b/apps/test/loadtest/src/main/java/org/onosproject/loadtest/DistributedConsensusLoadTest.java
index 7b7cf1b..3f8dbaf 100644
--- a/apps/test/loadtest/src/main/java/org/onosproject/loadtest/DistributedConsensusLoadTest.java
+++ b/apps/test/loadtest/src/main/java/org/onosproject/loadtest/DistributedConsensusLoadTest.java
@@ -46,6 +46,8 @@
import static com.google.common.base.Strings.isNullOrEmpty;
import static org.onlab.util.Tools.get;
+import static org.onosproject.loadtest.OsgiPropertyConstants.RATE;
+import static org.onosproject.loadtest.OsgiPropertyConstants.RATE_DEFAULT;
import static org.slf4j.LoggerFactory.getLogger;
/**
@@ -53,7 +55,13 @@
* <p>
* This application simply increments as {@link AsyncAtomicCounter} at a configurable rate.
*/
-@Component(immediate = true, service = DistributedConsensusLoadTest.class)
+@Component(
+ immediate = true,
+ service = DistributedConsensusLoadTest.class,
+ property = {
+ RATE + ":Integer=" + RATE_DEFAULT
+ }
+)
public class DistributedConsensusLoadTest {
private final Logger log = getLogger(getClass());
@@ -71,12 +79,10 @@
@Reference(cardinality = ReferenceCardinality.MANDATORY)
protected CoreService coreService;
- private static final int DEFAULT_RATE = 100;
private static final int TOTAL_COUNTERS = 50;
- //@Property(name = "rate", intValue = DEFAULT_RATE,
- // label = "Total number of increments per second to the atomic counter")
- protected int rate = 0;
+ /** Total number of increments per second to the atomic counter. */
+ protected int rate = RATE_DEFAULT;
private final AtomicLong previousReportTime = new AtomicLong(0);
private final AtomicLong previousCount = new AtomicLong(0);
@@ -145,11 +151,11 @@
@Modified
public void modified(ComponentContext context) {
- int newRate = DEFAULT_RATE;
+ int newRate = RATE_DEFAULT;
if (context != null) {
Dictionary properties = context.getProperties();
try {
- String s = get(properties, "rate");
+ String s = get(properties, RATE);
newRate = isNullOrEmpty(s)
? rate : Integer.parseInt(s.trim());
} catch (Exception e) {
diff --git a/apps/test/loadtest/src/main/java/org/onosproject/loadtest/OsgiPropertyConstants.java b/apps/test/loadtest/src/main/java/org/onosproject/loadtest/OsgiPropertyConstants.java
new file mode 100644
index 0000000..930945b
--- /dev/null
+++ b/apps/test/loadtest/src/main/java/org/onosproject/loadtest/OsgiPropertyConstants.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.loadtest;
+
+/**
+ * Name/Value constants for properties.
+ */
+public final class OsgiPropertyConstants {
+ private OsgiPropertyConstants() {
+ }
+
+ public static final String RATE = "rate";
+ public static final int RATE_DEFAULT = 100;
+
+}
diff --git a/apps/test/messaging-perf/src/main/java/org/onosproject/messagingperf/MessagingPerfApp.java b/apps/test/messaging-perf/src/main/java/org/onosproject/messagingperf/MessagingPerfApp.java
index c1b2513..f37b19a 100644
--- a/apps/test/messaging-perf/src/main/java/org/onosproject/messagingperf/MessagingPerfApp.java
+++ b/apps/test/messaging-perf/src/main/java/org/onosproject/messagingperf/MessagingPerfApp.java
@@ -55,13 +55,30 @@
import static com.google.common.base.Strings.isNullOrEmpty;
import static org.onlab.util.Tools.get;
import static org.onlab.util.Tools.groupedThreads;
+import static org.onosproject.messagingperf.OsgiPropertyConstants.RECEIVER_THREAD_POOL_SIZE;
+import static org.onosproject.messagingperf.OsgiPropertyConstants.RECEIVER_THREAD_POOL_SIZE_DEFAULT;
+import static org.onosproject.messagingperf.OsgiPropertyConstants.RECEIVE_ON_IO_LOOP_THREAD;
+import static org.onosproject.messagingperf.OsgiPropertyConstants.RECEIVE_ON_IO_LOOP_THREAD_DEFAULT;
+import static org.onosproject.messagingperf.OsgiPropertyConstants.SENDER_THREAD_POOL_SIZE;
+import static org.onosproject.messagingperf.OsgiPropertyConstants.SENDER_THREAD_POOL_SIZE_DEFAULT;
+import static org.onosproject.messagingperf.OsgiPropertyConstants.SERIALIZATION_ON;
+import static org.onosproject.messagingperf.OsgiPropertyConstants.SERIALIZATION_ON_DEFAULT;
import static org.osgi.service.component.annotations.ReferenceCardinality.MANDATORY;
import static org.slf4j.LoggerFactory.getLogger;
/**
* Application for measuring cluster messaging performance.
*/
-@Component(immediate = true, service = MessagingPerfApp.class)
+@Component(
+ immediate = true,
+ service = MessagingPerfApp.class,
+ property = {
+ SENDER_THREAD_POOL_SIZE + ":Integer=" + SENDER_THREAD_POOL_SIZE_DEFAULT,
+ RECEIVER_THREAD_POOL_SIZE + ":Integer=" + RECEIVER_THREAD_POOL_SIZE_DEFAULT,
+ SERIALIZATION_ON + ":Boolean=" + SERIALIZATION_ON_DEFAULT,
+ RECEIVE_ON_IO_LOOP_THREAD + ":Boolean=" + RECEIVE_ON_IO_LOOP_THREAD_DEFAULT
+ }
+)
public class MessagingPerfApp {
private final Logger log = getLogger(getClass());
@@ -83,26 +100,19 @@
private static final MessageSubject TEST_REQUEST_REPLY_TOPIC =
new MessageSubject("net-perf-rr-message");
- private static final int DEFAULT_SENDER_THREAD_POOL_SIZE = 2;
- private static final int DEFAULT_RECEIVER_THREAD_POOL_SIZE = 2;
+ /** Number of sender threads. */
+ private int totalSenderThreads = SENDER_THREAD_POOL_SIZE_DEFAULT;
- //@Property(name = "totalSenderThreads", intValue = DEFAULT_SENDER_THREAD_POOL_SIZE,
- // label = "Number of sender threads")
- protected int totalSenderThreads = DEFAULT_SENDER_THREAD_POOL_SIZE;
+ /** Number of receiver threads. */
+ private int totalReceiverThreads = RECEIVER_THREAD_POOL_SIZE_DEFAULT;
- //@Property(name = "totalReceiverThreads", intValue = DEFAULT_RECEIVER_THREAD_POOL_SIZE,
- // label = "Number of receiver threads")
- protected int totalReceiverThreads = DEFAULT_RECEIVER_THREAD_POOL_SIZE;
+ /** Turn serialization on/off. */
+ private boolean serializationOn = SERIALIZATION_ON_DEFAULT;
- //@Property(name = "serializationOn", boolValue = true,
- // label = "Turn serialization on/off")
- private boolean serializationOn = true;
+ /** Set this to true to handle message on IO thread. */
+ private boolean receiveOnIOLoopThread = RECEIVE_ON_IO_LOOP_THREAD_DEFAULT;
- //@Property(name = "receiveOnIOLoopThread", boolValue = false,
- // label = "Set this to true to handle message on IO thread")
- private boolean receiveOnIOLoopThread = false;
-
- protected int reportIntervalSeconds = 1;
+ private int reportIntervalSeconds = 1;
private Executor messageReceivingExecutor;
@@ -167,8 +177,8 @@
@Modified
public void modified(ComponentContext context) {
if (context == null) {
- totalSenderThreads = DEFAULT_SENDER_THREAD_POOL_SIZE;
- totalReceiverThreads = DEFAULT_RECEIVER_THREAD_POOL_SIZE;
+ totalSenderThreads = SENDER_THREAD_POOL_SIZE_DEFAULT;
+ totalReceiverThreads = RECEIVER_THREAD_POOL_SIZE_DEFAULT;
serializationOn = true;
receiveOnIOLoopThread = false;
return;
@@ -181,19 +191,19 @@
boolean newSerializationOn = serializationOn;
boolean newReceiveOnIOLoopThread = receiveOnIOLoopThread;
try {
- String s = get(properties, "totalSenderThreads");
+ String s = get(properties, SENDER_THREAD_POOL_SIZE);
newTotalSenderThreads = isNullOrEmpty(s)
? totalSenderThreads : Integer.parseInt(s.trim());
- s = get(properties, "totalReceiverThreads");
+ s = get(properties, RECEIVER_THREAD_POOL_SIZE);
newTotalReceiverThreads = isNullOrEmpty(s)
? totalReceiverThreads : Integer.parseInt(s.trim());
- s = get(properties, "serializationOn");
+ s = get(properties, SERIALIZATION_ON);
newSerializationOn = isNullOrEmpty(s)
? serializationOn : Boolean.parseBoolean(s.trim());
- s = get(properties, "receiveOnIOLoopThread");
+ s = get(properties, RECEIVE_ON_IO_LOOP_THREAD);
newReceiveOnIOLoopThread = isNullOrEmpty(s)
? receiveOnIOLoopThread : Boolean.parseBoolean(s.trim());
diff --git a/apps/test/messaging-perf/src/main/java/org/onosproject/messagingperf/OsgiPropertyConstants.java b/apps/test/messaging-perf/src/main/java/org/onosproject/messagingperf/OsgiPropertyConstants.java
new file mode 100644
index 0000000..7fffad4
--- /dev/null
+++ b/apps/test/messaging-perf/src/main/java/org/onosproject/messagingperf/OsgiPropertyConstants.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.messagingperf;
+
+/**
+ * Name/Value constants for properties.
+ */
+public final class OsgiPropertyConstants {
+ private OsgiPropertyConstants() {
+ }
+
+ public static final String SENDER_THREAD_POOL_SIZE = "totalSenderThreads";
+ public static final int SENDER_THREAD_POOL_SIZE_DEFAULT = 2;
+
+ public static final String RECEIVER_THREAD_POOL_SIZE = "totalReceiverThreads";
+ public static final int RECEIVER_THREAD_POOL_SIZE_DEFAULT = 2;
+
+ public static final String SERIALIZATION_ON = "serializationOn";
+ public static final boolean SERIALIZATION_ON_DEFAULT = true;
+
+ public static final String RECEIVE_ON_IO_LOOP_THREAD = "receiveOnIOLoopThread";
+ public static final boolean RECEIVE_ON_IO_LOOP_THREAD_DEFAULT = false;
+}
diff --git a/apps/test/primitive-perf/src/main/java/org/onosproject/primitiveperf/OsgiPropertyConstants.java b/apps/test/primitive-perf/src/main/java/org/onosproject/primitiveperf/OsgiPropertyConstants.java
new file mode 100644
index 0000000..186c7ee
--- /dev/null
+++ b/apps/test/primitive-perf/src/main/java/org/onosproject/primitiveperf/OsgiPropertyConstants.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.primitiveperf;
+
+/**
+ * Name/Value constants for properties.
+ */
+public final class OsgiPropertyConstants {
+ private OsgiPropertyConstants() {
+ }
+
+ public static final String NUM_CLIENTS = "numClients";
+ public static final int NUM_CLIENTS_DEFAULT = 8;
+
+ public static final String WRITE_PERCENTAGE = "writePercentage";
+ public static final int WRITE_PERCENTAGE_DEFAULT = 100;
+
+ public static final String NUM_KEYS = "numKeys";
+ public static final int NUM_KEYS_DEFAULT = 100000;
+
+ public static final String KEY_LENGTH = "keyLength";
+ public static final int KEY_LENGTH_DEFAULT = 32;
+
+ public static final String NUM_UNIQUE_VALUES = "numValues";
+ public static final int NUM_UNIQUE_VALUES_DEFAULT = 100;
+
+ public static final String VALUE_LENGTH = "valueLength";
+ public static final int VALUE_LENGTH_DEFAULT = 1024;
+
+ public static final String INCLUDE_EVENTS = "includeEvents";
+ public static final boolean INCLUDE_EVENTS_DEFAULT = false;
+
+ public static final String DETERMINISTIC = "deterministic";
+ public static final boolean DETERMINISTIC_DEFAULT = true;
+
+}
diff --git a/apps/test/primitive-perf/src/main/java/org/onosproject/primitiveperf/PrimitivePerfApp.java b/apps/test/primitive-perf/src/main/java/org/onosproject/primitiveperf/PrimitivePerfApp.java
index 9c62710..5d9257b 100644
--- a/apps/test/primitive-perf/src/main/java/org/onosproject/primitiveperf/PrimitivePerfApp.java
+++ b/apps/test/primitive-perf/src/main/java/org/onosproject/primitiveperf/PrimitivePerfApp.java
@@ -51,78 +51,73 @@
import static java.lang.System.currentTimeMillis;
import static org.onlab.util.Tools.get;
import static org.onlab.util.Tools.groupedThreads;
+import static org.onosproject.primitiveperf.OsgiPropertyConstants.DETERMINISTIC;
+import static org.onosproject.primitiveperf.OsgiPropertyConstants.DETERMINISTIC_DEFAULT;
+import static org.onosproject.primitiveperf.OsgiPropertyConstants.INCLUDE_EVENTS;
+import static org.onosproject.primitiveperf.OsgiPropertyConstants.INCLUDE_EVENTS_DEFAULT;
+import static org.onosproject.primitiveperf.OsgiPropertyConstants.KEY_LENGTH;
+import static org.onosproject.primitiveperf.OsgiPropertyConstants.KEY_LENGTH_DEFAULT;
+import static org.onosproject.primitiveperf.OsgiPropertyConstants.NUM_CLIENTS;
+import static org.onosproject.primitiveperf.OsgiPropertyConstants.NUM_CLIENTS_DEFAULT;
+import static org.onosproject.primitiveperf.OsgiPropertyConstants.NUM_KEYS;
+import static org.onosproject.primitiveperf.OsgiPropertyConstants.NUM_KEYS_DEFAULT;
+import static org.onosproject.primitiveperf.OsgiPropertyConstants.NUM_UNIQUE_VALUES;
+import static org.onosproject.primitiveperf.OsgiPropertyConstants.NUM_UNIQUE_VALUES_DEFAULT;
+import static org.onosproject.primitiveperf.OsgiPropertyConstants.VALUE_LENGTH;
+import static org.onosproject.primitiveperf.OsgiPropertyConstants.VALUE_LENGTH_DEFAULT;
+import static org.onosproject.primitiveperf.OsgiPropertyConstants.WRITE_PERCENTAGE;
+import static org.onosproject.primitiveperf.OsgiPropertyConstants.WRITE_PERCENTAGE_DEFAULT;
import static org.osgi.service.component.annotations.ReferenceCardinality.MANDATORY;
import static org.slf4j.LoggerFactory.getLogger;
/**
* Application to test sustained primitive throughput.
*/
-@Component(immediate = true, service = PrimitivePerfApp.class)
+@Component(
+ immediate = true,
+ service = PrimitivePerfApp.class,
+ property = {
+ NUM_CLIENTS + ":Integer=" + NUM_CLIENTS_DEFAULT,
+ WRITE_PERCENTAGE + ":Integer=" + WRITE_PERCENTAGE_DEFAULT,
+ NUM_KEYS + ":Integer=" + NUM_KEYS_DEFAULT,
+ KEY_LENGTH + ":Integer=" + KEY_LENGTH_DEFAULT,
+ NUM_UNIQUE_VALUES + ":Integer=" + NUM_UNIQUE_VALUES_DEFAULT,
+ VALUE_LENGTH + ":Integer=" + VALUE_LENGTH_DEFAULT,
+ INCLUDE_EVENTS + ":Boolean=" + INCLUDE_EVENTS_DEFAULT,
+ DETERMINISTIC + ":Boolean=" + DETERMINISTIC_DEFAULT,
+ }
+)
public class PrimitivePerfApp {
private final Logger log = getLogger(getClass());
- private static final int DEFAULT_NUM_CLIENTS = 8;
- private static final int DEFAULT_WRITE_PERCENTAGE = 100;
-
- private static final int DEFAULT_NUM_KEYS = 100_000;
- private static final int DEFAULT_KEY_LENGTH = 32;
- private static final int DEFAULT_NUM_UNIQUE_VALUES = 100;
- private static final int DEFAULT_VALUE_LENGTH = 1024;
- private static final boolean DEFAULT_INCLUDE_EVENTS = false;
- private static final boolean DEFAULT_DETERMINISTIC = true;
-
private static final int REPORT_PERIOD = 1_000; //ms
private static final char[] CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".toCharArray();
- //@Property(
- // name = "numClients",
- // intValue = DEFAULT_NUM_CLIENTS,
- // label = "Number of clients to use to submit writes")
- private int numClients = DEFAULT_NUM_CLIENTS;
+ /** Number of clients to use to submit writes. */
+ private int numClients = NUM_CLIENTS_DEFAULT;
- //@Property(
- // name = "writePercentage",
- // intValue = DEFAULT_WRITE_PERCENTAGE,
- // label = "Percentage of operations to perform as writes")
- private int writePercentage = DEFAULT_WRITE_PERCENTAGE;
+ /** Percentage of operations to perform as writes. */
+ private int writePercentage = WRITE_PERCENTAGE_DEFAULT;
- //@Property(
- // name = "numKeys",
- // intValue = DEFAULT_NUM_KEYS,
- // label = "Number of unique keys to write")
- private int numKeys = DEFAULT_NUM_KEYS;
+ /** Number of unique keys to write. */
+ private int numKeys = NUM_KEYS_DEFAULT;
- //@Property(
- // name = "keyLength",
- // intValue = DEFAULT_KEY_LENGTH,
- // label = "Key length")
- private int keyLength = DEFAULT_KEY_LENGTH;
+ /** Key length. */
+ private int keyLength = KEY_LENGTH_DEFAULT;
- //@Property(
- // name = "numValues",
- // intValue = DEFAULT_NUM_UNIQUE_VALUES,
- // label = "Number of unique values to write")
- private int numValues = DEFAULT_NUM_UNIQUE_VALUES;
+ /** Number of unique values to write. */
+ private int numValues = NUM_UNIQUE_VALUES_DEFAULT;
- //@Property(
- // name = "valueLength",
- // intValue = DEFAULT_VALUE_LENGTH,
- // label = "Value length")
- private int valueLength = DEFAULT_VALUE_LENGTH;
+ /** Value length. */
+ private int valueLength = VALUE_LENGTH_DEFAULT;
- //@Property(
- // name = "includeEvents",
- // boolValue = DEFAULT_INCLUDE_EVENTS,
- // label = "Whether to include events in test")
- private boolean includeEvents = DEFAULT_INCLUDE_EVENTS;
+ /** Whether to include events in test. */
+ private boolean includeEvents = INCLUDE_EVENTS_DEFAULT;
- //@Property(
- // name = "deterministic",
- // boolValue = DEFAULT_DETERMINISTIC,
- // label = "Whether to deterministically populate entries")
- private boolean deterministic = DEFAULT_DETERMINISTIC;
+ /** Whether to deterministically populate entries. */
+ private boolean deterministic = DETERMINISTIC_DEFAULT;
@Reference(cardinality = MANDATORY)
protected ClusterService clusterService;
@@ -216,19 +211,19 @@
}
Dictionary<?, ?> properties = context.getProperties();
- int newNumClients = parseInt(properties, "numClients", numClients, DEFAULT_NUM_CLIENTS);
- int newWritePercentage = parseInt(properties, "writePercentage", writePercentage, DEFAULT_WRITE_PERCENTAGE);
- int newNumKeys = parseInt(properties, "numKeys", numKeys, DEFAULT_NUM_KEYS);
- int newKeyLength = parseInt(properties, "keyLength", keyLength, DEFAULT_KEY_LENGTH);
- int newNumValues = parseInt(properties, "numValues", numValues, DEFAULT_NUM_UNIQUE_VALUES);
- int newValueLength = parseInt(properties, "valueLength", valueLength, DEFAULT_VALUE_LENGTH);
+ int newNumClients = parseInt(properties, NUM_CLIENTS, numClients, NUM_CLIENTS_DEFAULT);
+ int newWritePercentage = parseInt(properties, WRITE_PERCENTAGE, writePercentage, WRITE_PERCENTAGE_DEFAULT);
+ int newNumKeys = parseInt(properties, NUM_KEYS, numKeys, NUM_KEYS_DEFAULT);
+ int newKeyLength = parseInt(properties, KEY_LENGTH, keyLength, KEY_LENGTH_DEFAULT);
+ int newNumValues = parseInt(properties, NUM_UNIQUE_VALUES, numValues, NUM_UNIQUE_VALUES_DEFAULT);
+ int newValueLength = parseInt(properties, VALUE_LENGTH, valueLength, VALUE_LENGTH_DEFAULT);
- String includeEventsString = get(properties, "includeEvents");
+ String includeEventsString = get(properties, INCLUDE_EVENTS);
boolean newIncludeEvents = isNullOrEmpty(includeEventsString)
? includeEvents
: Boolean.parseBoolean(includeEventsString.trim());
- String deterministicString = get(properties, "deterministic");
+ String deterministicString = get(properties, DETERMINISTIC);
boolean newDeterministic = isNullOrEmpty(deterministicString)
? includeEvents
: Boolean.parseBoolean(deterministicString.trim());
diff --git a/apps/test/route-scale/src/main/java/org/onosproject/routescale/OsgiPropertyConstants.java b/apps/test/route-scale/src/main/java/org/onosproject/routescale/OsgiPropertyConstants.java
new file mode 100644
index 0000000..c7bcd4d
--- /dev/null
+++ b/apps/test/route-scale/src/main/java/org/onosproject/routescale/OsgiPropertyConstants.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.routescale;
+
+/**
+ * Name/Value constants for properties.
+ */
+public final class OsgiPropertyConstants {
+ private OsgiPropertyConstants() {
+ }
+
+ public static final String FLOW_COUNT = "flowCount";
+ public static final int FLOW_COUNT_DEFAULT = 0;
+
+ public static final String ROUTE_COUNT = "routeCount";
+ public static final int ROUTE_COUNT_DEFAULT = 0;
+}
diff --git a/apps/test/route-scale/src/main/java/org/onosproject/routescale/ScaleTestManager.java b/apps/test/route-scale/src/main/java/org/onosproject/routescale/ScaleTestManager.java
index d24a4b6..8c8b398 100644
--- a/apps/test/route-scale/src/main/java/org/onosproject/routescale/ScaleTestManager.java
+++ b/apps/test/route-scale/src/main/java/org/onosproject/routescale/ScaleTestManager.java
@@ -61,8 +61,19 @@
import static com.google.common.base.Strings.isNullOrEmpty;
import static org.onlab.util.Tools.get;
+import static org.onosproject.routescale.OsgiPropertyConstants.FLOW_COUNT;
+import static org.onosproject.routescale.OsgiPropertyConstants.FLOW_COUNT_DEFAULT;
+import static org.onosproject.routescale.OsgiPropertyConstants.ROUTE_COUNT;
+import static org.onosproject.routescale.OsgiPropertyConstants.ROUTE_COUNT_DEFAULT;
-@Component(immediate = true, service = ScaleTestManager.class)
+@Component(
+ immediate = true,
+ service = ScaleTestManager.class,
+ property = {
+ FLOW_COUNT + ":Integer=" + FLOW_COUNT_DEFAULT,
+ ROUTE_COUNT + ":Integer=" + ROUTE_COUNT_DEFAULT,
+ }
+)
public class ScaleTestManager {
private Logger log = LoggerFactory.getLogger(getClass());
@@ -88,13 +99,11 @@
@Reference(cardinality = ReferenceCardinality.MANDATORY)
protected ComponentConfigService componentConfigService;
- //@Property(name = "flowCount", intValue = 0,
- // label = "Number of flows to be maintained in the system")
- private int flowCount = 0;
+ /** Number of flows to be maintained in the system. */
+ private int flowCount = FLOW_COUNT_DEFAULT;
- //@Property(name = "routeCount", intValue = 0,
- // label = "Number of routes to be maintained in the system")
- private int routeCount = 0;
+ /** Number of routes to be maintained in the system. */
+ private int routeCount = ROUTE_COUNT_DEFAULT;
private final Random random = new Random(System.currentTimeMillis());
@@ -123,10 +132,10 @@
Dictionary<?, ?> properties = context.getProperties();
try {
- String s = get(properties, "flowCount");
+ String s = get(properties, FLOW_COUNT);
flowCount = isNullOrEmpty(s) ? flowCount : Integer.parseInt(s.trim());
- s = get(properties, "routeCount");
+ s = get(properties, ROUTE_COUNT);
routeCount = isNullOrEmpty(s) ? routeCount : Integer.parseInt(s.trim());
log.info("Reconfigured; flowCount={}; routeCount={}", flowCount, routeCount);
diff --git a/apps/test/transaction-perf/src/main/java/org/onosproject/transactionperf/OsgiPropertyConstants.java b/apps/test/transaction-perf/src/main/java/org/onosproject/transactionperf/OsgiPropertyConstants.java
new file mode 100644
index 0000000..ca8df1a
--- /dev/null
+++ b/apps/test/transaction-perf/src/main/java/org/onosproject/transactionperf/OsgiPropertyConstants.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.transactionperf;
+
+/**
+ * Name/Value constants for properties.
+ */
+public final class OsgiPropertyConstants {
+ private OsgiPropertyConstants() {
+ }
+
+ public static final String MAP_NAME = "mapName";
+ public static final String MAP_NAME_DEFAULT = "transaction-perf";
+
+ public static final String READ_PERCENTAGE = "readPercentage";
+ public static final double READ_PERCENTAGE_DEFAULT = .9;
+
+ public static final String TOTAL_OPERATIONS = "totalOperationsPerTransaction";
+ public static final int TOTAL_OPERATIONS_DEFAULT = 1000;
+
+ public static final String WITH_CONTENTION = "withContention";
+ public static final boolean WITH_CONTENTION_DEFAULT = false;
+
+ public static final String WITH_RETRIES = "withRetries";
+ public static final boolean WITH_RETRIES_DEFAULT = false;
+
+ public static final String REPORT_INTERVAL_SECONDS = "reportIntervalSeconds";
+ public static final int REPORT_INTERVAL_SECONDS_DEFAULT = 1;
+}
diff --git a/apps/test/transaction-perf/src/main/java/org/onosproject/transactionperf/TransactionPerfApp.java b/apps/test/transaction-perf/src/main/java/org/onosproject/transactionperf/TransactionPerfApp.java
index 45bdfd6..b79ea2e 100644
--- a/apps/test/transaction-perf/src/main/java/org/onosproject/transactionperf/TransactionPerfApp.java
+++ b/apps/test/transaction-perf/src/main/java/org/onosproject/transactionperf/TransactionPerfApp.java
@@ -44,13 +44,36 @@
import static com.google.common.base.Strings.isNullOrEmpty;
import static org.onlab.util.Tools.get;
import static org.onlab.util.Tools.groupedThreads;
+import static org.onosproject.transactionperf.OsgiPropertyConstants.MAP_NAME;
+import static org.onosproject.transactionperf.OsgiPropertyConstants.MAP_NAME_DEFAULT;
+import static org.onosproject.transactionperf.OsgiPropertyConstants.READ_PERCENTAGE;
+import static org.onosproject.transactionperf.OsgiPropertyConstants.READ_PERCENTAGE_DEFAULT;
+import static org.onosproject.transactionperf.OsgiPropertyConstants.REPORT_INTERVAL_SECONDS;
+import static org.onosproject.transactionperf.OsgiPropertyConstants.REPORT_INTERVAL_SECONDS_DEFAULT;
+import static org.onosproject.transactionperf.OsgiPropertyConstants.TOTAL_OPERATIONS;
+import static org.onosproject.transactionperf.OsgiPropertyConstants.TOTAL_OPERATIONS_DEFAULT;
+import static org.onosproject.transactionperf.OsgiPropertyConstants.WITH_CONTENTION;
+import static org.onosproject.transactionperf.OsgiPropertyConstants.WITH_CONTENTION_DEFAULT;
+import static org.onosproject.transactionperf.OsgiPropertyConstants.WITH_RETRIES;
+import static org.onosproject.transactionperf.OsgiPropertyConstants.WITH_RETRIES_DEFAULT;
import static org.osgi.service.component.annotations.ReferenceCardinality.MANDATORY;
import static org.slf4j.LoggerFactory.getLogger;
/**
* Application for measuring transaction performance.
*/
-@Component(immediate = true, service = TransactionPerfApp.class)
+@Component(
+ immediate = true,
+ service = TransactionPerfApp.class,
+ property = {
+ MAP_NAME_DEFAULT + "=" + MAP_NAME,
+ READ_PERCENTAGE + ":Double=" + READ_PERCENTAGE_DEFAULT,
+ TOTAL_OPERATIONS + ":Integer=" + TOTAL_OPERATIONS_DEFAULT,
+ WITH_CONTENTION + ":Boolean=" + WITH_CONTENTION_DEFAULT,
+ WITH_RETRIES + ":Boolean=" + WITH_RETRIES_DEFAULT,
+ REPORT_INTERVAL_SECONDS + ":Integer=" + REPORT_INTERVAL_SECONDS_DEFAULT
+ }
+)
public class TransactionPerfApp {
private final Logger log = getLogger(getClass());
@@ -63,37 +86,25 @@
@Reference(cardinality = MANDATORY)
protected ComponentConfigService configService;
- private static final String DEFAULT_MAP_NAME = "transaction-perf";
- private static final double DEFAULT_READ_PERCENTAGE = .9;
- private static final int DEFAULT_TOTAL_OPERATIONS = 1000;
- private static final boolean DEFAULT_WITH_CONTENTION = false;
- private static final boolean DEFAULT_WITH_RETRIES = false;
- private static final int DEFAULT_REPORT_INTERVAL_SECONDS = 1;
private static final String KEY_PREFIX = "key";
- //@Property(name = "mapName", value = DEFAULT_MAP_NAME,
- // label = "The name of the map to use for testing")
- protected String mapName = DEFAULT_MAP_NAME;
+ /** The name of the map to use for testing. */
+ protected String mapName = MAP_NAME_DEFAULT;
- //@Property(name = "readPercentage", doubleValue = DEFAULT_READ_PERCENTAGE,
- // label = "Percentage of reads to perform")
- protected double readPercentage = DEFAULT_READ_PERCENTAGE;
+ /** Percentage of reads to perform. */
+ protected double readPercentage = READ_PERCENTAGE_DEFAULT;
- //@Property(name = "totalOperationsPerTransaction", intValue = DEFAULT_TOTAL_OPERATIONS,
- // label = "Number of operations to perform within each transaction")
- protected int totalOperationsPerTransaction = DEFAULT_TOTAL_OPERATIONS;
+ /** Number of operations to perform within each transaction. */
+ protected int totalOperationsPerTransaction = TOTAL_OPERATIONS_DEFAULT;
- //@Property(name = "withContention", boolValue = DEFAULT_WITH_CONTENTION,
- // label = "Whether to test transactions with contention from all nodes")
- protected boolean withContention = DEFAULT_WITH_CONTENTION;
+ /** Whether to test transactions with contention from all nodes. */
+ protected boolean withContention = WITH_CONTENTION_DEFAULT;
- //@Property(name = "withRetries", boolValue = DEFAULT_WITH_RETRIES,
- // label = "Whether to retry transactions until success")
- protected boolean withRetries = DEFAULT_WITH_RETRIES;
+ /** Whether to retry transactions until success. */
+ protected boolean withRetries = WITH_RETRIES_DEFAULT;
- //@Property(name = "reportIntervalSeconds", intValue = DEFAULT_REPORT_INTERVAL_SECONDS,
- // label = "The frequency with which to report performance in seconds")
- protected int reportIntervalSeconds = 1;
+ /** The frequency with which to report performance in seconds. */
+ protected int reportIntervalSeconds = REPORT_INTERVAL_SECONDS_DEFAULT;
private ExecutorService testRunner =
Executors.newSingleThreadExecutor(Tools.groupedThreads("app/transaction-perf-test-runner", ""));
@@ -124,12 +135,12 @@
@Modified
public void modified(ComponentContext context) {
if (context == null) {
- mapName = DEFAULT_MAP_NAME;
- readPercentage = DEFAULT_READ_PERCENTAGE;
- totalOperationsPerTransaction = DEFAULT_TOTAL_OPERATIONS;
- withContention = DEFAULT_WITH_CONTENTION;
- withRetries = DEFAULT_WITH_RETRIES;
- reportIntervalSeconds = DEFAULT_REPORT_INTERVAL_SECONDS;
+ mapName = MAP_NAME_DEFAULT;
+ readPercentage = READ_PERCENTAGE_DEFAULT;
+ totalOperationsPerTransaction = TOTAL_OPERATIONS_DEFAULT;
+ withContention = WITH_CONTENTION_DEFAULT;
+ withRetries = WITH_RETRIES_DEFAULT;
+ reportIntervalSeconds = REPORT_INTERVAL_SECONDS_DEFAULT;
return;
}
@@ -145,32 +156,32 @@
try {
String s;
- s = get(properties, "mapName");
+ s = get(properties, MAP_NAME);
if (!isNullOrEmpty(s)) {
newMapName = s;
}
- s = get(properties, "readPercentage");
+ s = get(properties, READ_PERCENTAGE);
if (!isNullOrEmpty(s)) {
newReadPercentage = Double.parseDouble(s);
}
- s = get(properties, "totalOperationsPerTransaction");
+ s = get(properties, TOTAL_OPERATIONS);
if (!isNullOrEmpty(s)) {
newTotalOperationsPerTransaction = Integer.parseInt(s);
}
- s = get(properties, "withContention");
+ s = get(properties, WITH_CONTENTION);
if (!isNullOrEmpty(s)) {
newWithContention = Boolean.parseBoolean(s);
}
- s = get(properties, "withRetries");
+ s = get(properties, WITH_RETRIES);
if (!isNullOrEmpty(s)) {
newWithRetries = Boolean.parseBoolean(s);
}
- s = get(properties, "reportIntervalSeconds");
+ s = get(properties, REPORT_INTERVAL_SECONDS);
if (!isNullOrEmpty(s)) {
newReportIntervalSeconds = Integer.parseInt(s);
}