Example usage for org.springframework.util StopWatch stop

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

Introduction

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

Prototype

public void stop() throws IllegalStateException 

Source Link

Document

Stop the current task.

Usage

From source file:com.create.aop.LoggingAspect.java

private Object logPerformance(ProceedingJoinPoint joinPoint, Logger logger, String watchId) throws Throwable {
    final StopWatch stopWatch = new StopWatch(watchId);
    stopWatch.start(watchId);//from  w ww.j av  a2s .c  o  m
    try {
        return joinPoint.proceed();
    } finally {
        stopWatch.stop();
        logger.trace(stopWatch.shortSummary());
    }
}

From source file:com.swarmcn.user.web.config.SwaggerConfiguration.java

@Bean
public Docket swaggerSpringfoxDocket() {
    log.debug("Starting Swagger");
    StopWatch watch = new StopWatch();
    watch.start();/* w  ww  . j av a2s  .co m*/
    Docket swaggerSpringMvcPlugin = new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo())
            .genericModelSubstitutes(ResponseEntity.class).select().build();
    watch.stop();
    log.debug("Started Swagger in {} ms", watch.getTotalTimeMillis());
    return swaggerSpringMvcPlugin;
}

From source file:cn.edu.cqu.jwc.mis.ta.util.CallMonitoringAspect.java

@Around("within(@org.springframework.stereotype.Repository *)")
public Object invoke(ProceedingJoinPoint joinPoint) throws Throwable {
    if (this.enabled) {
        StopWatch sw = new StopWatch(joinPoint.toShortString());

        sw.start("invoke");
        try {//from  w w w  . j a  v  a  2s.c  o m
            return joinPoint.proceed();
        } finally {
            sw.stop();
            synchronized (this) {
                this.callCount++;
                this.accumulatedCallTime += sw.getTotalTimeMillis();
            }
        }
    } else {
        return joinPoint.proceed();
    }
}

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

@Override
public boolean execute() {
    boolean retval = true;
    try {/* w w w  .  java 2s.  c o 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:org.olegz.uuid.TimeBasedUUIDGeneratorTests.java

@Test
public void performanceTestSynch() {
    StopWatch stopWatch = new StopWatch();
    stopWatch.start();//from ww w  . j av  a 2 s .c  om
    for (int i = 0; i < 1000000; i++) {
        TimeBasedUUIDGenerator.generateId();
    }
    stopWatch.stop();
    System.out.println("Generated 1000000 UUID (sync) via TimeBasedUUIDGenerator.generateId(): in "
            + stopWatch.getTotalTimeSeconds() + " seconds");

    stopWatch = new StopWatch();
    stopWatch.start();
    for (int i = 0; i < 1000000; i++) {
        UUID.randomUUID();
    }
    stopWatch.stop();
    System.out.println("Generated 1000000 UUID  (sync) via UUID.randomUUID(): in "
            + stopWatch.getTotalTimeSeconds() + " seconds");
}

From source file:curly.commons.logging.MethodExecutionAspectInterceptor.java

@Around(value = "execution(* *(..)) && @annotation(loggable)) ", argNames = "joinPoint, loggable")
public Object invoke(ProceedingJoinPoint joinPoint, Loggable loggable) throws Throwable {
    if (executionEnabled) {
        StopWatch watch = new StopWatch(joinPoint.toShortString());
        watch.start();/*from  w w  w  .  j  a  va  2  s.com*/
        try {
            return joinPoint.proceed();
        } finally {
            watch.stop();
            synchronized (this) {
                if (actuatorEnabled && (gaugeService != null)) {
                    String gagueName = "gauge.execution." + joinPoint.getTarget() + "."
                            + joinPoint.getSignature().getName();
                    gaugeService.submit(gagueName, watch.getLastTaskTimeMillis());
                }
                log(loggable.value(), joinPoint.getTarget().getClass(), "Executed method {} in {} ms",
                        joinPoint.getSignature().getName(), watch.getLastTaskTimeMillis());
            }
        }

    }
    return joinPoint.proceed();
}

From source file:io.curly.commons.logging.MethodExecutionAspectInterceptor.java

@SuppressWarnings("ArgNamesErrorsInspection")
@Around(value = "execution(* *(..)) && @annotation(loggable)) ", argNames = "joinPoint, loggable")
public Object invoke(ProceedingJoinPoint joinPoint, Loggable loggable) throws Throwable {
    if (executionEnabled) {
        StopWatch watch = new StopWatch(joinPoint.toShortString());
        watch.start();// ww w .j a  v a  2 s.  c o m
        try {
            return joinPoint.proceed();
        } finally {
            watch.stop();
            synchronized (this) {
                if (actuatorEnabled && (gaugeService != null)) {
                    String gagueName = "gauge.execution." + joinPoint.getTarget() + "."
                            + joinPoint.getSignature().getName();
                    gaugeService.submit(gagueName, watch.getLastTaskTimeMillis());
                }
                log(loggable.value(), joinPoint.getTarget().getClass(), "Executed method {} in {} ms",
                        joinPoint.getSignature().getName(), watch.getLastTaskTimeMillis());
            }
        }

    }
    return joinPoint.proceed();
}

From source file:org.nebulaframework.grid.Grid.java

/**
 * Starts a {@link GridNode} with default settings, read from
 * default properties file.//from   ww  w. ja v  a2 s  .  c o m
 * 
 * @param useConfigDiscovery indicates whether to use information
 * from configuration to discover
 * 
 * @return GridNode
 * 
 * @throws IllegalStateException if a Grid Member (Cluster / Node) has
 * already started with in the current VM. Nebula supports only one Grid
 * Member per VM.
 */
public synchronized static GridNode startGridNode(boolean useConfigDiscovery) throws IllegalStateException {

    if (isInitialized()) {
        // A Grid Member has already started in this VM
        throw new IllegalStateException("A Grid Memeber Already Started in VM");
    }

    initializeDefaultExceptionHandler();

    StopWatch sw = new StopWatch();

    try {

        sw.start();

        // Set Security Manager
        System.setSecurityManager(new SecurityManager());

        // Detect Configuration
        Properties config = ConfigurationSupport.detectNodeConfiguration();

        log.info("GridNode Attempting Discovery...");

        // Discover Cluster If Needed
        GridNodeDiscoverySupport.discover(config, useConfigDiscovery);

        checkJMSBroker(config.getProperty(ConfigurationKeys.CLUSTER_SERVICE.value()));

        log.debug("Starting up Spring Container...");

        applicationContext = new NebulaApplicationContext(GRIDNODE_CONTEXT, config);

        log.debug("Spring Container Started");

        node = true;

        sw.stop();

        log.info("GridNode Started Up. " + sw.getLastTaskTimeMillis() + " ms");

        return (GridNode) applicationContext.getBean("localNode");
    } finally {
        if (sw.isRunning()) {
            sw.stop();
        }
    }
}

From source file:org.nebulaframework.grid.Grid.java

/**
 * Starts {@link ClusterManager} instance with default settings,
 * read from default properties file./*from   ww  w . ja  v a2  s . co m*/
 * 
 * @return ClusterManager
 * 
 * @throws IllegalStateException if a Grid Member (Cluster / Node) has
 * already started with in the current VM. Nebula supports only one Grid
 * Member per VM.
 */
public synchronized static ClusterManager startClusterManager() throws IllegalStateException {

    if (isInitialized()) {
        // A Grid Member has already started in this VM
        throw new IllegalStateException("A Grid Memeber Already Started in VM");
    }

    initializeDefaultExceptionHandler();

    StopWatch sw = new StopWatch();

    try {
        sw.start();
        log.info("ClusterManager Starting...");

        // Set Security Manager
        System.setSecurityManager(new SecurityManager());

        // Detect Configuration
        Properties config = ConfigurationSupport.detectClusterConfiguration();

        // Register with any Colombus Servers
        ClusterDiscoverySupport.registerColombus(config);

        clusterManager = true;

        log.debug("Starting up Spring Container...");

        applicationContext = new NebulaApplicationContext(CLUSTER_SPRING_CONTEXT, config);

        log.debug("Spring Container Started");

        return (ClusterManager) applicationContext.getBean("clusterManager");
    } finally {
        sw.stop();
        log.info("ClusterManager Started Up. " + sw.getLastTaskTimeMillis() + " ms");
    }

}

From source file:org.jsmiparser.AbstractMibTestCase.java

protected SmiMib getMib() {
    // this is a rather ugly hack to mimic JUnit4 @BeforeClass, without
    // having to annotate all test methods:
    if (m_mib.get() == null || m_testClass.get() != getClass()) {
        try {/*from w w w .jav  a  2  s .  c o m*/
            SmiParser parser = createParser();
            StopWatch stopWatch = new StopWatch();
            stopWatch.start();
            SmiMib mib = parser.parse();
            stopWatch.stop();
            m_log.info("Parsing time: " + stopWatch.getTotalTimeSeconds() + " s");

            m_mib.set(mib);
            m_testClass.set(getClass());
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
    return m_mib.get();
}