diff --git a/src/main/java/net/floodlightcontroller/core/IOFSwitch.java b/src/main/java/net/floodlightcontroller/core/IOFSwitch.java index 6bc92c98fae1e9866c99606d352f6115d1b0c618..0d823d839a59ac5d705349bddc9fe67b9e71e538 100644 --- a/src/main/java/net/floodlightcontroller/core/IOFSwitch.java +++ b/src/main/java/net/floodlightcontroller/core/IOFSwitch.java @@ -20,7 +20,6 @@ package net.floodlightcontroller.core; import java.io.IOException; import java.net.SocketAddress; import java.util.Collection; -import java.util.Date; import java.util.List; import java.util.Map; import java.util.concurrent.Future; @@ -293,7 +292,7 @@ public interface IOFSwitch { * Retrieves the date the switch connected to this controller * @return the date */ - public Date getConnectedSince(); + public String getConnectedSince(); /** * Returns the next available transaction id diff --git a/src/main/java/net/floodlightcontroller/core/OFSwitchBase.java b/src/main/java/net/floodlightcontroller/core/OFSwitchBase.java index 19b9fc1d5b571e5f7f6cc1a3c1e8e0e9247baae3..6c188a7177daf589923454144da722ce9d50203c 100644 --- a/src/main/java/net/floodlightcontroller/core/OFSwitchBase.java +++ b/src/main/java/net/floodlightcontroller/core/OFSwitchBase.java @@ -72,7 +72,7 @@ import org.slf4j.LoggerFactory; public abstract class OFSwitchBase implements IOFSwitch { // TODO: should we really do logging in the class or should we throw // exception that can then be handled by callers? - protected static Logger log = LoggerFactory.getLogger(OFSwitchBase.class); + protected static final Logger log = LoggerFactory.getLogger(OFSwitchBase.class); protected ConcurrentMap<Object, Object> attributes; protected IFloodlightProviderService floodlightProvider; @@ -144,8 +144,8 @@ public abstract class OFSwitchBase implements IOFSwitch { // Defaults properties for an ideal switch this.setAttribute(PROP_FASTWILDCARDS, OFMatch.OFPFW_ALL); - this.setAttribute(PROP_SUPPORTS_OFPP_FLOOD, new Boolean(true)); - this.setAttribute(PROP_SUPPORTS_OFPP_TABLE, new Boolean(true)); + this.setAttribute(PROP_SUPPORTS_OFPP_FLOOD, Boolean.valueOf(true)); + this.setAttribute(PROP_SUPPORTS_OFPP_TABLE, Boolean.valueOf(true)); } @@ -187,8 +187,15 @@ public abstract class OFSwitchBase implements IOFSwitch { } // For driver subclass to set throttling + @LogMessageDoc(level="INFO", + message="Enabled write throttling to {switch}", + explanation="OFMessage writes to switch is throttled " + + "to prevent excessively long queues") protected void enableWriteThrottle(boolean enable) { this.writeThrottleEnabled = enable; + if (enable) { + log.info("Enabled write throttling to {}", this); + } } @Override @@ -433,8 +440,8 @@ public abstract class OFSwitchBase implements IOFSwitch { } @Override - public Date getConnectedSince() { - return connectedSince; + public String getConnectedSince() { + return connectedSince.toString(); } @JsonIgnore diff --git a/src/main/java/net/floodlightcontroller/core/internal/Controller.java b/src/main/java/net/floodlightcontroller/core/internal/Controller.java index cfdf74d3aae86c1c97eb083fbcf076e5bdac83b0..77ee0e1d10c5b7dad37df8e80c064be96b493731 100644 --- a/src/main/java/net/floodlightcontroller/core/internal/Controller.java +++ b/src/main/java/net/floodlightcontroller/core/internal/Controller.java @@ -31,6 +31,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.LinkedHashMap; +import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Map.Entry; @@ -62,6 +63,7 @@ import net.floodlightcontroller.core.RoleInfo; import net.floodlightcontroller.core.annotations.LogMessageDoc; import net.floodlightcontroller.core.annotations.LogMessageDocs; import net.floodlightcontroller.core.internal.OFChannelState.HandshakeState; +import net.floodlightcontroller.core.internal.RoleChanger.PendingRoleRequestEntry; import net.floodlightcontroller.core.util.ListenerDispatcher; import net.floodlightcontroller.core.util.SingletonTask; import net.floodlightcontroller.core.web.CoreWebRoutable; @@ -1017,7 +1019,9 @@ public class Controller implements IFloodlightProviderService, // the master to someone else. // Only send if there are no pending requests. synchronized(roleChanger) { - if (roleChanger.pendingRequestMap.get(sw) == null) { + LinkedList<PendingRoleRequestEntry> list = + roleChanger.pendingRequestMap.get(sw); + if (list == null || list.isEmpty()) { log.info("Tell switch {} who is the master", sw); roleChanger.submitRequest(Collections.singleton(sw), role); } diff --git a/src/test/java/net/floodlightcontroller/util/OFMessageDamperMockSwitch.java b/src/test/java/net/floodlightcontroller/util/OFMessageDamperMockSwitch.java index 29191365cddad3344d7390f4d363cfcd0eaf8820..c4f8b83dbdeaac97ead70ea85fd31fcaada827ab 100644 --- a/src/test/java/net/floodlightcontroller/util/OFMessageDamperMockSwitch.java +++ b/src/test/java/net/floodlightcontroller/util/OFMessageDamperMockSwitch.java @@ -21,7 +21,6 @@ import java.io.IOException; import java.net.SocketAddress; import java.util.Collection; -import java.util.Date; import java.util.List; import java.util.Map; import java.util.concurrent.Future; @@ -228,7 +227,7 @@ public class OFMessageDamperMockSwitch implements IOFSwitch { } @Override - public Date getConnectedSince() { + public String getConnectedSince() { assertTrue("Unexpected method call", false); return null; }