OSGi property annotations for remaining apps
Change-Id: I5f87ebeb65eb85ee7161e35a838d9275fde22787
diff --git a/apps/mlb/src/main/java/org/onosproject/mlb/MastershipLoadBalancer.java b/apps/mlb/src/main/java/org/onosproject/mlb/MastershipLoadBalancer.java
index ca6cd59..f9ed0da 100644
--- a/apps/mlb/src/main/java/org/onosproject/mlb/MastershipLoadBalancer.java
+++ b/apps/mlb/src/main/java/org/onosproject/mlb/MastershipLoadBalancer.java
@@ -48,6 +48,8 @@
import java.util.concurrent.atomic.AtomicReference;
import static org.onlab.util.Tools.groupedThreads;
+import static org.onosproject.mlb.OsgiPropertyConstants.SCHEDULE_PERIOD;
+import static org.onosproject.mlb.OsgiPropertyConstants.SCHEDULE_PERIOD_DEFAULT;
import static org.slf4j.LoggerFactory.getLogger;
/**
@@ -56,15 +58,18 @@
* thread executor that must only have one thread due to issues that can occur is multiple balancing events occur in
* parallel.
*/
-@Component(immediate = true)
+@Component(
+ immediate = true,
+ property = {
+ SCHEDULE_PERIOD + ":Integer=" + SCHEDULE_PERIOD_DEFAULT
+ }
+)
public class MastershipLoadBalancer {
private final Logger log = getLogger(getClass());
- private static final int DEFAULT_SCHEDULE_PERIOD = 30;
- //@Property(name = "schedulePeriod", intValue = DEFAULT_SCHEDULE_PERIOD,
- // label = "Period to schedule balancing the mastership to be shared as evenly as by all online instances.")
- private int schedulePeriod = DEFAULT_SCHEDULE_PERIOD;
+ /** Period to schedule balancing the mastership to be shared as evenly as by all online instances. */
+ private int schedulePeriod = SCHEDULE_PERIOD_DEFAULT;
private static final String REBALANCE_MASTERSHIP = "rebalance/mastership";
@@ -200,11 +205,11 @@
Dictionary<?, ?> properties = context.getProperties();
Integer newSchedulePeriod = Tools.getIntegerProperty(properties,
- "schedulePeriod");
+ SCHEDULE_PERIOD);
if (newSchedulePeriod == null) {
- schedulePeriod = DEFAULT_SCHEDULE_PERIOD;
+ schedulePeriod = SCHEDULE_PERIOD_DEFAULT;
log.info("Schedule period is not configured, default value is {}",
- DEFAULT_SCHEDULE_PERIOD);
+ SCHEDULE_PERIOD_DEFAULT);
} else {
schedulePeriod = newSchedulePeriod;
log.info("Configured. Schedule period is configured to {}", schedulePeriod);
diff --git a/apps/mlb/src/main/java/org/onosproject/mlb/OsgiPropertyConstants.java b/apps/mlb/src/main/java/org/onosproject/mlb/OsgiPropertyConstants.java
new file mode 100644
index 0000000..9c7aa12
--- /dev/null
+++ b/apps/mlb/src/main/java/org/onosproject/mlb/OsgiPropertyConstants.java
@@ -0,0 +1,25 @@
+/*
+ * 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.mlb;
+
+public final class OsgiPropertyConstants {
+ private OsgiPropertyConstants() {
+ }
+
+ static final String SCHEDULE_PERIOD = "schedulePeriod";
+ static final int SCHEDULE_PERIOD_DEFAULT = 30;
+}