Open Kilda Java Documentation
StatsController.java
Go to the documentation of this file.
1 package org.openkilda.controller;
2 
3 import java.util.List;
4 
5 import org.apache.log4j.Logger;
12 import org.springframework.beans.factory.annotation.Autowired;
13 import org.springframework.http.HttpStatus;
14 import org.springframework.http.MediaType;
15 import org.springframework.stereotype.Controller;
16 import org.springframework.web.bind.annotation.PathVariable;
17 import org.springframework.web.bind.annotation.RequestBody;
18 import org.springframework.web.bind.annotation.RequestMapping;
19 import org.springframework.web.bind.annotation.RequestMethod;
20 import org.springframework.web.bind.annotation.ResponseBody;
21 import org.springframework.web.bind.annotation.ResponseStatus;
22 
23 @Controller
24 @RequestMapping(value = "/stats")
25 public class StatsController {
26 
27  private static final Logger LOGGER = Logger.getLogger(StatsController.class);
28 
29  @Autowired
30  private StatsService statsService;
31 
37  @RequestMapping(value = "/metrics")
38  @ResponseStatus(HttpStatus.OK)
39  public @ResponseBody List<String> getMetricDetail() {
40  return Metrics.list();
41  }
42 
43 
54  @RequestMapping(
55  value = "isl/{srcSwitch}/{srcPort}/{dstSwitch}/{dstPort}/{startDate}/{endDate}/{downsample}/{metric}",
56  method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
57  @ResponseStatus(HttpStatus.OK)
59  public @ResponseBody String getIslStats(@PathVariable String srcSwitch,
60  @PathVariable String srcPort, @PathVariable String dstSwitch,
61  @PathVariable String dstPort, @PathVariable String startDate,
62  @PathVariable String endDate, @PathVariable String downsample,
63  @PathVariable String metric) throws Exception {
64 
65  LOGGER.info("Inside StatsController method getIslStats ");
66  return statsService.getSwitchIslStats(startDate, endDate, downsample, srcSwitch,
67  srcPort, dstSwitch, dstPort, metric);
68 
69  }
70 
82  @RequestMapping(
83  value = "switchid/{switchid}/port/{port}/{startDate}/{endDate}/{downsample}/{metric}",
84  method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
85  @ResponseStatus(HttpStatus.OK)
87  public @ResponseBody String getPortStats(@PathVariable String switchid,
88  @PathVariable String port, @PathVariable String startDate,
89  @PathVariable String endDate, @PathVariable String downsample,
90  @PathVariable String metric) throws Exception {
91 
92  LOGGER.info("Inside StatsController method getPortStats ");
93  return statsService.getSwitchPortStats(startDate, endDate, downsample, switchid, port,
94  metric);
95 
96  }
97 
108  @RequestMapping(value = "flowid/{flowid}/{startDate}/{endDate}/{downsample}/{metric}",
109  method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
110  @ResponseStatus(HttpStatus.OK)
112  public @ResponseBody String getFlowStats(@PathVariable String flowid,
113  @PathVariable String startDate, @PathVariable String endDate,
114  @PathVariable String downsample, @PathVariable String metric) throws Exception {
115 
116  LOGGER.info("Inside StatsController method getFlowStats ");
117  return statsService.getFlowStats(startDate, endDate, downsample, flowid, metric);
118  }
119 
120 
135  @RequestMapping(
136  value = "isl/losspackets/{srcSwitch}/{srcPort}/{dstSwitch}/{dstPort}/{startDate}/{endDate}/{downsample}/{metric}",
137  method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
138  @ResponseStatus(HttpStatus.OK)
140  public @ResponseBody String getIslLossPacketStats(@PathVariable String srcSwitch,
141  @PathVariable String srcPort, @PathVariable String dstSwitch,
142  @PathVariable String dstPort, @PathVariable String startDate,
143  @PathVariable String endDate, @PathVariable String downsample,
144  @PathVariable String metric) throws Exception {
145 
146  LOGGER.info("Inside StatsController method getIslLossPacketStats ");
147  return statsService.getSwitchIslLossPacketStats(startDate, endDate, downsample, srcSwitch,
148  srcPort, dstSwitch, dstPort, metric);
149  }
150 
162  @RequestMapping(
163  value = "flow/losspackets/{flowid}/{startDate}/{endDate}/{downsample}/{direction}",
164  method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
165  @ResponseStatus(HttpStatus.OK)
167  public @ResponseBody String getFlowLossPacketStats(@PathVariable String flowid,
168  @PathVariable String startDate, @PathVariable String endDate,
169  @PathVariable String downsample, @PathVariable String direction) throws Exception {
170 
171  LOGGER.info("Inside StatsController method getFlowLossPacketStats ");
172  return statsService.getFlowLossPacketStats(startDate, endDate, downsample, flowid,
173  direction);
174  }
175 
183  @RequestMapping(value = "flowpath", method = RequestMethod.POST,
184  produces = MediaType.APPLICATION_JSON_VALUE)
185  @ResponseStatus(HttpStatus.OK)
187  public @ResponseBody String getFlowPathStat(@RequestBody FlowPathStats flowPathStats)
188  throws Exception {
189 
190  LOGGER.info("Inside StatsController method getFlowPathStat ");
191  return statsService.getFlowPathStats(flowPathStats);
192  }
193 
204  @RequestMapping(value = "switchports/{switchid}/{startDate}/{endDate}/{downsample}",
205  method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
206  @ResponseStatus(HttpStatus.OK)
208  public @ResponseBody List<PortInfo> getSwitchPortsStats(@PathVariable String switchid,
209  @PathVariable String startDate, @PathVariable String endDate,
210  @PathVariable String downsample) throws Exception {
211 
212  LOGGER.info("Inside StatsController method getSwitchPortsStats ");
213  return statsService.getSwitchPortsStats(startDate, endDate, downsample, switchid);
214  }
215 }
String getFlowPathStat(@RequestBody FlowPathStats flowPathStats)
value
Definition: nodes.py:62
String getFlowStats(@PathVariable String flowid, @PathVariable String startDate, @PathVariable String endDate, @PathVariable String downsample, @PathVariable String metric)
String getPortStats(@PathVariable String switchid, @PathVariable String port, @PathVariable String startDate, @PathVariable String endDate, @PathVariable String downsample, @PathVariable String metric)
String getIslStats(@PathVariable String srcSwitch, @PathVariable String srcPort, @PathVariable String dstSwitch, @PathVariable String dstPort, @PathVariable String startDate, @PathVariable String endDate, @PathVariable String downsample, @PathVariable String metric)
String getFlowLossPacketStats(@PathVariable String flowid, @PathVariable String startDate, @PathVariable String endDate, @PathVariable String downsample, @PathVariable String direction)
String getIslLossPacketStats(@PathVariable String srcSwitch, @PathVariable String srcPort, @PathVariable String dstSwitch, @PathVariable String dstPort, @PathVariable String startDate, @PathVariable String endDate, @PathVariable String downsample, @PathVariable String metric)
List< PortInfo > getSwitchPortsStats(@PathVariable String switchid, @PathVariable String startDate, @PathVariable String endDate, @PathVariable String downsample)