Cleaup Statistics northbound and add exmaples 01/1001/4
authorYevgeny Khodorkovsky <ykhodork@cisco.com>
Mon, 26 Aug 2013 22:48:15 +0000 (15:48 -0700)
committerYevgeny Khodorkovsky <ykhodork@cisco.com>
Mon, 26 Aug 2013 22:48:15 +0000 (15:48 -0700)
- Clean up stats northbound to align with common REST conventions,
  add more descriptive javadoc with examples

Change-Id: I9508e72b9f62dc576ab4a569f699b75e7bfb29a9
Signed-off-by: Yevgeny Khodorkovsky <ykhodork@cisco.com>
opendaylight/containermanager/api/src/main/java/org/opendaylight/controller/containermanager/IContainerManager.java
opendaylight/northbound/integrationtest/src/test/java/org/opendaylight/controller/northbound/integrationtest/NorthboundIT.java
opendaylight/northbound/statistics/src/main/java/org/opendaylight/controller/statistics/northbound/AllFlowStatistics.java
opendaylight/northbound/statistics/src/main/java/org/opendaylight/controller/statistics/northbound/AllPortStatistics.java
opendaylight/northbound/statistics/src/main/java/org/opendaylight/controller/statistics/northbound/AllTableStatistics.java
opendaylight/northbound/statistics/src/main/java/org/opendaylight/controller/statistics/northbound/FlowStatistics.java
opendaylight/northbound/statistics/src/main/java/org/opendaylight/controller/statistics/northbound/PortStatistics.java
opendaylight/northbound/statistics/src/main/java/org/opendaylight/controller/statistics/northbound/StatisticsNorthbound.java
opendaylight/northbound/statistics/src/main/java/org/opendaylight/controller/statistics/northbound/TableStatistics.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/NodeTable.java

index 89c0c0b217f6de65dfc6a2bfd855e6d259b65782..9300921be9c424dbc2b10146926a9d42dcb81f9c 100644 (file)
@@ -14,8 +14,7 @@ import java.util.List;
 import org.opendaylight.controller.sal.utils.Status;
 
 /**
- * Container Manager interface
- *
+ * Container Manager Interface - provides methods to get information on existing OSGI containers
  *
  */
 public interface IContainerManager {
@@ -23,14 +22,14 @@ public interface IContainerManager {
     /**
      * Returns true if there are any non-default Containers present.
      *
-     * @return  true, if any non-default container is present, else false
+     * @return  true if any non-default container is present false otherwise.
      */
     public boolean hasNonDefaultContainer();
 
     /**
-     * Returns a list of Containers that currently exist.
+     * Returns a list of the existing containers.
      *
-     * @return  array of String Container names
+     * @return  List of Container name strings.
      */
     public List<String> getContainerNames();
 
@@ -41,5 +40,6 @@ public interface IContainerManager {
      *
      * @return  status code
      */
+    @Deprecated
     public Status saveContainerConfig();
 }
index b4c3e1e028183b75cf35b0b122b4c014db4ddd4a..b672f5e9c2d9c769cc67b31e95032f9d9ef94cd5 100644 (file)
@@ -558,7 +558,7 @@ public class NorthboundIT {
 
         String baseURL = "http://127.0.0.1:8080/controller/nb/v2/statistics/default/";
 
-        String result = getJsonResult(baseURL + "flowstats");
+        String result = getJsonResult(baseURL + "flow");
         JSONTokener jt = new JSONTokener(result);
         JSONObject json = new JSONObject(jt);
         JSONObject flowStatistics = getJsonInstance(json, "flowStatistics", 0xCAFE);
@@ -568,7 +568,7 @@ public class NorthboundIT {
         Assert.assertEquals(node.getString("@type"), "STUB");
 
         // test that flow statistics results are correct
-        JSONArray flowStats = flowStatistics.getJSONArray("flowStat");
+        JSONArray flowStats = flowStatistics.getJSONArray("flowStatistic");
         for (int i = 0; i < flowStats.length(); i++) {
 
             JSONObject flowStat = flowStats.getJSONObject(i);
@@ -576,8 +576,8 @@ public class NorthboundIT {
 
         }
 
-        // for /controller/nb/v2/statistics/default/portstats
-        result = getJsonResult(baseURL + "portstats");
+        // for /controller/nb/v2/statistics/default/port
+        result = getJsonResult(baseURL + "port");
         jt = new JSONTokener(result);
         json = new JSONObject(jt);
         JSONObject portStatistics = getJsonInstance(json, "portStatistics", 0xCAFE);
@@ -587,7 +587,7 @@ public class NorthboundIT {
         Assert.assertEquals(node2.getString("@type"), "STUB");
 
         // test that port statistic results are correct
-        JSONObject portStat = portStatistics.getJSONObject("portStat");
+        JSONObject portStat = portStatistics.getJSONObject("portStatistic");
         Assert.assertTrue(portStat.getInt("receivePackets") == 250);
         Assert.assertTrue(portStat.getInt("transmitPackets") == 500);
         Assert.assertTrue(portStat.getInt("receiveBytes") == 1000);
@@ -602,7 +602,7 @@ public class NorthboundIT {
         Assert.assertTrue(portStat.getInt("collisionCount") == 4);
 
         // test for getting one specific node's stats
-        result = getJsonResult(baseURL + "flowstats/STUB/51966");
+        result = getJsonResult(baseURL + "flow/node/STUB/51966");
         jt = new JSONTokener(result);
         json = new JSONObject(jt);
         node = json.getJSONObject("node");
@@ -611,13 +611,13 @@ public class NorthboundIT {
         Assert.assertEquals(node.getString("@type"), "STUB");
 
         // test that flow statistics results are correct
-        flowStats = json.getJSONArray("flowStat");
+        flowStats = json.getJSONArray("flowStatistic");
         for (int i = 0; i < flowStats.length(); i++) {
             JSONObject flowStat = flowStats.getJSONObject(i);
             testFlowStat(flowStat, actionTypes[i], i);
         }
 
-        result = getJsonResult(baseURL + "portstats/STUB/51966");
+        result = getJsonResult(baseURL + "port/node/STUB/51966");
         jt = new JSONTokener(result);
         json = new JSONObject(jt);
         node2 = json.getJSONObject("node");
@@ -626,7 +626,7 @@ public class NorthboundIT {
         Assert.assertEquals(node2.getString("@type"), "STUB");
 
         // test that port statistic results are correct
-        portStat = json.getJSONObject("portStat");
+        portStat = json.getJSONObject("portStatistic");
         Assert.assertTrue(portStat.getInt("receivePackets") == 250);
         Assert.assertTrue(portStat.getInt("transmitPackets") == 500);
         Assert.assertTrue(portStat.getInt("receiveBytes") == 1000);
index 7f37afec21eb4c2e1201af6696c4076e2beda05b..18627285eaa7f7d834ccd96966d4691fa67101bf 100644 (file)
@@ -15,15 +15,14 @@ import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlRootElement;
 
-@XmlRootElement
+@XmlRootElement(name = "list")
 @XmlAccessorType(XmlAccessType.NONE)
-
 public class AllFlowStatistics {
         @XmlElement
         List<FlowStatistics> flowStatistics;
         //To satisfy JAXB
-        private AllFlowStatistics() {
-        }
+        @SuppressWarnings("unused")
+        private AllFlowStatistics() {}
 
         public AllFlowStatistics(List<FlowStatistics> flowStatistics) {
                 this.flowStatistics = flowStatistics;
index e377de2b8836a10c1089eddb098533e2bf95820b..2117690d974326eb0be37b93c02f56914b3f05ac 100644 (file)
@@ -15,15 +15,14 @@ import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlRootElement;
 
-@XmlRootElement
+@XmlRootElement(name = "list")
 @XmlAccessorType(XmlAccessType.NONE)
-
 public class AllPortStatistics {
         @XmlElement
         List<PortStatistics> portStatistics;
         //To satisfy JAXB
-        private AllPortStatistics() {
-        }
+        @SuppressWarnings("unused")
+        private AllPortStatistics() {}
 
         public AllPortStatistics(List<PortStatistics> portStatistics) {
                 this.portStatistics = portStatistics;
index 5b998ee21a131d4482ba70396c05937bcc091165..4a10eb4fa2af2d5151ba6d24da582855834e9e2b 100644 (file)
@@ -14,14 +14,14 @@ import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlRootElement;
 
-@XmlRootElement
+@XmlRootElement(name = "list")
 @XmlAccessorType(XmlAccessType.NONE)
 public class AllTableStatistics {
     @XmlElement
     List<TableStatistics> tableStatistics;
     //To satisfy JAXB
-    private AllTableStatistics() {
-    }
+    @SuppressWarnings("unused")
+    private AllTableStatistics() {}
 
     public AllTableStatistics(List<TableStatistics> tableStatistics) {
         this.tableStatistics = tableStatistics;
index 25b671c1a881d44cd7e61137fdaca09621aa1885..9b31b913fefa9f71cf0645da0cef0f89aa043bfc 100644 (file)
@@ -14,26 +14,27 @@ import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlRootElement;
+
 import org.opendaylight.controller.sal.core.Node;
 import org.opendaylight.controller.sal.reader.FlowOnNode;
 
-@XmlRootElement
+@XmlRootElement(name = "nodeFlowStatistics")
 @XmlAccessorType(XmlAccessType.NONE)
 public class FlowStatistics {
     @XmlElement
     private Node node;
-    @XmlElement(name="flowStat")
-    private List<FlowOnNode> flowStat;
+    @XmlElement
+    private List<FlowOnNode> flowStatistic;
 
     // To satisfy JAXB
     @SuppressWarnings("unused")
-        private FlowStatistics() {
+    private FlowStatistics() {
     }
 
     public FlowStatistics(Node node, List<FlowOnNode> flowStat) {
         super();
         this.node = node;
-        this.flowStat = flowStat;
+        this.flowStatistic = flowStat;
     }
 
     public Node getNode() {
@@ -45,10 +46,10 @@ public class FlowStatistics {
     }
 
     public List<FlowOnNode> getFlowStats() {
-        return flowStat;
+        return flowStatistic;
     }
 
     public void setFlowStats(List<FlowOnNode> flowStats) {
-        this.flowStat = flowStats;
+        this.flowStatistic = flowStats;
     }
 }
index 876bb7f7b08f11b85c068a12edb37a38747750ab..e519472d40c2afeb1ed2beaf3d6b7b31800e5c6d 100644 (file)
@@ -18,13 +18,13 @@ import javax.xml.bind.annotation.XmlRootElement;
 import org.opendaylight.controller.sal.core.Node;
 import org.opendaylight.controller.sal.reader.NodeConnectorStatistics;
 
-@XmlRootElement
+@XmlRootElement(name = "nodePortStatistics")
 @XmlAccessorType(XmlAccessType.NONE)
 public class PortStatistics {
     @XmlElement
     private Node node;
-    @XmlElement(name="portStat")
-    private List<NodeConnectorStatistics> portStats;
+    @XmlElement
+    private List<NodeConnectorStatistics> portStatistic;
 
     // To satisfy JAXB
     @SuppressWarnings("unused")
@@ -34,7 +34,7 @@ public class PortStatistics {
     public PortStatistics(Node node, List<NodeConnectorStatistics> portStats) {
         super();
         this.node = node;
-        this.portStats = portStats;
+        this.portStatistic = portStats;
     }
 
     public Node getNode() {
@@ -46,11 +46,11 @@ public class PortStatistics {
     }
 
     public List<NodeConnectorStatistics> getPortStats() {
-        return portStats;
+        return portStatistic;
     }
 
     public void setFlowStats(List<NodeConnectorStatistics> portStats) {
-        this.portStats = portStats;
+        this.portStatistic = portStats;
     }
 
 }
index 197ebabf9133d43f7b81f5360f46b7d3138b1f9e..1c3fd1cf2ea10d32b148aec6d8dbb2fb2fab357a 100644 (file)
@@ -23,9 +23,12 @@ import org.codehaus.enunciate.jaxrs.ResponseCode;
 import org.codehaus.enunciate.jaxrs.StatusCodes;
 import org.codehaus.enunciate.jaxrs.TypeHint;
 import org.opendaylight.controller.containermanager.IContainerManager;
-
 import org.opendaylight.controller.northbound.commons.RestMessages;
-import org.opendaylight.controller.northbound.commons.exception.*;
+import org.opendaylight.controller.northbound.commons.exception.InternalServerErrorException;
+import org.opendaylight.controller.northbound.commons.exception.ResourceConflictException;
+import org.opendaylight.controller.northbound.commons.exception.ResourceNotFoundException;
+import org.opendaylight.controller.northbound.commons.exception.ServiceUnavailableException;
+import org.opendaylight.controller.northbound.commons.exception.UnauthorizedException;
 import org.opendaylight.controller.northbound.commons.utils.NorthboundUtils;
 import org.opendaylight.controller.sal.authorization.Privilege;
 import org.opendaylight.controller.sal.core.Node;
@@ -39,7 +42,7 @@ import org.opendaylight.controller.switchmanager.ISwitchManager;
 
 /**
  * Northbound APIs that returns various Statistics exposed by the Southbound
- * plugins such as Openflow.
+ * protocol plugins such as Openflow.
  *
  * <br>
  * <br>
@@ -107,9 +110,114 @@ public class StatisticsNorthbound {
      *            Name of the Container. The Container name for the base
      *            controller is "default".
      * @return List of FlowStatistics from all the Nodes
+     *
+     *         <pre>
+     * Example:
+     * Request URL: localhost:8080/controller/nb/v2/statistics/default/flow
+     *
+     * Response in JSON:
+     * {
+     *     "flowStatistics": [
+     *         {
+     *             "node": {
+     *                 "@type": "OF",
+     *                 "@id": "00:00:00:00:00:00:00:02"
+     *             },
+     *             "flowStatistic": [
+     *                 {
+     *                     "flow": {
+     *                         "match": {
+     *                             "matchField": [
+     *                                 {
+     *                                     "type": "DL_TYPE",
+     *                                     "value": "2048"
+     *                                 },
+     *                                 {
+     *                                     "mask": "255.255.255.255",
+     *                                     "type": "NW_DST",
+     *                                     "value": "1.1.1.1"
+     *                                 }
+     *                             ]
+     *                         },
+     *                         "actions": {
+     *                             "@type": "output",
+     *                             "port": {
+     *                                 "@type": "OF",
+     *                                 "@id": "3",
+     *                                 "node": {
+     *                                     "@type": "OF",
+     *                                     "@id": "00:00:00:00:00:00:00:02"
+     *                                 }
+     *                             }
+     *                         },
+     *                         "priority": "1",
+     *                         "idleTimeout": "0",
+     *                         "hardTimeout": "0",
+     *                         "id": "0"
+     *                     },
+     *                     "tableId": "0",
+     *                     "durationSeconds": "1828",
+     *                     "durationNanoseconds": "397000000",
+     *                     "packetCount": "0",
+     *                     "byteCount": "0"
+     *                 }
+     *             ]
+     *         },
+     *         {   flow statistics of another node
+     *             ............
+     *             ................
+     *             ......................
+     *         }
+     *
+     *     ]
+     * }
+     * Response in XML:
+     * &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;yes&quot;?&gt;
+     * &lt;list&gt;
+     *     &lt;flowStatistics&gt;
+     *         &lt;node type=&quot;OF&quot; id=&quot;00:00:00:00:00:00:00:02&quot;/&gt;
+     *         &lt;flowStatistic&gt;
+     *             &lt;flow&gt;
+     *                 &lt;match&gt;
+     *                     &lt;matchField&gt;
+     *                         &lt;type&gt;DL_TYPE&lt;/type&gt;
+     *                         &lt;value&gt;2048&lt;/value&gt;
+     *                     &lt;/matchField&gt;
+     *                     &lt;matchField&gt;
+     *                         &lt;mask&gt;255.255.255.255&lt;/mask&gt;
+     *                         &lt;type&gt;NW_DST&lt;/type&gt;
+     *                         &lt;value&gt;1.1.1.2&lt;/value&gt;
+     *                     &lt;/matchField&gt;
+     *                 &lt;/match&gt;
+     *                 &lt;actions
+     *                     xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:type=&quot;output&quot;&gt;
+     *                     &lt;port type=&quot;OF&quot; id=&quot;3&quot;&gt;
+     *                         &lt;node type=&quot;OF&quot; id=&quot;00:00:00:00:00:00:00:02&quot;/&gt;
+     *                     &lt;/port&gt;
+     *                 &lt;/actions&gt;
+     *                 &lt;priority&gt;1&lt;/priority&gt;
+     *                 &lt;idleTimeout&gt;0&lt;/idleTimeout&gt;
+     *                 &lt;hardTimeout&gt;0&lt;/hardTimeout&gt;
+     *                 &lt;id&gt;0&lt;/id&gt;
+     *             &lt;/flow&gt;
+     *             &lt;tableId&gt;0&lt;/tableId&gt;
+     *             &lt;durationSeconds&gt;337&lt;/durationSeconds&gt;
+     *             &lt;durationNanoseconds&gt;149000000&lt;/durationNanoseconds&gt;
+     *             &lt;packetCount&gt;0&lt;/packetCount&gt;
+     *             &lt;byteCount&gt;0&lt;/byteCount&gt;
+     *         &lt;/flowStatistic&gt;
+     *     &lt;/flowStatistics&gt;
+     *     &lt;flowStatistics&gt;
+     *          flow statistics for another node
+     *          ..........
+     *          ................
+     *          .....................
+     *     &lt;/flowStatistics&gt;
+     * &lt;/list&gt;
+     * </pre>
      */
 
-    @Path("/{containerName}/flowstats")
+    @Path("/{containerName}/flow")
     @GET
     @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
     @TypeHint(AllFlowStatistics.class)
@@ -159,12 +267,138 @@ public class StatisticsNorthbound {
      *            Name of the Container. The Container name for the base
      *            controller is "default".
      * @param nodeType
-     *            Node Type as specifid by Node class
+     *            Node Type as specifid in {@link org.opendaylight.controller.sal.core.Node} class
      * @param nodeId
      *            Node Identifier
-     * @return List of Flow Statistics for a given Node.
+     * @return List of Flow Statistics for a given Node. *
+     *
+     *         <pre>
+     * Example:
+     * Request URL:
+     * http://host:8080/controller/nb/v2/statistics/default/flow/node/OF/00:00:00:00:00:00:00:01
+     *
+     * Response in JSON:
+     * {
+     *     "node": {
+     *         "@type": "OF",
+     *         "@id": "00:00:00:00:00:00:00:01"
+     *     },
+     *     "flowStatistic": [
+     *         {
+     *             "flow": {
+     *                 "match": {
+     *                     "matchField": [
+     *                         {
+     *                             "type": "DL_TYPE",
+     *                             "value": "2048"
+     *                         },
+     *                         {
+     *                             "mask": "255.255.255.255",
+     *                             "type": "NW_DST",
+     *                             "value": "1.1.1.2"
+     *                         }
+     *                     ]
+     *                 },
+     *                 "actions": [
+     *                     {
+     *                         "@type": "setDlDst",
+     *                         "address": "52d28b0f76ec"
+     *                     },
+     *                     {
+     *                         "@type": "output",
+     *                         "port": {
+     *                             "@type": "OF",
+     *                             "@id": "5",
+     *                             "node": {
+     *                                 "@type": "OF",
+     *                                 "@id": "00:00:00:00:00:00:00:01"
+     *                             }
+     *                         }
+     *                     }
+     *                 ],
+     *                 "priority": "1",
+     *                 "idleTimeout": "0",
+     *                 "hardTimeout": "0",
+     *                 "id": "0"
+     *             },
+     *             "tableId": "0",
+     *             "durationSeconds": "2089",
+     *             "durationNanoseconds": "538000000",
+     *             "packetCount": "0",
+     *             "byteCount": "0"
+     *         }
+     *     ]
+     * }
+     *
+     *
+     * Response in XML:
+     * &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;yes&quot;?&gt;
+     *     &lt;nodeFlowStatistics&gt;
+     *         &lt;node type=&quot;OF&quot; id=&quot;00:00:00:00:00:00:00:02&quot;/&gt;
+     *         &lt;flowStatistic&gt;
+     *             &lt;flow&gt;
+     *                 &lt;match&gt;
+     *                     &lt;matchField&gt;
+     *                         &lt;type&gt;DL_TYPE&lt;/type&gt;
+     *                         &lt;value&gt;2048&lt;/value&gt;
+     *                     &lt;/matchField&gt;
+     *                     &lt;matchField&gt;
+     *                         &lt;mask&gt;255.255.255.255&lt;/mask&gt;
+     *                         &lt;type&gt;NW_DST&lt;/type&gt;
+     *                         &lt;value&gt;1.1.1.2&lt;/value&gt;
+     *                     &lt;/matchField&gt;
+     *                 &lt;/match&gt;
+     *                 &lt;actions
+     *                     xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:type=&quot;output&quot;&gt;
+     *                     &lt;port type=&quot;OF&quot; id=&quot;3&quot;&gt;
+     *                         &lt;node type=&quot;OF&quot; id=&quot;00:00:00:00:00:00:00:02&quot;/&gt;
+     *                     &lt;/port&gt;
+     *                 &lt;/actions&gt;
+     *                 &lt;priority&gt;1&lt;/priority&gt;
+     *                 &lt;idleTimeout&gt;0&lt;/idleTimeout&gt;
+     *                 &lt;hardTimeout&gt;0&lt;/hardTimeout&gt;
+     *                 &lt;id&gt;0&lt;/id&gt;
+     *             &lt;/flow&gt;
+     *             &lt;tableId&gt;0&lt;/tableId&gt;
+     *             &lt;durationSeconds&gt;337&lt;/durationSeconds&gt;
+     *             &lt;durationNanoseconds&gt;149000000&lt;/durationNanoseconds&gt;
+     *             &lt;packetCount&gt;0&lt;/packetCount&gt;
+     *             &lt;byteCount&gt;0&lt;/byteCount&gt;
+     *         &lt;/flowStatistic&gt;
+     *         &lt;flowStatistic&gt;
+     *             &lt;flow&gt;
+     *                 &lt;match&gt;
+     *                     &lt;matchField&gt;
+     *                         &lt;type&gt;DL_TYPE&lt;/type&gt;
+     *                         &lt;value&gt;2048&lt;/value&gt;
+     *                     &lt;/matchField&gt;
+     *                     &lt;matchField&gt;
+     *                         &lt;mask&gt;255.255.255.255&lt;/mask&gt;
+     *                         &lt;type&gt;NW_DST&lt;/type&gt;
+     *                         &lt;value&gt;1.1.1.1&lt;/value&gt;
+     *                     &lt;/matchField&gt;
+     *                 &lt;/match&gt;
+     *                 &lt;actions
+     *                     xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:type=&quot;output&quot;&gt;
+     *                     &lt;port type=&quot;OF&quot; id=&quot;3&quot;&gt;
+     *                         &lt;node type=&quot;OF&quot; id=&quot;00:00:00:00:00:00:00:02&quot;/&gt;
+     *                     &lt;/port&gt;
+     *                 &lt;/actions&gt;
+     *                 &lt;priority&gt;1&lt;/priority&gt;
+     *                 &lt;idleTimeout&gt;0&lt;/idleTimeout&gt;
+     *                 &lt;hardTimeout&gt;0&lt;/hardTimeout&gt;
+     *                 &lt;id&gt;0&lt;/id&gt;
+     *             &lt;/flow&gt;
+     *             &lt;tableId&gt;0&lt;/tableId&gt;
+     *             &lt;durationSeconds&gt;337&lt;/durationSeconds&gt;
+     *             &lt;durationNanoseconds&gt;208000000&lt;/durationNanoseconds&gt;
+     *             &lt;packetCount&gt;0&lt;/packetCount&gt;
+     *             &lt;byteCount&gt;0&lt;/byteCount&gt;
+     *         &lt;/flowStatistic&gt;
+     *     &lt;/nodeFlowStatistics&gt;
+     * </pre>
      */
-    @Path("/{containerName}/flowstats/{nodeType}/{nodeId}")
+    @Path("/{containerName}/flow/node/{nodeType}/{nodeId}")
     @GET
     @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
     @TypeHint(FlowStatistics.class)
@@ -210,9 +444,128 @@ public class StatisticsNorthbound {
      *            controller is "default".
      * @return List of all the Port Statistics across all the NodeConnectors on
      *         all the Nodes.
+     *
+     *         <pre>
+     * Example:
+     *
+     * Requset URL: http://host:8080/controller/nb/v2/statistics/default/port
+     *
+     * Response in JSON:
+     * {
+     *     "portStatistics": [
+     *         {
+     *             "node": {
+     *                 "@type": "OF",
+     *                 "@id": "00:00:00:00:00:00:00:02"
+     *             },
+     *             "portStatistic": [
+     *                 {
+     *                     "nodeConnector": {
+     *                         "@type": "OF",
+     *                         "@id": "3",
+     *                         "node": {
+     *                             "@type": "OF",
+     *                             "@id": "00:00:00:00:00:00:00:02"
+     *                         }
+     *                     },
+     *                     "receivePackets": "182",
+     *                     "transmitPackets": "173",
+     *                     "receiveBytes": "12740",
+     *                     "transmitBytes": "12110",
+     *                     "receiveDrops": "0",
+     *                     "transmitDrops": "0",
+     *                     "receiveErrors": "0",
+     *                     "transmitErrors": "0",
+     *                     "receiveFrameError": "0",
+     *                     "receiveOverRunError": "0",
+     *                     "receiveCrcError": "0",
+     *                     "collisionCount": "0"
+     *                 },
+     *                 {
+     *                     "nodeConnector": {
+     *                         "@type": "OF",
+     *                         "@id": "2",
+     *                         "node": {
+     *                             "@type": "OF",
+     *                             "@id": "00:00:00:00:00:00:00:02"
+     *                         }
+     *                     },
+     *                     "receivePackets": "174",
+     *                     "transmitPackets": "181",
+     *                     "receiveBytes": "12180",
+     *                     "transmitBytes": "12670",
+     *                     "receiveDrops": "0",
+     *                     "transmitDrops": "0",
+     *                     "receiveErrors": "0",
+     *                     "transmitErrors": "0",
+     *                     "receiveFrameError": "0",
+     *                     "receiveOverRunError": "0",
+     *                     "receiveCrcError": "0",
+     *                     "collisionCount": "0"
+     *                 },
+     *
+     *             ]
+     *         },
+     *         {
+     *             "node": {
+     *                 "@type": "OF",
+     *                 "@id": "00:00:00:00:00:00:00:03"
+     *             },
+     *             "portStatistic": [
+     *                  ..................
+     *                  .......................
+     *                  ..........................
+     *             ]
+     *         }
+     *     ]
+     * }
+     *
+     * Response in XML:
+     * &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;yes&quot;?&gt;
+     * &lt;list&gt;
+     *     &lt;portStatistics&gt;
+     *         &lt;node type=&quot;OF&quot; id=&quot;00:00:00:00:00:00:00:02&quot;/&gt;
+     *         &lt;portStatistic&gt;
+     *             &lt;nodeConnector type=&quot;OF&quot; id=&quot;3&quot;&gt;
+     *                 &lt;node type=&quot;OF&quot; id=&quot;00:00:00:00:00:00:00:02&quot;/&gt;
+     *             &lt;/nodeConnector&gt;
+     *             &lt;receivePackets&gt;181&lt;/receivePackets&gt;
+     *             &lt;transmitPackets&gt;172&lt;/transmitPackets&gt;
+     *             &lt;receiveBytes&gt;12670&lt;/receiveBytes&gt;
+     *             &lt;transmitBytes&gt;12040&lt;/transmitBytes&gt;
+     *             &lt;receiveDrops&gt;0&lt;/receiveDrops&gt;
+     *             &lt;transmitDrops&gt;0&lt;/transmitDrops&gt;
+     *             &lt;receiveErrors&gt;0&lt;/receiveErrors&gt;
+     *             &lt;transmitErrors&gt;0&lt;/transmitErrors&gt;
+     *             &lt;receiveFrameError&gt;0&lt;/receiveFrameError&gt;
+     *             &lt;receiveOverRunError&gt;0&lt;/receiveOverRunError&gt;
+     *             &lt;receiveCrcError&gt;0&lt;/receiveCrcError&gt;
+     *             &lt;collisionCount&gt;0&lt;/collisionCount&gt;
+     *         &lt;/portStatistic&gt;
+     *         &lt;portStatistic&gt;
+     *             &lt;nodeConnector type=&quot;OF&quot; id=&quot;2&quot;&gt;
+     *                 &lt;node type=&quot;OF&quot; id=&quot;00:00:00:00:00:00:00:02&quot;/&gt;
+     *             &lt;/nodeConnector&gt;
+     *             &lt;receivePackets&gt;173&lt;/receivePackets&gt;
+     *             &lt;transmitPackets&gt;180&lt;/transmitPackets&gt;
+     *             &lt;receiveBytes&gt;12110&lt;/receiveBytes&gt;
+     *             &lt;transmitBytes&gt;12600&lt;/transmitBytes&gt;
+     *             &lt;receiveDrops&gt;0&lt;/receiveDrops&gt;
+     *             &lt;transmitDrops&gt;0&lt;/transmitDrops&gt;
+     *             &lt;receiveErrors&gt;0&lt;/receiveErrors&gt;
+     *             &lt;transmitErrors&gt;0&lt;/transmitErrors&gt;
+     *             &lt;receiveFrameError&gt;0&lt;/receiveFrameError&gt;
+     *             &lt;receiveOverRunError&gt;0&lt;/receiveOverRunError&gt;
+     *             &lt;receiveCrcError&gt;0&lt;/receiveCrcError&gt;
+     *             &lt;collisionCount&gt;0&lt;/collisionCount&gt;
+     *         &lt;/portStatistic&gt;
+     *
+     *     &lt;/portStatistics&gt;
+     * &lt;/list&gt;
+     * </pre>
      */
 
-    @Path("/{containerName}/portstats")
+    @Path("/{containerName}/port")
     @GET
     @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
     @TypeHint(AllPortStatistics.class)
@@ -260,13 +613,114 @@ public class StatisticsNorthbound {
      *            Name of the Container. The Container name for the base
      *            controller is "default".
      * @param nodeType
-     *            Node Type as specifid by Node class
+     *            Node Type as specifid in {@link org.opendaylight.controller.sal.core.Node} class
      * @param Node
-     *            Identifier
+     *            Identifier (e.g. MAC address)
      * @return Returns a list of all the Port Statistics across all the
      *         NodeConnectors in a given Node.
+     *
+     *         <pre>
+     * Example:
+     *
+     * Request URL:
+     * http://host:8080/controller/nb/v2/statistics/default/port/node/OF/00:00:00:00:00:00:00:01
+     *
+     * Response in JSON:
+     * {
+     *     "node": {
+     *         "@type": "OF",
+     *         "@id": "00:00:00:00:00:00:00:01"
+     *     },
+     *     "portStatistic": [
+     *         {
+     *             "nodeConnector": {
+     *                 "@type": "OF",
+     *                 "@id": "3",
+     *                 "node": {
+     *                     "@type": "OF",
+     *                     "@id": "00:00:00:00:00:00:00:01"
+     *                 }
+     *             },
+     *             "receivePackets": "171",
+     *             "transmitPackets": "2451",
+     *             "receiveBytes": "11970",
+     *             "transmitBytes": "235186",
+     *             "receiveDrops": "0",
+     *             "transmitDrops": "0",
+     *             "receiveErrors": "0",
+     *             "transmitErrors": "0",
+     *             "receiveFrameError": "0",
+     *             "receiveOverRunError": "0",
+     *             "receiveCrcError": "0",
+     *             "collisionCount": "0"
+     *         },
+     *         {
+     *             "nodeConnector": {
+     *                 "@type": "OF",
+     *                 "@id": "2",
+     *                 "node": {
+     *                     "@type": "OF",
+     *                     "@id": "00:00:00:00:00:00:00:01"
+     *                 }
+     *             },
+     *             "receivePackets": "179",
+     *             "transmitPackets": "2443",
+     *             "receiveBytes": "12530",
+     *             "transmitBytes": "234626",
+     *             "receiveDrops": "0",
+     *             "transmitDrops": "0",
+     *             "receiveErrors": "0",
+     *             "transmitErrors": "0",
+     *             "receiveFrameError": "0",
+     *             "receiveOverRunError": "0",
+     *             "receiveCrcError": "0",
+     *             "collisionCount": "0"
+     *         }
+     *     ]
+     * }
+     *
+     * Response in XML:
+     * &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;yes&quot;?&gt;
+     * &lt;nodePortStatistics&gt;
+     *     &lt;node type=&quot;OF&quot; id=&quot;00:00:00:00:00:00:00:01&quot;/&gt;
+     *     &lt;portStatistic&gt;
+     *         &lt;nodeConnector type=&quot;OF&quot; id=&quot;2&quot;&gt;
+     *             &lt;node type=&quot;OF&quot; id=&quot;00:00:00:00:00:00:00:01&quot;/&gt;
+     *         &lt;/nodeConnector&gt;
+     *         &lt;receivePackets&gt;180&lt;/receivePackets&gt;
+     *         &lt;transmitPackets&gt;2594&lt;/transmitPackets&gt;
+     *         &lt;receiveBytes&gt;12600&lt;/receiveBytes&gt;
+     *         &lt;transmitBytes&gt;249396&lt;/transmitBytes&gt;
+     *         &lt;receiveDrops&gt;0&lt;/receiveDrops&gt;
+     *         &lt;transmitDrops&gt;0&lt;/transmitDrops&gt;
+     *         &lt;receiveErrors&gt;0&lt;/receiveErrors&gt;
+     *         &lt;transmitErrors&gt;0&lt;/transmitErrors&gt;
+     *         &lt;receiveFrameError&gt;0&lt;/receiveFrameError&gt;
+     *         &lt;receiveOverRunError&gt;0&lt;/receiveOverRunError&gt;
+     *         &lt;receiveCrcError&gt;0&lt;/receiveCrcError&gt;
+     *         &lt;collisionCount&gt;0&lt;/collisionCount&gt;
+     *     &lt;/portStatistic&gt;
+     *     &lt;portStatistic&gt;
+     *         &lt;nodeConnector type=&quot;OF&quot; id=&quot;5&quot;&gt;
+     *             &lt;node type=&quot;OF&quot; id=&quot;00:00:00:00:00:00:00:01&quot;/&gt;
+     *         &lt;/nodeConnector&gt;
+     *         &lt;receivePackets&gt;2542&lt;/receivePackets&gt;
+     *         &lt;transmitPackets&gt;2719&lt;/transmitPackets&gt;
+     *         &lt;receiveBytes&gt;243012&lt;/receiveBytes&gt;
+     *         &lt;transmitBytes&gt;255374&lt;/transmitBytes&gt;
+     *         &lt;receiveDrops&gt;0&lt;/receiveDrops&gt;
+     *         &lt;transmitDrops&gt;0&lt;/transmitDrops&gt;
+     *         &lt;receiveErrors&gt;0&lt;/receiveErrors&gt;
+     *         &lt;transmitErrors&gt;0&lt;/transmitErrors&gt;
+     *         &lt;receiveFrameError&gt;0&lt;/receiveFrameError&gt;
+     *         &lt;receiveOverRunError&gt;0&lt;/receiveOverRunError&gt;
+     *         &lt;receiveCrcError&gt;0&lt;/receiveCrcError&gt;
+     *         &lt;collisionCount&gt;0&lt;/collisionCount&gt;
+     *     &lt;/portStatistic&gt;
+     * &lt;/nodePortStatistics&gt;
+     * </pre>
      */
-    @Path("/{containerName}/portstats/{nodeType}/{nodeId}")
+    @Path("/{containerName}/port/node/{nodeType}/{nodeId}")
     @GET
     @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
     @TypeHint(PortStatistics.class)
@@ -313,11 +767,91 @@ public class StatisticsNorthbound {
      *            controller is "default".
      *
      * @return Returns a list of all the Table Statistics in a given Node.
+     *
+     *         <pre>
+     *
+     *  Example:
+     *
+     *  Request URL:
+     *  http://host:8080/controller/nb/v2/statistics/default/table
+     *
+     *  Response in JSON:
+     *
+     * {
+     *     "tableStatistics": [
+     *         {
+     *             "node": {
+     *                 "@type": "OF",
+     *                 "@id": "00:00:00:00:00:00:00:02"
+     *             },
+     *             "tableStatistic": [
+     *                 {
+     *                     "nodeTable": {
+     *                         "@id": "0",
+     *                         "node": {
+     *                             "@type": "OF",
+     *                             "@id": "00:00:00:00:00:00:00:02"
+     *                         }
+     *                     },
+     *                     "activeCount": "11",
+     *                     "lookupCount": "816",
+     *                     "matchedCount": "220"
+     *                 },
+     *                 {
+     *                     ...another table
+     *                     .....
+     *                     ........
+     *                 }
+     *
+     *             ]
+     *         }
+     *     ]
+     * }
+     *
+     *
+     *  Response in XML:
+     *  &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;yes&quot;?&gt;
+     *  &lt;list&gt;
+     *  &lt;tableStatistics&gt;
+     *      &lt;node type=&quot;OF&quot; id=&quot;00:00:00:00:00:00:00:01&quot;/&gt;
+     *      &lt;tableStatistic&gt;
+     *          &lt;nodeTable id=&quot;0&quot;&gt;
+     *              &lt;node type=&quot;OF&quot; id=&quot;00:00:00:00:00:00:00:01&quot;/&gt;
+     *          &lt;/nodeTable&gt;
+     *          &lt;activeCount&gt;12&lt;/activeCount&gt;
+     *          &lt;lookupCount&gt;10935&lt;/lookupCount&gt;
+     *          &lt;matchedCount&gt;10084&lt;/matchedCount&gt;
+     *      &lt;/tableStatistic&gt;
+     *      &lt;tableStatistic&gt;
+     *          &lt;nodeTable id=&quot;1&quot;&gt;
+     *              &lt;node type=&quot;OF&quot; id=&quot;00:00:00:00:00:00:00:01&quot;/&gt;
+     *          &lt;/nodeTable&gt;
+     *          &lt;activeCount&gt;0&lt;/activeCount&gt;
+     *          &lt;lookupCount&gt;0&lt;/lookupCount&gt;
+     *          &lt;matchedCount&gt;0&lt;/matchedCount&gt;
+     *      &lt;/tableStatistic&gt;
+     *      &lt;tableStatistic&gt;
+     *          &lt;nodeTable id=&quot;2&quot;&gt;
+     *              &lt;node type=&quot;OF&quot; id=&quot;00:00:00:00:00:00:00:01&quot;/&gt;
+     *          &lt;/nodeTable&gt;
+     *          &lt;activeCount&gt;0&lt;/activeCount&gt;
+     *          &lt;lookupCount&gt;0&lt;/lookupCount&gt;
+     *          &lt;matchedCount&gt;0&lt;/matchedCount&gt;
+     *      &lt;/tableStatistic&gt;
+     *  &lt;/tableStatistics&gt;
+     *  &lt;tableStatistics&gt;
+     *  ...
+     *  ......
+     *  ........
+     *  &lt;/tableStatistics&gt;
+     *  &lt;/list&gt;
+     *
+     * </pre>
      */
-    @Path("/{containerName}/tablestats")
+    @Path("/{containerName}/table")
     @GET
     @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
-    @TypeHint(TableStatistics.class)
+    @TypeHint(AllTableStatistics.class)
     @StatusCodes({
         @ResponseCode(code = 200, condition = "Operation successful"),
         @ResponseCode(code = 404, condition = "The containerName is not found"),
@@ -325,17 +859,15 @@ public class StatisticsNorthbound {
     public AllTableStatistics getTableStatistics(
             @PathParam("containerName") String containerName) {
 
-        if (!NorthboundUtils.isAuthorized(
-                getUserName(), containerName, Privilege.READ, this)) {
-            throw new UnauthorizedException(
-                    "User is not authorized to perform this operation on container "
-                            + containerName);
+        if (!NorthboundUtils.isAuthorized(getUserName(), containerName, Privilege.READ, this)) {
+            throw new UnauthorizedException("User is not authorized to perform this operation on container "
+                    + containerName);
         }
         handleDefaultDisabled(containerName);
 
         IStatisticsManager statisticsManager = getStatisticsService(containerName);
         if (statisticsManager == null) {
-            throw new ServiceUnavailableException("Statistics "
+            throw new ServiceUnavailableException("Statistics manager"
                     + RestMessages.SERVICEUNAVAILABLE.toString());
         }
 
@@ -357,18 +889,92 @@ public class StatisticsNorthbound {
     }
 
     /**
-     * Returns a list of all the Table Statistics on all Nodes.
+     * Returns a list of all the Table Statistics on a specific node.
      *
      * @param containerName
      *            Name of the Container. The Container name for the base
      *            controller is "default".
      * @param nodeType
-     *            Node Type as specifid by Node class
+     *            Node Type as specified in {@link org.opendaylight.controller.sal.core.Node} class (e.g. OF for Openflow)
      * @param Node
-     *            Identifier
+     *            Identifier (e.g. MAC address)
      * @return Returns a list of all the Table Statistics in a given Node.
+     *
+     *         <pre>
+     *
+     * Example:
+     *
+     * Request URL:
+     * http://host:8080/controller/nb/v2/statistics/default/table/node/OF/00:00:00:00:00:00:00:01
+     *
+     * Response in JSON:
+     * {
+     *     "node": {
+     *         "@type": "OF",
+     *         "@id": "00:00:00:00:00:00:00:01"
+     *     },
+     *     "tableStatistic": [
+     *         {
+     *             "nodeTable": {
+     *                 "@id": "0",
+     *                 "node": {
+     *                     "@type": "OF",
+     *                     "@id": "00:00:00:00:00:00:00:01"
+     *                 }
+     *             },
+     *             "activeCount": "12",
+     *             "lookupCount": "11382",
+     *             "matchedCount": "10524"
+     *         },
+     *         {
+     *             "nodeTable": {
+     *                 "@id": "1",
+     *                 "node": {
+     *                     "@type": "OF",
+     *                     "@id": "00:00:00:00:00:00:00:01"
+     *                 }
+     *             },
+     *             "activeCount": "0",
+     *             "lookupCount": "0",
+     *             "matchedCount": "0"
+     *         }
+     *    ]
+     * }
+     *
+     * Response in XML:
+     * &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;yes&quot;?&gt;
+     * &lt;nodeTableStatistics&gt;
+     *     &lt;node type=&quot;OF&quot; id=&quot;00:00:00:00:00:00:00:01&quot;/&gt;
+     *     &lt;tableStatistic&gt;
+     *         &lt;nodeTable id=&quot;0&quot;&gt;
+     *             &lt;node type=&quot;OF&quot; id=&quot;00:00:00:00:00:00:00:01&quot;/&gt;
+     *         &lt;/nodeTable&gt;
+     *         &lt;activeCount&gt;12&lt;/activeCount&gt;
+     *         &lt;lookupCount&gt;10935&lt;/lookupCount&gt;
+     *         &lt;matchedCount&gt;10084&lt;/matchedCount&gt;
+     *     &lt;/tableStatistic&gt;
+     *     &lt;tableStatistic&gt;
+     *         &lt;nodeTable id=&quot;1&quot;&gt;
+     *             &lt;node type=&quot;OF&quot; id=&quot;00:00:00:00:00:00:00:01&quot;/&gt;
+     *         &lt;/nodeTable&gt;
+     *         &lt;activeCount&gt;0&lt;/activeCount&gt;
+     *         &lt;lookupCount&gt;0&lt;/lookupCount&gt;
+     *         &lt;matchedCount&gt;0&lt;/matchedCount&gt;
+     *     &lt;/tableStatistic&gt;
+     *     &lt;tableStatistic&gt;
+     *         &lt;nodeTable id=&quot;2&quot;&gt;
+     *             &lt;node type=&quot;OF&quot; id=&quot;00:00:00:00:00:00:00:01&quot;/&gt;
+     *         &lt;/nodeTable&gt;
+     *         &lt;activeCount&gt;0&lt;/activeCount&gt;
+     *         &lt;lookupCount&gt;0&lt;/lookupCount&gt;
+     *         &lt;matchedCount&gt;0&lt;/matchedCount&gt;
+     *     &lt;/tableStatistic&gt;
+     * &lt;/nodeTableStatistics&gt;
+     *
+     *
+     * </pre>
      */
-    @Path("/{containerName}/tablestats/{nodeType}/{nodeId}")
+    @Path("/{containerName}/table/node/{nodeType}/{nodeId}")
     @GET
     @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
     @TypeHint(TableStatistics.class)
index a1c20190e61499e26669a42a7597ea426f0cd34e..552e707daef5780b2c3f3c40c2f963a797fc41b7 100644 (file)
@@ -5,7 +5,9 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
+
 package org.opendaylight.controller.statistics.northbound;
+
 import java.util.List;
 
 import javax.xml.bind.annotation.XmlAccessType;
@@ -16,13 +18,13 @@ import javax.xml.bind.annotation.XmlRootElement;
 import org.opendaylight.controller.sal.core.Node;
 import org.opendaylight.controller.sal.reader.NodeTableStatistics;
 
-@XmlRootElement
+@XmlRootElement(name = "nodeTableStatistics")
 @XmlAccessorType(XmlAccessType.NONE)
 public class TableStatistics {
     @XmlElement
     private Node node;
-    @XmlElement(name="tableStat")
-    private List<NodeTableStatistics> tableStats;
+    @XmlElement
+    private List<NodeTableStatistics> tableStatistic;
 
     // To satisfy JAXB
     @SuppressWarnings("unused")
@@ -32,7 +34,7 @@ public class TableStatistics {
     public TableStatistics(Node node, List<NodeTableStatistics> tableStats) {
         super();
         this.node = node;
-        this.tableStats = tableStats;
+        this.tableStatistic = tableStats;
     }
 
     public Node getNode() {
@@ -44,11 +46,11 @@ public class TableStatistics {
     }
 
     public List<NodeTableStatistics> getTableStats() {
-        return tableStats;
+        return tableStatistic;
     }
 
     public void setTableStats(List<NodeTableStatistics> tableStats) {
-        this.tableStats = tableStats;
+        this.tableStatistic = tableStats;
     }
 
 }
index 22c379614dbd0657d0d97e556a06f48a25b91309..68ff9b4f3804d773790b5a573c77563b6b46ccea 100644 (file)
@@ -118,6 +118,7 @@ public class NodeTable implements Serializable {
     /**
      * Private constructor used for JAXB mapping
      */
+    @SuppressWarnings("unused")
     private NodeTable() {
         this.nodeTableIDString = null;
         this.nodeTableID = null;
@@ -207,7 +208,7 @@ public class NodeTable implements Serializable {
      */
     @XmlAttribute(name = "id")
     public String getNodeTableIDString() {
-        return this.nodeTableIDString.toString();
+        return this.nodeTableIDString != null? this.nodeTableIDString : nodeTableID.toString();
     }
 
     /**