Jonathan Hart

Remove IP addresses from the Port interface.

Addresses are now indirectly associated with Ports.
......@@ -2,13 +2,7 @@ package org.onlab.onos.net;
import static com.google.common.base.MoreObjects.toStringHelper;
import java.util.Collections;
import java.util.Objects;
import java.util.Set;
import org.onlab.packet.IpPrefix;
import com.google.common.collect.ImmutableSet;
/**
* Default port implementation.
......@@ -19,36 +13,18 @@ public class DefaultPort implements Port {
private final PortNumber number;
private final boolean isEnabled;
// Attributes
private final Set<IpPrefix> ipAddresses;
/**
* Creates a network element attributed to the specified provider.
*
* @param element parent network element
* @param number port number
* @param isEnabled indicator whether the port is up and active
*/
public DefaultPort(Element element, PortNumber number,
boolean isEnabled) {
this(element, number, isEnabled, null);
}
/**
* Creates a network element attributed to the specified provider.
*
* @param element parent network element
* @param number port number
* @param isEnabled indicator whether the port is up and active
* @param ipAddresses set of IP addresses assigned to the port
*/
public DefaultPort(Element element, PortNumber number,
boolean isEnabled, Set<IpPrefix> ipAddresses) {
boolean isEnabled) {
this.element = element;
this.number = number;
this.isEnabled = isEnabled;
this.ipAddresses = (ipAddresses == null) ? Collections.<IpPrefix>emptySet() :
ImmutableSet.copyOf(ipAddresses);
}
@Override
......@@ -94,9 +70,4 @@ public class DefaultPort implements Port {
return element;
}
@Override
public Set<IpPrefix> ipAddresses() {
return ipAddresses;
}
}
......
package org.onlab.onos.net;
import java.util.Set;
import org.onlab.packet.IpPrefix;
/**
* Abstraction of a network port.
......@@ -32,12 +29,4 @@ public interface Port {
// set of port attributes
/**
* Returns the set of IP addresses that are logically configured on this
* port.
*
* @return the set of IP addresses configured on the port. The set is empty
* if no addresses are configured.
*/
Set<IpPrefix> ipAddresses();
}
......
......@@ -6,7 +6,6 @@ import java.util.concurrent.TimeUnit;
import org.jboss.netty.util.Timeout;
import org.jboss.netty.util.TimerTask;
import org.onlab.onos.net.Device;
import org.onlab.onos.net.Host;
import org.onlab.onos.net.Port;
import org.onlab.onos.net.device.DeviceService;
......@@ -89,7 +88,7 @@ public class HostMonitor implements TimerTask {
// else (ip isn't in any configured subnet)
// send out all non-external edge ports
for (Device device : deviceService.getDevices()) {
/*for (Device device : deviceService.getDevices()) {
for (Port port : deviceService.getPorts(device.id())) {
for (IpPrefix ip : port.ipAddresses()) {
if (ip.contains(targetIp)) {
......@@ -98,7 +97,7 @@ public class HostMonitor implements TimerTask {
}
}
}
}
}*/
}
......
package org.onlab.onos.store.device.impl;
import java.util.ArrayList;
import java.util.Collection;
import org.onlab.onos.net.DefaultPort;
import org.onlab.onos.net.Element;
import org.onlab.onos.net.PortNumber;
import org.onlab.packet.IpPrefix;
import com.esotericsoftware.kryo.Kryo;
import com.esotericsoftware.kryo.Serializer;
import com.esotericsoftware.kryo.io.Input;
import com.esotericsoftware.kryo.io.Output;
import com.esotericsoftware.kryo.serializers.CollectionSerializer;
import com.google.common.collect.ImmutableSet;
// TODO move to util, etc.
/**
......@@ -22,10 +16,6 @@ import com.google.common.collect.ImmutableSet;
public final class DefaultPortSerializer extends
Serializer<DefaultPort> {
private final CollectionSerializer ipAddrSerializer
= new CollectionSerializer(IpPrefix.class,
new IpPrefixSerializer(), false);
/**
* Default constructor.
*/
......@@ -39,8 +29,6 @@ public final class DefaultPortSerializer extends
kryo.writeClassAndObject(output, object.element());
kryo.writeObject(output, object.number());
output.writeBoolean(object.isEnabled());
kryo.writeObject(output, object.ipAddresses(),
ipAddrSerializer);
}
@Override
......@@ -49,11 +37,7 @@ public final class DefaultPortSerializer extends
Element element = (Element) kryo.readClassAndObject(input);
PortNumber number = kryo.readObject(input, PortNumber.class);
boolean isEnabled = input.readBoolean();
@SuppressWarnings("unchecked")
Collection<IpPrefix> ipAddresses = kryo.readObject(
input, ArrayList.class, ipAddrSerializer);
return new DefaultPort(element, number, isEnabled,
ImmutableSet.copyOf(ipAddresses));
return new DefaultPort(element, number, isEnabled);
}
}
......