Fix checkstyle whitespace issues - WHITESPACE ONLY
Change-Id: Ic205c1afd639c6008d61d9de95cb764eeb6238ca
diff --git a/src/main/java/net/onrc/onos/core/linkdiscovery/ILinkDiscovery.java b/src/main/java/net/onrc/onos/core/linkdiscovery/ILinkDiscovery.java
index ba35850..bfc19d2 100644
--- a/src/main/java/net/onrc/onos/core/linkdiscovery/ILinkDiscovery.java
+++ b/src/main/java/net/onrc/onos/core/linkdiscovery/ILinkDiscovery.java
@@ -8,28 +8,29 @@
public interface ILinkDiscovery {
- @JsonSerialize(using=ToStringSerializer.class)
+ @JsonSerialize(using = ToStringSerializer.class)
public enum UpdateOperation {
- LINK_ADDED("Link Added"), // Operation Added by ONOS
+ LINK_ADDED("Link Added"), // Operation Added by ONOS
LINK_UPDATED("Link Updated"),
LINK_REMOVED("Link Removed"),
SWITCH_UPDATED("Switch Updated"),
SWITCH_REMOVED("Switch Removed"),
PORT_UP("Port Up"),
PORT_DOWN("Port Down");
-
+
private String value;
+
UpdateOperation(String v) {
value = v;
}
-
+
@Override
public String toString() {
return value;
}
}
- public class LDUpdate implements IUpdate{
+ public class LDUpdate implements IUpdate {
protected long src;
protected short srcPort;
protected long dst;
@@ -39,9 +40,9 @@
protected UpdateOperation operation;
public LDUpdate(long src, short srcPort,
- long dst, short dstPort,
- ILinkDiscovery.LinkType type,
- UpdateOperation operation) {
+ long dst, short dstPort,
+ ILinkDiscovery.LinkType type,
+ UpdateOperation operation) {
this.src = src;
this.srcPort = srcPort;
this.dst = dst;
@@ -61,7 +62,7 @@
}
// For updtedSwitch(sw)
- public LDUpdate(long switchId, SwitchType stype, UpdateOperation oper ){
+ public LDUpdate(long switchId, SwitchType stype, UpdateOperation oper) {
this.operation = oper;
this.src = switchId;
this.srcType = stype;
@@ -105,68 +106,69 @@
public void setOperation(UpdateOperation operation) {
this.operation = operation;
}
-
+
@Override
public String toString() {
switch (operation) {
- case LINK_ADDED:
- case LINK_REMOVED:
- case LINK_UPDATED:
- return "LDUpdate [operation=" + operation +
- ", src=" + HexString.toHexString(src)
- + ", srcPort=" + srcPort
- + ", dst=" + HexString.toHexString(dst)
- + ", dstPort=" + dstPort
- + ", type=" + type + "]";
- case PORT_DOWN:
- case PORT_UP:
- return "LDUpdate [operation=" + operation +
- ", src=" + HexString.toHexString(src)
- + ", srcPort=" + srcPort + "]";
- case SWITCH_REMOVED:
- case SWITCH_UPDATED:
- return "LDUpdate [operation=" + operation +
- ", src=" + HexString.toHexString(src) + "]";
- default:
- return "LDUpdate: Unknown update.";
+ case LINK_ADDED:
+ case LINK_REMOVED:
+ case LINK_UPDATED:
+ return "LDUpdate [operation=" + operation +
+ ", src=" + HexString.toHexString(src)
+ + ", srcPort=" + srcPort
+ + ", dst=" + HexString.toHexString(dst)
+ + ", dstPort=" + dstPort
+ + ", type=" + type + "]";
+ case PORT_DOWN:
+ case PORT_UP:
+ return "LDUpdate [operation=" + operation +
+ ", src=" + HexString.toHexString(src)
+ + ", srcPort=" + srcPort + "]";
+ case SWITCH_REMOVED:
+ case SWITCH_UPDATED:
+ return "LDUpdate [operation=" + operation +
+ ", src=" + HexString.toHexString(src) + "]";
+ default:
+ return "LDUpdate: Unknown update.";
}
}
- @Override
- public void dispatch() {
- // TODO Auto-generated method stub
-
- }
+ @Override
+ public void dispatch() {
+ // TODO Auto-generated method stub
+
+ }
}
public enum SwitchType {
- BASIC_SWITCH, CORE_SWITCH
- };
+ BASIC_SWITCH,
+ CORE_SWITCH
+ }
public enum LinkType {
INVALID_LINK {
- @Override
- public String toString() {
- return "invalid";
- }
- },
- DIRECT_LINK{
- @Override
- public String toString() {
- return "internal";
- }
- },
+ @Override
+ public String toString() {
+ return "invalid";
+ }
+ },
+ DIRECT_LINK {
+ @Override
+ public String toString() {
+ return "internal";
+ }
+ },
MULTIHOP_LINK {
- @Override
- public String toString() {
- return "external";
- }
- },
+ @Override
+ public String toString() {
+ return "external";
+ }
+ },
TUNNEL {
- @Override
- public String toString() {
- return "tunnel";
- }
+ @Override
+ public String toString() {
+ return "tunnel";
+ }
}
- };
+ }
}
diff --git a/src/main/java/net/onrc/onos/core/linkdiscovery/ILinkDiscoveryListener.java b/src/main/java/net/onrc/onos/core/linkdiscovery/ILinkDiscoveryListener.java
index 53721d8..9b237c4 100644
--- a/src/main/java/net/onrc/onos/core/linkdiscovery/ILinkDiscoveryListener.java
+++ b/src/main/java/net/onrc/onos/core/linkdiscovery/ILinkDiscoveryListener.java
@@ -1,7 +1,7 @@
/**
* Copyright 2011, Big Switch Networks, Inc.
* Originally created by David Erickson, Stanford University
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at
@@ -17,7 +17,7 @@
package net.onrc.onos.core.linkdiscovery;
-public interface ILinkDiscoveryListener extends ILinkDiscovery{
+public interface ILinkDiscoveryListener extends ILinkDiscovery {
public void linkDiscoveryUpdate(LDUpdate update);
}
diff --git a/src/main/java/net/onrc/onos/core/linkdiscovery/ILinkDiscoveryService.java b/src/main/java/net/onrc/onos/core/linkdiscovery/ILinkDiscoveryService.java
index 6d41532..dce8be0 100644
--- a/src/main/java/net/onrc/onos/core/linkdiscovery/ILinkDiscoveryService.java
+++ b/src/main/java/net/onrc/onos/core/linkdiscovery/ILinkDiscoveryService.java
@@ -1,19 +1,19 @@
/**
-* Copyright 2011, Big Switch Networks, Inc.
-* Originally created by David Erickson, Stanford University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
+ * Copyright 2011, Big Switch Networks, Inc.
+ * Originally created by David Erickson, Stanford University
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License. You may obtain
+ * a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ **/
package net.onrc.onos.core.linkdiscovery;
@@ -32,19 +32,21 @@
/**
* Returns link type of a given link
+ *
* @param info
* @return
*/
public ILinkDiscovery.LinkType getLinkType(Link lt, LinkInfo info);
/**
- * Returns an unmodifiable map from switch id to a set of all links with it
+ * Returns an unmodifiable map from switch id to a set of all links with it
* as an endpoint.
*/
public Map<Long, Set<Link>> getSwitchLinks();
/**
* Adds a listener to listen for ILinkDiscoveryService messages
+ *
* @param listener The listener that wants the notifications
*/
public void addListener(ILinkDiscoveryListener listener);
@@ -76,6 +78,7 @@
/**
* Set the state for auto port fast feature.
+ *
* @param autoPortFastFeature
*/
public void setAutoPortFastFeature(boolean autoPortFastFeature);
diff --git a/src/main/java/net/onrc/onos/core/linkdiscovery/Link.java b/src/main/java/net/onrc/onos/core/linkdiscovery/Link.java
index eb43304..254cc24 100755
--- a/src/main/java/net/onrc/onos/core/linkdiscovery/Link.java
+++ b/src/main/java/net/onrc/onos/core/linkdiscovery/Link.java
@@ -1,19 +1,19 @@
/**
-* Copyright 2011, Big Switch Networks, Inc.
-* Originally created by David Erickson, Stanford University
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
+ * Copyright 2011, Big Switch Networks, Inc.
+ * Originally created by David Erickson, Stanford University
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License. You may obtain
+ * a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ **/
package net.onrc.onos.core.linkdiscovery;
@@ -47,24 +47,25 @@
}
@JsonProperty("src-switch")
- @JsonSerialize(using=DPIDSerializer.class)
+ @JsonSerialize(using = DPIDSerializer.class)
public long getSrc() {
return src;
}
@JsonProperty("src-port")
- @JsonSerialize(using=UShortSerializer.class)
+ @JsonSerialize(using = UShortSerializer.class)
public short getSrcPort() {
return srcPort;
}
@JsonProperty("dst-switch")
- @JsonSerialize(using=DPIDSerializer.class)
+ @JsonSerialize(using = DPIDSerializer.class)
public long getDst() {
return dst;
}
+
@JsonProperty("dst-port")
- @JsonSerialize(using=UShortSerializer.class)
+ @JsonSerialize(using = UShortSerializer.class)
public short getDstPort() {
return dstPort;
}
@@ -103,7 +104,7 @@
@Override
public String toString() {
- return "Link [src=" + HexString.toHexString(this.src)
+ return "Link [src=" + HexString.toHexString(this.src)
+ " outPort="
+ (srcPort & 0xffff)
+ ", dst=" + HexString.toHexString(this.dst)
@@ -111,12 +112,12 @@
+ (dstPort & 0xffff)
+ "]";
}
-
+
public String toKeyString() {
- return (HexString.toHexString(this.src) + "|" +
- (this.srcPort & 0xffff) + "|" +
- HexString.toHexString(this.dst) + "|" +
- (this.dstPort & 0xffff) );
+ return (HexString.toHexString(this.src) + "|" +
+ (this.srcPort & 0xffff) + "|" +
+ HexString.toHexString(this.dst) + "|" +
+ (this.dstPort & 0xffff));
}
}
diff --git a/src/main/java/net/onrc/onos/core/linkdiscovery/LinkInfo.java b/src/main/java/net/onrc/onos/core/linkdiscovery/LinkInfo.java
index 831c63b..89e9a19 100644
--- a/src/main/java/net/onrc/onos/core/linkdiscovery/LinkInfo.java
+++ b/src/main/java/net/onrc/onos/core/linkdiscovery/LinkInfo.java
@@ -1,17 +1,17 @@
/**
-* Copyright 2011, Big Switch Networks, Inc.* Originally created by David Erickson, Stanford University
-** Licensed under the Apache License, Version 2.0 (the "License"); you may
-* not use this file except in compliance with the License. You may obtain
-* a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-* License for the specific language governing permissions and limitations
-* under the License.
-**/
+ * Copyright 2011, Big Switch Networks, Inc.* Originally created by David Erickson, Stanford University
+ ** Licensed under the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License. You may obtain
+ * a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ **/
package net.onrc.onos.core.linkdiscovery;
@@ -40,7 +40,8 @@
protected Long lastLldpReceivedTime; /* Standard LLLDP received time */
protected Long lastBddpReceivedTime; /* Modified LLDP received time */
- /** The port states stored here are topology's last knowledge of
+ /**
+ * The port states stored here are topology's last knowledge of
* the state of the port. This mostly mirrors the state
* maintained in the port list in IOFSwitch (i.e. the one returned
* from getPort), except that during a port status message the
@@ -51,10 +52,9 @@
*/
-
public boolean linkStpBlocked() {
return ((srcPortState & OFPortState.OFPPS_STP_MASK.getValue()) == OFPortState.OFPPS_STP_BLOCK.getValue()) ||
- ((dstPortState & OFPortState.OFPPS_STP_MASK.getValue()) == OFPortState.OFPPS_STP_BLOCK.getValue());
+ ((dstPortState & OFPortState.OFPPS_STP_MASK.getValue()) == OFPortState.OFPPS_STP_BLOCK.getValue());
}
public Long getFirstSeenTime() {
diff --git a/src/main/java/net/onrc/onos/core/linkdiscovery/NodePortTuple.java b/src/main/java/net/onrc/onos/core/linkdiscovery/NodePortTuple.java
index 8d7ba19..6e5e0c3 100644
--- a/src/main/java/net/onrc/onos/core/linkdiscovery/NodePortTuple.java
+++ b/src/main/java/net/onrc/onos/core/linkdiscovery/NodePortTuple.java
@@ -11,6 +11,7 @@
* A NodePortTuple is similar to a SwitchPortTuple
* but it only stores IDs instead of references
* to the actual objects.
+ *
* @author srini
*/
public class NodePortTuple {
@@ -19,6 +20,7 @@
/**
* Creates a NodePortTuple
+ *
* @param nodeId The DPID of the switch
* @param portId The port of the switch
*/
@@ -33,22 +35,25 @@
}
@JsonProperty("switch")
- @JsonSerialize(using=DPIDSerializer.class)
+ @JsonSerialize(using = DPIDSerializer.class)
public long getNodeId() {
return nodeId;
}
+
public void setNodeId(long nodeId) {
this.nodeId = nodeId;
}
+
@JsonProperty("port")
- @JsonSerialize(using=UShortSerializer.class)
+ @JsonSerialize(using = UShortSerializer.class)
public short getPortId() {
return portId;
}
+
public void setPortId(short portId) {
this.portId = portId;
}
-
+
public String toString() {
return "[id=" + HexString.toHexString(nodeId) + ", port=" + new Short(portId) + "]";
}
@@ -77,14 +82,15 @@
return false;
return true;
}
-
+
/**
* API to return a String value formed wtih NodeID and PortID
* The portID is a 16-bit field, so mask it as an integer to get full
* positive value
+ *
* @return
*/
public String toKeyString() {
- return (HexString.toHexString(nodeId)+ "|" + (portId & 0xffff));
+ return (HexString.toHexString(nodeId) + "|" + (portId & 0xffff));
}
}
diff --git a/src/main/java/net/onrc/onos/core/linkdiscovery/internal/EventHistoryTopologyCluster.java b/src/main/java/net/onrc/onos/core/linkdiscovery/internal/EventHistoryTopologyCluster.java
index 172714c..c92e02e 100644
--- a/src/main/java/net/onrc/onos/core/linkdiscovery/internal/EventHistoryTopologyCluster.java
+++ b/src/main/java/net/onrc/onos/core/linkdiscovery/internal/EventHistoryTopologyCluster.java
@@ -5,39 +5,42 @@
import org.codehaus.jackson.annotate.JsonProperty;
import org.codehaus.jackson.map.annotate.JsonSerialize;
-/***
+/**
* Topology Cluster merge/split event history related classes and members
- * @author subrata
*
+ * @author subrata
*/
public class EventHistoryTopologyCluster {
// The following fields are not stored as String to save memory
// They should be converted to appropriate human-readable strings by
// the front end (e.g. in cli in Python)
- public long dpid;
- public long clusterIdOld; // Switch with dpid moved from cluster x to y
- public long clusterIdNew;
- public String reason;
-
+ public long dpid;
+ public long clusterIdOld; // Switch with dpid moved from cluster x to y
+ public long clusterIdNew;
+ public String reason;
+
@JsonProperty("Switch")
- @JsonSerialize(using=DPIDSerializer.class)
+ @JsonSerialize(using = DPIDSerializer.class)
public long getDpid() {
return dpid;
}
+
@JsonProperty("OldClusterId")
- @JsonSerialize(using=DPIDSerializer.class)
+ @JsonSerialize(using = DPIDSerializer.class)
public long getClusterIdOld() {
return clusterIdOld;
}
+
@JsonProperty("NewClusterId")
- @JsonSerialize(using=DPIDSerializer.class)
+ @JsonSerialize(using = DPIDSerializer.class)
public long getClusterIdNew() {
return clusterIdNew;
}
+
@JsonProperty("Reason")
public String getReason() {
return reason;
}
-
-
+
+
}
diff --git a/src/main/java/net/onrc/onos/core/linkdiscovery/internal/EventHistoryTopologyLink.java b/src/main/java/net/onrc/onos/core/linkdiscovery/internal/EventHistoryTopologyLink.java
index 378859f..9f9bed9 100644
--- a/src/main/java/net/onrc/onos/core/linkdiscovery/internal/EventHistoryTopologyLink.java
+++ b/src/main/java/net/onrc/onos/core/linkdiscovery/internal/EventHistoryTopologyLink.java
@@ -5,58 +5,65 @@
import org.codehaus.jackson.annotate.JsonProperty;
import org.codehaus.jackson.map.annotate.JsonSerialize;
-/***
+/**
* Topology link up/down event history related classes and members
- * @author subrata
*
+ * @author subrata
*/
public class EventHistoryTopologyLink {
// The following fields are not stored as String to save memory
// They should be converted to appropriate human-readable strings by
// the front end (e.g. in cli in Python)
- public long srcSwDpid;
- public long dstSwDpid;
- public int srcPortState;
- public int dstPortState;
- public int srcSwport;
- public int dstSwport;
- public String linkType;
- public String reason;
-
+ public long srcSwDpid;
+ public long dstSwDpid;
+ public int srcPortState;
+ public int dstPortState;
+ public int srcSwport;
+ public int dstSwport;
+ public String linkType;
+ public String reason;
+
@JsonProperty("Source-Switch")
- @JsonSerialize(using=DPIDSerializer.class)
+ @JsonSerialize(using = DPIDSerializer.class)
public long getSrcSwDpid() {
return srcSwDpid;
}
+
@JsonProperty("Dest-Switch")
- @JsonSerialize(using=DPIDSerializer.class)
+ @JsonSerialize(using = DPIDSerializer.class)
public long getDstSwDpid() {
return dstSwDpid;
}
+
@JsonProperty("SrcPortState")
public int getSrcPortState() {
return srcPortState;
}
+
@JsonProperty("DstPortState")
public int getDstPortState() {
return dstPortState;
}
+
@JsonProperty("SrcPort")
public int getSrcSwport() {
return srcSwport;
}
+
@JsonProperty("DstPort")
public int getDstSwport() {
return dstSwport;
}
+
@JsonProperty("LinkType")
public String getLinkType() {
return linkType;
}
+
@JsonProperty("Reason")
public String getReason() {
return reason;
}
-
-
+
+
}
diff --git a/src/main/java/net/onrc/onos/core/linkdiscovery/internal/EventHistoryTopologySwitch.java b/src/main/java/net/onrc/onos/core/linkdiscovery/internal/EventHistoryTopologySwitch.java
index b659be7..4d77f76 100644
--- a/src/main/java/net/onrc/onos/core/linkdiscovery/internal/EventHistoryTopologySwitch.java
+++ b/src/main/java/net/onrc/onos/core/linkdiscovery/internal/EventHistoryTopologySwitch.java
@@ -6,38 +6,41 @@
import org.codehaus.jackson.annotate.JsonProperty;
import org.codehaus.jackson.map.annotate.JsonSerialize;
-/***
+/**
* Topology Switch event history related classes and members
- * @author subrata
*
+ * @author subrata
*/
public class EventHistoryTopologySwitch {
// The following fields are not stored as String to save memory
// They should be converted to appropriate human-readable strings by
// the front end (e.g. in cli in Python)
- public long dpid;
- public int ipv4Addr;
- public int l4Port;
- public String reason;
-
+ public long dpid;
+ public int ipv4Addr;
+ public int l4Port;
+ public String reason;
+
@JsonProperty("Switch")
- @JsonSerialize(using=DPIDSerializer.class)
+ @JsonSerialize(using = DPIDSerializer.class)
public long getDpid() {
return dpid;
}
+
@JsonProperty("IpAddr")
- @JsonSerialize(using=IPv4Serializer.class)
+ @JsonSerialize(using = IPv4Serializer.class)
public int getIpv4Addr() {
return ipv4Addr;
}
+
@JsonProperty("Port")
public int getL4Port() {
return l4Port;
}
+
@JsonProperty("Reason")
public String getReason() {
return reason;
}
-
-
+
+
}
diff --git a/src/main/java/net/onrc/onos/core/linkdiscovery/internal/LinkDiscoveryManager.java b/src/main/java/net/onrc/onos/core/linkdiscovery/internal/LinkDiscoveryManager.java
index daed20b..a395ab6 100644
--- a/src/main/java/net/onrc/onos/core/linkdiscovery/internal/LinkDiscoveryManager.java
+++ b/src/main/java/net/onrc/onos/core/linkdiscovery/internal/LinkDiscoveryManager.java
@@ -95,26 +95,26 @@
* match a known switch cause a new LinkTuple to be created according to the
* invariant rules listed below. This new LinkTuple is also passed to routing
* if it exists to trigger updates.
- *
+ * <p/>
* This class also handles removing links that are associated to switch ports
* that go down, and switches that are disconnected.
- *
+ * <p/>
* Invariants:
- * -portLinks and switchLinks will not contain empty Sets outside of
- * critical sections
- * -portLinks contains LinkTuples where one of the src or dst
- * SwitchPortTuple matches the map key
- * -switchLinks contains LinkTuples where one of the src or dst
- * SwitchPortTuple's id matches the switch id
- * -Each LinkTuple will be indexed into switchLinks for both
- * src.id and dst.id, and portLinks for each src and dst
- * -The updates queue is only added to from within a held write lock
+ * -portLinks and switchLinks will not contain empty Sets outside of
+ * critical sections
+ * -portLinks contains LinkTuples where one of the src or dst
+ * SwitchPortTuple matches the map key
+ * -switchLinks contains LinkTuples where one of the src or dst
+ * SwitchPortTuple's id matches the switch id
+ * -Each LinkTuple will be indexed into switchLinks for both
+ * src.id and dst.id, and portLinks for each src and dst
+ * -The updates queue is only added to from within a held write lock
*/
@LogMessageCategory("Network Topology")
public class LinkDiscoveryManager
-implements IOFMessageListener, IOFSwitchListener,
-ILinkDiscoveryService, IFloodlightModule {
- protected IFloodlightProviderService controller;
+ implements IOFMessageListener, IOFSwitchListener,
+ ILinkDiscoveryService, IFloodlightModule {
+ protected IFloodlightProviderService controller;
protected final static Logger log = LoggerFactory.getLogger(LinkDiscoveryManager.class);
protected IFloodlightProviderService floodlightProvider;
@@ -127,7 +127,7 @@
// LLDP and BDDP fields
private static final byte[] LLDP_STANDARD_DST_MAC_STRING =
HexString.fromHexString("01:80:c2:00:00:0e");
- private static final long LINK_LOCAL_MASK = 0xfffffffffff0L;
+ private static final long LINK_LOCAL_MASK = 0xfffffffffff0L;
private static final long LINK_LOCAL_VALUE = 0x0180c2000000L;
// BigSwitch OUI is 5C:16:C7, so 5D:16:C7 is the multicast version
@@ -142,27 +142,27 @@
private static final byte TLV_DIRECTION_VALUE_FORWARD[] = {0x01};
private static final byte TLV_DIRECTION_VALUE_REVERSE[] = {0x02};
private static final LLDPTLV forwardTLV
- = new LLDPTLV().
- setType(TLV_DIRECTION_TYPE).
- setLength(TLV_DIRECTION_LENGTH).
- setValue(TLV_DIRECTION_VALUE_FORWARD);
+ = new LLDPTLV().
+ setType(TLV_DIRECTION_TYPE).
+ setLength(TLV_DIRECTION_LENGTH).
+ setValue(TLV_DIRECTION_VALUE_FORWARD);
private static final LLDPTLV reverseTLV
- = new LLDPTLV().
- setType(TLV_DIRECTION_TYPE).
- setLength(TLV_DIRECTION_LENGTH).
- setValue(TLV_DIRECTION_VALUE_REVERSE);
+ = new LLDPTLV().
+ setType(TLV_DIRECTION_TYPE).
+ setLength(TLV_DIRECTION_LENGTH).
+ setValue(TLV_DIRECTION_VALUE_REVERSE);
// Link discovery task details.
protected SingletonTask discoveryTask;
protected final int DISCOVERY_TASK_INTERVAL = 1;
protected final int LINK_TIMEOUT = 35; // original 35 secs, aggressive 5 secs
- protected final int LLDP_TO_ALL_INTERVAL = 15 ; //original 15 seconds, aggressive 2 secs.
+ protected final int LLDP_TO_ALL_INTERVAL = 15; //original 15 seconds, aggressive 2 secs.
protected long lldpClock = 0;
// This value is intentionally kept higher than LLDP_TO_ALL_INTERVAL.
// If we want to identify link failures faster, we could decrease this
// value to a small number, say 1 or 2 sec.
- protected final int LLDP_TO_KNOWN_INTERVAL= 20; // LLDP frequency for known links
+ protected final int LLDP_TO_KNOWN_INTERVAL = 20; // LLDP frequency for known links
protected LLDPTLV controllerTLV;
protected ReentrantReadWriteLock lock;
@@ -209,34 +209,34 @@
protected class LinkUpdate extends LDUpdate {
- public LinkUpdate(LDUpdate old) {
- super(old);
- }
- @LogMessageDoc(level="ERROR",
- message="Error in link discovery updates loop",
- explanation="An unknown error occured while dispatching " +
- "link update notifications",
- recommendation=LogMessageDoc.GENERIC_ACTION)
- @Override
- public void dispatch() {
- if (linkDiscoveryAware != null) {
+ public LinkUpdate(LDUpdate old) {
+ super(old);
+ }
+
+ @LogMessageDoc(level = "ERROR",
+ message = "Error in link discovery updates loop",
+ explanation = "An unknown error occured while dispatching " +
+ "link update notifications",
+ recommendation = LogMessageDoc.GENERIC_ACTION)
+ @Override
+ public void dispatch() {
+ if (linkDiscoveryAware != null) {
if (log.isTraceEnabled()) {
log.trace("Dispatching link discovery update {} {} {} {} {} for {}",
- new Object[]{this.getOperation(),
- HexString.toHexString(this.getSrc()), this.getSrcPort(),
- HexString.toHexString(this.getDst()), this.getDstPort(),
- linkDiscoveryAware});
+ new Object[]{this.getOperation(),
+ HexString.toHexString(this.getSrc()), this.getSrcPort(),
+ HexString.toHexString(this.getDst()), this.getDstPort(),
+ linkDiscoveryAware});
}
try {
for (ILinkDiscoveryListener lda : linkDiscoveryAware) { // order maintained
lda.linkDiscoveryUpdate(this);
}
- }
- catch (Exception e) {
+ } catch (Exception e) {
log.error("Error in link discovery updates loop", e);
}
}
- }
+ }
}
/**
@@ -244,7 +244,8 @@
*/
protected Set<NodePortTuple> suppressLinkDiscovery;
- /** A list of ports that are quarantined for discovering links through
+ /**
+ * A list of ports that are quarantined for discovering links through
* them. Data traffic from these ports are not allowed until the ports
* are released from quarantine.
*/
@@ -265,6 +266,7 @@
/**
* Get the LLDP sending period in seconds.
+ *
* @return LLDP sending period in seconds.
*/
public int getLldpFrequency() {
@@ -273,6 +275,7 @@
/**
* Get the LLDP timeout value in seconds
+ *
* @return LLDP timeout value in seconds
*/
public int getLldpTimeout() {
@@ -293,8 +296,7 @@
* Remove any known links on the switch port.
*/
@Override
- public void AddToSuppressLLDPs(long sw, short port)
- {
+ public void AddToSuppressLLDPs(long sw, short port) {
NodePortTuple npt = new NodePortTuple(sw, port);
this.suppressLinkDiscovery.add(npt);
deleteLinksOnPort(npt, "LLDP suppressed.");
@@ -305,8 +307,7 @@
* Discover links on that switchport.
*/
@Override
- public void RemoveFromSuppressLLDPs(long sw, short port)
- {
+ public void RemoveFromSuppressLLDPs(long sw, short port) {
NodePortTuple npt = new NodePortTuple(sw, port);
this.suppressLinkDiscovery.remove(npt);
discover(npt);
@@ -341,7 +342,7 @@
timeoutLinks();
//increment LLDP clock
- lldpClock = (lldpClock + 1)% LLDP_TO_ALL_INTERVAL;
+ lldpClock = (lldpClock + 1) % LLDP_TO_ALL_INTERVAL;
if (lldpClock == 0) {
log.debug("Sending LLDP out on all ports.");
@@ -351,19 +352,18 @@
/**
- * Quarantine Ports.
+ * Quarantine Ports.
*/
protected class QuarantineWorker implements Runnable {
@Override
public void run() {
try {
processBDDPLists();
- }
- catch (Exception e) {
+ } catch (Exception e) {
log.error("Error in quarantine worker thread", e);
} finally {
- bddpTask.reschedule(BDDP_TASK_INTERVAL,
- TimeUnit.MILLISECONDS);
+ bddpTask.reschedule(BDDP_TASK_INTERVAL,
+ TimeUnit.MILLISECONDS);
}
}
}
@@ -372,6 +372,7 @@
* Add a switch port to the quarantine queue. Schedule the
* quarantine task if the quarantine queue was empty before adding
* this switch port.
+ *
* @param npt
*/
protected void addToQuarantineQueue(NodePortTuple npt) {
@@ -384,11 +385,12 @@
*/
protected void removeFromQuarantineQueue(NodePortTuple npt) {
// Remove all occurrences of the node port tuple from the list.
- while (quarantineQueue.remove(npt));
+ while (quarantineQueue.remove(npt)) ;
}
/**
* Add a switch port to maintenance queue.
+ *
* @param npt
*/
protected void addToMaintenanceQueue(NodePortTuple npt) {
@@ -401,26 +403,27 @@
/**
* Remove a switch port from maintenance queue.
+ *
* @param npt
*/
protected void removeFromMaintenanceQueue(NodePortTuple npt) {
// Remove all occurrences of the node port tuple from the queue.
- while (maintenanceQueue.remove(npt));
+ while (maintenanceQueue.remove(npt)) ;
}
/**
- * This method processes the quarantine list in bursts. The task is
- * at most once per BDDP_TASK_INTERVAL.
- * One each call, BDDP_TASK_SIZE number of switch ports are processed.
- * Once the BDDP packets are sent out through the switch ports, the ports
- * are removed from the quarantine list.
- */
+ * This method processes the quarantine list in bursts. The task is
+ * at most once per BDDP_TASK_INTERVAL.
+ * One each call, BDDP_TASK_SIZE number of switch ports are processed.
+ * Once the BDDP packets are sent out through the switch ports, the ports
+ * are removed from the quarantine list.
+ */
protected void processBDDPLists() {
int count = 0;
Set<NodePortTuple> nptList = new HashSet<NodePortTuple>();
- while(count < BDDP_TASK_SIZE && quarantineQueue.peek() !=null) {
+ while (count < BDDP_TASK_SIZE && quarantineQueue.peek() != null) {
NodePortTuple npt;
npt = quarantineQueue.remove();
sendDiscoveryMessage(npt.getNodeId(), npt.getPortId(), false, false);
@@ -436,7 +439,7 @@
count++;
}
- for(NodePortTuple npt:nptList) {
+ for (NodePortTuple npt : nptList) {
generateSwitchPortStatusUpdate(npt.getNodeId(), npt.getPortId());
}
}
@@ -487,7 +490,7 @@
nptSet.addAll(portLinks.keySet());
// Send LLDP from each of them.
- for(NodePortTuple npt: nptSet) {
+ for (NodePortTuple npt : nptSet) {
discover(npt);
}
}
@@ -504,27 +507,27 @@
* Learn remote switches when running as a distributed controller ONOS
*/
protected IOFSwitch addRemoteSwitch(long sw, short port) {
- IOnosRemoteSwitch remotesw = null;
+ IOnosRemoteSwitch remotesw = null;
- // add a switch if we have not seen it before
- remotesw = remoteSwitches.get(sw);
+ // add a switch if we have not seen it before
+ remotesw = remoteSwitches.get(sw);
- if (remotesw == null) {
- remotesw = new OFSwitchImpl();
- remotesw.setupRemoteSwitch(sw);
- remoteSwitches.put(remotesw.getId(), remotesw);
- log.debug("addRemoteSwitch(): added fake remote sw {}", remotesw);
+ if (remotesw == null) {
+ remotesw = new OFSwitchImpl();
+ remotesw.setupRemoteSwitch(sw);
+ remoteSwitches.put(remotesw.getId(), remotesw);
+ log.debug("addRemoteSwitch(): added fake remote sw {}", remotesw);
}
// add the port if we have not seen it before
if (remotesw.getPort(port) == null) {
- OFPhysicalPort remoteport = new OFPhysicalPort();
- remoteport.setPortNumber(port);
- remoteport.setName("fake_" + port);
- remoteport.setConfig(0);
- remoteport.setState(0);
- remotesw.setPort(remoteport);
- log.debug("addRemoteSwitch(): added fake remote port {} to sw {}", remoteport, remotesw.getId());
+ OFPhysicalPort remoteport = new OFPhysicalPort();
+ remoteport.setPortNumber(port);
+ remoteport.setName("fake_" + port);
+ remoteport.setConfig(0);
+ remoteport.setState(0);
+ remotesw.setPort(remoteport);
+ log.debug("addRemoteSwitch(): added fake remote port {} to sw {}", remoteport, remotesw.getId());
}
return remotesw;
@@ -534,22 +537,23 @@
* Send link discovery message out of a given switch port.
* The discovery message may be a standard LLDP or a modified
* LLDP, where the dst mac address is set to :ff.
- *
+ * <p/>
* TODO: The modified LLDP will updated in the future and may
* use a different eth-type.
+ *
* @param sw
* @param port
- * @param isStandard indicates standard or modified LLDP
- * @param isReverse indicates whether the LLDP was sent as a response
+ * @param isStandard indicates standard or modified LLDP
+ * @param isReverse indicates whether the LLDP was sent as a response
*/
- @LogMessageDoc(level="ERROR",
- message="Failure sending LLDP out port {port} on switch {switch}",
- explanation="An I/O error occured while sending LLDP message " +
- "to the switch.",
- recommendation=LogMessageDoc.CHECK_SWITCH)
+ @LogMessageDoc(level = "ERROR",
+ message = "Failure sending LLDP out port {port} on switch {switch}",
+ explanation = "An I/O error occured while sending LLDP message " +
+ "to the switch.",
+ recommendation = LogMessageDoc.CHECK_SWITCH)
protected void sendDiscoveryMessage(long sw, short port,
- boolean isStandard,
- boolean isReverse) {
+ boolean isStandard,
+ boolean isReverse) {
IOFSwitch iofSwitch = floodlightProvider.getSwitches().get(sw);
if (iofSwitch == null) {
@@ -581,17 +585,17 @@
if (log.isTraceEnabled()) {
log.trace("Sending LLDP packet out of swich: {}, port: {}",
- sw, port);
+ sw, port);
}
// using "nearest customer bridge" MAC address for broadest possible propagation
// through provider and TPMR bridges (see IEEE 802.1AB-2009 and 802.1Q-2011),
// in particular the Linux bridge which behaves mostly like a provider bridge
- byte[] chassisId = new byte[] {4, 0, 0, 0, 0, 0, 0}; // filled in later
- byte[] portId = new byte[] {2, 0, 0}; // filled in later
- byte[] ttlValue = new byte[] {0, 0x78};
+ byte[] chassisId = new byte[]{4, 0, 0, 0, 0, 0, 0}; // filled in later
+ byte[] portId = new byte[]{2, 0, 0}; // filled in later
+ byte[] ttlValue = new byte[]{0, 0x78};
// OpenFlow OUI - 00-26-E1
- byte[] dpidTLVValue = new byte[] {0x0, 0x26, (byte) 0xe1, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+ byte[] dpidTLVValue = new byte[]{0x0, 0x26, (byte) 0xe1, 0, 0, 0, 0, 0, 0, 0, 0, 0};
LLDPTLV dpidTLV = new LLDPTLV().setType((byte) 127).setLength((short) dpidTLVValue.length).setValue(dpidTLVValue);
byte[] dpidArray = new byte[8];
@@ -612,7 +616,7 @@
portBB.putShort(port);
if (log.isTraceEnabled()) {
log.trace("Sending LLDP out of interface: {}/{}",
- HexString.toHexString(sw), port);
+ HexString.toHexString(sw), port);
}
LLDP lldp = new LLDP();
@@ -625,25 +629,25 @@
lldp.getOptionalTLVList().add(controllerTLV);
if (isReverse) {
lldp.getOptionalTLVList().add(reverseTLV);
- }else {
+ } else {
lldp.getOptionalTLVList().add(forwardTLV);
}
Ethernet ethernet;
if (isStandard) {
ethernet = new Ethernet()
- .setSourceMACAddress(ofpPort.getHardwareAddress())
- .setDestinationMACAddress(LLDP_STANDARD_DST_MAC_STRING)
- .setEtherType(Ethernet.TYPE_LLDP);
+ .setSourceMACAddress(ofpPort.getHardwareAddress())
+ .setDestinationMACAddress(LLDP_STANDARD_DST_MAC_STRING)
+ .setEtherType(Ethernet.TYPE_LLDP);
ethernet.setPayload(lldp);
} else {
BSN bsn = new BSN(BSN.BSN_TYPE_BDDP);
bsn.setPayload(lldp);
ethernet = new Ethernet()
- .setSourceMACAddress(ofpPort.getHardwareAddress())
- .setDestinationMACAddress(LLDP_BSN_DST_MAC_STRING)
- .setEtherType(Ethernet.TYPE_BSN);
+ .setSourceMACAddress(ofpPort.getHardwareAddress())
+ .setDestinationMACAddress(LLDP_BSN_DST_MAC_STRING)
+ .setEtherType(Ethernet.TYPE_BSN);
ethernet.setPayload(bsn);
}
@@ -669,7 +673,7 @@
iofSwitch.write(po, null);
iofSwitch.flush();
} catch (IOException e) {
- log.error("Failure sending LLDP out port "+port+" on switch "+iofSwitch.getStringId(), e);
+ log.error("Failure sending LLDP out port " + port + " on switch " + iofSwitch.getStringId(), e);
}
}
@@ -683,11 +687,11 @@
}
Set<Long> switches = floodlightProvider.getSwitches().keySet();
// Send standard LLDPs
- for (long sw: switches) {
+ for (long sw : switches) {
IOFSwitch iofSwitch = floodlightProvider.getSwitches().get(sw);
if (iofSwitch == null) continue;
if (iofSwitch.getEnabledPorts() != null) {
- for (OFPhysicalPort ofp: iofSwitch.getEnabledPorts()) {
+ for (OFPhysicalPort ofp : iofSwitch.getEnabledPorts()) {
if (isLinkDiscoverySuppressed(sw, ofp.getPortNumber()))
continue;
if (autoPortFastFeature && isFastPort(sw, ofp.getPortNumber()))
@@ -714,10 +718,10 @@
InetAddress localIPAddress = null;
NetworkInterface localInterface = null;
- byte[] controllerTLVValue = new byte[] {0, 0, 0, 0, 0, 0, 0, 0}; // 8 byte value.
+ byte[] controllerTLVValue = new byte[]{0, 0, 0, 0, 0, 0, 0, 0}; // 8 byte value.
ByteBuffer bb = ByteBuffer.allocate(10);
- try{
+ try {
localIPAddress = java.net.InetAddress.getLocalHost();
localInterface = NetworkInterface.getByInetAddress(localIPAddress);
} catch (Exception e) {
@@ -787,16 +791,16 @@
for (LLDPTLV lldptlv : lldp.getOptionalTLVList()) {
if (lldptlv.getType() == 127 && lldptlv.getLength() == 12 &&
lldptlv.getValue()[0] == 0x0 && lldptlv.getValue()[1] == 0x26 &&
- lldptlv.getValue()[2] == (byte)0xe1 && lldptlv.getValue()[3] == 0x0) {
+ lldptlv.getValue()[2] == (byte) 0xe1 && lldptlv.getValue()[3] == 0x0) {
ByteBuffer dpidBB = ByteBuffer.wrap(lldptlv.getValue());
remoteSwitch = floodlightProvider.getSwitches().get(dpidBB.getLong(4));
if (remoteSwitch == null) {
- // Added by ONOS
- // floodlight LLDP coming from a remote switch connected to a different controller
- // add it to our cache of unconnected remote switches
- remoteSwitch = addRemoteSwitch(dpidBB.getLong(4), remotePort);
+ // Added by ONOS
+ // floodlight LLDP coming from a remote switch connected to a different controller
+ // add it to our cache of unconnected remote switches
+ remoteSwitch = addRemoteSwitch(dpidBB.getLong(4), remotePort);
}
- } else if (lldptlv.getType() == 12 && lldptlv.getLength() == 8){
+ } else if (lldptlv.getType() == 12 && lldptlv.getLength() == 8) {
otherId = ByteBuffer.wrap(lldptlv.getValue()).getLong();
if (myId == otherId)
myLLDP = true;
@@ -818,15 +822,14 @@
log.trace("Getting standard LLDP from a different controller and quelching it.");
}
return Command.STOP;
- }
- else if(sw <= remoteSwitch.getId()){
+ } else if (sw <= remoteSwitch.getId()) {
if (log.isTraceEnabled()) {
log.trace("Getting BBDP from a different controller. myId {}: remoteId {}", myId, otherId);
log.trace("and my controller id is smaller than the other, so quelching it. myPort {}: rPort {}", pi.getInPort(), remotePort);
- }
- //XXX ONOS: Fix the BDDP broadcast issue
- //return Command.CONTINUE;
- return Command.STOP;
+ }
+ //XXX ONOS: Fix the BDDP broadcast issue
+ //return Command.CONTINUE;
+ return Command.STOP;
}
/*
else if (myId < otherId) {
@@ -858,10 +861,10 @@
return Command.STOP;
}
if (suppressLinkDiscovery.contains(new NodePortTuple(remoteSwitch.getId(),
- remotePort))) {
+ remotePort))) {
if (log.isTraceEnabled()) {
log.trace("Ignoring link with suppressed src port: switch {} port {}",
- remoteSwitch, remotePort);
+ remoteSwitch, remotePort);
}
return Command.STOP;
}
@@ -893,7 +896,7 @@
LinkInfo newLinkInfo =
new LinkInfo(firstSeenTime, lastLldpTime, lastBddpTime,
- srcPortState, dstPortState);
+ srcPortState, dstPortState);
addOrUpdateLink(lt, newLinkInfo);
@@ -905,7 +908,7 @@
newLinkInfo = links.get(lt);
if (newLinkInfo != null && isStandard && isReverse == false) {
Link reverseLink = new Link(lt.getDst(), lt.getDstPort(),
- lt.getSrc(), lt.getSrcPort());
+ lt.getSrc(), lt.getSrcPort());
LinkInfo reverseInfo = links.get(reverseLink);
if (reverseInfo == null) {
// the reverse link does not exist.
@@ -919,12 +922,12 @@
// link as well.
if (!isStandard) {
Link reverseLink = new Link(lt.getDst(), lt.getDstPort(),
- lt.getSrc(), lt.getSrcPort());
+ lt.getSrc(), lt.getSrcPort());
// srcPortState and dstPort state are reversed.
LinkInfo reverseInfo =
new LinkInfo(firstSeenTime, lastLldpTime, lastBddpTime,
- dstPortState, srcPortState);
+ dstPortState, srcPortState);
addOrUpdateLink(reverseLink, reverseInfo);
}
@@ -945,9 +948,9 @@
FloodlightContext cntx) {
Ethernet eth =
IFloodlightProviderService.bcStore.get(cntx,
- IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
+ IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
- if(eth.getEtherType() == Ethernet.TYPE_BSN) {
+ if (eth.getEtherType() == Ethernet.TYPE_BSN) {
BSN bsn = (BSN) eth.getPayload();
if (bsn == null) return Command.STOP;
if (bsn.getPayload() == null) return Command.STOP;
@@ -956,11 +959,11 @@
if (bsn.getPayload() instanceof LLDP == false)
return Command.CONTINUE;
return handleLldp((LLDP) bsn.getPayload(), sw, pi, false, cntx);
- } else if (eth.getEtherType() == Ethernet.TYPE_LLDP) {
+ } else if (eth.getEtherType() == Ethernet.TYPE_LLDP) {
return handleLldp((LLDP) eth.getPayload(), sw, pi, true, cntx);
} else if (eth.getEtherType() < 1500) {
long destMac = eth.getDestinationMAC().toLong();
- if ((destMac & LINK_LOCAL_MASK) == LINK_LOCAL_VALUE){
+ if ((destMac & LINK_LOCAL_MASK) == LINK_LOCAL_VALUE) {
if (log.isTraceEnabled()) {
log.trace("Ignoring packet addressed to 802.1D/Q " +
"reserved address.");
@@ -980,18 +983,17 @@
int dstPortState) {
boolean added =
(((srcPortState &
- OFPortState.OFPPS_STP_MASK.getValue()) !=
- OFPortState.OFPPS_STP_BLOCK.getValue()) &&
- ((dstPortState &
- OFPortState.OFPPS_STP_MASK.getValue()) !=
- OFPortState.OFPPS_STP_BLOCK.getValue()));
+ OFPortState.OFPPS_STP_MASK.getValue()) !=
+ OFPortState.OFPPS_STP_BLOCK.getValue()) &&
+ ((dstPortState &
+ OFPortState.OFPPS_STP_MASK.getValue()) !=
+ OFPortState.OFPPS_STP_BLOCK.getValue()));
if (added) return UpdateOperation.LINK_UPDATED;
return UpdateOperation.LINK_REMOVED;
}
-
protected UpdateOperation getUpdateOperation(int srcPortState) {
boolean portUp = ((srcPortState &
OFPortState.OFPPS_STP_MASK.getValue()) !=
@@ -1016,8 +1018,8 @@
if (log.isTraceEnabled()) {
log.trace("addOrUpdateLink: {} {}",
- lt,
- (newInfo.getMulticastValidTime()!=null) ? "multicast" : "unicast");
+ lt,
+ (newInfo.getMulticastValidTime() != null) ? "multicast" : "unicast");
}
UpdateOperation updateOperation = null;
@@ -1056,12 +1058,12 @@
// Add to event history
evHistTopoLink(lt.getSrc(),
- lt.getDst(),
- lt.getSrcPort(),
- lt.getDstPort(),
- newInfo.getSrcPortState(), newInfo.getDstPortState(),
- getLinkType(lt, newInfo),
- EvAction.LINK_ADDED, "LLDP Recvd");
+ lt.getDst(),
+ lt.getSrcPort(),
+ lt.getDstPort(),
+ newInfo.getSrcPortState(), newInfo.getDstPortState(),
+ getLinkType(lt, newInfo),
+ EvAction.LINK_ADDED, "LLDP Recvd");
} else {
// Since the link info is already there, we need to
// update the right fields.
@@ -1099,33 +1101,33 @@
if (newInfo.getSrcPortState().intValue() !=
oldInfo.getSrcPortState().intValue() ||
newInfo.getDstPortState().intValue() !=
- oldInfo.getDstPortState().intValue())
+ oldInfo.getDstPortState().intValue())
linkChanged = true;
if (linkChanged) {
updateOperation = getUpdateOperation(newInfo.getSrcPortState(),
- newInfo.getDstPortState());
+ newInfo.getDstPortState());
if (log.isTraceEnabled()) {
log.trace("Updated link {}", lt);
}
// Add to event history
evHistTopoLink(lt.getSrc(),
- lt.getDst(),
- lt.getSrcPort(),
- lt.getDstPort(),
- newInfo.getSrcPortState(), newInfo.getDstPortState(),
- getLinkType(lt, newInfo),
- EvAction.LINK_PORT_STATE_UPDATED,
- "LLDP Recvd");
+ lt.getDst(),
+ lt.getSrcPort(),
+ lt.getDstPort(),
+ newInfo.getSrcPortState(), newInfo.getDstPortState(),
+ getLinkType(lt, newInfo),
+ EvAction.LINK_PORT_STATE_UPDATED,
+ "LLDP Recvd");
}
}
if (linkChanged) {
// find out if the link was added or removed here.
LinkUpdate update = new LinkUpdate(new LDUpdate(lt.getSrc(), lt.getSrcPort(),
- lt.getDst(), lt.getDstPort(),
- getLinkType(lt, newInfo),
- updateOperation));
+ lt.getDst(), lt.getDstPort(),
+ getLinkType(lt, newInfo),
+ updateOperation));
controller.publishUpdate(update);
}
} finally {
@@ -1142,6 +1144,7 @@
/**
* Removes links from memory and storage.
+ *
* @param links The List of @LinkTuple to delete.
*/
protected void deleteLinks(List<Link> links, String reason) {
@@ -1151,7 +1154,7 @@
try {
for (Link lt : links) {
srcNpt = new NodePortTuple(lt.getSrc(), lt.getSrcPort());
- dstNpt =new NodePortTuple(lt.getDst(), lt.getDstPort());
+ dstNpt = new NodePortTuple(lt.getDst(), lt.getDstPort());
switchLinks.get(lt.getSrc()).remove(lt);
switchLinks.get(lt.getDst()).remove(lt);
@@ -1175,19 +1178,19 @@
LinkInfo info = this.links.remove(lt);
LinkUpdate update = new LinkUpdate(new LDUpdate(lt.getSrc(), lt.getSrcPort(),
- lt.getDst(), lt.getDstPort(),
- getLinkType(lt, info),
- UpdateOperation.LINK_REMOVED));
+ lt.getDst(), lt.getDstPort(),
+ getLinkType(lt, info),
+ UpdateOperation.LINK_REMOVED));
controller.publishUpdate(update);
// Update Event History
evHistTopoLink(lt.getSrc(),
- lt.getDst(),
- lt.getSrcPort(),
- lt.getDstPort(),
- 0, 0, // Port states
- ILinkDiscovery.LinkType.INVALID_LINK,
- EvAction.LINK_DELETED, reason);
+ lt.getDst(),
+ lt.getSrcPort(),
+ lt.getDstPort(),
+ 0, 0, // Port states
+ ILinkDiscovery.LinkType.INVALID_LINK,
+ EvAction.LINK_DELETED, reason);
// TODO Whenever link is removed, it has to checked if
// the switchports must be added to quarantine.
@@ -1204,6 +1207,7 @@
/**
* Handles an OFPortStatus message from a switch. We will add or
* delete LinkTupes as well re-compute the topology if needed.
+ *
* @param sw The IOFSwitch that sent the port status message
* @param ps The OFPortStatus message
* @return The Command to continue or stop after we process this message
@@ -1214,57 +1218,57 @@
if (iofSwitch == null) return Command.CONTINUE;
// ONOS: If we do not control this switch, then we should not process its port status messages
- if (!registryService.hasControl(iofSwitch.getId())) return Command.CONTINUE;
+ if (!registryService.hasControl(iofSwitch.getId()))
+ return Command.CONTINUE;
if (log.isTraceEnabled()) {
log.trace("handlePortStatus: Switch {} port #{} reason {}; " +
"config is {} state is {}",
- new Object[] {iofSwitch.getStringId(),
- ps.getDesc().getPortNumber(),
- ps.getReason(),
- ps.getDesc().getConfig(),
- ps.getDesc().getState()});
+ new Object[]{iofSwitch.getStringId(),
+ ps.getDesc().getPortNumber(),
+ ps.getReason(),
+ ps.getDesc().getConfig(),
+ ps.getDesc().getState()});
}
short port = ps.getDesc().getPortNumber();
NodePortTuple npt = new NodePortTuple(sw, port);
- boolean linkDeleted = false;
+ boolean linkDeleted = false;
boolean linkInfoChanged = false;
lock.writeLock().lock();
try {
// if ps is a delete, or a modify where the port is down or
// configured down
- if ((byte)OFPortReason.OFPPR_DELETE.ordinal() == ps.getReason() ||
- ((byte)OFPortReason.OFPPR_MODIFY.ordinal() ==
- ps.getReason() && !portEnabled(ps.getDesc()))) {
+ if ((byte) OFPortReason.OFPPR_DELETE.ordinal() == ps.getReason() ||
+ ((byte) OFPortReason.OFPPR_MODIFY.ordinal() ==
+ ps.getReason() && !portEnabled(ps.getDesc()))) {
deleteLinksOnPort(npt, "Port Status Changed");
LinkUpdate update = new LinkUpdate(new LDUpdate(sw, port, UpdateOperation.PORT_DOWN));
controller.publishUpdate(update);
linkDeleted = true;
- }
- else if (ps.getReason() ==
- (byte)OFPortReason.OFPPR_MODIFY.ordinal()) {
+ } else if (ps.getReason() ==
+ (byte) OFPortReason.OFPPR_MODIFY.ordinal()) {
// If ps is a port modification and the port state has changed
// that affects links in the topology
if (this.portLinks.containsKey(npt)) {
- for (Link lt: this.portLinks.get(npt)) {
+ for (Link lt : this.portLinks.get(npt)) {
LinkInfo linkInfo = links.get(lt);
- assert(linkInfo != null);
+ assert (linkInfo != null);
Integer updatedSrcPortState = null;
Integer updatedDstPortState = null;
if (lt.getSrc() == npt.getNodeId() &&
lt.getSrcPort() == npt.getPortId() &&
(linkInfo.getSrcPortState() !=
- ps.getDesc().getState())) {
+ ps.getDesc().getState())) {
updatedSrcPortState = ps.getDesc().getState();
linkInfo.setSrcPortState(updatedSrcPortState);
}
if (lt.getDst() == npt.getNodeId() &&
lt.getDstPort() == npt.getPortId() &&
(linkInfo.getDstPortState() !=
- ps.getDesc().getState())) {
+ ps.getDesc().getState())) {
updatedDstPortState = ps.getDesc().getState();
linkInfo.setDstPortState(updatedDstPortState);
}
@@ -1275,11 +1279,11 @@
// send an LinkUpdate.
UpdateOperation operation =
getUpdateOperation(linkInfo.getSrcPortState(),
- linkInfo.getDstPortState());
+ linkInfo.getDstPortState());
LinkUpdate update = new LinkUpdate(new LDUpdate(lt.getSrc(), lt.getSrcPort(),
- lt.getDst(), lt.getDstPort(),
- getLinkType(lt, linkInfo),
- operation));
+ lt.getDst(), lt.getDstPort(),
+ getLinkType(lt, linkInfo),
+ operation));
controller.publishUpdate(update);
linkInfoChanged = true;
@@ -1293,13 +1297,13 @@
controller.publishUpdate(update);
}
- if (!linkDeleted && !linkInfoChanged){
+ if (!linkDeleted && !linkInfoChanged) {
if (log.isTraceEnabled()) {
- log.trace("handlePortStatus: Switch {} port #{} reason {};"+
+ log.trace("handlePortStatus: Switch {} port #{} reason {};" +
" no links to update/remove",
- new Object[] {HexString.toHexString(sw),
- ps.getDesc().getPortNumber(),
- ps.getReason()});
+ new Object[]{HexString.toHexString(sw),
+ ps.getDesc().getPortNumber(),
+ ps.getReason()});
}
}
} finally {
@@ -1324,17 +1328,16 @@
* If autoportfast feature is enabled and the port is a fast port, then
* do nothing.
* Otherwise, send LLDP message. Add the port to quarantine.
+ *
* @param sw
* @param p
*/
private void processNewPort(long sw, short p) {
if (isLinkDiscoverySuppressed(sw, p)) {
// Do nothing as link discovery is suppressed.
- }
- else if (autoPortFastFeature && isFastPort(sw, p)) {
+ } else if (autoPortFastFeature && isFastPort(sw, p)) {
// Do nothing as the port is a fast port.
- }
- else {
+ } else {
NodePortTuple npt = new NodePortTuple(sw, p);
discover(sw, p);
// if it is not a fast port, add it to quarantine.
@@ -1350,6 +1353,7 @@
/**
* We send out LLDP messages when a switch is added to discover the topology
+ *
* @param sw The IOFSwitch that connected to the controller
*/
@Override
@@ -1363,7 +1367,7 @@
// Update event history
evHistTopoSwitch(sw, EvAction.SWITCH_CONNECTED, "None");
LinkUpdate update = new LinkUpdate(new LDUpdate(sw.getId(), null,
- UpdateOperation.SWITCH_UPDATED));
+ UpdateOperation.SWITCH_UPDATED));
controller.publishUpdate(update);
}
@@ -1381,7 +1385,7 @@
if (switchLinks.containsKey(sw)) {
if (log.isTraceEnabled()) {
log.trace("Handle switchRemoved. Switch {}; removing links {}",
- HexString.toHexString(sw), switchLinks.get(sw));
+ HexString.toHexString(sw), switchLinks.get(sw));
}
// add all tuples with an endpoint on this switch to erase list
eraseList.addAll(switchLinks.get(sw));
@@ -1408,6 +1412,7 @@
/**
* Delete links incident on a given switch port.
+ *
* @param npt
* @param reason
*/
@@ -1417,9 +1422,9 @@
if (log.isTraceEnabled()) {
log.trace("handlePortStatus: Switch {} port #{} " +
"removing links {}",
- new Object[] {HexString.toHexString(npt.getNodeId()),
- npt.getPortId(),
- this.portLinks.get(npt)});
+ new Object[]{HexString.toHexString(npt.getNodeId()),
+ npt.getPortId(),
+ this.portLinks.get(npt)});
}
eraseList.addAll(this.portLinks.get(npt));
deleteLinks(eraseList, reason);
@@ -1448,7 +1453,7 @@
// Timeout the unicast and multicast LLDP valid times
// independently.
if ((info.getUnicastValidTime() != null) &&
- (info.getUnicastValidTime() + (this.LINK_TIMEOUT * 1000) < curTime)){
+ (info.getUnicastValidTime() + (this.LINK_TIMEOUT * 1000) < curTime)) {
info.setUnicastValidTime(null);
if (info.getMulticastValidTime() != null)
@@ -1457,8 +1462,8 @@
// the link would be deleted, which would trigger updateClusters().
linkChanged = true;
}
- if ((info.getMulticastValidTime()!= null) &&
- (info.getMulticastValidTime()+ (this.LINK_TIMEOUT * 1000) < curTime)) {
+ if ((info.getMulticastValidTime() != null) &&
+ (info.getMulticastValidTime() + (this.LINK_TIMEOUT * 1000) < curTime)) {
info.setMulticastValidTime(null);
// if uTime is not null, then link will remain as openflow
// link. If uTime is null, it will be deleted. So, we
@@ -1469,16 +1474,16 @@
// Add to the erase list only if the unicast
// time is null.
if (info.getUnicastValidTime() == null &&
- info.getMulticastValidTime() == null){
+ info.getMulticastValidTime() == null) {
eraseList.add(entry.getKey());
} else if (linkChanged) {
UpdateOperation operation;
operation = getUpdateOperation(info.getSrcPortState(),
- info.getDstPortState());
+ info.getDstPortState());
LinkUpdate update = new LinkUpdate(new LDUpdate(lt.getSrc(), lt.getSrcPort(),
- lt.getDst(), lt.getDstPort(),
- getLinkType(lt, info),
- operation));
+ lt.getDst(), lt.getDstPort(),
+ getLinkType(lt, info),
+ operation));
controller.publishUpdate(update);
}
}
@@ -1562,6 +1567,7 @@
/**
* Register a link discovery aware component
+ *
* @param linkDiscoveryAwareComponent
*/
public void addLinkDiscoveryAware(ILinkDiscoveryListener linkDiscoveryAwareComponent) {
@@ -1571,6 +1577,7 @@
/**
* Deregister a link discovery aware component
+ *
* @param linkDiscoveryAwareComponent
*/
public void removeLinkDiscoveryAware(ILinkDiscoveryListener linkDiscoveryAwareComponent) {
@@ -1603,9 +1610,9 @@
public Map<Class<? extends IFloodlightService>, IFloodlightService>
getServiceImpls() {
Map<Class<? extends IFloodlightService>,
- IFloodlightService> m =
- new HashMap<Class<? extends IFloodlightService>,
- IFloodlightService>();
+ IFloodlightService> m =
+ new HashMap<Class<? extends IFloodlightService>,
+ IFloodlightService>();
// We are the class that implements the service
m.put(ILinkDiscoveryService.class, this);
return m;
@@ -1659,27 +1666,27 @@
@Override
@LogMessageDocs({
- @LogMessageDoc(level="ERROR",
- message="No storage source found.",
- explanation="Storage source was not initialized; cannot initialize " +
- "link discovery.",
- recommendation=LogMessageDoc.REPORT_CONTROLLER_BUG),
- @LogMessageDoc(level="ERROR",
- message="Error in installing listener for " +
- "switch config table {table}",
- explanation="Failed to install storage notification for the " +
- "switch config table",
- recommendation=LogMessageDoc.REPORT_CONTROLLER_BUG),
- @LogMessageDoc(level="ERROR",
- message="No storage source found.",
- explanation="Storage source was not initialized; cannot initialize " +
- "link discovery.",
- recommendation=LogMessageDoc.REPORT_CONTROLLER_BUG),
- @LogMessageDoc(level="ERROR",
- message="Exception in LLDP send timer.",
- explanation="An unknown error occured while sending LLDP " +
- "messages to switches.",
- recommendation=LogMessageDoc.CHECK_SWITCH)
+ @LogMessageDoc(level = "ERROR",
+ message = "No storage source found.",
+ explanation = "Storage source was not initialized; cannot initialize " +
+ "link discovery.",
+ recommendation = LogMessageDoc.REPORT_CONTROLLER_BUG),
+ @LogMessageDoc(level = "ERROR",
+ message = "Error in installing listener for " +
+ "switch config table {table}",
+ explanation = "Failed to install storage notification for the " +
+ "switch config table",
+ recommendation = LogMessageDoc.REPORT_CONTROLLER_BUG),
+ @LogMessageDoc(level = "ERROR",
+ message = "No storage source found.",
+ explanation = "Storage source was not initialized; cannot initialize " +
+ "link discovery.",
+ recommendation = LogMessageDoc.REPORT_CONTROLLER_BUG),
+ @LogMessageDoc(level = "ERROR",
+ message = "Exception in LLDP send timer.",
+ explanation = "An unknown error occured while sending LLDP " +
+ "messages to switches.",
+ recommendation = LogMessageDoc.CHECK_SWITCH)
})
public void startUp(FloodlightModuleContext context) {
ScheduledExecutorService ses = threadPool.getScheduledExecutor();
@@ -1696,11 +1703,11 @@
log.error("Exception in LLDP send timer.", e);
} finally {
if (!shuttingDown) {
- // Always reschedule link discovery if we're not
- // shutting down (no chance of SLAVE role now)
+ // Always reschedule link discovery if we're not
+ // shutting down (no chance of SLAVE role now)
log.trace("Rescheduling discovery task");
discoveryTask.reschedule(DISCOVERY_TASK_INTERVAL,
- TimeUnit.SECONDS);
+ TimeUnit.SECONDS);
}
}
}
@@ -1730,11 +1737,11 @@
// ****************************************************
// Topology Manager event history
- public EventHistory<EventHistoryTopologySwitch> evHistTopologySwitch;
- public EventHistory<EventHistoryTopologyLink> evHistTopologyLink;
+ public EventHistory<EventHistoryTopologySwitch> evHistTopologySwitch;
+ public EventHistory<EventHistoryTopologyLink> evHistTopologyLink;
public EventHistory<EventHistoryTopologyCluster> evHistTopologyCluster;
- public EventHistoryTopologySwitch evTopoSwitch;
- public EventHistoryTopologyLink evTopoLink;
+ public EventHistoryTopologySwitch evTopoSwitch;
+ public EventHistoryTopologyLink evTopoLink;
public EventHistoryTopologyCluster evTopoCluster;
// Switch Added/Deleted
@@ -1742,21 +1749,21 @@
if (evTopoSwitch == null) {
evTopoSwitch = new EventHistoryTopologySwitch();
}
- evTopoSwitch.dpid = sw.getId();
+ evTopoSwitch.dpid = sw.getId();
if ((sw.getChannel() != null) &&
(SocketAddress.class.isInstance(
- sw.getChannel().getRemoteAddress()))) {
+ sw.getChannel().getRemoteAddress()))) {
evTopoSwitch.ipv4Addr =
- IPv4.toIPv4Address(((InetSocketAddress)(sw.getChannel().
+ IPv4.toIPv4Address(((InetSocketAddress) (sw.getChannel().
getRemoteAddress())).getAddress().getAddress());
- evTopoSwitch.l4Port =
- ((InetSocketAddress)(sw.getChannel().
+ evTopoSwitch.l4Port =
+ ((InetSocketAddress) (sw.getChannel().
getRemoteAddress())).getPort();
} else {
evTopoSwitch.ipv4Addr = 0;
evTopoSwitch.l4Port = 0;
}
- evTopoSwitch.reason = reason;
+ evTopoSwitch.reason = reason;
evTopoSwitch = evHistTopologySwitch.put(evTopoSwitch, actn);
}
@@ -1773,7 +1780,7 @@
evTopoLink.dstSwport = dstPort & 0xffff;
evTopoLink.srcPortState = srcPortState;
evTopoLink.dstPortState = dstPortState;
- evTopoLink.reason = reason;
+ evTopoLink.reason = reason;
switch (linkType) {
case DIRECT_LINK:
evTopoLink.linkType = "DIRECT_LINK";
@@ -1797,10 +1804,10 @@
if (evTopoCluster == null) {
evTopoCluster = new EventHistoryTopologyCluster();
}
- evTopoCluster.dpid = dpid;
+ evTopoCluster.dpid = dpid;
evTopoCluster.clusterIdOld = clusterIdOld;
evTopoCluster.clusterIdNew = clusterIdNew;
- evTopoCluster.reason = reason;
+ evTopoCluster.reason = reason;
evTopoCluster = evHistTopologyCluster.put(evTopoCluster, action);
}
diff --git a/src/main/java/net/onrc/onos/core/linkdiscovery/web/AutoPortFast.java b/src/main/java/net/onrc/onos/core/linkdiscovery/web/AutoPortFast.java
index 028776b..4b7eeca 100644
--- a/src/main/java/net/onrc/onos/core/linkdiscovery/web/AutoPortFast.java
+++ b/src/main/java/net/onrc/onos/core/linkdiscovery/web/AutoPortFast.java
@@ -14,10 +14,10 @@
@Get("json")
public String retrieve() {
ILinkDiscoveryService linkDiscovery;
- linkDiscovery = (ILinkDiscoveryService)getContext().getAttributes().
+ linkDiscovery = (ILinkDiscoveryService) getContext().getAttributes().
get(ILinkDiscoveryService.class.getCanonicalName());
- String param = ((String)getRequestAttributes().get("state")).toLowerCase();
+ String param = ((String) getRequestAttributes().get("state")).toLowerCase();
if (param.equals("enable") || param.equals("true")) {
linkDiscovery.setAutoPortFastFeature(true);
} else if (param.equals("disable") || param.equals("false")) {
diff --git a/src/main/java/net/onrc/onos/core/linkdiscovery/web/LinkWithType.java b/src/main/java/net/onrc/onos/core/linkdiscovery/web/LinkWithType.java
index c956cb1..733f28c 100644
--- a/src/main/java/net/onrc/onos/core/linkdiscovery/web/LinkWithType.java
+++ b/src/main/java/net/onrc/onos/core/linkdiscovery/web/LinkWithType.java
@@ -15,9 +15,10 @@
/**
* This class is both the datastructure and the serializer
* for a link with the corresponding type of link.
+ *
* @author alexreimers
*/
-@JsonSerialize(using=LinkWithType.class)
+@JsonSerialize(using = LinkWithType.class)
public class LinkWithType extends JsonSerializer<LinkWithType> {
public long srcSwDpid;
public short srcPort;
@@ -28,8 +29,9 @@
public LinkType type;
// Do NOT delete this, it's required for the serializer
- public LinkWithType() {}
-
+ public LinkWithType() {
+ }
+
public LinkWithType(Link link,
int srcPortState,
int dstPortState,
@@ -43,23 +45,23 @@
this.type = type;
}
- @Override
- public void serialize(LinkWithType lwt, JsonGenerator jgen, SerializerProvider arg2)
- throws IOException, JsonProcessingException {
- // You ****MUST*** use lwt for the fields as it's actually a different object.
- jgen.writeStartObject();
- jgen.writeStringField("src-switch", HexString.toHexString(lwt.srcSwDpid));
- jgen.writeNumberField("src-port", lwt.srcPort);
- jgen.writeNumberField("src-port-state", lwt.srcPortState);
- jgen.writeStringField("dst-switch", HexString.toHexString(lwt.dstSwDpid));
- jgen.writeNumberField("dst-port", lwt.dstPort);
- jgen.writeNumberField("dst-port-state", lwt.dstPortState);
- jgen.writeStringField("type", lwt.type.toString());
- jgen.writeEndObject();
- }
-
- @Override
- public Class<LinkWithType> handledType() {
- return LinkWithType.class;
- }
+ @Override
+ public void serialize(LinkWithType lwt, JsonGenerator jgen, SerializerProvider arg2)
+ throws IOException, JsonProcessingException {
+ // You ****MUST*** use lwt for the fields as it's actually a different object.
+ jgen.writeStartObject();
+ jgen.writeStringField("src-switch", HexString.toHexString(lwt.srcSwDpid));
+ jgen.writeNumberField("src-port", lwt.srcPort);
+ jgen.writeNumberField("src-port-state", lwt.srcPortState);
+ jgen.writeStringField("dst-switch", HexString.toHexString(lwt.dstSwDpid));
+ jgen.writeNumberField("dst-port", lwt.dstPort);
+ jgen.writeNumberField("dst-port-state", lwt.dstPortState);
+ jgen.writeStringField("type", lwt.type.toString());
+ jgen.writeEndObject();
+ }
+
+ @Override
+ public Class<LinkWithType> handledType() {
+ return LinkWithType.class;
+ }
}
\ No newline at end of file
diff --git a/src/main/java/net/onrc/onos/core/linkdiscovery/web/LinksResource.java b/src/main/java/net/onrc/onos/core/linkdiscovery/web/LinksResource.java
index 2714f66..81c0b9e 100644
--- a/src/main/java/net/onrc/onos/core/linkdiscovery/web/LinksResource.java
+++ b/src/main/java/net/onrc/onos/core/linkdiscovery/web/LinksResource.java
@@ -17,20 +17,20 @@
@Get("json")
public Set<LinkWithType> retrieve() {
- ILinkDiscoveryService ld = (ILinkDiscoveryService)getContext().getAttributes().
+ ILinkDiscoveryService ld = (ILinkDiscoveryService) getContext().getAttributes().
get(ILinkDiscoveryService.class.getCanonicalName());
Map<Link, LinkInfo> links = new HashMap<Link, LinkInfo>();
Set<LinkWithType> returnLinkSet = new HashSet<LinkWithType>();
if (ld != null) {
links.putAll(ld.getLinks());
- for(Entry<Link, LinkInfo> e : links.entrySet()) {
+ for (Entry<Link, LinkInfo> e : links.entrySet()) {
Link link = e.getKey();
LinkInfo info = e.getValue();
LinkWithType lwt = new LinkWithType(link,
- info.getSrcPortState(),
- info.getDstPortState(),
- ld.getLinkType(link, info));
+ info.getSrcPortState(),
+ info.getDstPortState(),
+ ld.getLinkType(link, info));
returnLinkSet.add(lwt);
}
}