Renamed networkgraph package to topology.
Moved NetworkGraphPublisher into new topology package.
net.onrc.onos.ofcontroller.networkgraph.* => net.onrc.onos.core.topology.*
net.onrc.onos.ofcontroller.floodlightlistener.NetworkGraphPublisher => net.onrc.onos.core.topology.NetworkGraphPublisher
Change-Id: I8b156d0fcbba520fee61e92ab659bb02cfa704ac
diff --git a/src/main/java/net/onrc/onos/core/topology/serializers/LinkSerializer.java b/src/main/java/net/onrc/onos/core/topology/serializers/LinkSerializer.java
new file mode 100644
index 0000000..93bce90
--- /dev/null
+++ b/src/main/java/net/onrc/onos/core/topology/serializers/LinkSerializer.java
@@ -0,0 +1,35 @@
+package net.onrc.onos.core.topology.serializers;
+
+import java.io.IOException;
+
+import net.onrc.onos.core.topology.Link;
+
+import org.codehaus.jackson.JsonGenerationException;
+import org.codehaus.jackson.JsonGenerator;
+import org.codehaus.jackson.map.SerializerProvider;
+import org.codehaus.jackson.map.ser.std.SerializerBase;
+import org.openflow.util.HexString;
+
+public class LinkSerializer extends SerializerBase<Link> {
+
+ public LinkSerializer() {
+ super(Link.class);
+ }
+
+ @Override
+ public void serialize(Link link, JsonGenerator jsonGenerator,
+ SerializerProvider serializerProvider)
+ throws IOException, JsonGenerationException {
+ jsonGenerator.writeStartObject();
+ jsonGenerator.writeStringField("src-switch",
+ HexString.toHexString(link.getSrcSwitch().getDpid()));
+ jsonGenerator.writeNumberField("src-port",
+ link.getSrcPort().getNumber());
+ jsonGenerator.writeStringField("dst-switch",
+ HexString.toHexString(link.getDstSwitch().getDpid()));
+ jsonGenerator.writeNumberField("dst-port",
+ link.getDstPort().getNumber());
+ jsonGenerator.writeEndObject();
+ }
+
+}
diff --git a/src/main/java/net/onrc/onos/core/topology/serializers/PortSerializer.java b/src/main/java/net/onrc/onos/core/topology/serializers/PortSerializer.java
new file mode 100644
index 0000000..25e64d0
--- /dev/null
+++ b/src/main/java/net/onrc/onos/core/topology/serializers/PortSerializer.java
@@ -0,0 +1,31 @@
+package net.onrc.onos.core.topology.serializers;
+
+import java.io.IOException;
+
+import net.onrc.onos.core.topology.Port;
+
+import org.codehaus.jackson.JsonGenerator;
+import org.codehaus.jackson.JsonProcessingException;
+import org.codehaus.jackson.map.SerializerProvider;
+import org.codehaus.jackson.map.ser.std.SerializerBase;
+
+public class PortSerializer extends SerializerBase<Port> {
+
+ public PortSerializer() {
+ super(Port.class);
+ }
+
+ @Override
+ public void serialize(Port port, JsonGenerator jsonGenerator,
+ SerializerProvider serializerProvider)
+ throws IOException, JsonProcessingException {
+ jsonGenerator.writeStartObject();
+ jsonGenerator.writeStringField("state", "ACTIVE");
+ jsonGenerator.writeNumberField("number", port.getNumber());
+ jsonGenerator.writeStringField("desc", port.getDescription());
+ jsonGenerator.writeArrayFieldStart("devices");
+ jsonGenerator.writeEndArray();
+ jsonGenerator.writeEndObject();
+ }
+
+}
diff --git a/src/main/java/net/onrc/onos/core/topology/serializers/SwitchSerializer.java b/src/main/java/net/onrc/onos/core/topology/serializers/SwitchSerializer.java
new file mode 100644
index 0000000..e36d35c
--- /dev/null
+++ b/src/main/java/net/onrc/onos/core/topology/serializers/SwitchSerializer.java
@@ -0,0 +1,36 @@
+package net.onrc.onos.core.topology.serializers;
+
+import java.io.IOException;
+
+import net.onrc.onos.core.topology.Port;
+import net.onrc.onos.core.topology.Switch;
+
+import org.codehaus.jackson.JsonGenerator;
+import org.codehaus.jackson.JsonProcessingException;
+import org.codehaus.jackson.map.SerializerProvider;
+import org.codehaus.jackson.map.ser.std.SerializerBase;
+import org.openflow.util.HexString;
+
+public class SwitchSerializer extends SerializerBase<Switch> {
+
+ public SwitchSerializer() {
+ super(Switch.class);
+ }
+
+ @Override
+ public void serialize(Switch sw, JsonGenerator jsonGenerator,
+ SerializerProvider serializerProvider) throws IOException,
+ JsonProcessingException {
+
+ jsonGenerator.writeStartObject();
+ jsonGenerator.writeStringField("dpid", HexString.toHexString(sw.getDpid()));
+ jsonGenerator.writeStringField("state", "ACTIVE");
+ jsonGenerator.writeArrayFieldStart("ports");
+ for (Port port : sw.getPorts()) {
+ jsonGenerator.writeObject(port);
+ }
+ jsonGenerator.writeEndArray();
+ jsonGenerator.writeEndObject();
+ }
+
+}