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
diff --git a/src/main/resources/META-INF/services/net.floodlightcontroller.core.module.IFloodlightModule b/src/main/resources/META-INF/services/net.floodlightcontroller.core.module.IFloodlightModule
index 37be163..b7636ab 100644
--- a/src/main/resources/META-INF/services/net.floodlightcontroller.core.module.IFloodlightModule
+++ b/src/main/resources/META-INF/services/net.floodlightcontroller.core.module.IFloodlightModule
@@ -14,7 +14,7 @@
net.onrc.onos.apps.forwarding.Forwarding
net.onrc.onos.apps.proxyarp.ProxyArpManager
net.onrc.onos.core.main.config.DefaultConfiguration
-net.onrc.onos.core.devicemanager.OnosDeviceManager
+net.onrc.onos.core.hostmanager.HostManager
net.onrc.onos.core.topology.TopologyModule
net.onrc.onos.core.intent.runtime.PathCalcRuntimeModule
net.onrc.onos.core.intent.runtime.PlanInstallModule
diff --git a/src/test/java/net/onrc/onos/apps/proxyarp/ProxyArpManagerTest.java b/src/test/java/net/onrc/onos/apps/proxyarp/ProxyArpManagerTest.java
index 5976add..347d31f 100644
--- a/src/test/java/net/onrc/onos/apps/proxyarp/ProxyArpManagerTest.java
+++ b/src/test/java/net/onrc/onos/apps/proxyarp/ProxyArpManagerTest.java
@@ -20,8 +20,8 @@
import net.onrc.onos.core.datagrid.IDatagridService;
import net.onrc.onos.core.datagrid.IEventChannel;
import net.onrc.onos.core.datagrid.IEventChannelListener;
-import net.onrc.onos.core.devicemanager.IOnosDeviceService;
import net.onrc.onos.core.flowprogrammer.IFlowPusherService;
+import net.onrc.onos.core.hostmanager.IHostService;
import net.onrc.onos.core.main.config.IConfigInfoService;
import net.onrc.onos.core.packet.ARP;
import net.onrc.onos.core.packet.Ethernet;
@@ -62,7 +62,7 @@
IDatagridService datagridService;
IFlowPusherService flowPusherService;
ITopologyService topologyService;
- IOnosDeviceService onosDeviceService;
+ IHostService hostService;
IPacketService packetService;
Map<String, String> configMap;
@@ -212,7 +212,7 @@
datagridService = EasyMock.createMock(IDatagridService.class);
flowPusherService = EasyMock.createMock(IFlowPusherService.class);
topologyService = EasyMock.createMock(ITopologyService.class);
- onosDeviceService = EasyMock.createMock(IOnosDeviceService.class);
+ hostService = EasyMock.createMock(IHostService.class);
packetService = EasyMock.createMock(IPacketService.class);
eg = EasyMock.createMock(IEventChannel.class);
el = EasyMock.createMock(IEventChannelListener.class);
@@ -241,7 +241,7 @@
EasyMock.expect(context.getServiceImpl(IDatagridService.class)).andReturn(datagridService);
EasyMock.expect(context.getServiceImpl(IFlowPusherService.class)).andReturn(flowPusherService);
EasyMock.expect(context.getServiceImpl(ITopologyService.class)).andReturn(topologyService);
- EasyMock.expect(context.getServiceImpl(IOnosDeviceService.class)).andReturn(onosDeviceService);
+ EasyMock.expect(context.getServiceImpl(IHostService.class)).andReturn(hostService);
EasyMock.expect(context.getServiceImpl(IPacketService.class)).andReturn(packetService);
}
@@ -283,7 +283,7 @@
EasyMock.replay(context, floodligthProviderService, configInfoService,
restApiService, datagridService, flowPusherService,
- topologyService, onosDeviceService, packetService, topology, eg,
+ topologyService, hostService, packetService, topology, eg,
el, dev1, inPort1, sw1);
arpManager.init(context);
arpManager.startUp(context);
@@ -302,7 +302,7 @@
EasyMock.replay(context, floodligthProviderService, configInfoService,
restApiService, datagridService, flowPusherService,
- topologyService, onosDeviceService, packetService, topology,
+ topologyService, hostService, packetService, topology,
eg, el, dev1, inPort1, sw1);
arpManager.init(context);
arpManager.startUp(context);
@@ -320,7 +320,7 @@
EasyMock.replay(context, floodligthProviderService, configInfoService,
restApiService, datagridService, flowPusherService,
- topologyService, onosDeviceService, packetService, topology,
+ topologyService, hostService, packetService, topology,
eg, el, dev1, inPort1, sw1);
arpManager.init(context);
arpManager.startUp(context);
@@ -335,7 +335,7 @@
EasyMock.replay(context, floodligthProviderService, configInfoService,
restApiService, datagridService, flowPusherService,
- topologyService, onosDeviceService, packetService, topology,
+ topologyService, hostService, packetService, topology,
eg, el, dev1, inPort1, sw1);
arpManager.init(context);
arpManager.startUp(context);
@@ -354,7 +354,7 @@
EasyMock.replay(context, floodligthProviderService, configInfoService,
restApiService, datagridService, flowPusherService,
- topologyService, onosDeviceService, packetService, topology,
+ topologyService, hostService, packetService, topology,
eg, el, dev1, inPort1, sw1);
arpManager.init(context);
arpManager.startUp(context);
@@ -371,7 +371,7 @@
EasyMock.replay(context, floodligthProviderService, configInfoService,
restApiService, datagridService, flowPusherService,
- topologyService, onosDeviceService, packetService, topology,
+ topologyService, hostService, packetService, topology,
eg, el, dev1, inPort1, sw1);
arpManager.init(context);
arpManager.startUp(context);
@@ -387,7 +387,7 @@
EasyMock.replay(context, floodligthProviderService, configInfoService,
restApiService, datagridService, flowPusherService,
- topologyService, onosDeviceService, packetService, topology,
+ topologyService, hostService, packetService, topology,
eg, el, dev1, inPort1, sw1);
arpManager.init(context);
arpManager.startUp(context);
@@ -409,7 +409,7 @@
EasyMock.replay(context, floodligthProviderService, configInfoService,
restApiService, datagridService, flowPusherService,
- topologyService, onosDeviceService, packetService, topology,
+ topologyService, hostService, packetService, topology,
eg, el, dev1, inPort1, sw1);
arpManager.init(context);
arpManager.startUp(context);
@@ -428,7 +428,7 @@
EasyMock.replay(context, floodligthProviderService, configInfoService,
restApiService, datagridService, flowPusherService,
- topologyService, onosDeviceService, packetService, topology,
+ topologyService, hostService, packetService, topology,
eg, el, dev1, inPort1, sw1);
arpManager.init(context);
arpManager.startUp(context);
diff --git a/src/test/java/net/onrc/onos/core/devicemanager/OnosDeviceManagerTest.java b/src/test/java/net/onrc/onos/core/hostmanager/HostManagerTest.java
similarity index 69%
rename from src/test/java/net/onrc/onos/core/devicemanager/OnosDeviceManagerTest.java
rename to src/test/java/net/onrc/onos/core/hostmanager/HostManagerTest.java
index 39e739f..5f22091 100644
--- a/src/test/java/net/onrc/onos/core/devicemanager/OnosDeviceManagerTest.java
+++ b/src/test/java/net/onrc/onos/core/hostmanager/HostManagerTest.java
@@ -1,4 +1,4 @@
-package net.onrc.onos.core.devicemanager;
+package net.onrc.onos.core.hostmanager;
import static org.easymock.EasyMock.anyObject;
import static org.easymock.EasyMock.createMock;
@@ -43,23 +43,23 @@
import org.openflow.protocol.OFType;
/**
- * Unit tests for the Device Manager module (OnosDeviceManger).
- * These test cases check the result of add/delete device and
- * verify the result of processPacketIn through inject faked packets
- * floodLightProvider, datagridService, networkGraphService,
- * controllerRegistryService, eventChannel are mocked out.
+ * Unit tests for the Host Manager module (HostManger).
+ * These test cases check the result of add/delete host and
+ * verify the result of processPacketIn by injecting fake packets.
+ * floodlightProvider, datagridService, topologyService,
+ * controllerRegistryService, eventChannel are mocked out.
*/
-public class OnosDeviceManagerTest extends FloodlightTestCase {
+public class HostManagerTest extends FloodlightTestCase {
private IPacket pkt0, pkt1, pkt2, pkt3, pkt4;
private IOFSwitch sw1;
private long sw1Dpid;
private long sw1DevPort, sw1DevPort2;
- private OnosDeviceManager odm;
+ private HostManager hostManager;
private OFPacketIn pktIn, pktIn2;
private FloodlightModuleContext modContext;
private ITopologyService networkGraphService;
- private IEventChannel<Long, OnosDevice> eventChannel;
- private IFloodlightProviderService floodLightProvider;
+ private IEventChannel<Long, Host> eventChannel;
+ private IFloodlightProviderService floodlightProvider;
private Date lastSeenTimestamp;
@Override
@@ -74,7 +74,7 @@
topology.createSampleTopology2();
modContext = new FloodlightModuleContext();
- floodLightProvider = createMock(IFloodlightProviderService.class);
+ floodlightProvider = createMock(IFloodlightProviderService.class);
datagridService = createMock(IDatagridService.class);
networkGraphService = createMock(ITopologyService.class);
controllerRegistryService = createMock(IControllerRegistryService.class);
@@ -83,14 +83,14 @@
networkGraphService.registerTopologyListener(anyObject(ITopologyListener.class));
expectLastCall();
- expect(datagridService.createChannel("onos.device", Long.class, OnosDevice.class))
+ expect(datagridService.createChannel("onos.host", Long.class, Host.class))
.andReturn(eventChannel).once();
expect(topology.getOutgoingLink(new Dpid(1L), new PortNumber((short) 100))).andReturn(null).anyTimes();
expect(datagridService.addListener(
- eq("onos.device"),
+ eq("onos.host"),
anyObject(IEventChannelListener.class),
eq(Long.class),
- eq(OnosDevice.class)))
+ eq(Host.class)))
.andReturn(eventChannel).once();
replay(datagridService);
@@ -99,7 +99,7 @@
modContext.addService(IDatagridService.class, datagridService);
modContext.addService(ITopologyService.class, networkGraphService);
- modContext.addService(IFloodlightProviderService.class, floodLightProvider);
+ modContext.addService(IFloodlightProviderService.class, floodlightProvider);
modContext.getServiceImpl(IFloodlightProviderService.class);
sw1Dpid = 1L;
sw1 = createMockSwitch(sw1Dpid);
@@ -108,7 +108,7 @@
sw1DevPort = 100;
sw1DevPort2 = 12L;
- odm = new OnosDeviceManager();
+ hostManager = new HostManager();
/*
* Broadcast source address
*/
@@ -223,26 +223,26 @@
}
/**
- * Test set operation on lastSeenTimstamp field in OnosDevice.
+ * Test set operation on lastSeenTimstamp field in Host.
*/
@Test
public void testSetLastSeenTimestamp() {
Ethernet eth = (Ethernet) pkt1;
- OnosDevice srcDevice = odm.getSourceDeviceFromPacket(eth, sw1Dpid, sw1DevPort);
+ Host srcHost = hostManager.getSourceHostFromPacket(eth, sw1Dpid, sw1DevPort);
- floodLightProvider.addOFMessageListener(EasyMock.eq(OFType.PACKET_IN), EasyMock.isA(OnosDeviceManager.class));
- srcDevice.setLastSeenTimestamp(lastSeenTimestamp);
- assertEquals(lastSeenTimestamp, srcDevice.getLastSeenTimestamp());
+ floodlightProvider.addOFMessageListener(EasyMock.eq(OFType.PACKET_IN), EasyMock.isA(HostManager.class));
+ srcHost.setLastSeenTimestamp(lastSeenTimestamp);
+ assertEquals(lastSeenTimestamp, srcHost.getLastSeenTimestamp());
}
/**
- * test the functionality to get the source device from Packet header
+ * test the functionality to get the source host from Packet header
* information.
*/
@Test
- public void testGetSourceDeviceFromPacket() {
+ public void testGetSourceHostFromPacket() {
byte[] address = new byte[] {0x00, 0x44, 0x33, 0x22, 0x11, 0x01};
MACAddress srcMac = new MACAddress(address);
- OnosDevice dev1 = new OnosDevice(srcMac,
+ Host host1 = new Host(srcMac,
null,
sw1Dpid,
sw1DevPort,
@@ -252,36 +252,36 @@
* test DHCP packet case
*/
Ethernet eth = (Ethernet) pkt3;
- OnosDevice dev2 = odm.getSourceDeviceFromPacket(eth, sw1Dpid, sw1DevPort);
- assertEquals(dev1, dev2);
+ Host host2 = hostManager.getSourceHostFromPacket(eth, sw1Dpid, sw1DevPort);
+ assertEquals(host1, host2);
/*
* test ARP packet case
*/
eth = (Ethernet) pkt4;
- dev2 = odm.getSourceDeviceFromPacket(eth, sw1Dpid, sw1DevPort);
- assertEquals(dev1, dev2);
+ host2 = hostManager.getSourceHostFromPacket(eth, sw1Dpid, sw1DevPort);
+ assertEquals(host1, host2);
}
/**
- * This test will invoke addOnosDevice to add a new device through Packet pkt1.
+ * This test will invoke addHost to add a new host through Packet pkt1.
* @throws FloodlightModuleException
*/
@Test
- public void testProcessPacketInAddNewDevice() throws FloodlightModuleException {
- floodLightProvider.addOFMessageListener(EasyMock.eq(OFType.PACKET_IN),
- EasyMock.isA(OnosDeviceManager.class));
+ public void testProcessPacketInAddNewHost() throws FloodlightModuleException {
+ floodlightProvider.addOFMessageListener(EasyMock.eq(OFType.PACKET_IN),
+ EasyMock.isA(HostManager.class));
EasyMock.expectLastCall();
- floodLightProvider.publishUpdate(EasyMock.isA(IUpdate.class));
+ floodlightProvider.publishUpdate(EasyMock.isA(IUpdate.class));
EasyMock.expectLastCall();
- replay(floodLightProvider);
+ replay(floodlightProvider);
- odm.init(modContext);
- odm.startUp(modContext);
- Command cmd = odm.processPacketIn(sw1, pktIn, (Ethernet) pkt1);
+ hostManager.init(modContext);
+ hostManager.startUp(modContext);
+ Command cmd = hostManager.processPacketIn(sw1, pktIn, (Ethernet) pkt1);
assertEquals(Command.CONTINUE, cmd);
- EasyMock.verify(floodLightProvider);
+ EasyMock.verify(floodlightProvider);
}
/**
@@ -290,17 +290,17 @@
*/
@Test
public void testProcessPacketInHasLink() throws FloodlightModuleException {
- floodLightProvider.addOFMessageListener(EasyMock.eq(OFType.PACKET_IN),
- EasyMock.isA(OnosDeviceManager.class));
+ floodlightProvider.addOFMessageListener(EasyMock.eq(OFType.PACKET_IN),
+ EasyMock.isA(HostManager.class));
EasyMock.expectLastCall();
- replay(floodLightProvider);
+ replay(floodlightProvider);
- odm.init(modContext);
- odm.startUp(modContext);
- Command cmd = odm.processPacketIn(sw1, pktIn2, (Ethernet) pkt1);
+ hostManager.init(modContext);
+ hostManager.startUp(modContext);
+ Command cmd = hostManager.processPacketIn(sw1, pktIn2, (Ethernet) pkt1);
assertEquals(Command.CONTINUE, cmd);
- EasyMock.verify(floodLightProvider);
+ EasyMock.verify(floodlightProvider);
}
/**
@@ -308,74 +308,74 @@
*/
@Test
public void testProcessPacketInStop() {
- Command cmd = odm.processPacketIn(sw1, pktIn, (Ethernet) pkt0);
+ Command cmd = hostManager.processPacketIn(sw1, pktIn, (Ethernet) pkt0);
assertEquals(Command.STOP, cmd);
}
/**
- * Test add a device from the information from packet.
+ * Test add a host from the information from packet.
* @throws FloodlightModuleException
*/
@Test
- public void testAddOnosDevice() throws FloodlightModuleException {
+ public void testAddHost() throws FloodlightModuleException {
Ethernet eth = (Ethernet) pkt1;
Long longmac = eth.getSourceMAC().toLong();
- OnosDevice srcDevice = odm.getSourceDeviceFromPacket(eth, sw1Dpid, sw1DevPort);
+ Host srcHost = hostManager.getSourceHostFromPacket(eth, sw1Dpid, sw1DevPort);
- floodLightProvider.addOFMessageListener(EasyMock.eq(OFType.PACKET_IN), EasyMock.isA(OnosDeviceManager.class));
+ floodlightProvider.addOFMessageListener(EasyMock.eq(OFType.PACKET_IN), EasyMock.isA(HostManager.class));
EasyMock.expectLastCall();
- floodLightProvider.publishUpdate(EasyMock.isA(IUpdate.class));
+ floodlightProvider.publishUpdate(EasyMock.isA(IUpdate.class));
EasyMock.expectLastCall();
- replay(floodLightProvider);
+ replay(floodlightProvider);
- odm.init(modContext);
- odm.startUp(modContext);
- odm.addOnosDevice(longmac, srcDevice);
+ hostManager.init(modContext);
+ hostManager.startUp(modContext);
+ hostManager.addHost(longmac, srcHost);
- EasyMock.verify(floodLightProvider);
+ EasyMock.verify(floodlightProvider);
}
/**
- * Test delete a device.
+ * Test delete a host.
* @throws FloodlightModuleException
*/
@Test
- public void testDeleteOnosDevice() throws FloodlightModuleException {
+ public void testDeleteHost() throws FloodlightModuleException {
Ethernet eth = (Ethernet) pkt1;
- OnosDevice srcDevice = odm.getSourceDeviceFromPacket(eth, sw1Dpid, sw1DevPort);
+ Host srcHost = hostManager.getSourceHostFromPacket(eth, sw1Dpid, sw1DevPort);
- floodLightProvider.addOFMessageListener(EasyMock.eq(OFType.PACKET_IN), EasyMock.isA(OnosDeviceManager.class));
+ floodlightProvider.addOFMessageListener(EasyMock.eq(OFType.PACKET_IN), EasyMock.isA(HostManager.class));
EasyMock.expectLastCall();
- floodLightProvider.publishUpdate(EasyMock.isA(IUpdate.class));
+ floodlightProvider.publishUpdate(EasyMock.isA(IUpdate.class));
EasyMock.expectLastCall();
- replay(floodLightProvider);
+ replay(floodlightProvider);
- odm.init(modContext);
- odm.startUp(modContext);
- odm.deleteOnosDevice(srcDevice);
+ hostManager.init(modContext);
+ hostManager.startUp(modContext);
+ hostManager.deleteHost(srcHost);
- EasyMock.verify(floodLightProvider);
+ EasyMock.verify(floodlightProvider);
}
/**
- * Test delete a device by using its source mac address.
+ * Test delete a host by using its source mac address.
* @throws FloodlightModuleException
*/
@Test
- public void testDeleteOnosDeviceByMac() throws FloodlightModuleException {
+ public void testDeleteHostByMac() throws FloodlightModuleException {
Ethernet eth = (Ethernet) pkt1;
MACAddress mac = eth.getSourceMAC();
- floodLightProvider.addOFMessageListener(EasyMock.eq(OFType.PACKET_IN), EasyMock.isA(OnosDeviceManager.class));
+ floodlightProvider.addOFMessageListener(EasyMock.eq(OFType.PACKET_IN), EasyMock.isA(HostManager.class));
EasyMock.expectLastCall();
- floodLightProvider.publishUpdate(EasyMock.isA(IUpdate.class));
+ floodlightProvider.publishUpdate(EasyMock.isA(IUpdate.class));
EasyMock.expectLastCall();
- replay(floodLightProvider);
+ replay(floodlightProvider);
- odm.init(modContext);
- odm.startUp(modContext);
- odm.deleteOnosDeviceByMac(mac);
+ hostManager.init(modContext);
+ hostManager.startUp(modContext);
+ hostManager.deleteHostByMac(mac);
- EasyMock.verify(floodLightProvider);
+ EasyMock.verify(floodlightProvider);
}
}
diff --git a/src/test/java/net/onrc/onos/core/devicemanager/OnosDeviceTest.java b/src/test/java/net/onrc/onos/core/hostmanager/HostTest.java
similarity index 64%
rename from src/test/java/net/onrc/onos/core/devicemanager/OnosDeviceTest.java
rename to src/test/java/net/onrc/onos/core/hostmanager/HostTest.java
index 6c79bf0..b9eed02 100644
--- a/src/test/java/net/onrc/onos/core/devicemanager/OnosDeviceTest.java
+++ b/src/test/java/net/onrc/onos/core/hostmanager/HostTest.java
@@ -1,4 +1,4 @@
-package net.onrc.onos.core.devicemanager;
+package net.onrc.onos.core.hostmanager;
import static org.junit.Assert.assertTrue;
@@ -10,10 +10,10 @@
import org.junit.Before;
import org.junit.Test;
-/*
- * This is the test for OnosDevice.class.
+/**
+ * This is the test for the Host class.
*/
-public class OnosDeviceTest {
+public class HostTest {
MACAddress mac1;
MACAddress mac2;
@@ -40,26 +40,26 @@
public void tearDown() throws Exception {
}
- /*
+ /**
* Test for making sure hashCode function works properly.
*/
@Test
public void testHashCode() {
- OnosDevice dev1 = new OnosDevice(mac1, null, dpid1, portNum1, date1);
- OnosDevice dev2 = new OnosDevice(mac2, null, dpid2, portNum2, date2);
+ Host host1 = new Host(mac1, null, dpid1, portNum1, date1);
+ Host host2 = new Host(mac2, null, dpid2, portNum2, date2);
- assertTrue(dev1.hashCode() == dev2.hashCode());
+ assertTrue(host1.hashCode() == host2.hashCode());
}
- /*
+ /**
* Test for making sure equals function works properly.
*/
@Test
public void testEqualsObject() {
- OnosDevice dev1 = new OnosDevice(mac1, null, dpid1, portNum1, date1);
- OnosDevice dev2 = new OnosDevice(mac2, null, dpid2, portNum2, date2);
+ Host host1 = new Host(mac1, null, dpid1, portNum1, date1);
+ Host host2 = new Host(mac2, null, dpid2, portNum2, date2);
- assertTrue(dev1.equals(dev2));
+ assertTrue(host1.equals(host2));
}
}