tom

Refactored the topology provider.

package org.onlab.onos.net.trivial.topology.provider.impl;
import org.onlab.onos.net.Link;
import org.onlab.onos.net.topology.TopoEdge;
import org.onlab.onos.net.topology.TopoVertex;
import java.util.Objects;
import static com.google.common.base.MoreObjects.toStringHelper;
/**
* Implementation of the topology edge backed by a link.
*/
class DefaultTopoEdge implements TopoEdge {
private final Link link;
private final TopoVertex src;
private final TopoVertex dst;
/**
* Creates a new topology edge.
*
* @param src source vertex
* @param dst destination vertex
* @param link infrastructure link
*/
DefaultTopoEdge(TopoVertex src, TopoVertex dst, Link link) {
this.src = src;
this.dst = dst;
this.link = link;
}
@Override
public Link link() {
return link;
}
@Override
public TopoVertex src() {
return src;
}
@Override
public TopoVertex dst() {
return dst;
}
@Override
public int hashCode() {
return Objects.hash(link);
}
@Override
public boolean equals(Object obj) {
if (obj instanceof DefaultTopoEdge) {
final DefaultTopoEdge other = (DefaultTopoEdge) obj;
return Objects.equals(this.link, other.link);
}
return false;
}
@Override
public String toString() {
return toStringHelper(this).add("src", src).add("dst", dst).toString();
}
}
package org.onlab.onos.net.trivial.topology.provider.impl;
import org.onlab.onos.net.DeviceId;
import org.onlab.onos.net.topology.TopoVertex;
import java.util.Objects;
/**
* Implementation of the topology vertex backed by a device id.
*/
class DefaultTopoVertex implements TopoVertex {
private final DeviceId deviceId;
/**
* Creates a new topology vertex.
*
* @param deviceId backing infrastructure device identifier
*/
DefaultTopoVertex(DeviceId deviceId) {
this.deviceId = deviceId;
}
@Override
public DeviceId deviceId() {
return deviceId;
}
@Override
public int hashCode() {
return Objects.hash(deviceId);
}
@Override
public boolean equals(Object obj) {
if (obj instanceof DefaultTopoVertex) {
final DefaultTopoVertex other = (DefaultTopoVertex) obj;
return Objects.equals(this.deviceId, other.deviceId);
}
return false;
}
@Override
public String toString() {
return deviceId.toString();
}
}
......@@ -115,7 +115,6 @@ public class SimpleTopologyProvider extends AbstractProvider
// Builds the topology using the latest device and link information
// and citing the specified events as reasons for the change.
private void buildTopology(List<Event> reasons) {
log.info("YO! Computing topology");
if (isStarted) {
TopologyDescription desc =
new DefaultTopologyDescription(System.nanoTime(),
......