Modify test app usages of Property annotations for new OSGi implementation
Change-Id: Ie16cc4c41541f9e199c0c9e5f1338ee617097942
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());