Fixing component properties for various providers.
Change-Id: I909c84958109f61e10a542774a2d4b82c428c0f5
diff --git a/providers/openflow/device/src/main/java/org/onosproject/provider/of/device/impl/OpenFlowDeviceProvider.java b/providers/openflow/device/src/main/java/org/onosproject/provider/of/device/impl/OpenFlowDeviceProvider.java
index 130ad53..6117339 100644
--- a/providers/openflow/device/src/main/java/org/onosproject/provider/of/device/impl/OpenFlowDeviceProvider.java
+++ b/providers/openflow/device/src/main/java/org/onosproject/provider/of/device/impl/OpenFlowDeviceProvider.java
@@ -139,13 +139,18 @@
import static org.onosproject.net.optical.device.OtuPortHelper.otuPortDescription;
import static org.onosproject.openflow.controller.Dpid.dpid;
import static org.onosproject.openflow.controller.Dpid.uri;
+import static org.onosproject.provider.of.device.impl.OsgiPropertyConstants.*;
import static org.slf4j.LoggerFactory.getLogger;
/**
* Provider which uses an OpenFlow controller to detect network
* infrastructure devices.
*/
-@Component(immediate = true)
+@Component(immediate = true,
+ property = {
+ POLL_FREQ + ":Integer=" + POLL_FREQ_DEFAULT,
+ PROP_FREQ + ":Boolean=" + PROP_FREQ_DEFAULT,
+ })
public class OpenFlowDeviceProvider extends AbstractProvider implements DeviceProvider {
private static final Logger LOG = getLogger(OpenFlowDeviceProvider.class);
@@ -448,17 +453,13 @@
private final InternalDeviceProvider listener = new InternalDeviceProvider();
- private static final String POLL_PROP_NAME = "portStatsPollFrequency";
- private static final int POLL_INTERVAL = 5;
//@Property(name = POLL_PROP_NAME, intValue = POLL_INTERVAL,
//label = "Frequency (in seconds) for polling switch Port statistics")
- private int portStatsPollFrequency = POLL_INTERVAL;
+ private int portStatsPollFrequency = POLL_FREQ_DEFAULT;
- private static final String PROP_FREQ = "propertyFrequency";
- private static final boolean DEFAULT_PROP_FREQ = true;
//@Property(name = PROP_FREQ, boolValue = DEFAULT_PROP_FREQ,
//label = "It indicates frequency must be used instead of wavelength for port tuning.")
- private static boolean propFreq = DEFAULT_PROP_FREQ;
+ private static boolean propFreq = PROP_FREQ_DEFAULT;
private final Timer timer = new Timer("onos-openflow-portstats-collector");
@@ -501,7 +502,7 @@
Dictionary<?, ?> properties = context != null ? context.getProperties() : new Properties();
int newPortStatsPollFrequency;
try {
- String s = get(properties, POLL_PROP_NAME);
+ String s = get(properties, POLL_FREQ);
newPortStatsPollFrequency = isNullOrEmpty(s) ? portStatsPollFrequency : Integer.parseInt(s.trim());
} catch (NumberFormatException | ClassCastException e) {
diff --git a/providers/openflow/device/src/main/java/org/onosproject/provider/of/device/impl/OsgiPropertyConstants.java b/providers/openflow/device/src/main/java/org/onosproject/provider/of/device/impl/OsgiPropertyConstants.java
new file mode 100644
index 0000000..7c6b804
--- /dev/null
+++ b/providers/openflow/device/src/main/java/org/onosproject/provider/of/device/impl/OsgiPropertyConstants.java
@@ -0,0 +1,32 @@
+/*
+ * 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.provider.of.device.impl;
+
+/**
+ * Constants for default values of configurable properties.
+ */
+public final class OsgiPropertyConstants {
+
+ private OsgiPropertyConstants() {}
+
+ public static final String POLL_FREQ = "portStatsPollFrequency";
+ public static final int POLL_FREQ_DEFAULT = 5;
+
+ public static final String PROP_FREQ = "propertyFrequency";
+ public static final boolean PROP_FREQ_DEFAULT = true;
+
+}
diff --git a/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/OpenFlowRuleProvider.java b/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/OpenFlowRuleProvider.java
index 33ffdb6..bc06fe6 100644
--- a/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/OpenFlowRuleProvider.java
+++ b/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/OpenFlowRuleProvider.java
@@ -102,13 +102,18 @@
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Strings.isNullOrEmpty;
import static org.onlab.util.Tools.get;
+import static org.onosproject.provider.of.flow.impl.OsgiPropertyConstants.*;
import static org.slf4j.LoggerFactory.getLogger;
/**
* Provider which uses an OpenFlow controller to detect network end-station
* hosts.
*/
-@Component(immediate = true)
+@Component(immediate = true,
+ property = {
+ POLL_FREQUENCY + ":Integer=" + POLL_FREQUENCY_DEFAULT,
+ ADAPTIVE_FLOW_SAMPLING + ":Boolean=" + ADAPTIVE_FLOW_SAMPLING_DEFAULT,
+ })
public class OpenFlowRuleProvider extends AbstractProvider
implements FlowRuleProvider {
@@ -126,18 +131,16 @@
@Reference(cardinality = ReferenceCardinality.MANDATORY)
protected DriverService driverService;
- private static final int DEFAULT_POLL_FREQUENCY = 5;
private static final int MIN_EXPECTED_BYTE_LEN = 56;
private static final int SKIP_BYTES = 4;
- private static final boolean DEFAULT_ADAPTIVE_FLOW_SAMPLING = false;
//@Property(name = "flowPollFrequency", intValue = DEFAULT_POLL_FREQUENCY,
// label = "Frequency (in seconds) for polling flow statistics")
- private int flowPollFrequency = DEFAULT_POLL_FREQUENCY;
+ private int flowPollFrequency = POLL_FREQUENCY_DEFAULT;
//@Property(name = "adaptiveFlowSampling", boolValue = DEFAULT_ADAPTIVE_FLOW_SAMPLING,
// label = "Adaptive Flow Sampling is on or off")
- private boolean adaptiveFlowSampling = DEFAULT_ADAPTIVE_FLOW_SAMPLING;
+ private boolean adaptiveFlowSampling = ADAPTIVE_FLOW_SAMPLING_DEFAULT;
private FlowRuleProviderService providerService;
@@ -194,7 +197,7 @@
Dictionary<?, ?> properties = context.getProperties();
int newFlowPollFrequency;
try {
- String s = get(properties, "flowPollFrequency");
+ String s = get(properties, POLL_FREQUENCY);
newFlowPollFrequency = isNullOrEmpty(s) ? flowPollFrequency : Integer.parseInt(s.trim());
} catch (NumberFormatException | ClassCastException e) {
@@ -209,7 +212,7 @@
log.info("Settings: flowPollFrequency={}", flowPollFrequency);
boolean newAdaptiveFlowSampling;
- String s = get(properties, "adaptiveFlowSampling");
+ String s = get(properties, ADAPTIVE_FLOW_SAMPLING);
newAdaptiveFlowSampling = isNullOrEmpty(s) ? adaptiveFlowSampling : Boolean.parseBoolean(s.trim());
if (newAdaptiveFlowSampling != adaptiveFlowSampling) {
diff --git a/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/OsgiPropertyConstants.java b/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/OsgiPropertyConstants.java
new file mode 100644
index 0000000..36022e8
--- /dev/null
+++ b/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/OsgiPropertyConstants.java
@@ -0,0 +1,32 @@
+/*
+ * 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.provider.of.flow.impl;
+
+/**
+ * Constants for default values of configurable properties.
+ */
+public final class OsgiPropertyConstants {
+
+ private OsgiPropertyConstants() {}
+
+ public static final String POLL_FREQUENCY = "flowPollFrequency";
+ public static final String ADAPTIVE_FLOW_SAMPLING = "adaptiveFlowSampling";
+
+ public static final int POLL_FREQUENCY_DEFAULT = 5;
+ public static final boolean ADAPTIVE_FLOW_SAMPLING_DEFAULT = false;
+
+}
diff --git a/providers/openflow/group/src/main/java/org/onosproject/provider/of/group/impl/OpenFlowGroupProvider.java b/providers/openflow/group/src/main/java/org/onosproject/provider/of/group/impl/OpenFlowGroupProvider.java
index a43c295..a74e2c7 100644
--- a/providers/openflow/group/src/main/java/org/onosproject/provider/of/group/impl/OpenFlowGroupProvider.java
+++ b/providers/openflow/group/src/main/java/org/onosproject/provider/of/group/impl/OpenFlowGroupProvider.java
@@ -84,12 +84,17 @@
import java.util.concurrent.atomic.AtomicLong;
import static org.onlab.util.Tools.getIntegerProperty;
+import static org.onosproject.provider.of.group.impl.OsgiPropertyConstants.POLL_FREQUENCY;
+import static org.onosproject.provider.of.group.impl.OsgiPropertyConstants.POLL_FREQUENCY_DEFAULT;
import static org.slf4j.LoggerFactory.getLogger;
/**
* Provider which uses an OpenFlow controller to handle Group.
*/
-@Component(immediate = true)
+@Component(immediate = true,
+ property = {
+ POLL_FREQUENCY + ":Integer=" + POLL_FREQUENCY_DEFAULT,
+ })
public class OpenFlowGroupProvider extends AbstractProvider implements GroupProvider {
private final Logger log = getLogger(getClass());
@@ -114,13 +119,11 @@
private GroupProviderService providerService;
- private static final int DEFAULT_POLL_INTERVAL = 10;
private static final String COMPONENT = "org.onosproject.provider.of.group.impl.OpenFlowGroupProvider";
- private static final String GROUP_POLL_INTERVAL_CONST = "groupPollInterval";
//@Property(name = "groupPollInterval", intValue = DEFAULT_POLL_INTERVAL,
// label = "Frequency (in seconds) for polling group statistics")
- private int groupPollInterval = DEFAULT_POLL_INTERVAL;
+ private int groupPollInterval = POLL_FREQUENCY_DEFAULT;
private final InternalGroupProvider listener = new InternalGroupProvider();
@@ -173,7 +176,7 @@
@Modified
public void modified(ComponentContext context) {
Dictionary<?, ?> properties = context != null ? context.getProperties() : new Properties();
- Integer newGroupPollInterval = getIntegerProperty(properties, GROUP_POLL_INTERVAL_CONST);
+ Integer newGroupPollInterval = getIntegerProperty(properties, POLL_FREQUENCY);
if (newGroupPollInterval != null && newGroupPollInterval > 0
&& newGroupPollInterval != groupPollInterval) {
groupPollInterval = newGroupPollInterval;
@@ -181,7 +184,7 @@
} else if (newGroupPollInterval != null && newGroupPollInterval <= 0) {
log.warn("groupPollInterval must be greater than 0");
//If the new value <= 0 reset property with old value.
- cfgService.setProperty(COMPONENT, GROUP_POLL_INTERVAL_CONST, Integer.toString(groupPollInterval));
+ cfgService.setProperty(COMPONENT, POLL_FREQUENCY, Integer.toString(groupPollInterval));
}
}
diff --git a/providers/openflow/group/src/main/java/org/onosproject/provider/of/group/impl/OsgiPropertyConstants.java b/providers/openflow/group/src/main/java/org/onosproject/provider/of/group/impl/OsgiPropertyConstants.java
new file mode 100644
index 0000000..43bd7e4
--- /dev/null
+++ b/providers/openflow/group/src/main/java/org/onosproject/provider/of/group/impl/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.provider.of.group.impl;
+
+/**
+ * Constants for default values of configurable properties.
+ */
+public final class OsgiPropertyConstants {
+
+ private OsgiPropertyConstants() {}
+
+ public static final String POLL_FREQUENCY = "groupPollInterval";
+ public static final int POLL_FREQUENCY_DEFAULT = 10;
+
+}