List of usage examples for org.springframework.util StopWatch StopWatch
public StopWatch()
From source file:com.agileapes.webexport.concurrent.Worker.java
@SuppressWarnings("unchecked") @Override//w w w. j a va 2s .c om 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); } } }
From source file:com.quartzdesk.test.quartz.v2.AbstractJob.java
/** * The method invoked by the Spring scheduler. This method simply delegates the * execution to the {@link #executeJob(JobExecutionContext)} method. * * @param context a {@link JobExecutionContext} instance. * @throws JobExecutionException if an error occurs while executing the * job.//from www . jav a2 s .co m */ @Override public final void execute(JobExecutionContext context) throws JobExecutionException { String jobFullName = context.getJobDetail().getKey().toString(); String triggerFullName = context.getTrigger().getKey().toString(); StopWatch sw = new StopWatch(); sw.start(); ClassLoader origContextClassLoader = Thread.currentThread().getContextClassLoader(); try { if (log.isInfoEnabled()) log.info("Started scheduled job: {}, fired by trigger: {}", jobFullName, triggerFullName); if (log.isDebugEnabled()) { StringBuilder jobDataMapDump = new StringBuilder(); // map that contains merged job data from the job detail data map and trigger data map JobDataMap jobDataMap = context.getMergedJobDataMap(); for (Iterator<String> keys = jobDataMap.keySet().iterator(); keys.hasNext();) { String key = keys.next(); String value = CommonUtils.safeToString(jobDataMap.get(key)); jobDataMapDump.append(key).append('=').append(value); if (keys.hasNext()) jobDataMapDump.append(CommonConst.NL); } log.debug("Job data map dump:{}{}", CommonConst.NL, jobDataMapDump.toString()); } // Set the context class loader to be the class loader of the job class. // This is a workaround/fix for a problem with setting the thread's context // class loader through Quartz properties when WebSphere work manager threads // are used. Thread.currentThread().setContextClassLoader(getClass().getClassLoader()); executeJob(context); sw.stop(); if (log.isInfoEnabled()) log.info("Finished scheduled job: {}. Time taken: {}s.", jobFullName, sw.getTotalTimeSeconds()); } catch (JobExecutionException e) { if (log.isErrorEnabled()) log.error("Error executing scheduled job: " + jobFullName, e); throw e; } finally { // restore the original thread context class loader Thread.currentThread().setContextClassLoader(origContextClassLoader); } }
From source file:com.quartzdesk.test.quartz.v1.AbstractJob.java
/** * The method invoked by the Spring scheduler. This method simply delegates the * execution to the {@link #executeJob(JobExecutionContext)} method. * * @param context a {@link JobExecutionContext} instance. * @throws JobExecutionException if an error occurs while executing the * job./*from w ww. java 2 s.c o m*/ */ @SuppressWarnings("unchecked") @Override public final void execute(JobExecutionContext context) throws JobExecutionException { String jobFullName = context.getJobDetail().getFullName(); String triggerFullName = context.getTrigger().getFullName(); StopWatch sw = new StopWatch(); sw.start(); ClassLoader origContextClassLoader = Thread.currentThread().getContextClassLoader(); try { if (log.isInfoEnabled()) log.info("Started scheduled job: {}, fired by trigger: {}", jobFullName, triggerFullName); if (log.isDebugEnabled()) { StringBuilder jobDataMapDump = new StringBuilder(); // map that contains merged job data from the job detail data map and trigger data map JobDataMap jobDataMap = context.getMergedJobDataMap(); for (Iterator<String> keys = (Iterator<String>) jobDataMap.keySet().iterator(); keys.hasNext();) { String key = keys.next(); String value = CommonUtils.safeToString(jobDataMap.get(key)); jobDataMapDump.append(key).append('=').append(value); if (keys.hasNext()) jobDataMapDump.append(CommonConst.NL); } log.debug("Job data map dump:{}{}", CommonConst.NL, jobDataMapDump.toString()); } // Set the context class loader to be the class loader of the job class. // This is a workaround/fix for a problem with setting the thread's context // class loader through Quartz properties when WebSphere work manager threads // are used. Thread.currentThread().setContextClassLoader(getClass().getClassLoader()); executeJob(context); sw.stop(); if (log.isInfoEnabled()) log.info("Finished scheduled job: {}. Time taken: {}s.", jobFullName, sw.getTotalTimeSeconds()); } catch (JobExecutionException e) { if (log.isErrorEnabled()) log.error("Error executing scheduled job: " + jobFullName, e); throw e; } finally { // restore the original thread context class loader Thread.currentThread().setContextClassLoader(origContextClassLoader); } }
From source file:com.persistent.cloudninja.scheduler.PerformanceMonitor.java
@Override public boolean execute() { StopWatch watch = new StopWatch(); try {/*from w w w . ja v a 2 s .co m*/ LOGGER.debug("PerformanceMonitor : Execute"); watch.start(); Date lastReadTime = kpiValueTempDao.getMaxTimestamp(); Date lastBatchTime = null; Calendar calendar = Calendar.getInstance(); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S z"); dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); String date = null; if (lastReadTime == null) { date = dateFormat.format(calendar.getTime()); lastReadTime = dateFormat.parse(date); } calendar = Calendar.getInstance(); date = dateFormat.format(calendar.getTime()); Date currentUTCTime = dateFormat.parse(date); List<KpiValueTempEntity> listKpiValueTempEntities = null; while (lastReadTime.getTime() <= currentUTCTime.getTime()) { LOGGER.debug("PerformanceMonitor : Process performance counters"); calendar.setTime(lastReadTime); calendar.add(Calendar.MINUTE, 30); date = dateFormat.format(calendar.getTime()); lastBatchTime = dateFormat.parse(date); WADPerformanceCountersEntity[] arrPerfCounter = storageUtility .getPerfCounterEntities(lastReadTime.getTime(), lastBatchTime.getTime()); listKpiValueTempEntities = convertAzureEntityToDBEntity(arrPerfCounter); kpiValueTempDao.addAll(listKpiValueTempEntities); kpiValueTempDao.executeProcessKpiValues(); LOGGER.debug("PerformanceMonitor : Process complete"); lastReadTime = lastBatchTime; } watch.stop(); taskCompletionDao.updateTaskCompletionDetails(watch.getTotalTimeSeconds(), "ProcessPerformanceCounters", ""); LOGGER.debug("PerformanceMonitor : Finish"); } catch (ParseException e) { LOGGER.error(e.getMessage(), e); } return true; }
From source file:org.springintegration.PayloadAwareTimingInterceptor.java
@Override public Message<?> preSend(Message<?> message, MessageChannel channel) { StopWatch stopWatch = new StopWatch(); stopWatch.start();// www. j ava2s. com this.stopWatchHolder.set(new StopWatchHolder(stopWatch, message.getPayload().getClass())); return super.preSend(message, channel); }
From source file:org.dd4t.core.filters.impl.RichTextResolverFilter.java
/** * Recursivly resolves all components links. * /*from w ww.java 2 s .c o m*/ * @param item * the to resolve the links * @param context * the requestContext */ @Override public void doFilter(Item item, RequestContext context) throws FilterException { StopWatch stopWatch = null; if (logger.isDebugEnabled()) { stopWatch = new StopWatch(); stopWatch.start(); } if (item instanceof GenericPage) { resolvePage((GenericPage) item); } else if (item instanceof GenericComponent) { resolveComponent((GenericComponent) item); } else { if (logger.isDebugEnabled()) { logger.debug( "RichTextResolverFilter. Item is not a GenericPage or GenericComponent so no component to resolve"); } } if (logger.isDebugEnabled()) { stopWatch.stop(); logger.debug("RichTextResolverFilter finished in " + stopWatch.getTotalTimeMillis() + " ms"); } }
From source file:org.arrow.test.SpringWorkflowTestExecutionListener.java
/** * {@inheritDoc}//from ww w .ja va 2 s .c o m */ @Override public void beforeTestMethod(TestContext testContext) throws Exception { ApplicationContext context = testContext.getApplicationContext(); CONTEXT_HOLDER.set(context); RepositoryService rs = context.getBean(RepositoryService.class); Class<?> testClass = testContext.getTestClass(); Method method = testContext.getTestMethod(); Given given = findAnnotation(method, Given.class); if (given != null) { final String[] fileNames = given.value(); for (String fileName : fileNames) { BpmnParser driver = new XStreamBpmnParser(); InputStream stream = testClass.getResourceAsStream(fileName); Definitions definitions = driver.parse(stream); rs.deploy(definitions); } } StopWatch stopWatch = new StopWatch(); stopWatch.start("START TEST"); testContext.setAttribute("stopWatch", stopWatch); }
From source file:org.nebulaframework.benchmark.linpack.LinPackBenchmark.java
/** * Splits the benchmark tasks.// w w w . j av a2s.c o m * * @return benchmark tasks */ @Override public List<GridTask<LinPackResult>> split() { List<GridTask<LinPackResult>> list = new ArrayList<GridTask<LinPackResult>>(); for (int i = 0; i < tasks; i++) { list.add(new LinPackTask(cycles)); } sw = new StopWatch(); sw.start(); return list; }
From source file:org.sventon.cache.logmessagecache.LogMessageCacheUpdater.java
/** * Updates the log entry cache with given revision information. * * @param revisionUpdate The updated revisions. *///from w w w. ja v a 2 s . c om public void update(final RevisionUpdate revisionUpdate) { final RepositoryName repositoryName = revisionUpdate.getRepositoryName(); final List<LogEntry> revisions = revisionUpdate.getRevisions(); LOGGER.info( "Listener got [" + revisions.size() + "] updated revision(s) for repository: " + repositoryName); final StopWatch stopWatch = new StopWatch(); stopWatch.start(); try { final LogMessageCache logMessageCache = logMessageCacheManager.getCache(repositoryName); if (revisionUpdate.isClearCacheBeforeUpdate()) { LOGGER.info("Clearing cache before population"); logMessageCache.clear(); } updateInternal(logMessageCache, revisions); } catch (final Exception ex) { LOGGER.warn("Could not update cache instance [" + repositoryName + "]", ex); } stopWatch.stop(); LOGGER.info("Update completed in [" + stopWatch.getTotalTimeSeconds() + "] seconds"); }
From source file:io.tronbot.graphql.actuator.config.apidoc.SwaggerConfiguration.java
/** * Swagger Springfox configuration.//from ww w. j av a 2s . co 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; }