HIGUCHI Yuta | 60a1014 | 2013-06-14 15:50:10 -0700 | [diff] [blame^] | 1 | package net.onrc.onos.ofcontroller.flowmanager.web; |
Umesh Krishnaswamy | e7a682b | 2013-03-21 14:16:28 -0700 | [diff] [blame] | 2 | |
| 3 | import java.util.ArrayList; |
| 4 | |
HIGUCHI Yuta | 2051490 | 2013-06-12 11:24:16 -0700 | [diff] [blame] | 5 | import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IFlowPath; |
HIGUCHI Yuta | 60a1014 | 2013-06-14 15:50:10 -0700 | [diff] [blame^] | 6 | import net.onrc.onos.ofcontroller.flowmanager.IFlowService; |
HIGUCHI Yuta | 356086e | 2013-06-12 15:21:19 -0700 | [diff] [blame] | 7 | import net.onrc.onos.ofcontroller.util.FlowId; |
Umesh Krishnaswamy | e7a682b | 2013-03-21 14:16:28 -0700 | [diff] [blame] | 8 | |
| 9 | import org.restlet.resource.Get; |
| 10 | import org.restlet.resource.ServerResource; |
| 11 | import org.slf4j.Logger; |
| 12 | import org.slf4j.LoggerFactory; |
| 13 | |
| 14 | public class GetSummaryFlowsResource extends ServerResource { |
Umesh Krishnaswamy | 57a32a9 | 2013-03-21 14:21:15 -0700 | [diff] [blame] | 15 | protected static Logger log = LoggerFactory.getLogger(GetSummaryFlowsResource.class); |
Umesh Krishnaswamy | e7a682b | 2013-03-21 14:16:28 -0700 | [diff] [blame] | 16 | |
| 17 | @Get("json") |
Jonathan Hart | 01f2d27 | 2013-04-04 20:03:46 -0700 | [diff] [blame] | 18 | public ArrayList<IFlowPath> retrieve() { |
| 19 | ArrayList<IFlowPath> result = null; |
Umesh Krishnaswamy | e7a682b | 2013-03-21 14:16:28 -0700 | [diff] [blame] | 20 | |
Umesh Krishnaswamy | 57a32a9 | 2013-03-21 14:21:15 -0700 | [diff] [blame] | 21 | FlowId flowId; |
| 22 | int maxFlows = 0; |
| 23 | |
Umesh Krishnaswamy | e7a682b | 2013-03-21 14:16:28 -0700 | [diff] [blame] | 24 | IFlowService flowService = (IFlowService)getContext().getAttributes().get(IFlowService.class.getCanonicalName()); |
| 25 | |
| 26 | if (flowService == null) { |
| 27 | log.debug("ONOS Flow Service not found"); |
| 28 | return result; |
| 29 | } |
| 30 | |
| 31 | // Extract the arguments |
Umesh Krishnaswamy | 57a32a9 | 2013-03-21 14:21:15 -0700 | [diff] [blame] | 32 | String flowIdStr = (String) getRequestAttributes().get("flow-id"); |
| 33 | String maxFlowStr = (String) getRequestAttributes().get("max-flows"); |
| 34 | log.debug("Get Summary Flows starting flow-id: " + flowIdStr + " max-flows: " + maxFlowStr); |
| 35 | |
| 36 | flowId = new FlowId(flowIdStr); |
| 37 | maxFlows = Integer.parseInt(maxFlowStr); |
| 38 | if (maxFlows < 0) maxFlows = 0; |
Umesh Krishnaswamy | e7a682b | 2013-03-21 14:16:28 -0700 | [diff] [blame] | 39 | |
Umesh Krishnaswamy | 57a32a9 | 2013-03-21 14:21:15 -0700 | [diff] [blame] | 40 | result = flowService.getAllFlowsSummary(flowId, maxFlows); |
Umesh Krishnaswamy | e7a682b | 2013-03-21 14:16:28 -0700 | [diff] [blame] | 41 | |
| 42 | return result; |
| 43 | } |
| 44 | } |