From d57a8a15cbfae3e701eb664b20086fcfb5951f49 Mon Sep 17 00:00:00 2001 From: Chi-Vien Ly Date: Thu, 28 Mar 2013 20:51:14 -0700 Subject: [PATCH] Ability to configure some system parameters on the controller This commit allows the controller to be brought up with the following parameters that can be specified in the config.ini file: - of.listenPort=6633. TCP port on which the controller is listening (default 6633) - of.messageResponseTimer=5000. The time (in milliseconds) the controller will wait for a response after sending a Barrier Request or a Statistic Request message (default 2000 msec) If the paramater is not specified in the config.ini, the controller will use the default value. Change-Id: Ifc805c5cedcbb9e68dc5c8e166b3f0f814b6fb8e Signed-off-by: Chi-Vien Ly --- .../main/resources/configuration/config.ini | 6 ++++++ .../openflow/core/internal/ControllerIO.java | 2 +- .../openflow/core/internal/SwitchHandler.java | 18 ++++++++++++++---- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/opendaylight/distribution/opendaylight/src/main/resources/configuration/config.ini b/opendaylight/distribution/opendaylight/src/main/resources/configuration/config.ini index 1b3d1ec062..3f373e95b7 100644 --- a/opendaylight/distribution/opendaylight/src/main/resources/configuration/config.ini +++ b/opendaylight/distribution/opendaylight/src/main/resources/configuration/config.ini @@ -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 diff --git a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/core/internal/ControllerIO.java b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/core/internal/ControllerIO.java index 3e39ab26e6..a4b7584337 100644 --- a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/core/internal/ControllerIO.java +++ b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/core/internal/ControllerIO.java @@ -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(); diff --git a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/core/internal/SwitchHandler.java b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/core/internal/SwitchHandler.java index 6d94703182..8881fb5364 100644 --- a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/core/internal/SwitchHandler.java +++ b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/core/internal/SwitchHandler.java @@ -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> 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>(); 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 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 -- 2.36.6