X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fnorthbound%2Fstatistics%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fstatistics%2Fnorthbound%2FStatisticsNorthbound.java;h=a47bfa70b77e9fa2d0657529df2e676f8ab98f2a;hb=refs%2Fchanges%2F49%2F1149%2F2;hp=1c3fd1cf2ea10d32b148aec6d8dbb2fb2fab357a;hpb=be985b56087bb36174d7ea7d25d202b7eef3a2fa;p=controller.git 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 1c3fd1cf2e..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 @@ -50,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("/") @@ -64,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() { @@ -111,17 +107,20 @@ public class StatisticsNorthbound { * controller is "default". * @return List of FlowStatistics from all the Nodes * - *
+     * 
+     *
      * Example:
-     * Request URL: localhost:8080/controller/nb/v2/statistics/default/flow
+     *
+     * Request URL:
+     * http://localhost:8080/controller/nb/v2/statistics/default/flow
      *
      * Response in JSON:
      * {
      *     "flowStatistics": [
      *         {
      *             "node": {
-     *                 "@type": "OF",
-     *                 "@id": "00:00:00:00:00:00:00:02"
+     *                 "id":"00:00:00:00:00:00:00:02",
+     *                 "type":"OF"
      *             },
      *             "flowStatistic": [
      *                 {
@@ -142,12 +141,12 @@ public class StatisticsNorthbound {
      *                         "actions": {
      *                             "@type": "output",
      *                             "port": {
-     *                                 "@type": "OF",
-     *                                 "@id": "3",
-     *                                 "node": {
-     *                                     "@type": "OF",
-     *                                     "@id": "00:00:00:00:00:00:00:02"
-     *                                 }
+     *                                 "node":{
+     *                                     "id":"00:00:00:00:00:00:00:02",
+     *                                     "type":"OF"
+     *                                 },
+     *                                 "id":"3",
+     *                                 "type":"OF"
      *                             }
      *                         },
      *                         "priority": "1",
@@ -171,11 +170,15 @@ public class StatisticsNorthbound {
      *
      *     ]
      * }
+     *
      * Response in XML:
      * <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
      * <list>
      *     <flowStatistics>
-     *         <node type="OF" id="00:00:00:00:00:00:00:02"/>
+     *         <node>
+     *             <id>00:00:00:00:00:00:00:02</id>
+     *             <type>OF</type>
+     *         </node>
      *         <flowStatistic>
      *             <flow>
      *                 <match>
@@ -191,8 +194,13 @@ public class StatisticsNorthbound {
      *                 </match>
      *                 <actions
      *                     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="output">
-     *                     <port type="OF" id="3">
-     *                         <node type="OF" id="00:00:00:00:00:00:00:02"/>
+     *                     <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>
@@ -272,16 +280,18 @@ public class StatisticsNorthbound {
      *            Node Identifier
      * @return List of Flow Statistics for a given Node. *
      *
-     *         
+     * 
+     *
      * Example:
+     *
      * Request URL:
-     * http://host:8080/controller/nb/v2/statistics/default/flow/node/OF/00:00:00:00:00:00:00:01
+     * http://localhost: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"
+     *         "id":"00:00:00:00:00:00:00:01",
+     *         "type":"OF"
      *     },
      *     "flowStatistic": [
      *         {
@@ -306,13 +316,13 @@ public class StatisticsNorthbound {
      *                     },
      *                     {
      *                         "@type": "output",
-     *                         "port": {
-     *                             "@type": "OF",
-     *                             "@id": "5",
-     *                             "node": {
-     *                                 "@type": "OF",
-     *                                 "@id": "00:00:00:00:00:00:00:01"
-     *                             }
+     *                         "port":{
+     *                             "node":{
+     *                                 "id":"00:00:00:00:00:00:00:01",
+     *                                 "type":"OF"
+     *                              },
+     *                              "id":"5",
+     *                              "type":"OF"
      *                         }
      *                     }
      *                 ],
@@ -330,11 +340,13 @@ public class StatisticsNorthbound {
      *     ]
      * }
      *
-     *
      * Response in XML:
      * <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
      *     <nodeFlowStatistics>
-     *         <node type="OF" id="00:00:00:00:00:00:00:02"/>
+     *         <node>
+     *             <id>00:00:00:00:00:00:00:02</id>
+     *             <type>OF</type>
+     *         </node>
      *         <flowStatistic>
      *             <flow>
      *                 <match>
@@ -350,8 +362,13 @@ public class StatisticsNorthbound {
      *                 </match>
      *                 <actions
      *                     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="output">
-     *                     <port type="OF" id="3">
-     *                         <node type="OF" id="00:00:00:00:00:00:00:02"/>
+     *                     <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>
@@ -380,8 +397,13 @@ public class StatisticsNorthbound {
      *                 </match>
      *                 <actions
      *                     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="output">
-     *                     <port type="OF" id="3">
-     *                         <node type="OF" id="00:00:00:00:00:00:00:02"/>
+     *                     <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>
@@ -445,28 +467,30 @@ public class StatisticsNorthbound {
      * @return List of all the Port Statistics across all the NodeConnectors on
      *         all the Nodes.
      *
-     *         
+     * 
+     *
      * Example:
      *
-     * Requset URL: http://host:8080/controller/nb/v2/statistics/default/port
+     * Request URL:
+     * http://localhost:8080/controller/nb/v2/statistics/default/port
      *
      * Response in JSON:
      * {
      *     "portStatistics": [
      *         {
      *             "node": {
-     *                 "@type": "OF",
-     *                 "@id": "00:00:00:00:00:00:00:02"
+     *                  "id":"00:00:00:00:00:00:00:02",
+     *                  "type":"OF"
      *             },
      *             "portStatistic": [
      *                 {
-     *                     "nodeConnector": {
-     *                         "@type": "OF",
-     *                         "@id": "3",
-     *                         "node": {
-     *                             "@type": "OF",
-     *                             "@id": "00:00:00:00:00:00:00:02"
-     *                         }
+     *                     "nodeConnector":{
+     *                          "node":{
+     *                                 "id":"00:00:00:00:00:00:00:02",
+     *                                 "type":"OF"
+     *                           },
+     *                           "id":"3",
+     *                           "type":"OF"
      *                     },
      *                     "receivePackets": "182",
      *                     "transmitPackets": "173",
@@ -483,12 +507,12 @@ public class StatisticsNorthbound {
      *                 },
      *                 {
      *                     "nodeConnector": {
-     *                         "@type": "OF",
-     *                         "@id": "2",
-     *                         "node": {
-     *                             "@type": "OF",
-     *                             "@id": "00:00:00:00:00:00:00:02"
-     *                         }
+     *                          "node":{
+     *                                  "id":"00:00:00:00:00:00:00:02",
+     *                                  "type":"OF"
+     *                           },
+     *                           "id":"2",
+     *                           "type":"OF"
      *                     },
      *                     "receivePackets": "174",
      *                     "transmitPackets": "181",
@@ -508,8 +532,8 @@ public class StatisticsNorthbound {
      *         },
      *         {
      *             "node": {
-     *                 "@type": "OF",
-     *                 "@id": "00:00:00:00:00:00:00:03"
+     *                  "id":"00:00:00:00:00:00:00:03",
+     *                  "type":"OF"
      *             },
      *             "portStatistic": [
      *                  ..................
@@ -524,10 +548,18 @@ public class StatisticsNorthbound {
      * <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
      * <list>
      *     <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"/>
+     *          <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>
@@ -543,8 +575,13 @@ public class StatisticsNorthbound {
      *             <collisionCount>0</collisionCount>
      *         </portStatistic>
      *         <portStatistic>
-     *             <nodeConnector type="OF" id="2">
-     *                 <node type="OF" id="00:00:00:00:00:00:00:02"/>
+     *             <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>
@@ -559,7 +596,6 @@ public class StatisticsNorthbound {
      *             <receiveCrcError>0</receiveCrcError>
      *             <collisionCount>0</collisionCount>
      *         </portStatistic>
-     *
      *     </portStatistics>
      * </list>
      * 
@@ -619,27 +655,28 @@ public class StatisticsNorthbound { * @return Returns a list of all the Port Statistics across all the * NodeConnectors in a given Node. * - *
+     * 
+     *
      * Example:
      *
      * Request URL:
-     * http://host:8080/controller/nb/v2/statistics/default/port/node/OF/00:00:00:00:00:00:00:01
+     * http://localhost: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"
+     *         "id":"00:00:00:00:00:00:00:01",
+     *         "type":"OF"
      *     },
      *     "portStatistic": [
      *         {
      *             "nodeConnector": {
-     *                 "@type": "OF",
-     *                 "@id": "3",
-     *                 "node": {
-     *                     "@type": "OF",
-     *                     "@id": "00:00:00:00:00:00:00:01"
-     *                 }
+     *                 "node":{
+     *                     "id":"00:00:00:00:00:00:00:01",
+     *                     "type":"OF"
+     *                 },
+     *                 "id":"3",
+     *                 "type":"OF"
      *             },
      *             "receivePackets": "171",
      *             "transmitPackets": "2451",
@@ -656,12 +693,12 @@ public class StatisticsNorthbound {
      *         },
      *         {
      *             "nodeConnector": {
-     *                 "@type": "OF",
-     *                 "@id": "2",
-     *                 "node": {
-     *                     "@type": "OF",
-     *                     "@id": "00:00:00:00:00:00:00:01"
-     *                 }
+     *                 "node":{
+     *                     "id":"00:00:00:00:00:00:00:01",
+     *                     "type":"OF"
+     *                 },
+     *                 "id":"2",
+     *                 "type":"OF"
      *             },
      *             "receivePackets": "179",
      *             "transmitPackets": "2443",
@@ -682,10 +719,18 @@ public class StatisticsNorthbound {
      * Response in XML:
      * <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
      * <nodePortStatistics>
-     *     <node type="OF" id="00:00:00:00:00:00:00:01"/>
+     *     <node>
+     *         <id>00:00:00:00:00:00:00:01</id>
+     *         <type>OF</type>
+     *     </node>
      *     <portStatistic>
-     *         <nodeConnector type="OF" id="2">
-     *             <node type="OF" id="00:00:00:00:00:00:00:01"/>
+     *         <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>
@@ -701,8 +746,13 @@ public class StatisticsNorthbound {
      *         <collisionCount>0</collisionCount>
      *     </portStatistic>
      *     <portStatistic>
-     *         <nodeConnector type="OF" id="5">
-     *             <node type="OF" id="00:00:00:00:00:00:00:01"/>
+     *         <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>
@@ -768,30 +818,29 @@ public class StatisticsNorthbound {
      *
      * @return Returns a list of all the Table Statistics in a given Node.
      *
-     *         
+     * 
      *
-     *  Example:
-     *
-     *  Request URL:
-     *  http://host:8080/controller/nb/v2/statistics/default/table
+     * Example:
      *
-     *  Response in JSON:
+     * Request URL:
+     * http://localhost:8080/controller/nb/v2/statistics/default/table
      *
+     * Response in JSON:
      * {
      *     "tableStatistics": [
      *         {
      *             "node": {
-     *                 "@type": "OF",
-     *                 "@id": "00:00:00:00:00:00:00:02"
+     *                 "id":"00:00:00:00:00:00:00:02",
+     *                 "type":"OF"
      *             },
      *             "tableStatistic": [
      *                 {
      *                     "nodeTable": {
-     *                         "@id": "0",
-     *                         "node": {
-     *                             "@type": "OF",
-     *                             "@id": "00:00:00:00:00:00:00:02"
-     *                         }
+     *                        "node":{
+     *                           "id":"00:00:00:00:00:00:00:02",
+     *                           "type":"OF"
+     *                         },
+     *                         "id":"0"
      *                     },
      *                     "activeCount": "11",
      *                     "lookupCount": "816",
@@ -808,31 +857,45 @@ public class StatisticsNorthbound {
      *     ]
      * }
      *
-     *
      *  Response in XML:
      *  <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
      *  <list>
      *  <tableStatistics>
-     *      <node type="OF" id="00:00:00:00:00:00:00:01"/>
+     *      <node>
+     *          <id>00:00:00:00:00:00:00:01</id>
+     *          <type>OF</type>
+     *      </node>
      *      <tableStatistic>
-     *          <nodeTable id="0">
-     *              <node type="OF" id="00:00:00:00:00:00:00:01"/>
+     *          <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 id="1">
-     *              <node type="OF" id="00:00:00:00:00:00:00:01"/>
+     *          <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 id="2">
-     *              <node type="OF" id="00:00:00:00:00:00:00:01"/>
+     *          <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>
@@ -900,27 +963,27 @@ public class StatisticsNorthbound {
      *            Identifier (e.g. MAC address)
      * @return Returns a list of all the Table Statistics in a given Node.
      *
-     *         
+     * 
      *
      * Example:
      *
      * Request URL:
-     * http://host:8080/controller/nb/v2/statistics/default/table/node/OF/00:00:00:00:00:00:00:01
+     * http://localhost: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"
+     *         "id":"00:00:00:00:00:00:00:01",
+     *         "type":"OF"
      *     },
      *     "tableStatistic": [
      *         {
      *             "nodeTable": {
-     *                 "@id": "0",
-     *                 "node": {
-     *                     "@type": "OF",
-     *                     "@id": "00:00:00:00:00:00:00:01"
-     *                 }
+     *                 "node":{
+     *                     "id":"00:00:00:00:00:00:00:01",
+     *                     "type":"OF"
+     *                 },
+     *                 "id":"0"
      *             },
      *             "activeCount": "12",
      *             "lookupCount": "11382",
@@ -928,11 +991,11 @@ public class StatisticsNorthbound {
      *         },
      *         {
      *             "nodeTable": {
-     *                 "@id": "1",
-     *                 "node": {
-     *                     "@type": "OF",
-     *                     "@id": "00:00:00:00:00:00:00:01"
-     *                 }
+     *                 "node":{
+     *                     "id":"00:00:00:00:00:00:00:01",
+     *                     "type":"OF"
+     *                 },
+     *                 "id":"1"
      *             },
      *             "activeCount": "0",
      *             "lookupCount": "0",
@@ -944,26 +1007,41 @@ public class StatisticsNorthbound {
      * Response in XML:
      * <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
      * <nodeTableStatistics>
-     *     <node type="OF" id="00:00:00:00:00:00:00:01"/>
+     *     <node>
+     *          <id>00:00:00:00:00:00:00:01</id>
+     *          <type>OF</type>
+     *     </node>
      *     <tableStatistic>
-     *         <nodeTable id="0">
-     *             <node type="OF" id="00:00:00:00:00:00:00:01"/>
+     *         <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 id="1">
-     *             <node type="OF" id="00:00:00:00:00:00:00:01"/>
+     *         <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 id="2">
-     *             <node type="OF" id="00:00:00:00:00:00:00:01"/>
+     *         <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>
@@ -971,7 +1049,6 @@ public class StatisticsNorthbound {
      *     </tableStatistic>
      * </nodeTableStatistics>
      *
-     *
      * 
*/ @Path("/{containerName}/table/node/{nodeType}/{nodeId}")