From 836cfa00a4cd5f343f993519a36fdd1297a54d3f Mon Sep 17 00:00:00 2001 From: Alex Reimers <alex@bigswitch.com> Date: Mon, 16 Jan 2012 14:00:39 -0800 Subject: [PATCH] 1 - Rename PortSettings to CmdLineSettings 2 - Added a call to change StaticFlowPusher push interval 3 - Added various comments Conflicts: src/main/java/net/floodlightcontroller/topology/internal/TopologyImpl.java --- ...PortSettings.java => CmdLineSettings.java} | 2 +- .../core/internal/Controller.java | 7 +++--- .../forwarding/Forwarding.java | 7 ++++-- .../StaticFlowEntryPusher.java | 24 ++++++++++++++----- .../topology/internal/TopologyImpl.java | 15 +++++++----- 5 files changed, 36 insertions(+), 19 deletions(-) rename src/main/java/net/floodlightcontroller/core/internal/{PortSettings.java => CmdLineSettings.java} (95%) diff --git a/src/main/java/net/floodlightcontroller/core/internal/PortSettings.java b/src/main/java/net/floodlightcontroller/core/internal/CmdLineSettings.java similarity index 95% rename from src/main/java/net/floodlightcontroller/core/internal/PortSettings.java rename to src/main/java/net/floodlightcontroller/core/internal/CmdLineSettings.java index bfcea91df..52b4fdefc 100644 --- a/src/main/java/net/floodlightcontroller/core/internal/PortSettings.java +++ b/src/main/java/net/floodlightcontroller/core/internal/CmdLineSettings.java @@ -5,7 +5,7 @@ import org.kohsuke.args4j.Option; /** * Expresses the port settings of OpenFlow controller. */ -public class PortSettings { +public class CmdLineSettings { private final int DEFAULT_OPENFLOW_PORT = 6633; private final int DEFAULT_REST_PORT = 8080; diff --git a/src/main/java/net/floodlightcontroller/core/internal/Controller.java b/src/main/java/net/floodlightcontroller/core/internal/Controller.java index 589ceac4c..7896a86b0 100644 --- a/src/main/java/net/floodlightcontroller/core/internal/Controller.java +++ b/src/main/java/net/floodlightcontroller/core/internal/Controller.java @@ -218,10 +218,10 @@ public class Controller } public Controller() { - this(new PortSettings()); + this(new CmdLineSettings()); } - public Controller(PortSettings settings) { + public Controller(CmdLineSettings settings) { this.messageListeners = new ConcurrentHashMap<OFType, ListenerDispatcher<OFType, @@ -1504,12 +1504,11 @@ public class Controller * Main function entry point; override init() for adding modules * @param args Command line arguments */ - public static void main(String args[]) throws Exception { System.setProperty("org.restlet.engine.loggerFacadeClass", "org.restlet.ext.slf4j.Slf4jLoggerFacade"); - PortSettings settings = new PortSettings(); + CmdLineSettings settings = new CmdLineSettings(); CmdLineParser parser = new CmdLineParser(settings); try { parser.parseArgument(args); diff --git a/src/main/java/net/floodlightcontroller/forwarding/Forwarding.java b/src/main/java/net/floodlightcontroller/forwarding/Forwarding.java index b6322e2f2..7fa76f2f9 100644 --- a/src/main/java/net/floodlightcontroller/forwarding/Forwarding.java +++ b/src/main/java/net/floodlightcontroller/forwarding/Forwarding.java @@ -41,6 +41,7 @@ import org.openflow.protocol.OFPort; import org.openflow.protocol.OFType; import org.openflow.protocol.action.OFAction; import org.openflow.protocol.action.OFActionOutput; +import org.openflow.util.HexString; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -73,11 +74,13 @@ public class Forwarding extends ForwardingBase { Long srcIsland = sw.getSwitchClusterId(); if (srcDevice == null) { - log.error("No device entry found for source device {}", dstDevice.getDataLayerAddress()); + log.error("No device entry found for source device {}", + HexString.toHexString(dstDevice.getDataLayerAddress())); return; } if (srcIsland == null) { - log.error("No openflow island found for source device {}", dstDevice.getDataLayerAddress()); + log.error("No openflow island found for source device {}", + HexString.toHexString(dstDevice.getDataLayerAddress())); return; } diff --git a/src/main/java/net/floodlightcontroller/staticflowentry/StaticFlowEntryPusher.java b/src/main/java/net/floodlightcontroller/staticflowentry/StaticFlowEntryPusher.java index 239fde01f..585c948ad 100644 --- a/src/main/java/net/floodlightcontroller/staticflowentry/StaticFlowEntryPusher.java +++ b/src/main/java/net/floodlightcontroller/staticflowentry/StaticFlowEntryPusher.java @@ -68,7 +68,7 @@ public class StaticFlowEntryPusher implements IStaticFlowEntryPusher, IOFSwitchL protected ArrayList<String> flowmodList; protected ArrayList<IOFSwitch> activeSwitches; protected HashMap<Long, HashMap<String, OFFlowMod>> flowmods; - protected Long pushEntriesFrequency = 25L; + protected int pushEntriesFrequency = 25; // seconds protected Runnable pushEntriesTimer; public StaticFlowEntryPusher() { @@ -90,9 +90,21 @@ public class StaticFlowEntryPusher implements IStaticFlowEntryPusher, IOFSwitchL this.floodlightProvider = floodlightProvider; } - public long getFlowPushTimeSeconds() { + /** + * Gets the static flow entry push interval + * @return The push interval in seconds + */ + public int getFlowPushTimeSeconds() { return pushEntriesFrequency; } + + /** + * Sets the static flow entry push interval + * @param s The interval in seconds to set + */ + public void setFlowPushTimeSeconds(int s) { + pushEntriesFrequency = s; + } @Override public void addedSwitch(IOFSwitch sw) { @@ -542,7 +554,7 @@ public class StaticFlowEntryPusher implements IStaticFlowEntryPusher, IOFSwitchL fm.setMatch(match); fm.setActions(actions); fm.setPriority((short)Integer.parseInt(priority)); - fm.setCookie(computeEntryCookie(fm, (int)Integer.parseInt(userCookie), name)); + fm.setCookie(computeEntryCookie((int)Integer.parseInt(userCookie), name)); fm.setLength(U16.t(OFFlowMod.MINIMUM_LENGTH + actionsLength)); flowmod.dpidStr = switchDpid; @@ -560,12 +572,11 @@ public class StaticFlowEntryPusher implements IStaticFlowEntryPusher, IOFSwitchL /** * Utility method to compute Cookie for an OFFlowMod object * - * @param fm * @param userCookie * @param name * @return long */ - protected long computeEntryCookie(OFFlowMod fm, int userCookie, String name) { + protected long computeEntryCookie(int userCookie, String name) { // Placeholder for now, but we should do something like this... int STATIC_FLOW_APP_ID = 10; @@ -608,7 +619,8 @@ public class StaticFlowEntryPusher implements IStaticFlowEntryPusher, IOFSwitchL } } }; - floodlightProvider.getScheduledExecutor().schedule(pushEntriesTimer, 1000, TimeUnit.MILLISECONDS); + // Initially push entries in 1 second + floodlightProvider.getScheduledExecutor().schedule(pushEntriesTimer, 1, TimeUnit.SECONDS); } /** diff --git a/src/main/java/net/floodlightcontroller/topology/internal/TopologyImpl.java b/src/main/java/net/floodlightcontroller/topology/internal/TopologyImpl.java index cfeeba6fd..a3e83a099 100644 --- a/src/main/java/net/floodlightcontroller/topology/internal/TopologyImpl.java +++ b/src/main/java/net/floodlightcontroller/topology/internal/TopologyImpl.java @@ -775,11 +775,13 @@ public class TopologyImpl implements IOFMessageListener, IOFSwitchListener, List<LinkTuple> eraseList = new ArrayList<LinkTuple>(); if (this.portLinks.containsKey(tuple)) { - log.debug("handlePortStatus: Switch {} port #{} " + - "reason {}; removing links", - new Object[] {HexString.toHexString(sw.getId()), - ps.getDesc().getPortNumber(), - ps.getReason()}); + if (log.isDebugEnabled()) { + log.debug("handlePortStatus: Switch {} port #{} " + + "reason {}; removing links", + new Object[] {HexString.toHexString(sw.getId()), + ps.getDesc().getPortNumber(), + ps.getReason()}); + } eraseList.addAll(this.portLinks.get(tuple)); deleteLinks(eraseList); topologyChanged = true; @@ -831,6 +833,7 @@ public class TopologyImpl implements IOFMessageListener, IOFSwitchListener, } finally { lock.writeLock().unlock(); } + if (!link_deleted) { // Send LLDP right away when port state is changed for faster // cluster-merge. If it is a link delete then there is not need @@ -1015,7 +1018,7 @@ public class TopologyImpl implements IOFMessageListener, IOFSwitchListener, return; } if (log.isTraceEnabled()) { - log.trace("Updating topology cluster info"); + log.trace("Computing topology cluster info"); } // Initialize all the new structures. -- GitLab