blob: 4b3c00f89c6458d3bc8a410f3ce4a02a7e7aca1b [file] [log] [blame]
HIGUCHI Yuta60a10142013-06-14 15:50:10 -07001package net.onrc.onos.ofcontroller.flowmanager.web;
Umesh Krishnaswamye7a682b2013-03-21 14:16:28 -07002
3import java.util.ArrayList;
4
HIGUCHI Yuta20514902013-06-12 11:24:16 -07005import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IFlowPath;
HIGUCHI Yuta60a10142013-06-14 15:50:10 -07006import net.onrc.onos.ofcontroller.flowmanager.IFlowService;
HIGUCHI Yuta356086e2013-06-12 15:21:19 -07007import net.onrc.onos.ofcontroller.util.FlowId;
Umesh Krishnaswamye7a682b2013-03-21 14:16:28 -07008
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")
Jonathan Hart01f2d272013-04-04 20:03:46 -070018 public ArrayList<IFlowPath> retrieve() {
19 ArrayList<IFlowPath> result = null;
Umesh Krishnaswamye7a682b2013-03-21 14:16:28 -070020
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}