Skip to content
Snippets Groups Projects
Commit ab381a37 authored by Wilson Ng's avatar Wilson Ng
Browse files

Move getLinkType() back into LinkDiscoveryManager and make it public.

parent 4c41c30a
No related branches found
No related tags found
No related merge requests found
...@@ -92,15 +92,6 @@ public class LinkInfo { ...@@ -92,15 +92,6 @@ public class LinkInfo {
public void setDstPortState(int dstPortState) { public void setDstPortState(int dstPortState) {
this.dstPortState = dstPortState; this.dstPortState = dstPortState;
} }
public static ILinkDiscovery.LinkType getLinkType(LinkTuple lt, LinkInfo info) {
if (info.getUnicastValidTime() != null) {
return ILinkDiscovery.LinkType.DIRECT_LINK;
} else if (info.getMulticastValidTime() != null) {
return ILinkDiscovery.LinkType.MULTIHOP_LINK;
}
return ILinkDiscovery.LinkType.INVALID_LINK;
}
/* (non-Javadoc) /* (non-Javadoc)
* @see java.lang.Object#hashCode() * @see java.lang.Object#hashCode()
......
...@@ -216,8 +216,13 @@ public class LinkDiscoveryManager ...@@ -216,8 +216,13 @@ public class LinkDiscoveryManager
return shuttingDown; return shuttingDown;
} }
protected ILinkDiscovery.LinkType getLinkType(LinkTuple lt, LinkInfo info) { public ILinkDiscovery.LinkType getLinkType(LinkTuple lt, LinkInfo info) {
return LinkInfo.getLinkType(lt, info); if (info.getUnicastValidTime() != null) {
return ILinkDiscovery.LinkType.DIRECT_LINK;
} else if (info.getMulticastValidTime() != null) {
return ILinkDiscovery.LinkType.MULTIHOP_LINK;
}
return ILinkDiscovery.LinkType.INVALID_LINK;
} }
private void doUpdatesThread() throws InterruptedException { private void doUpdatesThread() throws InterruptedException {
...@@ -616,7 +621,7 @@ public class LinkDiscoveryManager ...@@ -616,7 +621,7 @@ public class LinkDiscoveryManager
lt.getSrc().getPort(), lt.getSrc().getPort(),
lt.getDst().getPort(), lt.getDst().getPort(),
newLinkInfo.getSrcPortState(), newLinkInfo.getDstPortState(), newLinkInfo.getSrcPortState(), newLinkInfo.getDstPortState(),
LinkInfo.getLinkType(lt, newLinkInfo), getLinkType(lt, newLinkInfo),
EvAction.LINK_ADDED, "LLDP Recvd"); EvAction.LINK_ADDED, "LLDP Recvd");
} else { } else {
// Since the link info is already there, we need to // Since the link info is already there, we need to
...@@ -672,14 +677,14 @@ public class LinkDiscoveryManager ...@@ -672,14 +677,14 @@ public class LinkDiscoveryManager
lt.getSrc().getPort(), lt.getSrc().getPort(),
lt.getDst().getPort(), lt.getDst().getPort(),
newLinkInfo.getSrcPortState(), newLinkInfo.getDstPortState(), newLinkInfo.getSrcPortState(), newLinkInfo.getDstPortState(),
LinkInfo.getLinkType(lt, newLinkInfo), getLinkType(lt, newLinkInfo),
EvAction.LINK_PORT_STATE_UPDATED, EvAction.LINK_PORT_STATE_UPDATED,
"LLDP Recvd"); "LLDP Recvd");
} }
} }
if (linkChanged) { if (linkChanged) {
updates.add(new LDUpdate(lt, newLinkInfo.getSrcPortState(), newLinkInfo.getDstPortState(), LinkInfo.getLinkType(lt, newLinkInfo), updateOperation)); updates.add(new LDUpdate(lt, newLinkInfo.getSrcPortState(), newLinkInfo.getDstPortState(), getLinkType(lt, newLinkInfo), updateOperation));
} }
} finally { } finally {
lock.writeLock().unlock(); lock.writeLock().unlock();
...@@ -813,7 +818,7 @@ public class LinkDiscoveryManager ...@@ -813,7 +818,7 @@ public class LinkDiscoveryManager
// send an LDUpdate. // send an LDUpdate.
updates.add(new LDUpdate(lt, linkInfo.getSrcPortState(), updates.add(new LDUpdate(lt, linkInfo.getSrcPortState(),
linkInfo.getDstPortState(), linkInfo.getDstPortState(),
LinkInfo.getLinkType(lt, linkInfo), getLinkType(lt, linkInfo),
UpdateOperation.ADD_OR_UPDATE)); UpdateOperation.ADD_OR_UPDATE));
writeLink(lt, linkInfo); writeLink(lt, linkInfo);
linkInfoChanged = true; linkInfoChanged = true;
...@@ -936,7 +941,7 @@ public class LinkDiscoveryManager ...@@ -936,7 +941,7 @@ public class LinkDiscoveryManager
} else if (linkChanged) { } else if (linkChanged) {
updates.add(new LDUpdate(lt, info.getSrcPortState(), updates.add(new LDUpdate(lt, info.getSrcPortState(),
info.getDstPortState(), info.getDstPortState(),
LinkInfo.getLinkType(lt, info), getLinkType(lt, info),
UpdateOperation.ADD_OR_UPDATE)); UpdateOperation.ADD_OR_UPDATE));
} }
} }
...@@ -1073,7 +1078,7 @@ public class LinkDiscoveryManager ...@@ -1073,7 +1078,7 @@ public class LinkDiscoveryManager
rowValues.put(LINK_SRC_SWITCH, srcDpid); rowValues.put(LINK_SRC_SWITCH, srcDpid);
rowValues.put(LINK_SRC_PORT, lt.getSrc().getPort()); rowValues.put(LINK_SRC_PORT, lt.getSrc().getPort());
LinkType type = (LinkInfo.getLinkType(lt, linkInfo)); LinkType type = getLinkType(lt, linkInfo);
if (type == LinkType.DIRECT_LINK) if (type == LinkType.DIRECT_LINK)
rowValues.put(LINK_TYPE, "internal"); rowValues.put(LINK_TYPE, "internal");
else if (type == LinkType.MULTIHOP_LINK) else if (type == LinkType.MULTIHOP_LINK)
......
...@@ -21,7 +21,7 @@ public class LinksResource extends ServerResource { ...@@ -21,7 +21,7 @@ public class LinksResource extends ServerResource {
for (LinkTuple lt : linkSet) { for (LinkTuple lt : linkSet) {
LinkInfo info = topo.getLinkInfo(lt.getSrc(), true); LinkInfo info = topo.getLinkInfo(lt.getSrc(), true);
LinkTuple withType = new LinkTuple(lt.getSrc(), lt.getDst()); LinkTuple withType = new LinkTuple(lt.getSrc(), lt.getDst());
withType.setType(LinkInfo.getLinkType(lt, info)); withType.setType(topo.getLinkType(lt, info));
links.add(withType); links.add(withType);
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment