Code Review
/
controller.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Merge "Bug 1239 - Clean up and refactor netconf-ssh client"
[controller.git]
/
opendaylight
/
northbound
/
statistics
/
src
/
main
/
java
/
org
/
opendaylight
/
controller
/
statistics
/
northbound
/
StatisticsNorthbound.java
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 a07f6435fe0e92e96d53eea61dd5abdffab921a3..4175f1e3c49984c7d90ac03b2207df946c9f7e3a 100644
(file)
--- 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
@@
-15,9
+15,11
@@
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.SecurityContext;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.SecurityContext;
+import javax.ws.rs.ext.ContextResolver;
import org.codehaus.enunciate.jaxrs.ResponseCode;
import org.codehaus.enunciate.jaxrs.StatusCodes;
import org.codehaus.enunciate.jaxrs.ResponseCode;
import org.codehaus.enunciate.jaxrs.StatusCodes;
@@
-29,6
+31,7
@@
import org.opendaylight.controller.northbound.commons.exception.ResourceConflict
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.exception.ResourceNotFoundException;
import org.opendaylight.controller.northbound.commons.exception.ServiceUnavailableException;
import org.opendaylight.controller.northbound.commons.exception.UnauthorizedException;
+import org.opendaylight.controller.northbound.commons.query.QueryContext;
import org.opendaylight.controller.northbound.commons.utils.NorthboundUtils;
import org.opendaylight.controller.sal.authorization.Privilege;
import org.opendaylight.controller.sal.core.Node;
import org.opendaylight.controller.northbound.commons.utils.NorthboundUtils;
import org.opendaylight.controller.sal.authorization.Privilege;
import org.opendaylight.controller.sal.core.Node;
@@
-50,18
+53,21
@@
import org.opendaylight.controller.switchmanager.ISwitchManager;
* Authentication realm : <b>opendaylight</b><br>
* Transport : <b>HTTP and HTTPS</b><br>
* <br>
* Authentication realm : <b>opendaylight</b><br>
* Transport : <b>HTTP and HTTPS</b><br>
* <br>
- * 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.<br>
- * More info :
- * http://tomcat.apache.org/tomcat-7.0-doc/ssl-howto.html#Configuration
+ * HTTPS Authentication is disabled by default.
*
*/
@Path("/")
public class StatisticsNorthbound {
private String username;
*
*/
@Path("/")
public class StatisticsNorthbound {
private String username;
+ private QueryContext queryContext;
+ @Context
+ public void setQueryContext(ContextResolver<QueryContext> queryCtxResolver) {
+ if (queryCtxResolver != null) {
+ queryContext = queryCtxResolver.getContext(QueryContext.class);
+ }
+ }
@Context
public void setSecurityContext(SecurityContext context) {
if (context != null && context.getUserPrincipal() != null) username = context.getUserPrincipal().getName();
@Context
public void setSecurityContext(SecurityContext context) {
if (context != null && context.getUserPrincipal() != null) username = context.getUserPrincipal().getName();
@@
-118,7
+124,7
@@
public class StatisticsNorthbound {
* Request URL:
* http://localhost:8080/controller/nb/v2/statistics/default/flow
*
* Request URL:
* http://localhost:8080/controller/nb/v2/statistics/default/flow
*
- * Response in JSON:
+ * Response
body
in JSON:
* {
* "flowStatistics": [
* {
* {
* "flowStatistics": [
* {
@@
-175,7
+181,7
@@
public class StatisticsNorthbound {
* ]
* }
*
* ]
* }
*
- * Response in XML:
+ * Response
body
in XML:
* <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
* <list>
* <flowStatistics>
* <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
* <list>
* <flowStatistics>
@@
-238,7
+244,8
@@
public class StatisticsNorthbound {
@ResponseCode(code = 404, condition = "The containerName is not found"),
@ResponseCode(code = 503, condition = "One or more of Controller Services are unavailable") })
public AllFlowStatistics getFlowStatistics(
@ResponseCode(code = 404, condition = "The containerName is not found"),
@ResponseCode(code = 503, condition = "One or more of Controller Services are unavailable") })
public AllFlowStatistics getFlowStatistics(
- @PathParam("containerName") String containerName) {
+ @PathParam("containerName") String containerName,
+ @QueryParam("_q") String queryString) {
if (!NorthboundUtils.isAuthorized(
getUserName(), containerName, Privilege.READ, this)) {
throw new UnauthorizedException(
if (!NorthboundUtils.isAuthorized(
getUserName(), containerName, Privilege.READ, this)) {
throw new UnauthorizedException(
@@
-269,7
+276,12
@@
public class StatisticsNorthbound {
FlowStatistics stat = new FlowStatistics(node, flowStats);
statistics.add(stat);
}
FlowStatistics stat = new FlowStatistics(node, flowStats);
statistics.add(stat);
}
- return new AllFlowStatistics(statistics);
+ AllFlowStatistics result = new AllFlowStatistics(statistics);
+ if (queryString != null) {
+ queryContext.createQuery(queryString, AllFlowStatistics.class)
+ .filter(result, FlowStatistics.class);
+ }
+ return result;
}
/**
}
/**
@@
-291,7
+303,7
@@
public class StatisticsNorthbound {
* Request URL:
* http://localhost:8080/controller/nb/v2/statistics/default/flow/node/OF/00:00:00:00:00:00:00:01
*
* Request URL:
* http://localhost:8080/controller/nb/v2/statistics/default/flow/node/OF/00:00:00:00:00:00:00:01
*
- * Response in JSON:
+ * Response
body
in JSON:
* {
* "node": {
* "id":"00:00:00:00:00:00:00:01",
* {
* "node": {
* "id":"00:00:00:00:00:00:00:01",
@@
-344,7
+356,7
@@
public class StatisticsNorthbound {
* ]
* }
*
* ]
* }
*
- * Response in XML:
+ * Response
body
in XML:
* <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
* <nodeFlowStatistics>
* <node>
* <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
* <nodeFlowStatistics>
* <node>
@@
-478,7
+490,7
@@
public class StatisticsNorthbound {
* Request URL:
* http://localhost:8080/controller/nb/v2/statistics/default/port
*
* Request URL:
* http://localhost:8080/controller/nb/v2/statistics/default/port
*
- * Response in JSON:
+ * Response
body
in JSON:
* {
* "portStatistics": [
* {
* {
* "portStatistics": [
* {
@@
-548,7
+560,7
@@
public class StatisticsNorthbound {
* ]
* }
*
* ]
* }
*
- * Response in XML:
+ * Response
body
in XML:
* <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
* <list>
* <portStatistics>
* <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
* <list>
* <portStatistics>
@@
-614,7
+626,8
@@
public class StatisticsNorthbound {
@ResponseCode(code = 404, condition = "The containerName is not found"),
@ResponseCode(code = 503, condition = "One or more of Controller Services are unavailable") })
public AllPortStatistics getPortStatistics(
@ResponseCode(code = 404, condition = "The containerName is not found"),
@ResponseCode(code = 503, condition = "One or more of Controller Services are unavailable") })
public AllPortStatistics getPortStatistics(
- @PathParam("containerName") String containerName) {
+ @PathParam("containerName") String containerName,
+ @QueryParam("_q") String queryString) {
if (!NorthboundUtils.isAuthorized(
getUserName(), containerName, Privilege.READ, this)) {
if (!NorthboundUtils.isAuthorized(
getUserName(), containerName, Privilege.READ, this)) {
@@
-642,7
+655,13
@@
public class StatisticsNorthbound {
PortStatistics portStat = new PortStatistics(node, stat);
statistics.add(portStat);
}
PortStatistics portStat = new PortStatistics(node, stat);
statistics.add(portStat);
}
- return new AllPortStatistics(statistics);
+
+ AllPortStatistics result = new AllPortStatistics(statistics);
+ if (queryString != null) {
+ queryContext.createQuery(queryString, AllPortStatistics.class)
+ .filter(result, PortStatistics.class);
+ }
+ return result;
}
/**
}
/**
@@
-666,7
+685,7
@@
public class StatisticsNorthbound {
* Request URL:
* http://localhost:8080/controller/nb/v2/statistics/default/port/node/OF/00:00:00:00:00:00:00:01
*
* Request URL:
* http://localhost:8080/controller/nb/v2/statistics/default/port/node/OF/00:00:00:00:00:00:00:01
*
- * Response in JSON:
+ * Response
body
in JSON:
* {
* "node": {
* "id":"00:00:00:00:00:00:00:01",
* {
* "node": {
* "id":"00:00:00:00:00:00:00:01",
@@
-720,7
+739,7
@@
public class StatisticsNorthbound {
* ]
* }
*
* ]
* }
*
- * Response in XML:
+ * Response
body
in XML:
* <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
* <nodePortStatistics>
* <node>
* <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
* <nodePortStatistics>
* <node>
@@
-829,7
+848,7
@@
public class StatisticsNorthbound {
* Request URL:
* http://localhost:8080/controller/nb/v2/statistics/default/table
*
* Request URL:
* http://localhost:8080/controller/nb/v2/statistics/default/table
*
- * Response in JSON:
+ * Response
body
in JSON:
* {
* "tableStatistics": [
* {
* {
* "tableStatistics": [
* {
@@
-848,7
+867,8
@@
public class StatisticsNorthbound {
* },
* "activeCount": "11",
* "lookupCount": "816",
* },
* "activeCount": "11",
* "lookupCount": "816",
- * "matchedCount": "220"
+ * "matchedCount": "220",
+ * "maximumEntries": "1000"
* },
* {
* ...another table
* },
* {
* ...another table
@@
-861,7
+881,7
@@
public class StatisticsNorthbound {
* ]
* }
*
* ]
* }
*
- * Response in XML:
+ * Response
body
in XML:
* <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
* <list>
* <tableStatistics>
* <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
* <list>
* <tableStatistics>
@@
-880,6
+900,7
@@
public class StatisticsNorthbound {
* <activeCount>12</activeCount>
* <lookupCount>10935</lookupCount>
* <matchedCount>10084</matchedCount>
* <activeCount>12</activeCount>
* <lookupCount>10935</lookupCount>
* <matchedCount>10084</matchedCount>
+ * <maximumEntries>1000</maximumEntries>
* </tableStatistic>
* <tableStatistic>
* <nodeTable>
* </tableStatistic>
* <tableStatistic>
* <nodeTable>
@@
-892,6
+913,7
@@
public class StatisticsNorthbound {
* <activeCount>0</activeCount>
* <lookupCount>0</lookupCount>
* <matchedCount>0</matchedCount>
* <activeCount>0</activeCount>
* <lookupCount>0</lookupCount>
* <matchedCount>0</matchedCount>
+ * <maximumEntries>0</maximumEntries>
* </tableStatistic>
* <tableStatistic>
* <nodeTable>
* </tableStatistic>
* <tableStatistic>
* <nodeTable>
@@
-904,6
+926,7
@@
public class StatisticsNorthbound {
* <activeCount>0</activeCount>
* <lookupCount>0</lookupCount>
* <matchedCount>0</matchedCount>
* <activeCount>0</activeCount>
* <lookupCount>0</lookupCount>
* <matchedCount>0</matchedCount>
+ * <maximumEntries>0</maximumEntries>
* </tableStatistic>
* </tableStatistics>
* <tableStatistics>
* </tableStatistic>
* </tableStatistics>
* <tableStatistics>
@@
-924,7
+947,8
@@
public class StatisticsNorthbound {
@ResponseCode(code = 404, condition = "The containerName is not found"),
@ResponseCode(code = 503, condition = "One or more of Controller Services are unavailable") })
public AllTableStatistics getTableStatistics(
@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) {
+ @PathParam("containerName") String containerName,
+ @QueryParam("_q") String queryString) {
if (!NorthboundUtils.isAuthorized(getUserName(), containerName, Privilege.READ, this)) {
throw new UnauthorizedException("User is not authorized to perform this operation on container "
if (!NorthboundUtils.isAuthorized(getUserName(), containerName, Privilege.READ, this)) {
throw new UnauthorizedException("User is not authorized to perform this operation on container "
@@
-952,7
+976,12
@@
public class StatisticsNorthbound {
TableStatistics tableStat = new TableStatistics(node, stat);
statistics.add(tableStat);
}
TableStatistics tableStat = new TableStatistics(node, stat);
statistics.add(tableStat);
}
- return new AllTableStatistics(statistics);
+ AllTableStatistics allstats = new AllTableStatistics(statistics);
+ if (queryString != null) {
+ queryContext.createQuery(queryString, AllTableStatistics.class)
+ .filter(allstats, TableStatistics.class);
+ }
+ return allstats;
}
/**
}
/**
@@
-974,7
+1003,7
@@
public class StatisticsNorthbound {
* Request URL:
* http://localhost:8080/controller/nb/v2/statistics/default/table/node/OF/00:00:00:00:00:00:00:01
*
* Request URL:
* http://localhost:8080/controller/nb/v2/statistics/default/table/node/OF/00:00:00:00:00:00:00:01
*
- * Response in JSON:
+ * Response
body
in JSON:
* {
* "node": {
* "id":"00:00:00:00:00:00:00:01",
* {
* "node": {
* "id":"00:00:00:00:00:00:00:01",
@@
-991,7
+1020,8
@@
public class StatisticsNorthbound {
* },
* "activeCount": "12",
* "lookupCount": "11382",
* },
* "activeCount": "12",
* "lookupCount": "11382",
- * "matchedCount": "10524"
+ * "matchedCount": "10524",
+ * "maximumEntries": "1000"
* },
* {
* "nodeTable": {
* },
* {
* "nodeTable": {
@@
-1003,12
+1033,13
@@
public class StatisticsNorthbound {
* },
* "activeCount": "0",
* "lookupCount": "0",
* },
* "activeCount": "0",
* "lookupCount": "0",
- * "matchedCount": "0"
+ * "matchedCount": "0",
+ * "maximumEntries": "0"
* }
* ]
* }
*
* }
* ]
* }
*
- * Response in XML:
+ * Response
body
in XML:
* <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
* <nodeTableStatistics>
* <node>
* <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
* <nodeTableStatistics>
* <node>
@@
-1026,6
+1057,7
@@
public class StatisticsNorthbound {
* <activeCount>12</activeCount>
* <lookupCount>10935</lookupCount>
* <matchedCount>10084</matchedCount>
* <activeCount>12</activeCount>
* <lookupCount>10935</lookupCount>
* <matchedCount>10084</matchedCount>
+ * <maximumEntries>1000</maximumEntries>
* </tableStatistic>
* <tableStatistic>
* <nodeTable>
* </tableStatistic>
* <tableStatistic>
* <nodeTable>
@@
-1038,6
+1070,7
@@
public class StatisticsNorthbound {
* <activeCount>0</activeCount>
* <lookupCount>0</lookupCount>
* <matchedCount>0</matchedCount>
* <activeCount>0</activeCount>
* <lookupCount>0</lookupCount>
* <matchedCount>0</matchedCount>
+ * <maximumEntries>0</maximumEntries>
* </tableStatistic>
* <tableStatistic>
* <nodeTable>
* </tableStatistic>
* <tableStatistic>
* <nodeTable>
@@
-1050,6
+1083,7
@@
public class StatisticsNorthbound {
* <activeCount>0</activeCount>
* <lookupCount>0</lookupCount>
* <matchedCount>0</matchedCount>
* <activeCount>0</activeCount>
* <lookupCount>0</lookupCount>
* <matchedCount>0</matchedCount>
+ * <maximumEntries>0</maximumEntries>
* </tableStatistic>
* </nodeTableStatistics>
*
* </tableStatistic>
* </nodeTableStatistics>
*