- DiscoveryService yields to avoid hogging the cpu 16/1116/1
authorJason Ye <yisye@cisco.com>
Fri, 6 Sep 2013 20:15:34 +0000 (13:15 -0700)
committerJason Ye <yisye@cisco.com>
Fri, 6 Sep 2013 20:15:34 +0000 (13:15 -0700)
- SwitchManager getNodes() not to return null

Change-Id: I7fc6bcc3953108745505c6c3ed8060618f500fe3
Signed-off-by: Jason Ye <yisye@cisco.com>
opendaylight/distribution/opendaylight/src/main/resources/configuration/config.ini
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/DiscoveryService.java
opendaylight/switchmanager/implementation/src/main/java/org/opendaylight/controller/switchmanager/internal/SwitchManager.java

index 5501be46b2e59afb2743d70aad90c549ad5a4ae7..ba1a54b662f3f4c68d328bc5390c57239c2d451e 100644 (file)
@@ -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
 # 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.
 
 # TLS configuration
 # To enable TLS, set secureChannelEnabled=true and specify the location of controller Java KeyStore and TrustStore files.
index 1938cb1ae68e66efe8bb68b12f42e3fcf1373703..0895d9af27c85132965a98ea23cd166784a3e538 100644 (file)
@@ -131,6 +131,7 @@ public class DiscoveryService implements IInventoryShimExternalListener, IDataPa
 
     class DiscoveryTransmit implements Runnable {
         private final BlockingQueue<NodeConnector> transmitQ;
 
     class DiscoveryTransmit implements Runnable {
         private final BlockingQueue<NodeConnector> transmitQ;
+        private int count = 0;
 
         DiscoveryTransmit(BlockingQueue<NodeConnector> transmitQ) {
             this.transmitQ = transmitQ;
 
         DiscoveryTransmit(BlockingQueue<NodeConnector> transmitQ) {
             this.transmitQ = transmitQ;
@@ -144,6 +145,9 @@ public class DiscoveryService implements IInventoryShimExternalListener, IDataPa
                     RawPacket outPkt = createDiscoveryPacket(nodeConnector);
                     sendDiscoveryPacket(nodeConnector, outPkt);
                     nodeConnector = null;
                     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) {
                 } 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");
      */
     private int getDiscoveryBatchMaxPorts() {
         String val = System.getProperty("of.discoveryBatchMaxPorts");
-        int ports = 1024;
+        int ports = 512;
 
         if (val != null) {
             try {
 
         if (val != null) {
             try {
index 60330c1ad46b4709c56267578b411ccba2d4aefa..1390f94b494c423198abde7736b4e77f965046d0 100644 (file)
@@ -1104,7 +1104,7 @@ public class SwitchManager implements ISwitchManager, IConfigurationContainerAwa
     @Override
     public Set<Node> getNodes() {
         return (nodeProps != null) ? new HashSet<Node>(nodeProps.keySet())
     @Override
     public Set<Node> getNodes() {
         return (nodeProps != null) ? new HashSet<Node>(nodeProps.keySet())
-                : null;
+                : new HashSet<Node>();
     }
 
     /*
     }
 
     /*