blob: a2ee5d49b7f0861072e339ea7993cb68da00371e [file] [log] [blame]
Umesh Krishnaswamye7a682b2013-03-21 14:16:28 -07001package net.floodlightcontroller.flowcache.web;
2
3import java.util.ArrayList;
4
Umesh Krishnaswamye7a682b2013-03-21 14:16:28 -07005import net.floodlightcontroller.util.FlowId;
Jonathan Hart01f2d272013-04-04 20:03:46 -07006import net.floodlightcontroller.util.FlowPath;
HIGUCHI Yuta20514902013-06-12 11:24:16 -07007import net.onrc.onos.ofcontroller.core.INetMapTopologyObjects.IFlowPath;
HIGUCHI Yutaedf81d72013-06-12 12:06:57 -07008import net.onrc.onos.ofcontroller.flowcache.IFlowService;
Umesh Krishnaswamye7a682b2013-03-21 14:16:28 -07009
10import org.restlet.resource.Get;
11import org.restlet.resource.ServerResource;
12import org.slf4j.Logger;
13import org.slf4j.LoggerFactory;
14
15public class GetSummaryFlowsResource extends ServerResource {
Umesh Krishnaswamy57a32a92013-03-21 14:21:15 -070016 protected static Logger log = LoggerFactory.getLogger(GetSummaryFlowsResource.class);
Umesh Krishnaswamye7a682b2013-03-21 14:16:28 -070017
18 @Get("json")
Jonathan Hart01f2d272013-04-04 20:03:46 -070019 public ArrayList<IFlowPath> retrieve() {
20 ArrayList<IFlowPath> result = null;
Umesh Krishnaswamye7a682b2013-03-21 14:16:28 -070021
Umesh Krishnaswamy57a32a92013-03-21 14:21:15 -070022 FlowId flowId;
23 int maxFlows = 0;
24
Umesh Krishnaswamye7a682b2013-03-21 14:16:28 -070025 IFlowService flowService = (IFlowService)getContext().getAttributes().get(IFlowService.class.getCanonicalName());
26
27 if (flowService == null) {
28 log.debug("ONOS Flow Service not found");
29 return result;
30 }
31
32 // Extract the arguments
Umesh Krishnaswamy57a32a92013-03-21 14:21:15 -070033 String flowIdStr = (String) getRequestAttributes().get("flow-id");
34 String maxFlowStr = (String) getRequestAttributes().get("max-flows");
35 log.debug("Get Summary Flows starting flow-id: " + flowIdStr + " max-flows: " + maxFlowStr);
36
37 flowId = new FlowId(flowIdStr);
38 maxFlows = Integer.parseInt(maxFlowStr);
39 if (maxFlows < 0) maxFlows = 0;
Umesh Krishnaswamye7a682b2013-03-21 14:16:28 -070040
Umesh Krishnaswamy57a32a92013-03-21 14:21:15 -070041 result = flowService.getAllFlowsSummary(flowId, maxFlows);
Umesh Krishnaswamye7a682b2013-03-21 14:16:28 -070042
43 return result;
44 }
45}