Merge "Ability to configure some system parameters on the controller"
authorGiovanni Meo <gmeo@cisco.com>
Fri, 29 Mar 2013 07:52:55 +0000 (07:52 +0000)
committerGerrit Code Review <gerrit@daylight1.linux-foundation.org>
Fri, 29 Mar 2013 07:52:55 +0000 (07:52 +0000)
opendaylight/distribution/opendaylight/src/main/resources/configuration/config.ini
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/core/internal/ControllerIO.java
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/core/internal/SwitchHandler.java

index 1b3d1ec062c658e22194ef79ccac36151d3b715a..3f373e95b78fb7ca409c0949b1613275e5658f98 100644 (file)
@@ -39,3 +39,9 @@ logback.configurationFile=configuration/logback.xml
 
 # Embedded Tomcat configuration File
 org.eclipse.gemini.web.tomcat.config.path=configuration/tomcat-server.xml
+
+# Open Flow related system parameters
+# TCP port on which the controller is listening (default 6633)
+# of.listenPort=6633
+# The time (in milliseconds) the controller will wait for a response after sending a Barrier Request or a Statistic Request message (default 2000 msec)
+# of.messageResponseTimer=2000
index 3e39ab26e6680603391da98b08bef1d82e1df6ba..a4b75843376071ba402729f63e591c2e7bb0b7fe 100644 (file)
@@ -35,7 +35,7 @@ public class ControllerIO {
     public ControllerIO(IController l) {
         this.listener = l;
         this.openFlowPort = defaultOpenFlowPort;
-        String portString = System.getProperty("port");
+        String portString = System.getProperty("of.listenPort");
         if (portString != null) {
             try {
                 openFlowPort = Short.decode(portString).shortValue();
index 6d94703182cf7564be00a60725cab45417046ee0..8881fb53640caa58e692a08bdbdbb7bbb80916e6 100644 (file)
@@ -62,8 +62,7 @@ public class SwitchHandler implements ISwitch {
             .getLogger(SwitchHandler.class);
     private static final int SWITCH_LIVENESS_TIMER = 5000;
     private static final int SWITCH_LIVENESS_TIMEOUT = 2 * SWITCH_LIVENESS_TIMER + 500;
-    private static final int SYNCHRONOUS_FLOW_TIMEOUT = 2000;
-    private static final int STATS_COLLECTION_TIMEOUT = 2000;
+    private int MESSAGE_RESPONSE_TIMER = 2000;
     private static final int bufferSize = 1024 * 1024;
 
     private String instanceName;
@@ -92,6 +91,7 @@ public class SwitchHandler implements ISwitch {
     private ConcurrentHashMap<Integer, Callable<Object>> messageWaitingDone;
     private boolean running;
     private Thread switchHandlerThread;
+    private Integer responseTimerValue;
 
     private enum SwitchState {
         NON_OPERATIONAL(0), WAIT_FEATURES_REPLY(1), WAIT_CONFIG_REPLY(2), OPERATIONAL(
@@ -132,6 +132,16 @@ public class SwitchHandler implements ISwitch {
         this.messageWaitingDone = new ConcurrentHashMap<Integer, Callable<Object>>();
         this.inBuffer = ByteBuffer.allocateDirect(bufferSize);
         this.outBuffer = ByteBuffer.allocateDirect(bufferSize);
+        this.responseTimerValue = MESSAGE_RESPONSE_TIMER;
+        String rTimer = System.getProperty("of.messageResponseTimer");
+        if (rTimer != null) {
+            try {
+                responseTimerValue = Integer.decode(rTimer);
+            } catch (NumberFormatException e) {
+                logger.warn("Invalid of.messageResponseTimer:" + rTimer + ", use default("
+                        + MESSAGE_RESPONSE_TIMER+ ")");
+            }
+        }
     }
 
     public void start() {
@@ -532,7 +542,7 @@ public class SwitchHandler implements ISwitch {
         Object result = null;
         try {
             result = submit
-                    .get(STATS_COLLECTION_TIMEOUT, TimeUnit.MILLISECONDS);
+                    .get(MESSAGE_RESPONSE_TIMER, TimeUnit.MILLISECONDS);
             return result;
         } catch (Exception e) {
             logger.warn("Timeout while waiting for " + req.getType()
@@ -552,7 +562,7 @@ public class SwitchHandler implements ISwitch {
         Future<Object> submit = executor.submit(worker);
         try {
             result = submit
-                    .get(SYNCHRONOUS_FLOW_TIMEOUT, TimeUnit.MILLISECONDS);
+                    .get(responseTimerValue, TimeUnit.MILLISECONDS);
             messageWaitingDone.remove(xid);
             if (result == null) {
                 // if result  is null, then it means the switch can handle this message successfully