tom

Added default link description & model entities.

......@@ -7,7 +7,7 @@ import java.util.Objects;
import static com.google.common.base.Objects.toStringHelper;
/**
* Default device model implementation.
* Default infrastructure device model implementation.
*/
public class DefaultDevice extends AbstractElement implements Device {
......
package org.onlab.onos.net;
import org.onlab.onos.net.link.LinkDescription;
import java.util.Objects;
import static com.google.common.base.Objects.toStringHelper;
/**
* Default infrastructure link model implementation.
*/
public class DefaultLink implements LinkDescription {
private ConnectPoint src;
private ConnectPoint dst;
/**
* Creates a link description using the supplied information.
*
* @param src link source
* @param dst link destination
*/
public DefaultLink(ConnectPoint src, ConnectPoint dst) {
this.src = src;
this.dst = dst;
}
@Override
public ConnectPoint src() {
return src;
}
@Override
public ConnectPoint dst() {
return dst;
}
@Override
public int hashCode() {
return Objects.hash(src, dst);
}
@Override
public boolean equals(Object obj) {
if (obj instanceof DefaultDevice) {
final DefaultLink other = (DefaultLink) obj;
return Objects.equals(this.src, other.src) &&
Objects.equals(this.dst, other.dst);
}
return false;
}
@Override
public String toString() {
return toStringHelper(this)
.add("src", src)
.add("dst", dst)
.toString();
}
}
......@@ -4,7 +4,6 @@ package org.onlab.onos.net;
* Abstraction of a network infrastructure link.
*/
public interface Link extends Provided {
// TODO: Consider extending graph Edge<Element> once the graph module is available
/**
* Coarse representation of the link type.
......
package org.onlab.onos.net.link;
import org.onlab.onos.net.ConnectPoint;
/**
* Default implementation of immutable link description entity.
*/
public class DefaultLinkDescription implements LinkDescription {
private ConnectPoint src;
private ConnectPoint dst;
/**
* Creates a link description using the supplied information.
*
* @param src link source
* @param dst link destination
*/
public DefaultLinkDescription(ConnectPoint src, ConnectPoint dst) {
this.src = src;
this.dst = dst;
}
@Override
public ConnectPoint src() {
return src;
}
@Override
public ConnectPoint dst() {
return dst;
}
}
package org.onlab.onos.net.link;
import org.onlab.onos.net.ConnectPoint;
/**
* Describes an infrastructure link.
*/
public interface LinkDescription {
// TODO: src, dst connection points, which are pairs of (DeviceId, PortNumber)
// On the north:
// Link = (ConnectPoint src, ConnectPoint dst);
// ConnectPoint = (DeviceId, PortNumber);
/**
* Returns the link source.
*
* @return links source
*/
ConnectPoint src();
// On the south
// LinkDescription ~ Link
/**
* Returns the link destination.
*
* @return links destination
*/
ConnectPoint dst();
// Add further link attributes
}
......
......@@ -34,6 +34,8 @@ public class SimpleLinkManager
private final AbstractListenerRegistry<LinkEvent, LinkListener>
listenerRegistry = new AbstractListenerRegistry<>();
private final SimpleLinkStore store = new SimpleLinkStore();
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
private EventDeliveryService eventDispatcher;
......
package org.onlab.onos.net.trivial.impl;
/**
* Manages inventory of infrastructure links using trivial in-memory link
* implementation.
*/
public class SimpleLinkStore {
}