Fixing component properties in BMV2 drivers.
Change-Id: I1883c6a7c44b5f5ad738d0f97b5befd9a580bdef
diff --git a/drivers/bmv2/src/main/java/org/onosproject/drivers/bmv2/ctl/Bmv2PreControllerImpl.java b/drivers/bmv2/src/main/java/org/onosproject/drivers/bmv2/ctl/Bmv2PreControllerImpl.java
index 1616734..f9661f2 100644
--- a/drivers/bmv2/src/main/java/org/onosproject/drivers/bmv2/ctl/Bmv2PreControllerImpl.java
+++ b/drivers/bmv2/src/main/java/org/onosproject/drivers/bmv2/ctl/Bmv2PreControllerImpl.java
@@ -50,18 +50,21 @@
import static com.google.common.base.Preconditions.checkNotNull;
import static java.lang.String.format;
+import static org.onosproject.drivers.bmv2.ctl.OsgiPropertyDefaults.*;
import static org.slf4j.LoggerFactory.getLogger;
/**
* BMv2 PRE controller implementation.
*/
-@Component(immediate = true, service = Bmv2PreController.class)
+@Component(immediate = true, service = Bmv2PreController.class,
+ property = {
+ "numConnectionRetries:Integer=" + NUM_CONNECTION_RETRIES_DEFAULT,
+ "timeBetweenRetries:Integer=" + TIME_BETWEEN_RETRIES_DEFAULT,
+ "deviceLockWaitingTime:Integer=" + DEVICE_LOCK_WAITING_TIME_IN_SEC_DEFAULT,
+ })
public class Bmv2PreControllerImpl implements Bmv2PreController {
private static final int DEVICE_LOCK_CACHE_EXPIRE_TIME_IN_MIN = 10;
- private static final int DEVICE_LOCK_WAITING_TIME_IN_SEC = 60;
- private static final int DEFAULT_NUM_CONNECTION_RETRIES = 2;
- private static final int DEFAULT_TIME_BETWEEN_RETRIES = 10;
private static final String THRIFT_SERVICE_NAME = "simple_pre_lag";
private final Logger log = getLogger(getClass());
private final Map<DeviceId, Pair<TTransport, Bmv2DeviceThriftClient>> clients = Maps.newHashMap();
@@ -78,13 +81,13 @@
protected ComponentConfigService cfgService;
//@Property(name = "numConnectionRetries", intValue = DEFAULT_NUM_CONNECTION_RETRIES,
// label = "Number of connection retries after a network error")
- private int numConnectionRetries = DEFAULT_NUM_CONNECTION_RETRIES;
+ private int numConnectionRetries = NUM_CONNECTION_RETRIES_DEFAULT;
//@Property(name = "timeBetweenRetries", intValue = DEFAULT_TIME_BETWEEN_RETRIES,
// label = "Time between retries in milliseconds")
- private int timeBetweenRetries = DEFAULT_TIME_BETWEEN_RETRIES;
+ private int timeBetweenRetries = TIME_BETWEEN_RETRIES_DEFAULT;
//@Property(name = "deviceLockWaitingTime", intValue = DEVICE_LOCK_WAITING_TIME_IN_SEC,
// label = "Waiting time for a read/write lock in seconds")
- private int deviceLockWaitingTime = DEVICE_LOCK_WAITING_TIME_IN_SEC;
+ private int deviceLockWaitingTime = DEVICE_LOCK_WAITING_TIME_IN_SEC_DEFAULT;
@Activate
public void activate() {
diff --git a/drivers/bmv2/src/main/java/org/onosproject/drivers/bmv2/ctl/OsgiPropertyDefaults.java b/drivers/bmv2/src/main/java/org/onosproject/drivers/bmv2/ctl/OsgiPropertyDefaults.java
new file mode 100644
index 0000000..3d63934
--- /dev/null
+++ b/drivers/bmv2/src/main/java/org/onosproject/drivers/bmv2/ctl/OsgiPropertyDefaults.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.drivers.bmv2.ctl;
+
+/**
+ * Constants for default values of configurable properties.
+ */
+public final class OsgiPropertyDefaults {
+
+ private OsgiPropertyDefaults() {}
+
+ public static final int DEVICE_LOCK_WAITING_TIME_IN_SEC_DEFAULT = 60;
+ public static final int NUM_CONNECTION_RETRIES_DEFAULT = 2;
+ public static final int TIME_BETWEEN_RETRIES_DEFAULT = 10;
+}