Search in sources :

Example 6 with Stopwatch

use of org.n52.web.common.Stopwatch in project arctic-sea by 52North.

the class Service method options.

@RequestMapping(method = RequestMethod.OPTIONS)
private void options(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
    Stopwatch stopwatch = Stopwatch.createStarted();
    long currentCount = logRequest(request);
    Binding binding = null;
    try {
        binding = getBinding(request);
        binding.doOptionsOperation(request, response);
    } catch (HTTPException exception) {
        if (exception.getStatus() == HTTPStatus.METHOD_NOT_ALLOWED && binding != null) {
            doDefaultOptions(binding, request, response);
        } else {
            onHttpException(request, response, exception);
        }
    } finally {
        logResponse(request, response, currentCount, stopwatch);
    }
}
Also used : Binding(org.n52.iceland.binding.Binding) HTTPException(org.n52.iceland.exception.HTTPException) Stopwatch(com.google.common.base.Stopwatch) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 7 with Stopwatch

use of org.n52.web.common.Stopwatch in project arctic-sea by 52North.

the class Service method delete.

@RequestMapping(method = RequestMethod.DELETE)
public void delete(HttpServletRequest request, HttpServletResponse response) throws IOException {
    Stopwatch stopwatch = Stopwatch.createStarted();
    long currentCount = logRequest(request);
    try {
        getBinding(request).doDeleteOperation(request, response);
    } catch (HTTPException exception) {
        onHttpException(request, response, exception);
    } finally {
        logResponse(request, response, currentCount, stopwatch);
    }
}
Also used : HTTPException(org.n52.iceland.exception.HTTPException) Stopwatch(com.google.common.base.Stopwatch) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 8 with Stopwatch

use of org.n52.web.common.Stopwatch in project series-rest-api by 52North.

the class ParameterController method getCollection.

@Override
public ModelAndView getCollection(HttpServletResponse response, String locale, MultiValueMap<String, String> query) {
    Stopwatch stopwatch = Stopwatch.startStopwatch();
    IoParameters parameters = createParameters(query, locale, response);
    try {
        LOGGER.debug("getCollection() with query '{}'", parameters);
        preparePagingHeaders(parameters, response);
        return createModelAndView(getCollection(parameters), parameters);
    } finally {
        LOGGER.debug("Processing request took {} seconds.", stopwatch.stopInSeconds());
    }
}
Also used : Stopwatch(org.n52.web.common.Stopwatch) IoParameters(org.n52.io.request.IoParameters)

Example 9 with Stopwatch

use of org.n52.web.common.Stopwatch in project series-rest-api by 52North.

the class ParameterController method getCollection.

@Override
public ModelAndView getCollection(String locale, MultiValueMap<String, String> query) {
    RequestUtils.overrideQueryLocaleWhenSet(locale, query);
    IoParameters queryMap = QueryParameters.createFromQuery(query);
    LOGGER.debug("getCollection() with query '{}'", queryMap);
    if (queryMap.isExpanded()) {
        Stopwatch stopwatch = Stopwatch.startStopwatch();
        OutputCollection<T> result = addExtensionInfos(parameterService.getExpandedParameters(queryMap));
        LOGGER.debug("Processing request took {} seconds.", stopwatch.stopInSeconds());
        return createModelAndView(result);
    } else {
        OutputCollection<T> results = parameterService.getCondensedParameters(queryMap);
        return createModelAndView(results);
    }
}
Also used : Stopwatch(org.n52.web.common.Stopwatch) IoParameters(org.n52.io.request.IoParameters)

Example 10 with Stopwatch

use of org.n52.web.common.Stopwatch in project series-rest-api by 52North.

the class PreRenderingJob method execute.

@Override
public void execute(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.getSeriesStyles();
    for (RenderingConfig config : phenomenonStyles) {
        Map<String, String> parameters = new HashMap<>();
        parameters.put("phenomenon", config.getId());
        IoParameters query = QueryParameters.createFromQuery(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());
}
Also used : JobDetail(org.quartz.JobDetail) JobDataMap(org.quartz.JobDataMap) HashMap(java.util.HashMap) Stopwatch(org.n52.web.common.Stopwatch) IoParameters(org.n52.io.request.IoParameters) RenderingConfig(org.n52.io.PrerenderingJobConfig.RenderingConfig)

Aggregations

Stopwatch (org.n52.web.common.Stopwatch)10 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)9 IoParameters (org.n52.io.request.IoParameters)8 Stopwatch (com.google.common.base.Stopwatch)5 HTTPException (org.n52.iceland.exception.HTTPException)5 ModelAndView (org.springframework.web.servlet.ModelAndView)4 HashMap (java.util.HashMap)2 ResourceNotFoundException (org.n52.web.exception.ResourceNotFoundException)2 JobDataMap (org.quartz.JobDataMap)2 JobDetail (org.quartz.JobDetail)2 Binding (org.n52.iceland.binding.Binding)1 OutgoingResponseEvent (org.n52.iceland.event.events.OutgoingResponseEvent)1 RenderingConfig (org.n52.io.PrerenderingJobConfig.RenderingConfig)1 GeneralizingQuantityService (org.n52.io.quantity.generalize.GeneralizingQuantityService)1 Data (org.n52.io.response.dataset.Data)1 QuantityData (org.n52.io.response.dataset.quantity.QuantityData)1 RenderingConfig (org.n52.io.task.PreRenderingConfig.RenderingConfig)1 GeneralizingQuantityService (org.n52.io.type.quantity.generalize.GeneralizingQuantityService)1 OffsetBasedPagination (org.n52.web.common.OffsetBasedPagination)1 Paginated (org.n52.web.common.Paginated)1