Skip to content

Commit

Permalink
<Issue> dlinknctu#74 - upgrade LinkResource.java to floodlight v.10
Browse files Browse the repository at this point in the history
Signed-off-by: hwchiu <[email protected]>
  • Loading branch information
hungweic authored and hwchiu committed Feb 3, 2015
1 parent 7396562 commit 4993efb
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions adapter/floodlight/omniui/LinkResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import net.floodlightcontroller.routing.Link;


import org.projectfloodlight.openflow.types.DatapathId;
import org.projectfloodlight.openflow.types.OFPort;
import org.restlet.resource.Get;
import org.restlet.resource.ServerResource;

Expand All @@ -21,30 +23,29 @@ public List<LinkInfoForOmniUI> retrieve() {
ILinkDiscoveryService ld = (ILinkDiscoveryService)getContext().getAttributes().get(ILinkDiscoveryService.class.getCanonicalName());
Map<Link,LinkInfo> links = new HashMap<Link,LinkInfo>();
List<LinkInfoForOmniUI> result = new ArrayList<LinkInfoForOmniUI>();
if(ld!=null){

if (null != links) {
//copy the whole hash map
links.putAll(ld.getLinks());
for (Link link: links.keySet()){
long srcDpid = link.getSrc();
long dstDpid = link.getDst();
short srcPort = link.getSrcPort();
short dstPort = link.getDstPort();
for (Link link: links.keySet()) {
DatapathId srcDpid = link.getSrc();
DatapathId dstDpid = link.getDst();
OFPort srcPort = link.getSrcPort();
OFPort dstPort = link.getDstPort();

//There are two link entry of the bi-direction link in the links map,
//So we should checkout this condtion for avoiding duplicate link.

LinkInfo reverseInfo = links.get(new Link(dstDpid,dstPort,srcDpid,srcPort));
if(reverseInfo!=null){
if((srcDpid < dstDpid))

if (null != reverseInfo) {
if ((srcDpid.getLong() < dstDpid.getLong())) {
result.add(new LinkInfoForOmniUI(link));
}
else{
}
} else{
result.add(new LinkInfoForOmniUI(link));
}

}


}

return result;
Expand Down

0 comments on commit 4993efb

Please sign in to comment.