Example usage for org.springframework.util StopWatch start

List of usage examples for org.springframework.util StopWatch start

Introduction

In this page you can find the example usage for org.springframework.util StopWatch start.

Prototype

public void start() throws IllegalStateException 

Source Link

Document

Start an unnamed task.

Usage

From source file:be.craftworkz.ucll.config.apidoc.SwaggerConfiguration.java

/**
 * Swagger Springfox configuration./*from www  .  j a  v a  2  s.c  o m*/
 */
@Bean
public Docket swaggerSpringfoxDocket() {
    log.debug("Starting Swagger");
    StopWatch watch = new StopWatch();
    watch.start();
    Docket docket = new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo())
            .genericModelSubstitutes(ResponseEntity.class).forCodeGeneration(true)
            .genericModelSubstitutes(ResponseEntity.class)
            .directModelSubstitute(org.joda.time.LocalDate.class, String.class)
            .directModelSubstitute(org.joda.time.LocalDateTime.class, Date.class)
            .directModelSubstitute(org.joda.time.DateTime.class, Date.class)
            .directModelSubstitute(java.time.LocalDate.class, String.class)
            .directModelSubstitute(java.time.ZonedDateTime.class, Date.class)
            .directModelSubstitute(java.time.LocalDateTime.class, Date.class).select()
            .paths(regex(DEFAULT_INCLUDE_PATTERN)).build();
    watch.stop();
    log.debug("Started Swagger in {} ms", watch.getTotalTimeMillis());
    return docket;
}

From source file:io.github.jhipster.config.liquibase.AsyncSpringLiquibase.java

protected void initDb() throws LiquibaseException {
    StopWatch watch = new StopWatch();
    watch.start();
    super.afterPropertiesSet();
    watch.stop();//from w  w w.ja  va  2  s  .  c  o m
    logger.debug("Liquibase has updated your database in {} ms", watch.getTotalTimeMillis());
    if (watch.getTotalTimeMillis() > 5_000) {
        logger.warn("Warning, Liquibase took more than 5 seconds to start up!");
    }
}

From source file:com.springboot.demo.config.apidoc.SwaggerConfiguration.java

/**
 * Swagger Springfox configuration./*from   ww  w  .ja  v a  2s  .  co  m*/
 */
@Bean
public Docket swaggerSpringfoxDocket() {
    log.info("Starting Swagger");
    StopWatch watch = new StopWatch();
    watch.start();
    Docket docket = new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo())
            .genericModelSubstitutes(ResponseEntity.class).forCodeGeneration(true)
            .genericModelSubstitutes(ResponseEntity.class)
            .directModelSubstitute(org.joda.time.LocalDate.class, String.class)
            .directModelSubstitute(org.joda.time.LocalDateTime.class, Date.class)
            .directModelSubstitute(org.joda.time.DateTime.class, Date.class)
            .directModelSubstitute(java.time.LocalDate.class, String.class)
            .directModelSubstitute(java.time.ZonedDateTime.class, Date.class)
            .directModelSubstitute(java.time.LocalDateTime.class, Date.class).select()
            .paths(regex(DEFAULT_INCLUDE_PATTERN)).build();
    watch.stop();
    log.info("Started Swagger in {} ms", watch.getTotalTimeMillis());
    return docket;
}

From source file:de.accso.performancetesting.tools.PerformanceLogger.java

private Object measureTime(ProceedingJoinPoint thisJoinPoint, String tag) throws Throwable {
    StopWatch sp = new StopWatch();
    sp.start();
    Object result = thisJoinPoint.proceed();
    sp.stop();/*  w  ww  . j av  a2 s  . c om*/
    logger.info(append("durationinmillis", sp.getTotalTimeMillis()).and(append("tag", tag))
            .and(append("req_id", CTX_HOLDER.get().reqId)).and(append("url", getCtxUrl()))
            .and(append("servicename", thisJoinPoint.getTarget().getClass().getCanonicalName() + "."
                    + thisJoinPoint.getSignature().getName())),
            "Performance");

    return result;
}

From source file:org.zalando.zmon.actuator.ZmonMetricsFilter.java

@Override
protected void doFilterInternal(final HttpServletRequest request, final HttpServletResponse response,
        final FilterChain chain) throws ServletException, IOException {
    StopWatch stopWatch = new StopWatch();
    stopWatch.start();

    String path = new UrlPathHelper().getPathWithinApplication(request);
    int status = HttpStatus.INTERNAL_SERVER_ERROR.value();
    try {/*from  w ww  .  j  av a2s  .  co m*/
        chain.doFilter(request, response);
        status = getStatus(response);
    } finally {
        stopWatch.stop();
        metricsWrapper.recordClientRequestMetrics(request, path, status, stopWatch.getTotalTimeMillis());
    }
}

From source file:no.arkivlab.hioa.nikita.webapp.spring.SwaggerConfig.java

@Bean
public Docket swaggerDocket() { // @formatter:off

    logger.debug("Starting Swagger");
    StopWatch watch = new StopWatch();
    watch.start();
    Contact contact = new Contact(webappProperties.getSwagger().getContactName(),
            webappProperties.getSwagger().getContactUrl(), webappProperties.getSwagger().getContactEmail());

    ApiInfo apiInfo = new ApiInfo(webappProperties.getSwagger().getTitle(),
            webappProperties.getSwagger().getDescription(), webappProperties.getSwagger().getVersion(),
            webappProperties.getSwagger().getTermsOfServiceUrl(), contact,
            webappProperties.getSwagger().getLicense(), webappProperties.getSwagger().getLicenseUrl());

    Docket docket = new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo).forCodeGeneration(true)
            .genericModelSubstitutes(ResponseEntity.class).ignoredParameterTypes(Pageable.class)
            .ignoredParameterTypes(java.sql.Date.class)
            .directModelSubstitute(java.time.LocalDate.class, java.sql.Date.class)
            .directModelSubstitute(java.time.ZonedDateTime.class, Date.class)
            .directModelSubstitute(java.time.LocalDateTime.class, Date.class).select()
            .apis(RequestHandlerSelectors.any()).paths(PathSelectors.any()).build()
            .pathMapping(Constants.HATEOAS_API_PATH).genericModelSubstitutes(ResponseEntity.class);

    watch.stop();// www . j a v  a  2  s  .com
    logger.debug("Started Swagger in {} ms", watch.getTotalTimeMillis());
    return docket;
    // @formatter:on
}

From source file:com.persistent.cloudninja.scheduler.TenantDeletionTask.java

@Override
public boolean execute() {
    boolean retval = true;
    try {// w  w  w  . j a  va 2s .co  m
        TenantDeletionQueue tntDeletionQueue = (TenantDeletionQueue) getWorkQueue();
        String tenantId = tntDeletionQueue.dequeue(SchedulerSettings.MessageVisibilityTimeout);
        if (tenantId == null) {
            LOGGER.debug("Msg is null");
            retval = false;
        } else {
            StopWatch watch = new StopWatch();
            watch.start();
            provisioningService.removeTenant(tenantId);
            LOGGER.debug("tenant deleted :" + tenantId);
            watch.stop();
            taskCompletionDao.updateTaskCompletionDetails(watch.getTotalTimeSeconds(), "DeleteTenant",
                    "Tenant Id " + tenantId + " is deleted.");
        }
    } catch (StorageException e) {
        retval = false;
        LOGGER.error(e.getMessage(), e);
    }
    return retval;
}

From source file:io.github.jhipster.config.apidoc.SwaggerConfiguration.java

/**
 * Swagger Springfox configuration.// w w  w.  java 2  s  .com
 *
 * @param jHipsterProperties the properties of the application
 * @return the Swagger Springfox configuration
 */
@Bean
public Docket swaggerSpringfoxDocket(JHipsterProperties jHipsterProperties) {
    log.debug("Starting Swagger");
    StopWatch watch = new StopWatch();
    watch.start();
    Contact contact = new Contact(jHipsterProperties.getSwagger().getContactName(),
            jHipsterProperties.getSwagger().getContactUrl(), jHipsterProperties.getSwagger().getContactEmail());

    ApiInfo apiInfo = new ApiInfo(jHipsterProperties.getSwagger().getTitle(),
            jHipsterProperties.getSwagger().getDescription(), jHipsterProperties.getSwagger().getVersion(),
            jHipsterProperties.getSwagger().getTermsOfServiceUrl(), contact,
            jHipsterProperties.getSwagger().getLicense(), jHipsterProperties.getSwagger().getLicenseUrl());

    Docket docket = new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo).forCodeGeneration(true)
            .directModelSubstitute(java.nio.ByteBuffer.class, String.class)
            .genericModelSubstitutes(ResponseEntity.class).select()
            .paths(regex(jHipsterProperties.getSwagger().getDefaultIncludePattern())).build();
    watch.stop();
    log.debug("Started Swagger in {} ms", watch.getTotalTimeMillis());
    return docket;
}

From source file:io.tronbot.graphql.actuator.config.apidoc.SwaggerConfiguration.java

/**
 * Swagger Springfox configuration.//  ww w.j a  v a2 s  .c o  m
 *
 * @param jHipsterProperties the properties of the application
 * @return the Swagger Springfox configuration
 */
@Bean
public Docket swaggerSpringfoxDocket(JHipsterProperties jHipsterProperties) {
    log.debug("Starting Swagger");
    StopWatch watch = new StopWatch();
    watch.start();
    Contact contact = new Contact(jHipsterProperties.getSwagger().getContactName(),
            jHipsterProperties.getSwagger().getContactUrl(), jHipsterProperties.getSwagger().getContactEmail());

    ApiInfo apiInfo = new ApiInfo(jHipsterProperties.getSwagger().getTitle(),
            jHipsterProperties.getSwagger().getDescription(), jHipsterProperties.getSwagger().getVersion(),
            jHipsterProperties.getSwagger().getTermsOfServiceUrl(), contact,
            jHipsterProperties.getSwagger().getLicense(), jHipsterProperties.getSwagger().getLicenseUrl());

    List<Parameter> globalOperationParameters = new ArrayList<>();
    globalOperationParameters.add(new ParameterBuilder().parameterType("header").description("JWT Token")
            .modelRef(new ModelRef("string")).name(JWTConfigurer.AUTHORIZATION_HEADER)
            .defaultValue(JWTConfigurer.AUTHORIZATION_TOKEN_SCHEMA + authenticationService.authJWT())
            .required(false).build());

    Docket docket = new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo).forCodeGeneration(true)
            .genericModelSubstitutes(ResponseEntity.class).ignoredParameterTypes(java.sql.Date.class)
            .directModelSubstitute(java.time.LocalDate.class, java.sql.Date.class)
            .directModelSubstitute(java.time.ZonedDateTime.class, Date.class)
            .directModelSubstitute(java.time.LocalDateTime.class, Date.class)
            .globalOperationParameters(globalOperationParameters).select().paths(regex(DEFAULT_INCLUDE_PATTERN))
            .build();

    watch.stop();
    log.debug("Started Swagger in {} ms", watch.getTotalTimeMillis());
    return docket;
}

From source file:com.agileapes.webexport.concurrent.Worker.java

@SuppressWarnings("unchecked")
@Override/*from  ww w .  j  a  va2  s  . co  m*/
public void run() {
    synchronized (this) {
        while (true) {
            try {
                logger.info("Waiting for a task.");
                wait();
            } catch (InterruptedException e) {
                logger.warn(getName() + " was interrupted.");
                manager.interrupted(this);
                return;
            }
            try {
                final StopWatch watch = new StopWatch();
                watch.start();
                perform();
                watch.stop();
                logger.info("Action performed in " + watch.getTotalTimeMillis() + "ms");
            } catch (Throwable e) {
                logger.error(e);
                manager.fail(this);
            }
            logger.info(getName() + " is done.");
            manager.done(this);
        }
    }
}