X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fnorthbound%2Fstatistics%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fstatistics%2Fnorthbound%2FStatisticsNorthbound.java;h=a47bfa70b77e9fa2d0657529df2e676f8ab98f2a;hp=197ebabf9133d43f7b81f5360f46b7d3138b1f9e;hb=171c283d513bc07c4422a37120b203b4bcc53e43;hpb=eb9e1983a0fce7e4a381eff33e40cae957cddf53 diff --git a/opendaylight/northbound/statistics/src/main/java/org/opendaylight/controller/statistics/northbound/StatisticsNorthbound.java b/opendaylight/northbound/statistics/src/main/java/org/opendaylight/controller/statistics/northbound/StatisticsNorthbound.java index 197ebabf91..a47bfa70b7 100644 --- a/opendaylight/northbound/statistics/src/main/java/org/opendaylight/controller/statistics/northbound/StatisticsNorthbound.java +++ b/opendaylight/northbound/statistics/src/main/java/org/opendaylight/controller/statistics/northbound/StatisticsNorthbound.java @@ -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. * *
*
@@ -47,11 +50,7 @@ import org.opendaylight.controller.switchmanager.ISwitchManager; * Authentication realm : opendaylight
* Transport : HTTP and HTTPS
*
- * HTTPS Authentication is disabled by default. Administrator can enable it in - * tomcat-server.xml after adding a proper keystore / SSL certificate from a - * trusted authority.
- * More info : - * http://tomcat.apache.org/tomcat-7.0-doc/ssl-howto.html#Configuration + * HTTPS Authentication is disabled by default. * */ @Path("/") @@ -61,7 +60,7 @@ public class StatisticsNorthbound { @Context public void setSecurityContext(SecurityContext context) { - username = context.getUserPrincipal().getName(); + if (context != null && context.getUserPrincipal() != null) username = context.getUserPrincipal().getName(); } protected String getUserName() { @@ -107,9 +106,126 @@ public class StatisticsNorthbound { * Name of the Container. The Container name for the base * controller is "default". * @return List of FlowStatistics from all the Nodes + * + *
+     *
+     * Example:
+     *
+     * Request URL:
+     * http://localhost:8080/controller/nb/v2/statistics/default/flow
+     *
+     * Response in JSON:
+     * {
+     *     "flowStatistics": [
+     *         {
+     *             "node": {
+     *                 "id":"00:00:00:00:00:00:00:02",
+     *                 "type":"OF"
+     *             },
+     *             "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": {
+     *                                 "node":{
+     *                                     "id":"00:00:00:00:00:00:00:02",
+     *                                     "type":"OF"
+     *                                 },
+     *                                 "id":"3",
+     *                                 "type":"OF"
+     *                             }
+     *                         },
+     *                         "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:
+     * <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+     * <list>
+     *     <flowStatistics>
+     *         <node>
+     *             <id>00:00:00:00:00:00:00:02</id>
+     *             <type>OF</type>
+     *         </node>
+     *         <flowStatistic>
+     *             <flow>
+     *                 <match>
+     *                     <matchField>
+     *                         <type>DL_TYPE</type>
+     *                         <value>2048</value>
+     *                     </matchField>
+     *                     <matchField>
+     *                         <mask>255.255.255.255</mask>
+     *                         <type>NW_DST</type>
+     *                         <value>1.1.1.2</value>
+     *                     </matchField>
+     *                 </match>
+     *                 <actions
+     *                     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="output">
+     *                     <port>
+     *                         <node>
+     *                             <id>00:00:00:00:00:00:00:02</id>
+     *                             <type>OF</type>
+     *                         </node>
+     *                         <id>3</id>
+     *                         <type>OF</type>
+     *                     </port>
+     *                 </actions>
+     *                 <priority>1</priority>
+     *                 <idleTimeout>0</idleTimeout>
+     *                 <hardTimeout>0</hardTimeout>
+     *                 <id>0</id>
+     *             </flow>
+     *             <tableId>0</tableId>
+     *             <durationSeconds>337</durationSeconds>
+     *             <durationNanoseconds>149000000</durationNanoseconds>
+     *             <packetCount>0</packetCount>
+     *             <byteCount>0</byteCount>
+     *         </flowStatistic>
+     *     </flowStatistics>
+     *     <flowStatistics>
+     *          flow statistics for another node
+     *          ..........
+     *          ................
+     *          .....................
+     *     </flowStatistics>
+     * </list>
+     * 
*/ - @Path("/{containerName}/flowstats") + @Path("/{containerName}/flow") @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @TypeHint(AllFlowStatistics.class) @@ -159,12 +275,152 @@ 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. * + * + *
+     *
+     * Example:
+     *
+     * Request URL:
+     * http://localhost:8080/controller/nb/v2/statistics/default/flow/node/OF/00:00:00:00:00:00:00:01
+     *
+     * Response in JSON:
+     * {
+     *     "node": {
+     *         "id":"00:00:00:00:00:00:00:01",
+     *         "type":"OF"
+     *     },
+     *     "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":{
+     *                             "node":{
+     *                                 "id":"00:00:00:00:00:00:00:01",
+     *                                 "type":"OF"
+     *                              },
+     *                              "id":"5",
+     *                              "type":"OF"
+     *                         }
+     *                     }
+     *                 ],
+     *                 "priority": "1",
+     *                 "idleTimeout": "0",
+     *                 "hardTimeout": "0",
+     *                 "id": "0"
+     *             },
+     *             "tableId": "0",
+     *             "durationSeconds": "2089",
+     *             "durationNanoseconds": "538000000",
+     *             "packetCount": "0",
+     *             "byteCount": "0"
+     *         }
+     *     ]
+     * }
+     *
+     * Response in XML:
+     * <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+     *     <nodeFlowStatistics>
+     *         <node>
+     *             <id>00:00:00:00:00:00:00:02</id>
+     *             <type>OF</type>
+     *         </node>
+     *         <flowStatistic>
+     *             <flow>
+     *                 <match>
+     *                     <matchField>
+     *                         <type>DL_TYPE</type>
+     *                         <value>2048</value>
+     *                     </matchField>
+     *                     <matchField>
+     *                         <mask>255.255.255.255</mask>
+     *                         <type>NW_DST</type>
+     *                         <value>1.1.1.2</value>
+     *                     </matchField>
+     *                 </match>
+     *                 <actions
+     *                     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="output">
+     *                     <port>
+     *                         <node>
+     *                             <id>00:00:00:00:00:00:00:02</id>
+     *                             <type>OF</type>
+     *                         </node>
+     *                         <id>3</id>
+     *                         <type>OF</type>
+     *                     </port>
+     *                 </actions>
+     *                 <priority>1</priority>
+     *                 <idleTimeout>0</idleTimeout>
+     *                 <hardTimeout>0</hardTimeout>
+     *                 <id>0</id>
+     *             </flow>
+     *             <tableId>0</tableId>
+     *             <durationSeconds>337</durationSeconds>
+     *             <durationNanoseconds>149000000</durationNanoseconds>
+     *             <packetCount>0</packetCount>
+     *             <byteCount>0</byteCount>
+     *         </flowStatistic>
+     *         <flowStatistic>
+     *             <flow>
+     *                 <match>
+     *                     <matchField>
+     *                         <type>DL_TYPE</type>
+     *                         <value>2048</value>
+     *                     </matchField>
+     *                     <matchField>
+     *                         <mask>255.255.255.255</mask>
+     *                         <type>NW_DST</type>
+     *                         <value>1.1.1.1</value>
+     *                     </matchField>
+     *                 </match>
+     *                 <actions
+     *                     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="output">
+     *                     <port>
+     *                         <node>
+     *                             <id>00:00:00:00:00:00:00:02</id>
+     *                             <type>OF</type>
+     *                         </node>
+     *                         <id>3</id>
+     *                         <type>OF</type>
+     *                     </port>
+     *                 </actions>
+     *                 <priority>1</priority>
+     *                 <idleTimeout>0</idleTimeout>
+     *                 <hardTimeout>0</hardTimeout>
+     *                 <id>0</id>
+     *             </flow>
+     *             <tableId>0</tableId>
+     *             <durationSeconds>337</durationSeconds>
+     *             <durationNanoseconds>208000000</durationNanoseconds>
+     *             <packetCount>0</packetCount>
+     *             <byteCount>0</byteCount>
+     *         </flowStatistic>
+     *     </nodeFlowStatistics>
+     * 
*/ - @Path("/{containerName}/flowstats/{nodeType}/{nodeId}") + @Path("/{containerName}/flow/node/{nodeType}/{nodeId}") @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @TypeHint(FlowStatistics.class) @@ -210,9 +466,142 @@ public class StatisticsNorthbound { * controller is "default". * @return List of all the Port Statistics across all the NodeConnectors on * all the Nodes. + * + *
+     *
+     * Example:
+     *
+     * Request URL:
+     * http://localhost:8080/controller/nb/v2/statistics/default/port
+     *
+     * Response in JSON:
+     * {
+     *     "portStatistics": [
+     *         {
+     *             "node": {
+     *                  "id":"00:00:00:00:00:00:00:02",
+     *                  "type":"OF"
+     *             },
+     *             "portStatistic": [
+     *                 {
+     *                     "nodeConnector":{
+     *                          "node":{
+     *                                 "id":"00:00:00:00:00:00:00:02",
+     *                                 "type":"OF"
+     *                           },
+     *                           "id":"3",
+     *                           "type":"OF"
+     *                     },
+     *                     "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": {
+     *                          "node":{
+     *                                  "id":"00:00:00:00:00:00:00:02",
+     *                                  "type":"OF"
+     *                           },
+     *                           "id":"2",
+     *                           "type":"OF"
+     *                     },
+     *                     "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": {
+     *                  "id":"00:00:00:00:00:00:00:03",
+     *                  "type":"OF"
+     *             },
+     *             "portStatistic": [
+     *                  ..................
+     *                  .......................
+     *                  ..........................
+     *             ]
+     *         }
+     *     ]
+     * }
+     *
+     * Response in XML:
+     * <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+     * <list>
+     *     <portStatistics>
+     *          <node>
+     *             <id>00:00:00:00:00:00:00:02</id>
+     *             <type>OF</type>
+     *          </node>
+     *          <portStatistic>
+     *             <nodeConnector>
+     *                <node>
+     *                   <id>00:00:00:00:00:00:00:02</id>
+     *                   <type>OF</type>
+     *                </node>
+     *                <id>3</id>
+     *                <type>OF</type>
+     *             </nodeConnector>
+     *             <receivePackets>181</receivePackets>
+     *             <transmitPackets>172</transmitPackets>
+     *             <receiveBytes>12670</receiveBytes>
+     *             <transmitBytes>12040</transmitBytes>
+     *             <receiveDrops>0</receiveDrops>
+     *             <transmitDrops>0</transmitDrops>
+     *             <receiveErrors>0</receiveErrors>
+     *             <transmitErrors>0</transmitErrors>
+     *             <receiveFrameError>0</receiveFrameError>
+     *             <receiveOverRunError>0</receiveOverRunError>
+     *             <receiveCrcError>0</receiveCrcError>
+     *             <collisionCount>0</collisionCount>
+     *         </portStatistic>
+     *         <portStatistic>
+     *             <nodeConnector>
+     *                <node>
+     *                   <id>00:00:00:00:00:00:00:02</id>
+     *                   <type>OF</type>
+     *                </node>
+     *                <id>2</id>
+     *                <type>OF</type>
+     *             </nodeConnector>
+     *             <receivePackets>173</receivePackets>
+     *             <transmitPackets>180</transmitPackets>
+     *             <receiveBytes>12110</receiveBytes>
+     *             <transmitBytes>12600</transmitBytes>
+     *             <receiveDrops>0</receiveDrops>
+     *             <transmitDrops>0</transmitDrops>
+     *             <receiveErrors>0</receiveErrors>
+     *             <transmitErrors>0</transmitErrors>
+     *             <receiveFrameError>0</receiveFrameError>
+     *             <receiveOverRunError>0</receiveOverRunError>
+     *             <receiveCrcError>0</receiveCrcError>
+     *             <collisionCount>0</collisionCount>
+     *         </portStatistic>
+     *     </portStatistics>
+     * </list>
+     * 
*/ - @Path("/{containerName}/portstats") + @Path("/{containerName}/port") @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @TypeHint(AllPortStatistics.class) @@ -260,13 +649,128 @@ 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. + * + *
+     *
+     * Example:
+     *
+     * Request URL:
+     * http://localhost:8080/controller/nb/v2/statistics/default/port/node/OF/00:00:00:00:00:00:00:01
+     *
+     * Response in JSON:
+     * {
+     *     "node": {
+     *         "id":"00:00:00:00:00:00:00:01",
+     *         "type":"OF"
+     *     },
+     *     "portStatistic": [
+     *         {
+     *             "nodeConnector": {
+     *                 "node":{
+     *                     "id":"00:00:00:00:00:00:00:01",
+     *                     "type":"OF"
+     *                 },
+     *                 "id":"3",
+     *                 "type":"OF"
+     *             },
+     *             "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": {
+     *                 "node":{
+     *                     "id":"00:00:00:00:00:00:00:01",
+     *                     "type":"OF"
+     *                 },
+     *                 "id":"2",
+     *                 "type":"OF"
+     *             },
+     *             "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:
+     * <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+     * <nodePortStatistics>
+     *     <node>
+     *         <id>00:00:00:00:00:00:00:01</id>
+     *         <type>OF</type>
+     *     </node>
+     *     <portStatistic>
+     *         <nodeConnector>
+     *             <node>
+     *                 <id>00:00:00:00:00:00:00:01</id>
+     *                 <type>OF</type>
+     *             </node>
+     *             <id>2</id>
+     *             <type>OF</type>
+     *         </nodeConnector>
+     *         <receivePackets>180</receivePackets>
+     *         <transmitPackets>2594</transmitPackets>
+     *         <receiveBytes>12600</receiveBytes>
+     *         <transmitBytes>249396</transmitBytes>
+     *         <receiveDrops>0</receiveDrops>
+     *         <transmitDrops>0</transmitDrops>
+     *         <receiveErrors>0</receiveErrors>
+     *         <transmitErrors>0</transmitErrors>
+     *         <receiveFrameError>0</receiveFrameError>
+     *         <receiveOverRunError>0</receiveOverRunError>
+     *         <receiveCrcError>0</receiveCrcError>
+     *         <collisionCount>0</collisionCount>
+     *     </portStatistic>
+     *     <portStatistic>
+     *         <nodeConnector>
+     *             <node>
+     *                 <id>00:00:00:00:00:00:00:01</id>
+     *                 <type>OF</type>
+     *             </node>
+     *             <id>5</id>
+     *             <type>OF</type>
+     *         </nodeConnector>
+     *         <receivePackets>2542</receivePackets>
+     *         <transmitPackets>2719</transmitPackets>
+     *         <receiveBytes>243012</receiveBytes>
+     *         <transmitBytes>255374</transmitBytes>
+     *         <receiveDrops>0</receiveDrops>
+     *         <transmitDrops>0</transmitDrops>
+     *         <receiveErrors>0</receiveErrors>
+     *         <transmitErrors>0</transmitErrors>
+     *         <receiveFrameError>0</receiveFrameError>
+     *         <receiveOverRunError>0</receiveOverRunError>
+     *         <receiveCrcError>0</receiveCrcError>
+     *         <collisionCount>0</collisionCount>
+     *     </portStatistic>
+     * </nodePortStatistics>
+     * 
*/ - @Path("/{containerName}/portstats/{nodeType}/{nodeId}") + @Path("/{containerName}/port/node/{nodeType}/{nodeId}") @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @TypeHint(PortStatistics.class) @@ -313,11 +817,104 @@ public class StatisticsNorthbound { * controller is "default". * * @return Returns a list of all the Table Statistics in a given Node. + * + *
+     *
+     * Example:
+     *
+     * Request URL:
+     * http://localhost:8080/controller/nb/v2/statistics/default/table
+     *
+     * Response in JSON:
+     * {
+     *     "tableStatistics": [
+     *         {
+     *             "node": {
+     *                 "id":"00:00:00:00:00:00:00:02",
+     *                 "type":"OF"
+     *             },
+     *             "tableStatistic": [
+     *                 {
+     *                     "nodeTable": {
+     *                        "node":{
+     *                           "id":"00:00:00:00:00:00:00:02",
+     *                           "type":"OF"
+     *                         },
+     *                         "id":"0"
+     *                     },
+     *                     "activeCount": "11",
+     *                     "lookupCount": "816",
+     *                     "matchedCount": "220"
+     *                 },
+     *                 {
+     *                     ...another table
+     *                     .....
+     *                     ........
+     *                 }
+     *
+     *             ]
+     *         }
+     *     ]
+     * }
+     *
+     *  Response in XML:
+     *  <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+     *  <list>
+     *  <tableStatistics>
+     *      <node>
+     *          <id>00:00:00:00:00:00:00:01</id>
+     *          <type>OF</type>
+     *      </node>
+     *      <tableStatistic>
+     *          <nodeTable>
+     *              <node>
+     *                  <id>00:00:00:00:00:00:00:01</id>
+     *                  <type>OF</type>
+     *              </node>
+     *              <id>0</id>
+     *          </nodeTable>
+     *          <activeCount>12</activeCount>
+     *          <lookupCount>10935</lookupCount>
+     *          <matchedCount>10084</matchedCount>
+     *      </tableStatistic>
+     *      <tableStatistic>
+     *          <nodeTable>
+     *              <node>
+     *                  <id>00:00:00:00:00:00:00:01</id>
+     *                  <type>OF</type>
+     *              </node>
+     *              <id>1</id>
+     *          </nodeTable>
+     *          <activeCount>0</activeCount>
+     *          <lookupCount>0</lookupCount>
+     *          <matchedCount>0</matchedCount>
+     *      </tableStatistic>
+     *      <tableStatistic>
+     *          <nodeTable>
+     *              <node>
+     *                  <id>00:00:00:00:00:00:00:01</id>
+     *                  <type>OF</type>
+     *              </node>
+     *              <id>2</id>
+     *          </nodeTable>
+     *          <activeCount>0</activeCount>
+     *          <lookupCount>0</lookupCount>
+     *          <matchedCount>0</matchedCount>
+     *      </tableStatistic>
+     *  </tableStatistics>
+     *  <tableStatistics>
+     *  ...
+     *  ......
+     *  ........
+     *  </tableStatistics>
+     *  </list>
+     *
+     * 
*/ - @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 +922,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 +952,106 @@ 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. + * + *
+     *
+     * Example:
+     *
+     * Request URL:
+     * http://localhost:8080/controller/nb/v2/statistics/default/table/node/OF/00:00:00:00:00:00:00:01
+     *
+     * Response in JSON:
+     * {
+     *     "node": {
+     *         "id":"00:00:00:00:00:00:00:01",
+     *         "type":"OF"
+     *     },
+     *     "tableStatistic": [
+     *         {
+     *             "nodeTable": {
+     *                 "node":{
+     *                     "id":"00:00:00:00:00:00:00:01",
+     *                     "type":"OF"
+     *                 },
+     *                 "id":"0"
+     *             },
+     *             "activeCount": "12",
+     *             "lookupCount": "11382",
+     *             "matchedCount": "10524"
+     *         },
+     *         {
+     *             "nodeTable": {
+     *                 "node":{
+     *                     "id":"00:00:00:00:00:00:00:01",
+     *                     "type":"OF"
+     *                 },
+     *                 "id":"1"
+     *             },
+     *             "activeCount": "0",
+     *             "lookupCount": "0",
+     *             "matchedCount": "0"
+     *         }
+     *    ]
+     * }
+     *
+     * Response in XML:
+     * <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+     * <nodeTableStatistics>
+     *     <node>
+     *          <id>00:00:00:00:00:00:00:01</id>
+     *          <type>OF</type>
+     *     </node>
+     *     <tableStatistic>
+     *         <nodeTable>
+     *             <node>
+     *                 <id>00:00:00:00:00:00:00:01</id>
+     *                 <type>OF</type>
+     *             </node>
+     *             <id>0</id>
+     *         </nodeTable>
+     *         <activeCount>12</activeCount>
+     *         <lookupCount>10935</lookupCount>
+     *         <matchedCount>10084</matchedCount>
+     *     </tableStatistic>
+     *     <tableStatistic>
+     *         <nodeTable>
+     *             <node>
+     *                 <id>00:00:00:00:00:00:00:01</id>
+     *                 <type>OF</type>
+     *             </node>
+     *             <id>1</id>
+     *         </nodeTable>
+     *         <activeCount>0</activeCount>
+     *         <lookupCount>0</lookupCount>
+     *         <matchedCount>0</matchedCount>
+     *     </tableStatistic>
+     *     <tableStatistic>
+     *         <nodeTable>
+     *             <node>
+     *                 <id>00:00:00:00:00:00:00:01</id>
+     *                 <type>OF</type>
+     *             </node>
+     *             <id>2</id>
+     *         </nodeTable>
+     *         <activeCount>0</activeCount>
+     *         <lookupCount>0</lookupCount>
+     *         <matchedCount>0</matchedCount>
+     *     </tableStatistic>
+     * </nodeTableStatistics>
+     *
+     * 
*/ - @Path("/{containerName}/tablestats/{nodeType}/{nodeId}") + @Path("/{containerName}/table/node/{nodeType}/{nodeId}") @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @TypeHint(TableStatistics.class)