Fixing component properties for various providers.
Change-Id: I909c84958109f61e10a542774a2d4b82c428c0f5
diff --git a/providers/general/device/src/main/java/org/onosproject/provider/general/device/impl/GeneralDeviceProvider.java b/providers/general/device/src/main/java/org/onosproject/provider/general/device/impl/GeneralDeviceProvider.java
index 9918327..6e8fe1d 100644
--- a/providers/general/device/src/main/java/org/onosproject/provider/general/device/impl/GeneralDeviceProvider.java
+++ b/providers/general/device/src/main/java/org/onosproject/provider/general/device/impl/GeneralDeviceProvider.java
@@ -106,6 +106,9 @@
import static java.util.concurrent.Executors.newSingleThreadScheduledExecutor;
import static org.onlab.util.Tools.groupedThreads;
import static org.onosproject.net.device.DeviceEvent.Type;
+import static org.onosproject.provider.general.device.impl.OsgiPropertyDefaults.OP_TIMEOUT_SHORT_DEFAULT;
+import static org.onosproject.provider.general.device.impl.OsgiPropertyDefaults.PROBE_FREQUENCY_DEFAULT;
+import static org.onosproject.provider.general.device.impl.OsgiPropertyDefaults.STATS_POLL_FREQUENCY_DEFAULT;
import static org.slf4j.LoggerFactory.getLogger;
/**
@@ -114,7 +117,12 @@
* also delegated to the DeviceHandshaker driver.
*/
@Beta
-@Component(immediate = true)
+@Component(immediate = true,
+ property = {
+ "deviceStatsPollFrequency:Integer=" + STATS_POLL_FREQUENCY_DEFAULT,
+ "deviceProbeFrequency:Integer=" + PROBE_FREQUENCY_DEFAULT,
+ "deviceOperationTimeoutShort:Integer=" + OP_TIMEOUT_SHORT_DEFAULT,
+ })
public class GeneralDeviceProvider extends AbstractProvider
implements DeviceProvider {
@@ -159,26 +167,23 @@
private PiPipeconfWatchdogService pipeconfWatchdogService;
private static final String STATS_POLL_FREQUENCY = "deviceStatsPollFrequency";
- private static final int DEFAULT_STATS_POLL_FREQUENCY = 10;
//@Property(name = STATS_POLL_FREQUENCY, intValue = DEFAULT_STATS_POLL_FREQUENCY,
// label = "Configure poll frequency for port status and statistics; " +
// "default is 10 sec")
- private int statsPollFrequency = DEFAULT_STATS_POLL_FREQUENCY;
+ private int statsPollFrequency = STATS_POLL_FREQUENCY_DEFAULT;
private static final String PROBE_FREQUENCY = "deviceProbeFrequency";
- private static final int DEFAULT_PROBE_FREQUENCY = 10;
//@Property(name = PROBE_FREQUENCY, intValue = DEFAULT_PROBE_FREQUENCY,
// label = "Configure probe frequency for checking device availability; " +
// "default is 10 sec")
- private int probeFrequency = DEFAULT_PROBE_FREQUENCY;
+ private int probeFrequency = PROBE_FREQUENCY_DEFAULT;
private static final String OP_TIMEOUT_SHORT = "deviceOperationTimeoutShort";
- private static final int DEFAULT_OP_TIMEOUT_SHORT = 10;
//@Property(name = OP_TIMEOUT_SHORT, intValue = DEFAULT_OP_TIMEOUT_SHORT,
// label = "Configure timeout in seconds for device operations " +
// "that are supposed to take a short time " +
// "(e.g. checking device reachability); default is 10 seconds")
- private int opTimeoutShort = DEFAULT_OP_TIMEOUT_SHORT;
+ private int opTimeoutShort = OP_TIMEOUT_SHORT_DEFAULT;
//FIXME to be removed when netcfg will issue device events in a bundle or
//ensures all configuration needed is present
@@ -235,16 +240,16 @@
Dictionary<?, ?> properties = context.getProperties();
final int oldStatsPollFrequency = statsPollFrequency;
statsPollFrequency = Tools.getIntegerProperty(
- properties, STATS_POLL_FREQUENCY, DEFAULT_STATS_POLL_FREQUENCY);
+ properties, STATS_POLL_FREQUENCY, STATS_POLL_FREQUENCY_DEFAULT);
log.info("Configured. {} is configured to {} seconds",
STATS_POLL_FREQUENCY, statsPollFrequency);
final int oldProbeFrequency = probeFrequency;
probeFrequency = Tools.getIntegerProperty(
- properties, PROBE_FREQUENCY, DEFAULT_PROBE_FREQUENCY);
+ properties, PROBE_FREQUENCY, PROBE_FREQUENCY_DEFAULT);
log.info("Configured. {} is configured to {} seconds",
PROBE_FREQUENCY, probeFrequency);
opTimeoutShort = Tools.getIntegerProperty(
- properties, OP_TIMEOUT_SHORT, DEFAULT_OP_TIMEOUT_SHORT);
+ properties, OP_TIMEOUT_SHORT, OP_TIMEOUT_SHORT_DEFAULT);
log.info("Configured. {} is configured to {} seconds",
OP_TIMEOUT_SHORT, opTimeoutShort);
diff --git a/providers/general/device/src/main/java/org/onosproject/provider/general/device/impl/OsgiPropertyDefaults.java b/providers/general/device/src/main/java/org/onosproject/provider/general/device/impl/OsgiPropertyDefaults.java
new file mode 100644
index 0000000..90cf437
--- /dev/null
+++ b/providers/general/device/src/main/java/org/onosproject/provider/general/device/impl/OsgiPropertyDefaults.java
@@ -0,0 +1,30 @@
+/*
+ * 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.general.device.impl;
+
+/**
+ * Constants for default values of configurable properties.
+ */
+public final class OsgiPropertyDefaults {
+
+ private OsgiPropertyDefaults() {}
+
+ public static final int STATS_POLL_FREQUENCY_DEFAULT = 10;
+ public static final int PROBE_FREQUENCY_DEFAULT = 10;
+ public static final int OP_TIMEOUT_SHORT_DEFAULT = 10;
+
+}
diff --git a/providers/host/src/main/java/org/onosproject/provider/host/impl/HostLocationProvider.java b/providers/host/src/main/java/org/onosproject/provider/host/impl/HostLocationProvider.java
index 434cefc..b804c6d 100644
--- a/providers/host/src/main/java/org/onosproject/provider/host/impl/HostLocationProvider.java
+++ b/providers/host/src/main/java/org/onosproject/provider/host/impl/HostLocationProvider.java
@@ -109,7 +109,16 @@
* Provider which uses an OpenFlow controller to detect network end-station
* hosts.
*/
-@Component(immediate = true, service = HostProvider.class)
+@Component(immediate = true, service = HostProvider.class,
+ property = {
+ "hostRemovalEnabled:Boolean=true",
+ "requestArp:Boolean=true",
+ "requestIpv6ND:Boolean=false",
+ "useDhcp:Boolean=false",
+ "useDhcp6:Boolean=false",
+ "requestInterceptsEnabled:Boolean=true",
+ "multihomingEnabled:Boolean=false",
+ })
public class HostLocationProvider extends AbstractProvider implements HostProvider {
private final Logger log = getLogger(getClass());
diff --git a/providers/link/src/main/java/org/onosproject/provider/linkdiscovery/impl/LinkDiscoveryProvider.java b/providers/link/src/main/java/org/onosproject/provider/linkdiscovery/impl/LinkDiscoveryProvider.java
index 1415290..44dd60d 100644
--- a/providers/link/src/main/java/org/onosproject/provider/linkdiscovery/impl/LinkDiscoveryProvider.java
+++ b/providers/link/src/main/java/org/onosproject/provider/linkdiscovery/impl/LinkDiscoveryProvider.java
@@ -58,13 +58,19 @@
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.onlab.util.Tools.get;
import static org.onlab.util.Tools.groupedThreads;
+import static org.onosproject.provider.linkdiscovery.impl.OsgiPropertyDefaults.POLL_DELAY_SECONDS_DEFAULT;
+import static org.onosproject.provider.linkdiscovery.impl.OsgiPropertyDefaults.POLL_FREQUENCY_SECONDS_DEFAULT;
import static org.slf4j.LoggerFactory.getLogger;
/**
* Link provider capable of polling the environment using the device driver
* {@link LinkDiscovery} behaviour.
*/
-@Component(immediate = true)
+@Component(immediate = true,
+ property = {
+ "linkPollDelaySeconds:Integer=" + POLL_DELAY_SECONDS_DEFAULT,
+ "linkPollFrequencySeconds:Integer=" + POLL_FREQUENCY_SECONDS_DEFAULT,
+ })
public class LinkDiscoveryProvider extends AbstractProvider
implements LinkProvider {
@@ -72,14 +78,13 @@
protected static final String SCHEME_NAME = "linkdiscovery";
private static final String LINK_PROVIDER_PACKAGE = "org.onosproject.provider.linkdiscovery";
private final Logger log = getLogger(getClass());
- private static final int DEFAULT_POLL_DELAY_SECONDS = 20;
//@Property(name = "linkPollDelaySeconds", intValue = DEFAULT_POLL_DELAY_SECONDS,
// label = "Initial delay (in seconds) for polling link discovery")
- protected static int linkPollDelaySeconds = DEFAULT_POLL_DELAY_SECONDS;
- private static final int DEFAULT_POLL_FREQUENCY_SECONDS = 10;
+ protected static int linkPollDelaySeconds = POLL_DELAY_SECONDS_DEFAULT;
+
//@Property(name = "linkPollFrequencySeconds", intValue = DEFAULT_POLL_FREQUENCY_SECONDS,
// label = "Frequency (in seconds) for polling link discovery")
- protected static int linkPollFrequencySeconds = DEFAULT_POLL_FREQUENCY_SECONDS;
+ protected static int linkPollFrequencySeconds = POLL_FREQUENCY_SECONDS_DEFAULT;
@Reference(cardinality = ReferenceCardinality.MANDATORY)
@@ -118,7 +123,7 @@
cfgService.registerProperties(getClass());
if (context == null) {
- linkPollFrequencySeconds = DEFAULT_POLL_FREQUENCY_SECONDS;
+ linkPollFrequencySeconds = POLL_FREQUENCY_SECONDS_DEFAULT;
log.info("No component configuration");
} else {
Dictionary<?, ?> properties = context.getProperties();
@@ -169,7 +174,7 @@
String s = get(properties, "linkPollFrequencySeconds");
newPollFrequency = isNullOrEmpty(s) ? pollFrequency : Integer.parseInt(s.trim());
} catch (NumberFormatException | ClassCastException e) {
- newPollFrequency = DEFAULT_POLL_FREQUENCY_SECONDS;
+ newPollFrequency = POLL_FREQUENCY_SECONDS_DEFAULT;
}
return newPollFrequency;
}
@@ -180,7 +185,7 @@
String s = get(properties, "linkPollDelaySeconds");
newPollFrequency = isNullOrEmpty(s) ? pollDelay : Integer.parseInt(s.trim());
} catch (NumberFormatException | ClassCastException e) {
- newPollFrequency = DEFAULT_POLL_DELAY_SECONDS;
+ newPollFrequency = POLL_DELAY_SECONDS_DEFAULT;
}
return newPollFrequency;
}
diff --git a/providers/link/src/main/java/org/onosproject/provider/linkdiscovery/impl/OsgiPropertyDefaults.java b/providers/link/src/main/java/org/onosproject/provider/linkdiscovery/impl/OsgiPropertyDefaults.java
new file mode 100644
index 0000000..ba85b86
--- /dev/null
+++ b/providers/link/src/main/java/org/onosproject/provider/linkdiscovery/impl/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.provider.linkdiscovery.impl;
+
+/**
+ * Constants for default values of configurable properties.
+ */
+public final class OsgiPropertyDefaults {
+
+ private OsgiPropertyDefaults() {}
+
+ public static final int POLL_DELAY_SECONDS_DEFAULT = 20;
+ public static final int POLL_FREQUENCY_SECONDS_DEFAULT = 10;
+
+}
diff --git a/providers/lldp/src/main/java/org/onosproject/provider/lldp/impl/LldpLinkProvider.java b/providers/lldp/src/main/java/org/onosproject/provider/lldp/impl/LldpLinkProvider.java
index e425678..e2e3fbe 100644
--- a/providers/lldp/src/main/java/org/onosproject/provider/lldp/impl/LldpLinkProvider.java
+++ b/providers/lldp/src/main/java/org/onosproject/provider/lldp/impl/LldpLinkProvider.java
@@ -87,12 +87,19 @@
import static org.onosproject.net.config.basics.SubjectFactories.APP_SUBJECT_FACTORY;
import static org.onosproject.net.config.basics.SubjectFactories.CONNECT_POINT_SUBJECT_FACTORY;
import static org.onosproject.net.config.basics.SubjectFactories.DEVICE_SUBJECT_FACTORY;
+import static org.onosproject.provider.lldp.impl.OsgiPropertyConstants.*;
import static org.slf4j.LoggerFactory.getLogger;
/**
* Provider which uses LLDP and BDDP packets to detect network infrastructure links.
*/
-@Component(immediate = true)
+@Component(immediate = true,
+ property = {
+ PROP_ENABLED + ":Boolean=" + ENABLED_DEFAULT,
+ PROP_USE_BDDP + ":Boolean=" + USE_BDDP_DEFAULT,
+ PROP_PROBE_RATE + ":Integer=" + PROBE_RATE_DEFAULT,
+ PROP_STALE_LINK_AGE + ":Integer=" + STALE_LINK_AGE_DEFAULT,
+ })
public class LldpLinkProvider extends AbstractProvider implements ProbedLinkProvider {
private static final String PROVIDER_NAME = "org.onosproject.provider.lldp";
@@ -104,9 +111,6 @@
// When a Device/Port has this annotation, do not send out LLDP/BDDP
public static final String NO_LLDP = "no-lldp";
- private static final int MAX_RETRIES = 5;
- private static final int RETRY_DELAY = 1_000; // millis
-
private final Logger log = getLogger(getClass());
@Reference(cardinality = ReferenceCardinality.MANDATORY)
@@ -150,27 +154,21 @@
private static final long DEVICE_SYNC_DELAY = 5;
private static final long LINK_PRUNER_DELAY = 3;
- private static final String PROP_ENABLED = "enabled";
//@Property(name = PROP_ENABLED, boolValue = true,
// label = "If false, link discovery is disabled")
- private boolean enabled = false;
+ private boolean enabled = ENABLED_DEFAULT;
- private static final String PROP_USE_BDDP = "useBDDP";
//@Property(name = PROP_USE_BDDP, boolValue = true,
// label = "Use BDDP for link discovery")
- private boolean useBddp = true;
+ private boolean useBddp = USE_BDDP_DEFAULT;
- private static final String PROP_PROBE_RATE = "probeRate";
- private static final int DEFAULT_PROBE_RATE = 3000;
//@Property(name = PROP_PROBE_RATE, intValue = DEFAULT_PROBE_RATE,
// label = "LLDP and BDDP probe rate specified in millis")
- private int probeRate = DEFAULT_PROBE_RATE;
+ private int probeRate = PROBE_RATE_DEFAULT;
- private static final String PROP_STALE_LINK_AGE = "staleLinkAge";
- private static final int DEFAULT_STALE_LINK_AGE = 10000;
//@Property(name = PROP_STALE_LINK_AGE, intValue = DEFAULT_STALE_LINK_AGE,
// label = "Number of millis beyond which links will be considered stale")
- private int staleLinkAge = DEFAULT_STALE_LINK_AGE;
+ private int staleLinkAge = STALE_LINK_AGE_DEFAULT;
private final LinkDiscoveryContext context = new InternalDiscoveryContext();
private final InternalRoleListener roleListener = new InternalRoleListener();
diff --git a/providers/lldp/src/main/java/org/onosproject/provider/lldp/impl/OsgiPropertyConstants.java b/providers/lldp/src/main/java/org/onosproject/provider/lldp/impl/OsgiPropertyConstants.java
new file mode 100644
index 0000000..ab20c03
--- /dev/null
+++ b/providers/lldp/src/main/java/org/onosproject/provider/lldp/impl/OsgiPropertyConstants.java
@@ -0,0 +1,38 @@
+/*
+ * 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.lldp.impl;
+
+/**
+ * Constants for default values of configurable properties.
+ */
+public final class OsgiPropertyConstants {
+
+ private OsgiPropertyConstants() {}
+
+ public static final String PROP_ENABLED = "enabled";
+ public static final boolean ENABLED_DEFAULT = false;
+
+ public static final String PROP_USE_BDDP = "useBDDP";
+ public static final boolean USE_BDDP_DEFAULT = true;
+
+ public static final String PROP_PROBE_RATE = "probeRate";
+ public static final int PROBE_RATE_DEFAULT = 3000;
+
+ public static final String PROP_STALE_LINK_AGE = "staleLinkAge";
+ public static final int STALE_LINK_AGE_DEFAULT = 10000;
+
+}
diff --git a/providers/netcfglinks/src/main/java/org/onosproject/provider/netcfglinks/NetworkConfigLinksProvider.java b/providers/netcfglinks/src/main/java/org/onosproject/provider/netcfglinks/NetworkConfigLinksProvider.java
index 2d44c5b..6092cec 100644
--- a/providers/netcfglinks/src/main/java/org/onosproject/provider/netcfglinks/NetworkConfigLinksProvider.java
+++ b/providers/netcfglinks/src/main/java/org/onosproject/provider/netcfglinks/NetworkConfigLinksProvider.java
@@ -68,13 +68,18 @@
import static org.onlab.packet.Ethernet.TYPE_BSN;
import static org.onlab.packet.Ethernet.TYPE_LLDP;
import static org.onosproject.net.PortNumber.portNumber;
+import static org.onosproject.provider.netcfglinks.OsgiPropertyConstants.PROP_PROBE_RATE;
+import static org.onosproject.provider.netcfglinks.OsgiPropertyConstants.PROBE_RATE_DEFAULT;
/**
* Provider to pre-discover links and devices based on a specified network
* config.
*/
-@Component(immediate = true)
+@Component(immediate = true,
+ property = {
+ PROP_PROBE_RATE + ":Integer=" + PROBE_RATE_DEFAULT,
+ })
public class NetworkConfigLinksProvider
extends AbstractProvider
implements ProbedLinkProvider {
@@ -100,11 +105,9 @@
@Reference(cardinality = ReferenceCardinality.MANDATORY)
protected ClusterMetadataService metadataService;
- private static final String PROP_PROBE_RATE = "probeRate";
- private static final int DEFAULT_PROBE_RATE = 3000;
//@Property(name = PROP_PROBE_RATE, intValue = DEFAULT_PROBE_RATE,
// label = "LLDP and BDDP probe rate specified in millis")
- private int probeRate = DEFAULT_PROBE_RATE;
+ private int probeRate = PROBE_RATE_DEFAULT;
// Device link discovery helpers.
protected final Map<DeviceId, LinkDiscovery> discoverers = new ConcurrentHashMap<>();
diff --git a/providers/netcfglinks/src/main/java/org/onosproject/provider/netcfglinks/OsgiPropertyConstants.java b/providers/netcfglinks/src/main/java/org/onosproject/provider/netcfglinks/OsgiPropertyConstants.java
new file mode 100644
index 0000000..c04dedb
--- /dev/null
+++ b/providers/netcfglinks/src/main/java/org/onosproject/provider/netcfglinks/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.netcfglinks;
+
+/**
+ * Constants for default values of configurable properties.
+ */
+public final class OsgiPropertyConstants {
+
+ private OsgiPropertyConstants() {}
+
+ public static final String PROP_PROBE_RATE = "probeRate";
+ public static final int PROBE_RATE_DEFAULT = 3000;
+
+}
diff --git a/providers/netconf/device/src/main/java/org/onosproject/provider/netconf/device/impl/NetconfDeviceProvider.java b/providers/netconf/device/src/main/java/org/onosproject/provider/netconf/device/impl/NetconfDeviceProvider.java
index 9f1a6c4..9987c6e 100644
--- a/providers/netconf/device/src/main/java/org/onosproject/provider/netconf/device/impl/NetconfDeviceProvider.java
+++ b/providers/netconf/device/src/main/java/org/onosproject/provider/netconf/device/impl/NetconfDeviceProvider.java
@@ -94,12 +94,17 @@
import static java.util.concurrent.Executors.newScheduledThreadPool;
import static org.onlab.util.Tools.groupedThreads;
+import static org.onosproject.provider.netconf.device.impl.OsgiPropertyConstants.*;
import static org.slf4j.LoggerFactory.getLogger;
/**
* Provider which uses an NETCONF controller to detect device.
*/
-@Component(immediate = true)
+@Component(immediate = true,
+ property = {
+ POLL_FREQUENCY_SECONDS_DEFAULT + ":Integer=" + POLL_FREQUENCY_SECONDS_DEFAULT,
+ MAX_RETRIES + ":Integer=" + MAX_RETRIES_DEFAULT,
+ })
public class NetconfDeviceProvider extends AbstractProvider
implements DeviceProvider {
@@ -140,17 +145,15 @@
private static final String PORT = "port";
private static final int CORE_POOL_SIZE = 10;
- private static final int DEFAULT_POLL_FREQUENCY_SECONDS = 30;
//@Property(name = "pollFrequency", intValue = DEFAULT_POLL_FREQUENCY_SECONDS,
// label = "Configure poll frequency for port status and statistics; " +
// "default is 30 sec")
- private int pollFrequency = DEFAULT_POLL_FREQUENCY_SECONDS;
+ private int pollFrequency = POLL_FREQUENCY_SECONDS_DEFAULT;
- private static final int DEFAULT_MAX_RETRIES = 5;
//@Property(name = "maxRetries", intValue = DEFAULT_MAX_RETRIES,
// label = "Configure maximum allowed number of retries for obtaining list of ports; " +
// "default is 5 times")
- private int maxRetries = DEFAULT_MAX_RETRIES;
+ private int maxRetries = MAX_RETRIES_DEFAULT;
protected ExecutorService executor =
Executors.newFixedThreadPool(5, groupedThreads("onos/netconfdeviceprovider",
@@ -224,12 +227,11 @@
public void modified(ComponentContext context) {
if (context != null) {
Dictionary<?, ?> properties = context.getProperties();
- pollFrequency = Tools.getIntegerProperty(properties, "pollFrequency",
- DEFAULT_POLL_FREQUENCY_SECONDS);
+ pollFrequency = Tools.getIntegerProperty(properties, POLL_FREQUENCY_SECONDS,
+ POLL_FREQUENCY_SECONDS_DEFAULT);
log.info("Configured. Poll frequency is configured to {} seconds", pollFrequency);
- maxRetries = Tools.getIntegerProperty(properties, "maxRetries",
- DEFAULT_MAX_RETRIES);
+ maxRetries = Tools.getIntegerProperty(properties, MAX_RETRIES, MAX_RETRIES_DEFAULT);
log.info("Configured. Number of retries is configured to {} times", maxRetries);
}
if (scheduledTask != null) {
diff --git a/providers/netconf/device/src/main/java/org/onosproject/provider/netconf/device/impl/OsgiPropertyConstants.java b/providers/netconf/device/src/main/java/org/onosproject/provider/netconf/device/impl/OsgiPropertyConstants.java
new file mode 100644
index 0000000..8ededfd
--- /dev/null
+++ b/providers/netconf/device/src/main/java/org/onosproject/provider/netconf/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.netconf.device.impl;
+
+/**
+ * Constants for default values of configurable properties.
+ */
+public final class OsgiPropertyConstants {
+
+ private OsgiPropertyConstants() {}
+
+ public static final String POLL_FREQUENCY_SECONDS = "pollFrequency";
+ public static final int POLL_FREQUENCY_SECONDS_DEFAULT = 30;
+
+ public static final String MAX_RETRIES = "maxRetries";
+ public static final int MAX_RETRIES_DEFAULT = 5;
+
+}
diff --git a/providers/null/src/main/java/org/onosproject/provider/nil/NullProviders.java b/providers/null/src/main/java/org/onosproject/provider/nil/NullProviders.java
index 2258f44..1f21244 100644
--- a/providers/null/src/main/java/org/onosproject/provider/nil/NullProviders.java
+++ b/providers/null/src/main/java/org/onosproject/provider/nil/NullProviders.java
@@ -64,13 +64,23 @@
import static org.onosproject.net.DeviceId.deviceId;
import static org.onosproject.net.MastershipRole.MASTER;
import static org.onosproject.net.MastershipRole.NONE;
+import static org.onosproject.provider.nil.OsgiPropertyDefaults.*;
import static org.slf4j.LoggerFactory.getLogger;
/**
* Provider of a fake network environment, i.e. devices, links, hosts, etc.
* To be used for benchmarking only.
*/
-@Component(immediate = true, service = NullProviders.class)
+@Component(immediate = true, service = NullProviders.class,
+ property = {
+ "enabled:Boolean=" + false,
+ "topoShape=" + TOPO_SHAPE_DEFAULT,
+ "deviceCount:Integer=" + DEVICE_COUNT_DEFAULT,
+ "hostCount:Integer=" + HOST_COUNT_DEFAULT,
+ "packetRate:Integer=" + PACKET_RATE_DEFAULT,
+ "mutationRate:Double=" + MUTATION_RATE_DEFAULT,
+ "mastership=" + MASTERSHIP_DEFAULT,
+ })
public class NullProviders {
private static final Logger log = getLogger(NullProviders.class);
@@ -82,7 +92,6 @@
"Settings: enabled={}, topoShape={}, deviceCount={}, " +
"hostCount={}, packetRate={}, mutationRate={}";
-
@Reference(cardinality = ReferenceCardinality.MANDATORY)
protected ClusterService clusterService;
@@ -141,35 +150,29 @@
// label = "Enables or disables the provider")
private boolean enabled = false;
- private static final String DEFAULT_TOPO_SHAPE = "configured";
//@Property(name = "topoShape", value = DEFAULT_TOPO_SHAPE,
// label = "Topology shape: configured, linear, reroute, tree, spineleaf, mesh, grid")
- private String topoShape = DEFAULT_TOPO_SHAPE;
+ private String topoShape = TOPO_SHAPE_DEFAULT;
- private static final int DEFAULT_DEVICE_COUNT = 10;
//@Property(name = "deviceCount", intValue = DEFAULT_DEVICE_COUNT,
// label = "Number of devices to generate")
- private int deviceCount = DEFAULT_DEVICE_COUNT;
+ private int deviceCount = DEVICE_COUNT_DEFAULT;
- private static final int DEFAULT_HOST_COUNT = 5;
//@Property(name = "hostCount", intValue = DEFAULT_HOST_COUNT,
// label = "Number of host to generate per device")
- private int hostCount = DEFAULT_HOST_COUNT;
+ private int hostCount = HOST_COUNT_DEFAULT;
- private static final int DEFAULT_PACKET_RATE = 0;
//@Property(name = "packetRate", intValue = DEFAULT_PACKET_RATE,
// label = "Packet-in/s rate; 0 for no packets")
- private int packetRate = DEFAULT_PACKET_RATE;
+ private int packetRate = PACKET_RATE_DEFAULT;
- private static final double DEFAULT_MUTATION_RATE = 0;
//@Property(name = "mutationRate", doubleValue = DEFAULT_MUTATION_RATE,
// label = "Link event/s topology mutation rate; 0 for no mutations")
- private double mutationRate = DEFAULT_MUTATION_RATE;
+ private double mutationRate = MUTATION_RATE_DEFAULT;
- private static final String DEFAULT_MASTERSHIP = "random";
//@Property(name = "mastership", value = DEFAULT_MASTERSHIP,
// label = "Mastership given as 'random' or 'node1=dpid,dpid/node2=dpid,...'")
- private String mastership = DEFAULT_MASTERSHIP;
+ private String mastership = MASTERSHIP_DEFAULT;
@Activate
@@ -407,7 +410,7 @@
// Re-assigns mastership roles.
private void reassignMastership() {
- if (mastership.equals(DEFAULT_MASTERSHIP)) {
+ if (mastership.equals(MASTERSHIP_DEFAULT)) {
mastershipService.balanceRoles();
} else {
NodeId localNode = clusterService.getLocalNode().id();
diff --git a/providers/null/src/main/java/org/onosproject/provider/nil/OsgiPropertyDefaults.java b/providers/null/src/main/java/org/onosproject/provider/nil/OsgiPropertyDefaults.java
new file mode 100644
index 0000000..2dd35e5
--- /dev/null
+++ b/providers/null/src/main/java/org/onosproject/provider/nil/OsgiPropertyDefaults.java
@@ -0,0 +1,33 @@
+/*
+ * 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.nil;
+
+/**
+ * Constants for default values of configurable properties.
+ */
+public final class OsgiPropertyDefaults {
+
+ private OsgiPropertyDefaults() {}
+
+ public static final String TOPO_SHAPE_DEFAULT = "configured";
+ public static final int DEVICE_COUNT_DEFAULT = 10;
+ public static final int HOST_COUNT_DEFAULT = 5;
+ public static final int PACKET_RATE_DEFAULT = 0;
+ public static final double MUTATION_RATE_DEFAULT = 0;
+ public static final String MASTERSHIP_DEFAULT = "random";
+
+}
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;
+
+}
diff --git a/providers/pcep/tunnel/src/main/java/org/onosproject/provider/pcep/tunnel/impl/OsgiPropertyConstants.java b/providers/pcep/tunnel/src/main/java/org/onosproject/provider/pcep/tunnel/impl/OsgiPropertyConstants.java
new file mode 100644
index 0000000..4d7b840
--- /dev/null
+++ b/providers/pcep/tunnel/src/main/java/org/onosproject/provider/pcep/tunnel/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.pcep.tunnel.impl;
+
+/**
+ * Constants for default values of configurable properties.
+ */
+public final class OsgiPropertyConstants {
+
+ private OsgiPropertyConstants() {}
+
+ public static final String POLL_FREQUENCY = "tunnelStatsPollFrequency";
+ public static final int POLL_FREQUENCY_DEFAULT = 10;
+
+}
diff --git a/providers/pcep/tunnel/src/main/java/org/onosproject/provider/pcep/tunnel/impl/PcepTunnelProvider.java b/providers/pcep/tunnel/src/main/java/org/onosproject/provider/pcep/tunnel/impl/PcepTunnelProvider.java
index 41215ba..04612c45 100644
--- a/providers/pcep/tunnel/src/main/java/org/onosproject/provider/pcep/tunnel/impl/PcepTunnelProvider.java
+++ b/providers/pcep/tunnel/src/main/java/org/onosproject/provider/pcep/tunnel/impl/PcepTunnelProvider.java
@@ -154,6 +154,8 @@
import static org.onosproject.pcep.server.PcepLspSyncAction.SEND_UPDATE;
import static org.onosproject.pcepio.protocol.ver1.PcepMetricObjectVer1.IGP_METRIC;
import static org.onosproject.pcepio.protocol.ver1.PcepMetricObjectVer1.TE_METRIC;
+import static org.onosproject.provider.pcep.tunnel.impl.OsgiPropertyConstants.POLL_FREQUENCY;
+import static org.onosproject.provider.pcep.tunnel.impl.OsgiPropertyConstants.POLL_FREQUENCY_DEFAULT;
import static org.onosproject.provider.pcep.tunnel.impl.RequestType.CREATE;
import static org.onosproject.provider.pcep.tunnel.impl.RequestType.DELETE;
import static org.onosproject.provider.pcep.tunnel.impl.RequestType.LSP_STATE_RPT;
@@ -164,7 +166,10 @@
* Provider which uses an PCEP controller to detect, update, create network
* tunnels.
*/
-@Component(immediate = true, service = TunnelProvider.class)
+@Component(immediate = true, service = TunnelProvider.class,
+ property = {
+ POLL_FREQUENCY + ":Integer=" + POLL_FREQUENCY_DEFAULT,
+ })
public class PcepTunnelProvider extends AbstractProvider implements TunnelProvider {
private static final Logger log = getLogger(PcepTunnelProvider.class);
@@ -178,10 +183,9 @@
private static final int WAIT_TIME = 5;
public static final String LSRID = "lsrId";
- static final int POLL_INTERVAL = 10;
//@Property(name = "tunnelStatsPollFrequency", intValue = POLL_INTERVAL,
// label = "Frequency (in seconds) for polling tunnel statistics")
- private int tunnelStatsPollFrequency = POLL_INTERVAL;
+ private int tunnelStatsPollFrequency = POLL_FREQUENCY_DEFAULT;
private static final String TUNNLE_NOT_NULL = "Create failed,The given port may be wrong or has been occupied.";
@@ -262,7 +266,7 @@
Dictionary<?, ?> properties = context.getProperties();
int newTunnelStatsPollFrequency;
try {
- String s = get(properties, "tunnelStatsPollFrequency");
+ String s = get(properties, POLL_FREQUENCY);
newTunnelStatsPollFrequency = isNullOrEmpty(s) ? tunnelStatsPollFrequency : Integer.parseInt(s.trim());
} catch (NumberFormatException | ClassCastException e) {
diff --git a/providers/rest/device/src/main/java/org/onosproject/provider/rest/device/impl/OsgiPropertyConstants.java b/providers/rest/device/src/main/java/org/onosproject/provider/rest/device/impl/OsgiPropertyConstants.java
new file mode 100644
index 0000000..41e65ba
--- /dev/null
+++ b/providers/rest/device/src/main/java/org/onosproject/provider/rest/device/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.rest.device.impl;
+
+/**
+ * Constants for default values of configurable properties.
+ */
+public final class OsgiPropertyConstants {
+
+ private OsgiPropertyConstants() {}
+
+ public static final String POLL_FREQUENCY = "pollFrequency";
+ public static final int POLL_FREQUENCY_DEFAULT = 30;
+
+}
diff --git a/providers/rest/device/src/main/java/org/onosproject/provider/rest/device/impl/RestDeviceProvider.java b/providers/rest/device/src/main/java/org/onosproject/provider/rest/device/impl/RestDeviceProvider.java
index e63e6e0..c6a0ae9 100644
--- a/providers/rest/device/src/main/java/org/onosproject/provider/rest/device/impl/RestDeviceProvider.java
+++ b/providers/rest/device/src/main/java/org/onosproject/provider/rest/device/impl/RestDeviceProvider.java
@@ -92,12 +92,17 @@
import static org.onosproject.net.config.NetworkConfigEvent.Type.CONFIG_ADDED;
import static org.onosproject.net.config.NetworkConfigEvent.Type.CONFIG_REMOVED;
import static org.onosproject.net.config.NetworkConfigEvent.Type.CONFIG_UPDATED;
+import static org.onosproject.provider.rest.device.impl.OsgiPropertyConstants.POLL_FREQUENCY;
+import static org.onosproject.provider.rest.device.impl.OsgiPropertyConstants.POLL_FREQUENCY_DEFAULT;
import static org.slf4j.LoggerFactory.getLogger;
/**
* Provider for devices that use REST as means of configuration communication.
*/
-@Component(immediate = true, service = DeviceProvider.class)
+@Component(immediate = true, service = DeviceProvider.class,
+ property = {
+ POLL_FREQUENCY + ":Integer=" + POLL_FREQUENCY_DEFAULT,
+ })
public class RestDeviceProvider extends AbstractProvider
implements DeviceProvider {
private static final String APP_NAME = "org.onosproject.restsb";
@@ -106,7 +111,6 @@
private static final String IPADDRESS = "ipaddress";
private static final String ISNOTNULL = "Rest device is not null";
private static final String UNKNOWN = "unknown";
- private static final String POLL_FREQUENCY = "pollFrequency";
private static final int REST_TIMEOUT_SEC = 5;
private static final int EXECUTOR_THREAD_POOL_SIZE = 8;
private final Logger log = getLogger(getClass());
@@ -132,11 +136,10 @@
@Reference(cardinality = ReferenceCardinality.MANDATORY)
protected DriverService driverService;
- private static final int DEFAULT_POLL_FREQUENCY_SECONDS = 30;
//@Property(name = POLL_FREQUENCY, intValue = DEFAULT_POLL_FREQUENCY_SECONDS,
// label = "Configure poll frequency for port status and statistics; " +
// "default is 30 seconds")
- private int pollFrequency = DEFAULT_POLL_FREQUENCY_SECONDS;
+ private int pollFrequency = POLL_FREQUENCY_DEFAULT;
private DeviceProviderService providerService;
private ApplicationId appId;
@@ -182,7 +185,7 @@
if (context != null) {
Dictionary<?, ?> properties = context.getProperties();
pollFrequency = Tools.getIntegerProperty(properties, POLL_FREQUENCY,
- DEFAULT_POLL_FREQUENCY_SECONDS);
+ POLL_FREQUENCY_DEFAULT);
log.info("Configured. Poll frequency is configured to {} seconds", pollFrequency);
}