use of org.n52.web.common.Stopwatch in project series-rest-api by 52North.
the class PreRenderingJob method executeInternal.
@Override
protected void executeInternal(JobExecutionContext context) throws JobExecutionException {
if (interrupted) {
return;
}
LOGGER.info("Start prerendering task");
final Stopwatch stopwatch = Stopwatch.startStopwatch();
final JobDetail details = context.getJobDetail();
JobDataMap jobDataMap = details.getJobDataMap();
taskConfigPrerendering = readJobConfig(jobDataMap.getString(JOB_DATA_CONFIG_FILE));
webappFolder = jobDataMap.getString(JOB_DATA_WEBAPP_FOLDER);
List<RenderingConfig> phenomenonStyles = taskConfigPrerendering.getPhenomenonStyles();
List<RenderingConfig> styles = taskConfigPrerendering.getDatasetStyles();
for (RenderingConfig config : phenomenonStyles) {
Map<String, String> parameters = new HashMap<>();
parameters.put(Parameters.PHENOMENA, config.getId());
parameters.put(Parameters.FILTER_DATASET_TYPES, "timeseries");
parameters.put(Parameters.FILTER_OBSERVATION_TYPES, "simple");
parameters.put(Parameters.FILTER_VALUE_TYPES, "quantity");
IoParameters query = IoParameters.createFromSingleValueMap(parameters);
for (DatasetOutput<?> metadata : datasetService.getCondensedParameters(query)) {
String timeseriesId = metadata.getId();
renderConfiguredIntervals(timeseriesId, config);
if (interrupted) {
return;
}
}
}
for (RenderingConfig config : styles) {
renderConfiguredIntervals(config.getId(), config);
if (interrupted) {
return;
}
}
LOGGER.debug("prerendering took '{}'", stopwatch.stopInSeconds());
}
use of org.n52.web.common.Stopwatch in project series-rest-api by 52North.
the class StationsParameterController method getItem.
@Override
@RequestMapping(value = "/{item}", method = RequestMethod.GET)
public ModelAndView getItem(@PathVariable("item") String procedureId, @RequestHeader(value = Parameters.HttpHeader.ACCEPT_LANGUAGE, required = false) String httpLocale, @RequestParam(required = false) MultiValueMap<String, String> query, HttpServletResponse response) {
IoParameters parameters = createParameters(query, httpLocale, response);
// TODO check parameters and throw BAD_REQUEST if invalid
Stopwatch stopwatch = Stopwatch.startStopwatch();
Object result = parameterService.getParameter(procedureId, parameters);
logRequestTime(stopwatch);
if (result == null) {
throw new ResourceNotFoundException("Found no station with given id.");
}
return new ModelAndView().addObject(result);
}
use of org.n52.web.common.Stopwatch in project series-rest-api by 52North.
the class StationsParameterController method getCollection.
@Override
@RequestMapping(method = RequestMethod.GET)
public ModelAndView getCollection(HttpServletResponse response, @RequestHeader(value = Parameters.HttpHeader.ACCEPT_LANGUAGE, required = false) String httpLocale, @RequestParam(required = false) MultiValueMap<String, String> query) {
IoParameters map = createParameters(query, httpLocale, response).respectBackwardsCompatibility();
OutputCollection<?> result;
if (map.isExpanded()) {
Stopwatch stopwatch = Stopwatch.startStopwatch();
result = parameterService.getExpandedParameters(map);
logRequestTime(stopwatch);
} else {
Stopwatch stopwatch = Stopwatch.startStopwatch();
result = parameterService.getCondensedParameters(map);
logRequestTime(stopwatch);
}
// XXX refactor (is redundant here)
if (map.containsParameter("limit") || map.containsParameter("offset")) {
Long elementcount = this.counter.getStationCount();
if (elementcount != -1) {
OffsetBasedPagination obp = new OffsetBasedPagination(map.getOffset(), map.getLimit());
Paginated paginated = new Paginated(obp, elementcount);
String collectionHref = createCollectionUrl(getCollectionName());
PageLinkUtil.addPagingHeaders(collectionHref, response, paginated);
}
}
return new ModelAndView().addObject(result.getItems());
}
use of org.n52.web.common.Stopwatch in project series-rest-api by 52North.
the class TimeseriesDataController method getTimeseriesData.
private DataCollection<Data<QuantityValue>> getTimeseriesData(IoParameters parameters) {
Stopwatch stopwatch = Stopwatch.startStopwatch();
DataCollection<Data<QuantityValue>> timeseriesData = parameters.isGeneralize() ? new GeneralizingQuantityService(timeseriesDataService).getData(parameters) : timeseriesDataService.getData(parameters);
LOGGER.debug("Processing request took {} seconds.", stopwatch.stopInSeconds());
return timeseriesData;
}
use of org.n52.web.common.Stopwatch in project arctic-sea by 52North.
the class Service method get.
@RequestMapping(method = RequestMethod.GET)
public void get(HttpServletRequest request, HttpServletResponse response) throws IOException {
Stopwatch stopwatch = Stopwatch.createStarted();
long currentCount = logRequest(request);
try {
getBinding(request).doGetOperation(request, response);
} catch (HTTPException exception) {
onHttpException(request, response, exception);
} finally {
logResponse(request, response, currentCount, stopwatch);
}
}
Aggregations