From 3887c13f845f1478f5d507c5b39fec6e078f277b Mon Sep 17 00:00:00 2001
From: Geddings Barrineau <cbarrin@g.clemson.edu>
Date: Wed, 13 Jul 2016 13:58:17 -0400
Subject: [PATCH] Added latency code into Link serializer. Users can now get
 link latencies from the GUI.

---
 .../linkdiscovery/web/LinkWithType.java            | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/src/main/java/net/floodlightcontroller/linkdiscovery/web/LinkWithType.java b/src/main/java/net/floodlightcontroller/linkdiscovery/web/LinkWithType.java
index 81b5094dd..8be807236 100644
--- a/src/main/java/net/floodlightcontroller/linkdiscovery/web/LinkWithType.java
+++ b/src/main/java/net/floodlightcontroller/linkdiscovery/web/LinkWithType.java
@@ -16,20 +16,19 @@
 
 package net.floodlightcontroller.linkdiscovery.web;
 
-import java.io.IOException;
-
-import org.projectfloodlight.openflow.types.DatapathId;
-import org.projectfloodlight.openflow.types.OFPort;
-
 import com.fasterxml.jackson.core.JsonGenerator;
 import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fasterxml.jackson.databind.JsonSerializer;
 import com.fasterxml.jackson.databind.SerializerProvider;
 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-
 import net.floodlightcontroller.linkdiscovery.ILinkDiscovery.LinkDirection;
 import net.floodlightcontroller.linkdiscovery.ILinkDiscovery.LinkType;
 import net.floodlightcontroller.routing.Link;
+import org.projectfloodlight.openflow.types.DatapathId;
+import org.projectfloodlight.openflow.types.OFPort;
+import org.projectfloodlight.openflow.types.U64;
+
+import java.io.IOException;
 
 /**
  * This class is both the datastructure and the serializer
@@ -44,6 +43,7 @@ public class LinkWithType extends JsonSerializer<LinkWithType> {
     public OFPort dstPort;
     public LinkType type;
     public LinkDirection direction;
+    public U64 latency;
 
     // Do NOT delete this, it's required for the serializer
     public LinkWithType() {}
@@ -57,6 +57,7 @@ public class LinkWithType extends JsonSerializer<LinkWithType> {
         this.dstPort = link.getDstPort();
         this.type = type;
         this.direction = direction;
+        this.latency = link.getLatency();
     }
 
     @Override
@@ -70,6 +71,7 @@ public class LinkWithType extends JsonSerializer<LinkWithType> {
         jgen.writeNumberField("dst-port", lwt.dstPort.getPortNumber());
         jgen.writeStringField("type", lwt.type.toString());
         jgen.writeStringField("direction", lwt.direction.toString());
+        jgen.writeNumberField("latency", lwt.latency.getValue()); // Might be an issue if value exceed what unsigned long can hold
         jgen.writeEndObject();
     }
 
-- 
GitLab