Renamed OnosDevice classes to Host.
Note this change only affects the driver level Host discovery module (and
any modules that make use of it). I did not rename the Device class in
the topology module yet.
Change-Id: I38bf42b2378da736199957d05467e8407548759e
diff --git a/src/main/java/net/onrc/onos/apps/forwarding/Forwarding.java b/src/main/java/net/onrc/onos/apps/forwarding/Forwarding.java
index b44f32b..c1c1707 100644
--- a/src/main/java/net/onrc/onos/apps/forwarding/Forwarding.java
+++ b/src/main/java/net/onrc/onos/apps/forwarding/Forwarding.java
@@ -18,7 +18,6 @@
import net.onrc.onos.api.packet.IPacketListener;
import net.onrc.onos.api.packet.IPacketService;
import net.onrc.onos.apps.proxyarp.IProxyArpService;
-import net.onrc.onos.core.devicemanager.IOnosDeviceService;
import net.onrc.onos.core.intent.Intent;
import net.onrc.onos.core.intent.Intent.IntentState;
import net.onrc.onos.core.intent.IntentMap;
@@ -191,7 +190,6 @@
List<Class<? extends IFloodlightService>> dependencies =
new ArrayList<Class<? extends IFloodlightService>>();
dependencies.add(IControllerRegistryService.class);
- dependencies.add(IOnosDeviceService.class);
dependencies.add(ITopologyService.class);
dependencies.add(IPathCalcRuntimeService.class);
// We don't use the IProxyArpService directly, but reactive forwarding
diff --git a/src/main/java/net/onrc/onos/core/devicemanager/IOnosDeviceListener.java b/src/main/java/net/onrc/onos/core/devicemanager/IOnosDeviceListener.java
deleted file mode 100644
index 405340f..0000000
--- a/src/main/java/net/onrc/onos/core/devicemanager/IOnosDeviceListener.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package net.onrc.onos.core.devicemanager;
-
-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
deleted file mode 100644
index ee38c6a..0000000
--- a/src/main/java/net/onrc/onos/core/devicemanager/IOnosDeviceService.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package net.onrc.onos.core.devicemanager;
-
-import net.floodlightcontroller.core.module.IFloodlightService;
-import net.floodlightcontroller.util.MACAddress;
-
-/**
- * {@link OnosDeviceManager} doesn't yet provide any API to fellow modules,
- * however making it export a dummy service means we can specify it as
- * a dependency of Forwarding.
- */
-public interface IOnosDeviceService extends IFloodlightService {
-
- public void addOnosDeviceListener(IOnosDeviceListener listener);
-
- 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/hostmanager/Host.java
similarity index 88%
rename from src/main/java/net/onrc/onos/core/devicemanager/OnosDevice.java
rename to src/main/java/net/onrc/onos/core/hostmanager/Host.java
index 6348932..45452e0 100644
--- a/src/main/java/net/onrc/onos/core/devicemanager/OnosDevice.java
+++ b/src/main/java/net/onrc/onos/core/hostmanager/Host.java
@@ -15,7 +15,7 @@
* under the License.
**/
-package net.onrc.onos.core.devicemanager;
+package net.onrc.onos.core.hostmanager;
import java.io.Serializable;
import java.util.Date;
@@ -38,7 +38,7 @@
* <!-- CHECKSTYLE IGNORE WriteTag FOR NEXT 1 LINES -->
* @author readams
*/
-public class OnosDevice implements Serializable {
+public class Host implements Serializable {
private static final long serialVersionUID = 1L;
@@ -74,19 +74,19 @@
// ************
// Constructors
// ************
- protected OnosDevice() {
+ protected Host() {
}
/**
- * Create a new device and its information.
+ * Create a new host and its information.
*
- * @param macAddress mac address of this device
- * @param vlan vlan ID of this device
- * @param switchDPID switch DPID where the device is attached
- * @param switchPort port number where the device is attached
- * @param lastSeenTimestamp last packet-in time of this device
+ * @param macAddress mac address of this host
+ * @param vlan vlan ID of this host
+ * @param switchDPID switch DPID where the host is attached
+ * @param switchPort port number where the host is attached
+ * @param lastSeenTimestamp last packet-in time of this host
*/
- public OnosDevice(MACAddress macAddress, Short vlan, Long switchDPID,
+ public Host(MACAddress macAddress, Short vlan, Long switchDPID,
Long switchPort, Date lastSeenTimestamp) {
this.macAddress = macAddress;
this.vlan = vlan;
@@ -152,7 +152,7 @@
if (getClass() != obj.getClass()) {
return false;
}
- OnosDevice other = (OnosDevice) obj;
+ Host other = (Host) obj;
if (hashCode() != other.hashCode()) {
return false;
}
@@ -174,7 +174,7 @@
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
- builder.append("OnosDevice [macAddress=");
+ builder.append("Host [macAddress=");
builder.append(macAddress.toString());
builder.append(", vlan=");
builder.append(vlan);
diff --git a/src/main/java/net/onrc/onos/core/devicemanager/OnosDeviceManager.java b/src/main/java/net/onrc/onos/core/hostmanager/HostManager.java
similarity index 66%
rename from src/main/java/net/onrc/onos/core/devicemanager/OnosDeviceManager.java
rename to src/main/java/net/onrc/onos/core/hostmanager/HostManager.java
index 30ffb19..9e62bd9 100644
--- a/src/main/java/net/onrc/onos/core/devicemanager/OnosDeviceManager.java
+++ b/src/main/java/net/onrc/onos/core/hostmanager/HostManager.java
@@ -1,4 +1,4 @@
-package net.onrc.onos.core.devicemanager;
+package net.onrc.onos.core.hostmanager;
import java.util.ArrayList;
import java.util.Collection;
@@ -37,16 +37,16 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class OnosDeviceManager implements IFloodlightModule,
+public class HostManager implements IFloodlightModule,
IOFMessageListener,
- IOnosDeviceService {
+ IHostService {
- private static final Logger log = LoggerFactory.getLogger(OnosDeviceManager.class);
- private static final long DEVICE_CLEANING_INITIAL_DELAY = 30;
+ private static final Logger log = LoggerFactory.getLogger(HostManager.class);
+ private static final long HOST_CLEANING_INITIAL_DELAY = 30;
private int cleanupSecondConfig = 60 * 60;
private int agingMillisecConfig = 60 * 60 * 1000;
- private CopyOnWriteArrayList<IOnosDeviceListener> deviceListeners;
+ private CopyOnWriteArrayList<IHostListener> hostListeners;
private IFloodlightProviderService floodlightProvider;
private static final ScheduledExecutorService EXECUTOR_SERVICE =
Executors.newSingleThreadScheduledExecutor();
@@ -54,28 +54,28 @@
private ITopologyService topologyService;
private Topology topology;
- public enum OnosDeviceUpdateType {
+ public enum HostUpdateType {
ADD, DELETE, UPDATE;
}
- private class OnosDeviceUpdate implements IUpdate {
- private final OnosDevice device;
- private final OnosDeviceUpdateType type;
+ private class HostUpdate implements IUpdate {
+ private final Host host;
+ private final HostUpdateType type;
- public OnosDeviceUpdate(OnosDevice device, OnosDeviceUpdateType type) {
- this.device = device;
+ public HostUpdate(Host host, HostUpdateType type) {
+ this.host = host;
this.type = type;
}
@Override
public void dispatch() {
- if (type == OnosDeviceUpdateType.ADD) {
- for (IOnosDeviceListener listener : deviceListeners) {
- listener.onosDeviceAdded(device);
+ if (type == HostUpdateType.ADD) {
+ for (IHostListener listener : hostListeners) {
+ listener.hostAdded(host);
}
- } else if (type == OnosDeviceUpdateType.DELETE) {
- for (IOnosDeviceListener listener : deviceListeners) {
- listener.onosDeviceRemoved(device);
+ } else if (type == HostUpdateType.DELETE) {
+ for (IHostListener listener : hostListeners) {
+ listener.hostRemoved(host);
}
}
}
@@ -83,13 +83,13 @@
@Override
public String getName() {
- return "onosdevicemanager";
+ return "hostmanager";
}
@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
+ // end up reading bad host info from LLDP packets
return type == OFType.PACKET_IN && "linkdiscovery".equals(name);
}
@@ -126,72 +126,72 @@
final PortNumber portNum = new PortNumber(pi.getInPort());
Long mac = eth.getSourceMAC().toLong();
- OnosDevice srcDevice =
- getSourceDeviceFromPacket(eth, dpid.value(), portNum.value());
+ Host srcHost =
+ getSourceHostFromPacket(eth, dpid.value(), portNum.value());
- if (srcDevice == null) {
+ if (srcHost == null) {
return Command.STOP;
}
- // If the switch port we try to attach a new device already has a link,
- // then don't add the device
+ // If the switch port we try to attach a new host already has a link,
+ // then don't add the host
// TODO We probably don't need to check this here, it should be done in
// the Topology module.
topology.acquireReadLock();
try {
if (topology.getOutgoingLink(dpid, portNum) != null ||
topology.getIncomingLink(dpid, portNum) != null) {
- log.debug("Stop adding OnosDevice {} as " +
+ log.debug("Not adding host {} as " +
"there is a link on the port: dpid {} port {}",
- srcDevice.getMacAddress(), dpid, portNum);
+ srcHost.getMacAddress(), dpid, portNum);
return Command.CONTINUE;
}
} finally {
topology.releaseReadLock();
}
- addOnosDevice(mac, srcDevice);
+ addHost(mac, srcHost);
if (log.isTraceEnabled()) {
- log.trace("Add device info: {}", srcDevice);
+ log.trace("Add host info: {}", srcHost);
}
return Command.CONTINUE;
}
- // Thread to delete devices periodically.
- // Remove all devices from the map first and then finally delete devices
+ // Thread to delete hosts periodically.
+ // Remove all hosts from the map first and then finally delete hosts
// from the DB.
- // TODO This should be sharded based on device 'owner' (i.e. the instance
+ // TODO This should be sharded based on host 'owner' (i.e. the instance
// that owns the switch it is attached to). Currently any instance can
- // issue deletes for any device, which permits race conditions and could
+ // issue deletes for any host, which permits race conditions and could
// cause the Topology replicas to diverge.
- private class CleanDevice implements Runnable {
+ private class HostCleaner implements Runnable {
@Override
public void run() {
- log.debug("called CleanDevice");
+ log.debug("called HostCleaner");
topology.acquireReadLock();
try {
Set<Device> deleteSet = new HashSet<Device>();
- for (Device dev : topology.getDevices()) {
+ for (Device host : topology.getDevices()) {
long now = System.currentTimeMillis();
- if ((now - dev.getLastSeenTime() > agingMillisecConfig)) {
+ if ((now - host.getLastSeenTime() > agingMillisecConfig)) {
if (log.isTraceEnabled()) {
- log.trace("Removing device info: mac {}, now {}, lastSeenTime {}, diff {}",
- dev.getMacAddress(), now, dev.getLastSeenTime(), now - dev.getLastSeenTime());
+ log.trace("Removing host info: mac {}, now {}, lastSeenTime {}, diff {}",
+ host.getMacAddress(), now, host.getLastSeenTime(), now - host.getLastSeenTime());
}
- deleteSet.add(dev);
+ deleteSet.add(host);
}
}
- for (Device dev : deleteSet) {
- deleteOnosDeviceByMac(dev.getMacAddress());
+ for (Device host : deleteSet) {
+ deleteHostByMac(host.getMacAddress());
}
} catch (Exception e) {
// Any exception thrown by the task will prevent the Executor
// from running the next iteration, so we need to catch and log
// all exceptions here.
- log.error("Exception in device cleanup thread:", e);
+ log.error("Exception in host cleanup thread:", e);
} finally {
topology.releaseReadLock();
}
@@ -199,16 +199,15 @@
}
/**
- * Parse a device from an {@link Ethernet} packet.
+ * Parse a host from an {@link Ethernet} packet.
*
* @param eth the packet to parse
* @param swdpid the switch on which the packet arrived
* @param port the port on which the packet arrived
- * @return the device from the packet
+ * @return the host from the packet
*/
- protected OnosDevice getSourceDeviceFromPacket(Ethernet eth,
- long swdpid,
- long port) {
+ protected Host getSourceHostFromPacket(Ethernet eth,
+ long swdpid, long port) {
MACAddress sourceMac = eth.getSourceMAC();
// Ignore broadcast/multicast source
@@ -217,7 +216,7 @@
}
short vlan = eth.getVlanID();
- return new OnosDevice(sourceMac,
+ return new Host(sourceMac,
((vlan >= 0) ? vlan : null),
swdpid,
port,
@@ -228,7 +227,7 @@
public Collection<Class<? extends IFloodlightService>> getModuleServices() {
List<Class<? extends IFloodlightService>> services =
new ArrayList<Class<? extends IFloodlightService>>();
- services.add(IOnosDeviceService.class);
+ services.add(IHostService.class);
return services;
}
@@ -236,7 +235,7 @@
public Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls() {
Map<Class<? extends IFloodlightService>, IFloodlightService> impls =
new HashMap<Class<? extends IFloodlightService>, IFloodlightService>();
- impls.put(IOnosDeviceService.class, this);
+ impls.put(IHostService.class, this);
return impls;
}
@@ -253,68 +252,68 @@
public void init(FloodlightModuleContext context)
throws FloodlightModuleException {
floodlightProvider = context.getServiceImpl(IFloodlightProviderService.class);
- deviceListeners = new CopyOnWriteArrayList<IOnosDeviceListener>();
+ hostListeners = new CopyOnWriteArrayList<IHostListener>();
topologyService = context.getServiceImpl(ITopologyService.class);
topology = topologyService.getTopology();
- setOnosDeviceManagerProperty(context);
+ setHostManagerProperties(context);
}
@Override
public void startUp(FloodlightModuleContext context) {
floodlightProvider.addOFMessageListener(OFType.PACKET_IN, this);
- EXECUTOR_SERVICE.scheduleAtFixedRate(new CleanDevice(),
- DEVICE_CLEANING_INITIAL_DELAY, cleanupSecondConfig, TimeUnit.SECONDS);
+ EXECUTOR_SERVICE.scheduleAtFixedRate(new HostCleaner(),
+ HOST_CLEANING_INITIAL_DELAY, cleanupSecondConfig, TimeUnit.SECONDS);
}
@Override
- public void deleteOnosDevice(OnosDevice dev) {
+ public void deleteHost(Host host) {
floodlightProvider.publishUpdate(
- new OnosDeviceUpdate(dev, OnosDeviceUpdateType.DELETE));
+ new HostUpdate(host, HostUpdateType.DELETE));
}
@Override
- public void deleteOnosDeviceByMac(MACAddress mac) {
- OnosDevice deleteDevice = null;
+ public void deleteHostByMac(MACAddress mac) {
+ Host deleteHost = null;
topology.acquireReadLock();
try {
- Device dev = topology.getDeviceByMac(mac);
+ Device host = topology.getDeviceByMac(mac);
- for (Port switchPort : dev.getAttachmentPoints()) {
+ for (Port switchPort : host.getAttachmentPoints()) {
// We don't handle vlan now and multiple attachment points.
- deleteDevice = new OnosDevice(dev.getMacAddress(),
+ deleteHost = new Host(host.getMacAddress(),
null,
switchPort.getDpid().value(),
(long) switchPort.getNumber().value(),
- new Date(dev.getLastSeenTime()));
+ new Date(host.getLastSeenTime()));
break;
}
} finally {
topology.releaseReadLock();
}
- if (deleteDevice != null) {
- deleteOnosDevice(deleteDevice);
+ if (deleteHost != null) {
+ deleteHost(deleteHost);
}
}
@Override
- public void addOnosDevice(Long mac, OnosDevice dev) {
+ public void addHost(Long mac, Host host) {
floodlightProvider.publishUpdate(
- new OnosDeviceUpdate(dev, OnosDeviceUpdateType.ADD));
+ new HostUpdate(host, HostUpdateType.ADD));
}
@Override
- public void addOnosDeviceListener(IOnosDeviceListener listener) {
- deviceListeners.add(listener);
+ public void addHostListener(IHostListener listener) {
+ hostListeners.add(listener);
}
@Override
- public void deleteOnosDeviceListener(IOnosDeviceListener listener) {
- deviceListeners.remove(listener);
+ public void removeHostListener(IHostListener listener) {
+ hostListeners.remove(listener);
}
- private void setOnosDeviceManagerProperty(FloodlightModuleContext context) {
+ private void setHostManagerProperties(FloodlightModuleContext context) {
Map<String, String> configOptions = context.getConfigParams(this);
String cleanupsec = configOptions.get("cleanupsec");
String agingmsec = configOptions.get("agingmsec");
diff --git a/src/main/java/net/onrc/onos/core/hostmanager/IHostListener.java b/src/main/java/net/onrc/onos/core/hostmanager/IHostListener.java
new file mode 100644
index 0000000..2a61ab2
--- /dev/null
+++ b/src/main/java/net/onrc/onos/core/hostmanager/IHostListener.java
@@ -0,0 +1,8 @@
+package net.onrc.onos.core.hostmanager;
+
+public interface IHostListener {
+
+ public void hostAdded(Host host);
+
+ public void hostRemoved(Host host);
+}
diff --git a/src/main/java/net/onrc/onos/core/hostmanager/IHostService.java b/src/main/java/net/onrc/onos/core/hostmanager/IHostService.java
new file mode 100644
index 0000000..54c532d
--- /dev/null
+++ b/src/main/java/net/onrc/onos/core/hostmanager/IHostService.java
@@ -0,0 +1,22 @@
+package net.onrc.onos.core.hostmanager;
+
+import net.floodlightcontroller.core.module.IFloodlightService;
+import net.floodlightcontroller.util.MACAddress;
+
+/**
+ * {@link HostManager} doesn't yet provide any API to fellow modules,
+ * however making it export a dummy service means we can specify it as
+ * a dependency of Forwarding.
+ */
+public interface IHostService extends IFloodlightService {
+
+ public void addHostListener(IHostListener listener);
+
+ public void removeHostListener(IHostListener listener);
+
+ public void deleteHost(Host host);
+
+ public void deleteHostByMac(MACAddress mac);
+
+ public void addHost(Long mac, Host host);
+}
diff --git a/src/main/java/net/onrc/onos/core/topology/TopologyPublisher.java b/src/main/java/net/onrc/onos/core/topology/TopologyPublisher.java
index 5e2b192..1074905 100644
--- a/src/main/java/net/onrc/onos/core/topology/TopologyPublisher.java
+++ b/src/main/java/net/onrc/onos/core/topology/TopologyPublisher.java
@@ -14,9 +14,9 @@
import net.floodlightcontroller.core.module.IFloodlightService;
import net.floodlightcontroller.core.util.SingletonTask;
import net.floodlightcontroller.threadpool.IThreadPoolService;
-import net.onrc.onos.core.devicemanager.IOnosDeviceListener;
-import net.onrc.onos.core.devicemanager.IOnosDeviceService;
-import net.onrc.onos.core.devicemanager.OnosDevice;
+import net.onrc.onos.core.hostmanager.Host;
+import net.onrc.onos.core.hostmanager.IHostListener;
+import net.onrc.onos.core.hostmanager.IHostService;
import net.onrc.onos.core.linkdiscovery.ILinkDiscoveryListener;
import net.onrc.onos.core.linkdiscovery.ILinkDiscoveryService;
import net.onrc.onos.core.linkdiscovery.Link;
@@ -42,7 +42,7 @@
IOFSwitchPortListener,
ILinkDiscoveryListener,
IFloodlightModule,
- IOnosDeviceListener {
+ IHostListener {
private static final Logger log =
LoggerFactory.getLogger(TopologyPublisher.class);
@@ -51,7 +51,7 @@
private IControllerRegistryService registryService;
private ITopologyService topologyService;
- private IOnosDeviceService onosDeviceService;
+ private IHostService hostService;
private Topology topology;
private TopologyDiscoveryInterface topologyDiscoveryInterface;
@@ -308,7 +308,7 @@
l.add(IThreadPoolService.class);
l.add(IControllerRegistryService.class);
l.add(ITopologyService.class);
- l.add(IOnosDeviceService.class);
+ l.add(IHostService.class);
return l;
}
@@ -318,7 +318,7 @@
floodlightProvider = context.getServiceImpl(IFloodlightProviderService.class);
linkDiscovery = context.getServiceImpl(ILinkDiscoveryService.class);
registryService = context.getServiceImpl(IControllerRegistryService.class);
- onosDeviceService = context.getServiceImpl(IOnosDeviceService.class);
+ hostService = context.getServiceImpl(IHostService.class);
topologyService = context.getServiceImpl(ITopologyService.class);
}
@@ -327,7 +327,7 @@
public void startUp(FloodlightModuleContext context) {
floodlightProvider.addOFSwitchListener(this);
linkDiscovery.addListener(this);
- onosDeviceService.addOnosDeviceListener(this);
+ hostService.addHostListener(this);
topology = topologyService.getTopology();
topologyDiscoveryInterface =
@@ -354,15 +354,15 @@
}
@Override
- public void onosDeviceAdded(OnosDevice device) {
- log.debug("Called onosDeviceAdded mac {}", device.getMacAddress());
+ public void hostAdded(Host host) {
+ log.debug("Called onosDeviceAdded mac {}", host.getMacAddress());
- SwitchPort sp = new SwitchPort(device.getSwitchDPID(), device.getSwitchPort());
+ SwitchPort sp = new SwitchPort(host.getSwitchDPID(), host.getSwitchPort());
List<SwitchPort> spLists = new ArrayList<SwitchPort>();
spLists.add(sp);
- DeviceEvent event = new DeviceEvent(device.getMacAddress());
+ DeviceEvent event = new DeviceEvent(host.getMacAddress());
event.setAttachmentPoints(spLists);
- event.setLastSeenTime(device.getLastSeenTimestamp().getTime());
+ event.setLastSeenTime(host.getLastSeenTimestamp().getTime());
// Does not use vlan info now.
event.freeze();
@@ -370,10 +370,10 @@
}
@Override
- public void onosDeviceRemoved(OnosDevice device) {
+ public void hostRemoved(Host host) {
log.debug("Called onosDeviceRemoved");
- DeviceEvent event = new DeviceEvent(device.getMacAddress());
- // XXX shouldn't we be setting attachment points?
+ DeviceEvent event = new DeviceEvent(host.getMacAddress());
+ //XXX shouldn't we be setting attachment points?
event.freeze();
topologyDiscoveryInterface.removeDeviceDiscoveryEvent(event);
}
diff --git a/src/main/java/net/onrc/onos/core/util/serializers/KryoFactory.java b/src/main/java/net/onrc/onos/core/util/serializers/KryoFactory.java
index 07efbbe..9fdc506 100644
--- a/src/main/java/net/onrc/onos/core/util/serializers/KryoFactory.java
+++ b/src/main/java/net/onrc/onos/core/util/serializers/KryoFactory.java
@@ -12,7 +12,7 @@
import net.floodlightcontroller.util.MACAddress;
import net.onrc.onos.apps.proxyarp.ArpCacheNotification;
import net.onrc.onos.apps.proxyarp.ArpReplyNotification;
-import net.onrc.onos.core.devicemanager.OnosDevice;
+import net.onrc.onos.core.hostmanager.Host;
import net.onrc.onos.core.intent.ConstrainedShortestPathIntent;
import net.onrc.onos.core.intent.ErrorIntent;
import net.onrc.onos.core.intent.Intent;
@@ -223,7 +223,7 @@
// Device-related classes
kryo.register(HashSet.class);
- kryo.register(OnosDevice.class);
+ kryo.register(Host.class);
kryo.register(Date.class);
// ProxyArp-related classes