+ Node node = handleNodeAvailability(containerName, nodeType, nodeId);
+ return new PortStatistics(node,
+ statisticsManager.getNodeConnectorStatistics(node));
+ }
+
+ /**
+ * Returns a list of all the Table Statistics on all Nodes.
+ *
+ * @param containerName
+ * Name of the Container. The Container name for the base
+ * controller is "default".
+ *
+ * @return Returns a list of all the Table Statistics in a given Node.
+ *
+ * <pre>
+ *
+ * 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>
+ *
+ * </pre>
+ */
+ @Path("/{containerName}/table")
+ @GET
+ @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
+ @TypeHint(AllTableStatistics.class)
+ @StatusCodes({
+ @ResponseCode(code = 200, condition = "Operation successful"),
+ @ResponseCode(code = 404, condition = "The containerName is not found"),
+ @ResponseCode(code = 503, condition = "One or more of Controller Services are unavailable") })
+ 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);
+ }
+ handleDefaultDisabled(containerName);
+
+ IStatisticsManager statisticsManager = getStatisticsService(containerName);
+ if (statisticsManager == null) {
+ throw new ServiceUnavailableException("Statistics manager"
+ + RestMessages.SERVICEUNAVAILABLE.toString());
+ }
+
+ ISwitchManager switchManager = (ISwitchManager) ServiceHelper
+ .getInstance(ISwitchManager.class, containerName, this);
+ if (switchManager == null) {
+ throw new ServiceUnavailableException("Switch manager "
+ + RestMessages.SERVICEUNAVAILABLE.toString());
+ }
+
+ List<TableStatistics> statistics = new ArrayList<TableStatistics>();
+ for (Node node : switchManager.getNodes()) {
+ List<NodeTableStatistics> stat = statisticsManager
+ .getNodeTableStatistics(node);
+ TableStatistics tableStat = new TableStatistics(node, stat);
+ statistics.add(tableStat);
+ }
+ return new AllTableStatistics(statistics);
+ }
+
+ /**
+ * 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 specified in {@link org.opendaylight.controller.sal.core.Node} class (e.g. OF for Openflow)
+ * @param Node
+ * Identifier (e.g. MAC address)
+ * @return Returns a list of all the Table Statistics in a given Node.
+ *
+ * <pre>
+ *
+ * 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>
+ *
+ * </pre>
+ */
+ @Path("/{containerName}/table/node/{nodeType}/{nodeId}")
+ @GET
+ @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
+ @TypeHint(TableStatistics.class)
+ @StatusCodes({
+ @ResponseCode(code = 200, condition = "Operation successful"),
+ @ResponseCode(code = 404, condition = "The containerName is not found"),
+ @ResponseCode(code = 503, condition = "One or more of Controller Services are unavailable") })
+ public TableStatistics getTableStatistics(
+ @PathParam("containerName") String containerName,
+ @PathParam("nodeType") String nodeType,
+ @PathParam("nodeId") String nodeId) {
+
+ 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 "
+ + RestMessages.SERVICEUNAVAILABLE.toString());
+ }
+
+ ISwitchManager switchManager = (ISwitchManager) ServiceHelper
+ .getInstance(ISwitchManager.class, containerName, this);
+ if (switchManager == null) {
+ throw new ServiceUnavailableException("Switch manager "
+ + RestMessages.SERVICEUNAVAILABLE.toString());
+ }
+
+ Node node = handleNodeAvailability(containerName, nodeType, nodeId);
+ return new TableStatistics(node,
+ statisticsManager.getNodeTableStatistics(node));