From: Jason Ye Date: Fri, 6 Sep 2013 20:15:34 +0000 (-0700) Subject: - DiscoveryService yields to avoid hogging the cpu X-Git-Tag: releasepom-0.1.0~122^2 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=00fcf9417690756f1847a908bc9062ddfea76025 - DiscoveryService yields to avoid hogging the cpu - SwitchManager getNodes() not to return null Change-Id: I7fc6bcc3953108745505c6c3ed8060618f500fe3 Signed-off-by: Jason Ye --- diff --git a/opendaylight/distribution/opendaylight/src/main/resources/configuration/config.ini b/opendaylight/distribution/opendaylight/src/main/resources/configuration/config.ini index 5501be46b2..ba1a54b662 100644 --- a/opendaylight/distribution/opendaylight/src/main/resources/configuration/config.ini +++ b/opendaylight/distribution/opendaylight/src/main/resources/configuration/config.ini @@ -70,8 +70,8 @@ org.eclipse.gemini.web.tomcat.config.path=configuration/tomcat-server.xml # of.discoveryTimeoutMultiple=2 # For newly added ports, allow one more retry if the elapsed time exceeds this threshold (default 30 sec) # of.discoveryThreshold=30 -# The maximum number of ports handled in one discovery batch (default 1024) -# of.discoveryBatchMaxPorts=1024 +# The maximum number of ports handled in one discovery batch (default 512) +# of.discoveryBatchMaxPorts=512 # TLS configuration # To enable TLS, set secureChannelEnabled=true and specify the location of controller Java KeyStore and TrustStore files. diff --git a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/DiscoveryService.java b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/DiscoveryService.java index 1938cb1ae6..0895d9af27 100644 --- a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/DiscoveryService.java +++ b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/DiscoveryService.java @@ -131,6 +131,7 @@ public class DiscoveryService implements IInventoryShimExternalListener, IDataPa class DiscoveryTransmit implements Runnable { private final BlockingQueue transmitQ; + private int count = 0; DiscoveryTransmit(BlockingQueue transmitQ) { this.transmitQ = transmitQ; @@ -144,6 +145,9 @@ public class DiscoveryService implements IInventoryShimExternalListener, IDataPa RawPacket outPkt = createDiscoveryPacket(nodeConnector); sendDiscoveryPacket(nodeConnector, outPkt); nodeConnector = null; + if ((++count & 0x7f) == 0) { + Thread.sleep(10); + } } catch (InterruptedException e1) { logger.warn("DiscoveryTransmit interupted", e1.getMessage()); if (shuttingDown) { @@ -1679,7 +1683,7 @@ public class DiscoveryService implements IInventoryShimExternalListener, IDataPa */ private int getDiscoveryBatchMaxPorts() { String val = System.getProperty("of.discoveryBatchMaxPorts"); - int ports = 1024; + int ports = 512; if (val != null) { try { diff --git a/opendaylight/switchmanager/implementation/src/main/java/org/opendaylight/controller/switchmanager/internal/SwitchManager.java b/opendaylight/switchmanager/implementation/src/main/java/org/opendaylight/controller/switchmanager/internal/SwitchManager.java index 60330c1ad4..1390f94b49 100644 --- a/opendaylight/switchmanager/implementation/src/main/java/org/opendaylight/controller/switchmanager/internal/SwitchManager.java +++ b/opendaylight/switchmanager/implementation/src/main/java/org/opendaylight/controller/switchmanager/internal/SwitchManager.java @@ -1104,7 +1104,7 @@ public class SwitchManager implements ISwitchManager, IConfigurationContainerAwa @Override public Set getNodes() { return (nodeProps != null) ? new HashSet(nodeProps.keySet()) - : null; + : new HashSet(); } /*