Fix checkstyle whitespace issues - WHITESPACE ONLY
Change-Id: Ic205c1afd639c6008d61d9de95cb764eeb6238ca
diff --git a/src/main/java/net/onrc/onos/core/devicemanager/IOnosDeviceListener.java b/src/main/java/net/onrc/onos/core/devicemanager/IOnosDeviceListener.java
index 69b340b..405340f 100644
--- a/src/main/java/net/onrc/onos/core/devicemanager/IOnosDeviceListener.java
+++ b/src/main/java/net/onrc/onos/core/devicemanager/IOnosDeviceListener.java
@@ -3,5 +3,6 @@
public interface IOnosDeviceListener {
public void onosDeviceAdded(OnosDevice device);
+
public void onosDeviceRemoved(OnosDevice device);
}
diff --git a/src/main/java/net/onrc/onos/core/devicemanager/IOnosDeviceService.java b/src/main/java/net/onrc/onos/core/devicemanager/IOnosDeviceService.java
index f343308..9eb6e31 100644
--- a/src/main/java/net/onrc/onos/core/devicemanager/IOnosDeviceService.java
+++ b/src/main/java/net/onrc/onos/core/devicemanager/IOnosDeviceService.java
@@ -5,20 +5,20 @@
/**
* {@link OnosDeviceManager} doesn't yet provide any API to fellow modules,
- * however making it export a dummy service means we can specify it as
+ * however making it export a dummy service means we can specify it as
* a dependency of Forwarding
- * @author jono
*
+ * @author jono
*/
public interface IOnosDeviceService extends IFloodlightService {
- public void addOnosDeviceListener(IOnosDeviceListener listener);
-
- public void deleteOnosDeviceListener(IOnosDeviceListener listener);
-
- public void deleteOnosDevice(OnosDevice dev);
+ public void addOnosDeviceListener(IOnosDeviceListener listener);
- public void deleteOnosDeviceByMac(MACAddress mac);
-
- public void addOnosDevice(Long mac, OnosDevice dev);
+ public void deleteOnosDeviceListener(IOnosDeviceListener listener);
+
+ public void deleteOnosDevice(OnosDevice dev);
+
+ public void deleteOnosDeviceByMac(MACAddress mac);
+
+ public void addOnosDevice(Long mac, OnosDevice dev);
}
diff --git a/src/main/java/net/onrc/onos/core/devicemanager/OnosDevice.java b/src/main/java/net/onrc/onos/core/devicemanager/OnosDevice.java
index 4ff17a3..adac787 100644
--- a/src/main/java/net/onrc/onos/core/devicemanager/OnosDevice.java
+++ b/src/main/java/net/onrc/onos/core/devicemanager/OnosDevice.java
@@ -1,19 +1,19 @@
/**
-l* Copyright 2011,2012, 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.
-**/
+ l* Copyright 2011,2012, 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.devicemanager;
@@ -29,63 +29,63 @@
* with a particular VLAN tag, and a particular MAC address, along with any
* other packet characteristics we might want to consider as helpful for
* disambiguating devices.
- *
+ * <p/>
* Entities are the most basic element of devices; devices consist of one or
* more entities. Entities are immutable once created, except for the last
* seen timestamp.
- *
- * @author readams
*
+ * @author readams
*/
public class OnosDevice implements Serializable { //implements Comparable<OnosDevice> {
private static int ACTIVITY_TIMEOUT = 30000;
-
+
/**
* The MAC address associated with this entity
*/
private MACAddress macAddress;
-
+
/**
* The IP address associated with this entity, or null if no IP learned
* from the network observation associated with this entity
*/
private Integer ipv4Address;
-
+
/**
* The VLAN tag on this entity, or null if untagged
*/
private Short vlan;
-
+
/**
* The DPID of the switch for the ingress point for this entity,
* or null if not present
*/
private long switchDPID;
-
+
/**
* The port number of the switch for the ingress point for this entity,
* or null if not present
*/
private short switchPort;
-
+
/**
* The last time we observed this entity on the network
*/
private Date lastSeenTimestamp;
private Date activeSince;
-
+
private int hashCode = 0;
// ************
// Constructors
// ************
- protected OnosDevice() {}
-
+ protected OnosDevice() {
+ }
+
/**
* Create a new entity
- *
+ *
* @param macAddress
* @param vlan
* @param ipv4Address
@@ -93,9 +93,9 @@
* @param switchPort
* @param lastSeenTimestamp
*/
- public OnosDevice(MACAddress macAddress, Short vlan,
- Integer ipv4Address, Long switchDPID, short switchPort,
- Date lastSeenTimestamp) {
+ public OnosDevice(MACAddress macAddress, Short vlan,
+ Integer ipv4Address, Long switchDPID, short switchPort,
+ Date lastSeenTimestamp) {
this.macAddress = macAddress;
this.ipv4Address = ipv4Address;
this.vlan = vlan;
@@ -116,9 +116,9 @@
public Integer getIpv4Address() {
return ipv4Address;
}
-
+
public void setIpv4Address(Integer ipv4Address) {
- this.ipv4Address = ipv4Address;
+ this.ipv4Address = ipv4Address;
}
public Short getVlan() {
@@ -128,28 +128,28 @@
public Long getSwitchDPID() {
return switchDPID;
}
-
+
public void setSwitchDPID(long dpid) {
- this.switchDPID = dpid;
+ this.switchDPID = dpid;
}
public short getSwitchPort() {
return switchPort;
}
-
+
public void setSwitchPort(short port) {
- this.switchPort = port;
+ this.switchPort = port;
}
public Date getLastSeenTimestamp() {
return lastSeenTimestamp;
}
-
+
public void setLastSeenTimestamp(Date lastSeenTimestamp) {
if (activeSince == null ||
- (activeSince.getTime() + ACTIVITY_TIMEOUT) <
- lastSeenTimestamp.getTime())
+ (activeSince.getTime() + ACTIVITY_TIMEOUT) <
+ lastSeenTimestamp.getTime())
this.activeSince = lastSeenTimestamp;
this.lastSeenTimestamp = lastSeenTimestamp;
}
@@ -161,17 +161,17 @@
public void setActiveSince(Date activeSince) {
this.activeSince = activeSince;
}
-
+
@Override
public int hashCode() {
if (hashCode != 0) return hashCode;
final int prime = 31;
hashCode = 1;
hashCode = prime * hashCode
- + ((ipv4Address == null) ? 0 : ipv4Address.hashCode());
+ + ((ipv4Address == null) ? 0 : ipv4Address.hashCode());
hashCode = prime * hashCode + (int) (macAddress.toLong() ^ (macAddress.toLong() >>> 32));
- hashCode = prime * hashCode + (int)switchDPID;
- hashCode = prime * hashCode + (int)switchPort;
+ hashCode = prime * hashCode + (int) switchDPID;
+ hashCode = prime * hashCode + (int) switchPort;
hashCode = prime * hashCode + ((vlan == null) ? 0 : vlan.hashCode());
return hashCode;
}
@@ -185,26 +185,26 @@
if (hashCode() != other.hashCode()) return false;
if (ipv4Address == null) {
if (other.ipv4Address != null) return false;
- } else if (!ipv4Address.equals(other.ipv4Address)) return false;
+ } else if (!ipv4Address.equals(other.ipv4Address)) return false;
if (macAddress == null) {
if (other.macAddress != null) return false;
} else if (!macAddress.equals(other.macAddress)) return false;
- if(switchDPID != other.switchDPID) return false;
+ if (switchDPID != other.switchDPID) return false;
if (switchPort != other.switchPort) return false;
if (vlan == null) {
if (other.vlan != null) return false;
} else if (!vlan.equals(other.vlan)) return false;
return true;
}
-
+
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("Entity [macAddress=");
builder.append(macAddress.toString());
builder.append(", ipv4Address=");
- builder.append(IPv4.fromIPv4Address(ipv4Address==null ?
- 0 : ipv4Address.intValue()));
+ builder.append(IPv4.fromIPv4Address(ipv4Address == null ?
+ 0 : ipv4Address.intValue()));
builder.append(", vlan=");
builder.append(vlan);
builder.append(", switchDPID=");
@@ -212,9 +212,9 @@
builder.append(", switchPort=");
builder.append(switchPort);
builder.append(", lastSeenTimestamp=");
- builder.append(lastSeenTimestamp == null? "null" : lastSeenTimestamp.getTime());
+ builder.append(lastSeenTimestamp == null ? "null" : lastSeenTimestamp.getTime());
builder.append(", activeSince=");
- builder.append(activeSince == null? "null" : activeSince.getTime());
+ builder.append(activeSince == null ? "null" : activeSince.getTime());
builder.append("]");
return builder.toString();
}
@@ -260,5 +260,5 @@
return 0;
}*/
-
+
}
diff --git a/src/main/java/net/onrc/onos/core/devicemanager/OnosDeviceManager.java b/src/main/java/net/onrc/onos/core/devicemanager/OnosDeviceManager.java
index cd4fa0d..22a564b 100644
--- a/src/main/java/net/onrc/onos/core/devicemanager/OnosDeviceManager.java
+++ b/src/main/java/net/onrc/onos/core/devicemanager/OnosDeviceManager.java
@@ -42,173 +42,174 @@
import org.slf4j.LoggerFactory;
public class OnosDeviceManager implements IFloodlightModule,
- IOFMessageListener,
- IOnosDeviceService,
- IEventChannelListener<Long, OnosDevice> {
- protected final static Logger log = LoggerFactory.getLogger(OnosDeviceManager.class);
- private static final int CLEANUP_SECOND = 60*60;
- private static final int AGEING_MILLSEC = 60*60*1000;
+ IOFMessageListener,
+ IOnosDeviceService,
+ IEventChannelListener<Long, OnosDevice> {
+ protected final static Logger log = LoggerFactory.getLogger(OnosDeviceManager.class);
+ private static final int CLEANUP_SECOND = 60 * 60;
+ private static final int AGEING_MILLSEC = 60 * 60 * 1000;
- private CopyOnWriteArrayList<IOnosDeviceListener> deviceListeners;
- private IFloodlightProviderService floodlightProvider;
- private final static ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
+ private CopyOnWriteArrayList<IOnosDeviceListener> deviceListeners;
+ private IFloodlightProviderService floodlightProvider;
+ private final static ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
- private IDatagridService datagrid;
- private IEventChannel<Long, OnosDevice> eventChannel;
- private static final String DEVICE_CHANNEL_NAME = "onos.device";
- private Map<Long, OnosDevice> mapDevice = new ConcurrentHashMap<Long, OnosDevice>();
- private INetworkGraphService networkGraphService;
- private NetworkGraph networkGraph;
+ private IDatagridService datagrid;
+ private IEventChannel<Long, OnosDevice> eventChannel;
+ private static final String DEVICE_CHANNEL_NAME = "onos.device";
+ private Map<Long, OnosDevice> mapDevice = new ConcurrentHashMap<Long, OnosDevice>();
+ private INetworkGraphService networkGraphService;
+ private NetworkGraph networkGraph;
public enum OnosDeviceUpdateType {
ADD, DELETE, UPDATE;
}
- private class OnosDeviceUpdate implements IUpdate {
- private OnosDevice device;
- private OnosDeviceUpdateType type;
+ private class OnosDeviceUpdate implements IUpdate {
+ private OnosDevice device;
+ private OnosDeviceUpdateType type;
- public OnosDeviceUpdate(OnosDevice device, OnosDeviceUpdateType type) {
- this.device = device;
- this.type = type;
- }
+ public OnosDeviceUpdate(OnosDevice device, OnosDeviceUpdateType type) {
+ this.device = device;
+ this.type = type;
+ }
- @Override
- public void dispatch() {
- if(type == OnosDeviceUpdateType.ADD) {
- for(IOnosDeviceListener listener: deviceListeners) {
- listener.onosDeviceAdded(device);
- }
- } else if (type == OnosDeviceUpdateType.DELETE){
- for(IOnosDeviceListener listener: deviceListeners) {
- listener.onosDeviceRemoved(device);
- }
- }
- }
- }
+ @Override
+ public void dispatch() {
+ if (type == OnosDeviceUpdateType.ADD) {
+ for (IOnosDeviceListener listener : deviceListeners) {
+ listener.onosDeviceAdded(device);
+ }
+ } else if (type == OnosDeviceUpdateType.DELETE) {
+ for (IOnosDeviceListener listener : deviceListeners) {
+ listener.onosDeviceRemoved(device);
+ }
+ }
+ }
+ }
- @Override
- public String getName() {
- return "onosdevicemanager";
- }
+ @Override
+ public String getName() {
+ return "onosdevicemanager";
+ }
- @Override
- public boolean isCallbackOrderingPrereq(OFType type, String name) {
- // We want link discovery to consume LLDP first otherwise we'll
- // end up reading bad device info from LLDP packets
- return type == OFType.PACKET_IN && "linkdiscovery".equals(name);
- }
+ @Override
+ public boolean isCallbackOrderingPrereq(OFType type, String name) {
+ // We want link discovery to consume LLDP first otherwise we'll
+ // end up reading bad device info from LLDP packets
+ return type == OFType.PACKET_IN && "linkdiscovery".equals(name);
+ }
- @Override
- public boolean isCallbackOrderingPostreq(OFType type, String name) {
- return type == OFType.PACKET_IN &&
- ("proxyarpmanager".equals(name) || "onosforwarding".equals(name));
- }
+ @Override
+ public boolean isCallbackOrderingPostreq(OFType type, String name) {
+ return type == OFType.PACKET_IN &&
+ ("proxyarpmanager".equals(name) || "onosforwarding".equals(name));
+ }
- @Override
- public Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx) {
- if (msg.getType().equals(OFType.PACKET_IN)) {
- OFPacketIn pi = (OFPacketIn) msg;
+ @Override
+ public Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx) {
+ if (msg.getType().equals(OFType.PACKET_IN)) {
+ OFPacketIn pi = (OFPacketIn) msg;
- Ethernet eth = IFloodlightProviderService.bcStore.
- get(cntx, IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
+ Ethernet eth = IFloodlightProviderService.bcStore.
+ get(cntx, IFloodlightProviderService.CONTEXT_PI_PAYLOAD);
- return processPacketIn(sw, pi, eth);
- }
+ return processPacketIn(sw, pi, eth);
+ }
- return Command.CONTINUE;
- }
+ return Command.CONTINUE;
+ }
- private Command processPacketIn(IOFSwitch sw, OFPacketIn pi, Ethernet eth) {
- long dpid =sw.getId();
+ private Command processPacketIn(IOFSwitch sw, OFPacketIn pi, Ethernet eth) {
+ long dpid = sw.getId();
short portId = pi.getInPort();
Long mac = eth.getSourceMAC().toLong();
OnosDevice srcDevice =
getSourceDeviceFromPacket(eth, dpid, portId);
- if (srcDevice == null){
- return Command.STOP;
+ if (srcDevice == null) {
+ return Command.STOP;
}
//We check if it is the same device in datagrid to suppress the device update
OnosDevice exDev = null;
- if((exDev = mapDevice.get(mac)) != null ){
- if(exDev.equals(srcDevice)) {
- //There is the same existing device. Update only ActiveSince time.
- exDev.setLastSeenTimestamp(new Date());
- if(log.isTraceEnabled()) {
- log.debug("In the datagrid, there is the same device."
- + "Only update last seen time. dpid {}, port {}, mac {}, ip {}, lastSeenTime {}",
- dpid, portId, srcDevice.getMacAddress(), srcDevice.getIpv4Address(), srcDevice.getLastSeenTimestamp().getTime());
- }
- return Command.CONTINUE;
- } else if (srcDevice.getIpv4Address() == null &&
- exDev.getSwitchDPID().equals(srcDevice.getSwitchDPID()) &&
- exDev.getSwitchPort() == srcDevice.getSwitchPort()) {
- //Vlan should be handled based on the Onos spec. Until then, don't handle it.
- //Device attachment point and mac address are the same
- //but the packet does not have an ip address.
- exDev.setLastSeenTimestamp(new Date());
- if(log.isTraceEnabled()) {
- log.debug("In the datagrid, there is the same device with no ip."
- + "Keep ip and update last seen time. dpid {}, port {}, mac {}, ip {} lastSeenTime {}",
- dpid, portId, srcDevice.getMacAddress(), exDev.getIpv4Address(), srcDevice.getLastSeenTimestamp().getTime());
- }
- return Command.CONTINUE;
- }
- }
+ if ((exDev = mapDevice.get(mac)) != null) {
+ if (exDev.equals(srcDevice)) {
+ //There is the same existing device. Update only ActiveSince time.
+ exDev.setLastSeenTimestamp(new Date());
+ if (log.isTraceEnabled()) {
+ log.debug("In the datagrid, there is the same device."
+ + "Only update last seen time. dpid {}, port {}, mac {}, ip {}, lastSeenTime {}",
+ dpid, portId, srcDevice.getMacAddress(), srcDevice.getIpv4Address(), srcDevice.getLastSeenTimestamp().getTime());
+ }
+ return Command.CONTINUE;
+ } else if (srcDevice.getIpv4Address() == null &&
+ exDev.getSwitchDPID().equals(srcDevice.getSwitchDPID()) &&
+ exDev.getSwitchPort() == srcDevice.getSwitchPort()) {
+ //Vlan should be handled based on the Onos spec. Until then, don't handle it.
+ //Device attachment point and mac address are the same
+ //but the packet does not have an ip address.
+ exDev.setLastSeenTimestamp(new Date());
+ if (log.isTraceEnabled()) {
+ log.debug("In the datagrid, there is the same device with no ip."
+ + "Keep ip and update last seen time. dpid {}, port {}, mac {}, ip {} lastSeenTime {}",
+ dpid, portId, srcDevice.getMacAddress(), exDev.getIpv4Address(), srcDevice.getLastSeenTimestamp().getTime());
+ }
+ return Command.CONTINUE;
+ }
+ }
//If the switch port we try to attach a new device already has a link, then stop adding device
- if(networkGraph.getLink(dpid, (long)portId) != null) {
- if(log.isTraceEnabled()) {
- log.debug("Stop adding OnosDevice {} due to there is a link to: dpid {} port {}",
- srcDevice.getMacAddress(), dpid, portId);
- }
- return Command.CONTINUE;
+ if (networkGraph.getLink(dpid, (long) portId) != null) {
+ if (log.isTraceEnabled()) {
+ log.debug("Stop adding OnosDevice {} due to there is a link to: dpid {} port {}",
+ srcDevice.getMacAddress(), dpid, portId);
+ }
+ return Command.CONTINUE;
}
addOnosDevice(mac, srcDevice);
- if(log.isTraceEnabled()) {
- log.debug("Add device info in the set. dpid {}, port {}, mac {}, ip {}, lastSeenTime {}",
- dpid, portId, srcDevice.getMacAddress(), srcDevice.getIpv4Address(), srcDevice.getLastSeenTimestamp().getTime());
+ if (log.isTraceEnabled()) {
+ log.debug("Add device info in the set. dpid {}, port {}, mac {}, ip {}, lastSeenTime {}",
+ dpid, portId, srcDevice.getMacAddress(), srcDevice.getIpv4Address(), srcDevice.getLastSeenTimestamp().getTime());
}
return Command.CONTINUE;
- }
+ }
- //Thread to delete devices periodically.
- //Remove all devices from the map first and then finally delete devices from the DB.
- private class CleanDevice implements Runnable {
- @Override
- public void run() {
- log.debug("called CleanDevice");
- try{
- Set<OnosDevice> deleteSet = new HashSet<OnosDevice>();
- for (OnosDevice dev : mapDevice.values() ) {
- long now = new Date().getTime();
- if((now - dev.getLastSeenTimestamp().getTime() > AGEING_MILLSEC)) {
- if(log.isTraceEnabled()) {
- log.debug("Remove device info in the datagrid. dpid {}, port {}, mac {}, ip {}, lastSeenTime {}, diff {}",
- dev.getSwitchDPID(), dev.getSwitchPort(), dev.getMacAddress(), dev.getIpv4Address(),
- dev.getLastSeenTimestamp().getTime(), now - dev.getLastSeenTimestamp().getTime());
- }
- deleteSet.add(dev);
- }
- }
+ //Thread to delete devices periodically.
+ //Remove all devices from the map first and then finally delete devices from the DB.
+ private class CleanDevice implements Runnable {
+ @Override
+ public void run() {
+ log.debug("called CleanDevice");
+ try {
+ Set<OnosDevice> deleteSet = new HashSet<OnosDevice>();
+ for (OnosDevice dev : mapDevice.values()) {
+ long now = new Date().getTime();
+ if ((now - dev.getLastSeenTimestamp().getTime() > AGEING_MILLSEC)) {
+ if (log.isTraceEnabled()) {
+ log.debug("Remove device info in the datagrid. dpid {}, port {}, mac {}, ip {}, lastSeenTime {}, diff {}",
+ dev.getSwitchDPID(), dev.getSwitchPort(), dev.getMacAddress(), dev.getIpv4Address(),
+ dev.getLastSeenTimestamp().getTime(), now - dev.getLastSeenTimestamp().getTime());
+ }
+ deleteSet.add(dev);
+ }
+ }
- for(OnosDevice dev : deleteSet) {
- deleteOnosDevice(dev);
- }
- } catch(Exception e) {
- log.error("Error:", e);
- }
- }
- }
+ for (OnosDevice dev : deleteSet) {
+ deleteOnosDevice(dev);
+ }
+ } catch (Exception e) {
+ log.error("Error:", e);
+ }
+ }
+ }
/**
* Get IP address from packet if the packet is either an ARP
* or a DHCP packet
+ *
* @param eth
* @param dlAddr
* @return
@@ -223,9 +224,9 @@
} else if (eth.getPayload() instanceof IPv4) {
IPv4 ipv4 = (IPv4) eth.getPayload();
if (ipv4.getPayload() instanceof UDP) {
- UDP udp = (UDP)ipv4.getPayload();
+ UDP udp = (UDP) ipv4.getPayload();
if (udp.getPayload() instanceof DHCP) {
- DHCP dhcp = (DHCP)udp.getPayload();
+ DHCP dhcp = (DHCP) udp.getPayload();
if (dhcp.getOpCode() == DHCP.OPCODE_REPLY) {
return ipv4.getSourceAddress();
}
@@ -237,14 +238,15 @@
/**
* Parse an entity from an {@link Ethernet} packet.
+ *
* @param eth the packet to parse
- * @param sw the switch on which the packet arrived
- * @param pi the original packetin
+ * @param sw the switch on which the packet arrived
+ * @param pi the original packetin
* @return the entity from the packet
*/
private OnosDevice getSourceDeviceFromPacket(Ethernet eth,
- long swdpid,
- short port) {
+ long swdpid,
+ short port) {
byte[] dlAddrArr = eth.getSourceMACAddress();
long dlAddr = Ethernet.toLong(dlAddrArr);
@@ -255,106 +257,106 @@
short vlan = eth.getVlanID();
int nwSrc = getSrcNwAddr(eth, dlAddr);
return new OnosDevice(MACAddress.valueOf(dlAddr),
- ((vlan >= 0) ? vlan : null),
- ((nwSrc != 0) ? nwSrc : null),
- swdpid,
- port,
- new Date());
+ ((vlan >= 0) ? vlan : null),
+ ((nwSrc != 0) ? nwSrc : null),
+ swdpid,
+ port,
+ new Date());
}
- @Override
- public Collection<Class<? extends IFloodlightService>> getModuleServices() {
- List<Class<? extends IFloodlightService>> services =
- new ArrayList<Class<? extends IFloodlightService>>();
- services.add(IOnosDeviceService.class);
- return services;
- }
-
- @Override
- public Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls() {
- Map<Class<? extends IFloodlightService>, IFloodlightService> impls =
- new HashMap<Class<? extends IFloodlightService>, IFloodlightService>();
- impls.put(IOnosDeviceService.class, this);
- return impls;
- }
-
- @Override
- public Collection<Class<? extends IFloodlightService>> getModuleDependencies() {
- List<Class<? extends IFloodlightService>> dependencies =
- new ArrayList<Class<? extends IFloodlightService>>();
- dependencies.add(IFloodlightProviderService.class);
- dependencies.add(INetworkGraphService.class);
- dependencies.add(IDatagridService.class);
- return dependencies;
- }
-
- @Override
- public void init(FloodlightModuleContext context)
- throws FloodlightModuleException {
- floodlightProvider = context.getServiceImpl(IFloodlightProviderService.class);
- executor.scheduleAtFixedRate(new CleanDevice(), 30 ,CLEANUP_SECOND, TimeUnit.SECONDS);
-
- deviceListeners = new CopyOnWriteArrayList<IOnosDeviceListener>();
- datagrid = context.getServiceImpl(IDatagridService.class);
- networkGraphService = context.getServiceImpl(INetworkGraphService.class);
- networkGraph = networkGraphService.getNetworkGraph();
- }
-
- @Override
- public void startUp(FloodlightModuleContext context) {
- floodlightProvider.addOFMessageListener(OFType.PACKET_IN, this);
- eventChannel = datagrid.addListener(DEVICE_CHANNEL_NAME, this,
- Long.class,
- OnosDevice.class);
- }
+ @Override
+ public Collection<Class<? extends IFloodlightService>> getModuleServices() {
+ List<Class<? extends IFloodlightService>> services =
+ new ArrayList<Class<? extends IFloodlightService>>();
+ services.add(IOnosDeviceService.class);
+ return services;
+ }
@Override
- public void deleteOnosDevice(OnosDevice dev) {
- Long mac = dev.getMacAddress().toLong();
- eventChannel.removeEntry(mac);
- floodlightProvider.publishUpdate(new OnosDeviceUpdate(dev, OnosDeviceUpdateType.DELETE));
- }
-
+ public Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls() {
+ Map<Class<? extends IFloodlightService>, IFloodlightService> impls =
+ new HashMap<Class<? extends IFloodlightService>, IFloodlightService>();
+ impls.put(IOnosDeviceService.class, this);
+ return impls;
+ }
+
@Override
- public void deleteOnosDeviceByMac(MACAddress mac) {
- OnosDevice deleteDevice = mapDevice.get(mac);
- deleteOnosDevice(deleteDevice);
- }
-
- @Override
- public void addOnosDevice(Long mac, OnosDevice dev) {
- eventChannel.addEntry(mac, dev);
- floodlightProvider.publishUpdate(new OnosDeviceUpdate(dev, OnosDeviceUpdateType.ADD));
- }
+ public Collection<Class<? extends IFloodlightService>> getModuleDependencies() {
+ List<Class<? extends IFloodlightService>> dependencies =
+ new ArrayList<Class<? extends IFloodlightService>>();
+ dependencies.add(IFloodlightProviderService.class);
+ dependencies.add(INetworkGraphService.class);
+ dependencies.add(IDatagridService.class);
+ return dependencies;
+ }
- @Override
- public void entryAdded(OnosDevice dev) {
- Long mac = dev.getMacAddress().toLong();
- mapDevice.put(mac, dev);
- log.debug("Device added: device mac {}", mac);
- }
+ @Override
+ public void init(FloodlightModuleContext context)
+ throws FloodlightModuleException {
+ floodlightProvider = context.getServiceImpl(IFloodlightProviderService.class);
+ executor.scheduleAtFixedRate(new CleanDevice(), 30, CLEANUP_SECOND, TimeUnit.SECONDS);
- @Override
- public void entryRemoved(OnosDevice dev) {
- Long mac = dev.getMacAddress().toLong();
- mapDevice.remove(mac);
- log.debug("Device removed: device mac {}", mac);
- }
+ deviceListeners = new CopyOnWriteArrayList<IOnosDeviceListener>();
+ datagrid = context.getServiceImpl(IDatagridService.class);
+ networkGraphService = context.getServiceImpl(INetworkGraphService.class);
+ networkGraph = networkGraphService.getNetworkGraph();
+ }
- @Override
- public void entryUpdated(OnosDevice dev) {
- Long mac = dev.getMacAddress().toLong();
- mapDevice.put(mac, dev);
- log.debug("Device updated: device mac {}", mac);
- }
+ @Override
+ public void startUp(FloodlightModuleContext context) {
+ floodlightProvider.addOFMessageListener(OFType.PACKET_IN, this);
+ eventChannel = datagrid.addListener(DEVICE_CHANNEL_NAME, this,
+ Long.class,
+ OnosDevice.class);
+ }
- @Override
- public void addOnosDeviceListener(IOnosDeviceListener listener) {
- deviceListeners.add(listener);
- }
+ @Override
+ public void deleteOnosDevice(OnosDevice dev) {
+ Long mac = dev.getMacAddress().toLong();
+ eventChannel.removeEntry(mac);
+ floodlightProvider.publishUpdate(new OnosDeviceUpdate(dev, OnosDeviceUpdateType.DELETE));
+ }
- @Override
- public void deleteOnosDeviceListener(IOnosDeviceListener listener) {
- deviceListeners.remove(listener);
- }
+ @Override
+ public void deleteOnosDeviceByMac(MACAddress mac) {
+ OnosDevice deleteDevice = mapDevice.get(mac);
+ deleteOnosDevice(deleteDevice);
+ }
+
+ @Override
+ public void addOnosDevice(Long mac, OnosDevice dev) {
+ eventChannel.addEntry(mac, dev);
+ floodlightProvider.publishUpdate(new OnosDeviceUpdate(dev, OnosDeviceUpdateType.ADD));
+ }
+
+ @Override
+ public void entryAdded(OnosDevice dev) {
+ Long mac = dev.getMacAddress().toLong();
+ mapDevice.put(mac, dev);
+ log.debug("Device added: device mac {}", mac);
+ }
+
+ @Override
+ public void entryRemoved(OnosDevice dev) {
+ Long mac = dev.getMacAddress().toLong();
+ mapDevice.remove(mac);
+ log.debug("Device removed: device mac {}", mac);
+ }
+
+ @Override
+ public void entryUpdated(OnosDevice dev) {
+ Long mac = dev.getMacAddress().toLong();
+ mapDevice.put(mac, dev);
+ log.debug("Device updated: device mac {}", mac);
+ }
+
+ @Override
+ public void addOnosDeviceListener(IOnosDeviceListener listener) {
+ deviceListeners.add(listener);
+ }
+
+ @Override
+ public void deleteOnosDeviceListener(IOnosDeviceListener listener) {
+ deviceListeners.remove(listener);
+ }
}