blob: 7a928c9ec4d2b1325fe63b34e159db1b2528aab0 [file] [log] [blame]
Umesh Krishnaswamye7a682b2013-03-21 14:16:28 -07001package net.floodlightcontroller.flowcache.web;
2
3import java.util.ArrayList;
4
5import net.floodlightcontroller.flowcache.IFlowService;
6import net.floodlightcontroller.util.FlowPath;
7import net.floodlightcontroller.util.FlowId;
8
9import org.restlet.resource.Get;
10import org.restlet.resource.ServerResource;
11import org.slf4j.Logger;
12import org.slf4j.LoggerFactory;
13
14public class GetSummaryFlowsResource extends ServerResource {
Umesh Krishnaswamy57a32a92013-03-21 14:21:15 -070015 protected static Logger log = LoggerFactory.getLogger(GetSummaryFlowsResource.class);
Umesh Krishnaswamye7a682b2013-03-21 14:16:28 -070016
17 @Get("json")
18 public ArrayList<FlowPath> retrieve() {
19 ArrayList<FlowPath> result = null;
20
Umesh Krishnaswamy57a32a92013-03-21 14:21:15 -070021 FlowId flowId;
22 int maxFlows = 0;
23
Umesh Krishnaswamye7a682b2013-03-21 14:16:28 -070024 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 Krishnaswamy57a32a92013-03-21 14:21:15 -070032 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 Krishnaswamye7a682b2013-03-21 14:16:28 -070039
Umesh Krishnaswamy57a32a92013-03-21 14:21:15 -070040 result = flowService.getAllFlowsSummary(flowId, maxFlows);
Umesh Krishnaswamye7a682b2013-03-21 14:16:28 -070041
42 return result;
43 }
44}