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.jxt.web.service.FilteredMapServiceImpl.java

/**
 * filtered application map//from w w w  .  ja  v a  2s . c  o  m
 */
@Override
public ApplicationMap selectApplicationMap(List<TransactionId> transactionIdList, Range originalRange,
        Range scanRange, Filter filter) {
    if (transactionIdList == null) {
        throw new NullPointerException("transactionIdList must not be null");
    }
    if (filter == null) {
        throw new NullPointerException("filter must not be null");
    }

    StopWatch watch = new StopWatch();
    watch.start();

    final List<List<SpanBo>> filterList = selectFilteredSpan(transactionIdList, filter);

    DotExtractor dotExtractor = createDotExtractor(scanRange, filterList);
    ApplicationMap map = createMap(originalRange, scanRange, filterList);

    ApplicationMapWithScatterScanResult applicationMapWithScatterScanResult = new ApplicationMapWithScatterScanResult(
            map, dotExtractor.getApplicationScatterScanResult());

    watch.stop();
    logger.debug("Select filtered application map elapsed. {}ms", watch.getTotalTimeMillis());

    return applicationMapWithScatterScanResult;
}

From source file:com.jxt.web.service.FilteredMapServiceImpl.java

@Override
public ApplicationMap selectApplicationMapWithScatterData(List<TransactionId> transactionIdList,
        Range originalRange, Range scanRange, int xGroupUnit, int yGroupUnit, Filter filter) {
    if (transactionIdList == null) {
        throw new NullPointerException("transactionIdList must not be null");
    }//ww  w.ja va2 s  .c  o  m
    if (filter == null) {
        throw new NullPointerException("filter must not be null");
    }

    StopWatch watch = new StopWatch();
    watch.start();

    final List<List<SpanBo>> filterList = selectFilteredSpan(transactionIdList, filter);

    DotExtractor dotExtractor = createDotExtractor(scanRange, filterList);
    ApplicationMap map = createMap(originalRange, scanRange, filterList);

    ApplicationMapWithScatterData applicationMapWithScatterData = new ApplicationMapWithScatterData(map,
            dotExtractor.getApplicationScatterData(originalRange.getFrom(), originalRange.getTo(), xGroupUnit,
                    yGroupUnit));

    watch.stop();
    logger.debug("Select filtered application map elapsed. {}ms", watch.getTotalTimeMillis());

    return applicationMapWithScatterData;
}

From source file:com.mmnaseri.dragonfly.runtime.analysis.ApplicationDesignAdvisor.java

@Override
public List<DesignIssue> analyze() {
    final List<DesignIssue> issues = new CopyOnWriteArrayList<DesignIssue>();
    final StopWatch stopWatch = new StopWatch();
    stopWatch.start();/*  w  w  w.ja  va  2s.com*/
    log.info("Starting design advisor on " + applicationContext.getDisplayName());
    final TaskManager taskManager = new ThreadPoolTaskManager(Runtime.getRuntime().availableProcessors(), true);
    final Thread analyzerThread = new Thread(taskManager);
    final SessionPreparator sessionPreparator = applicationContext.getBean(SessionPreparator.class);
    with(getAnalyzers(sessionPreparator)).each(new Processor<ApplicationDesignAnalyzer>() {
        @Override
        public void process(ApplicationDesignAnalyzer applicationDesignAnalyzer) {
            taskManager.schedule(new AnalyzerTask(applicationDesignAnalyzer, issues));
        }
    });
    try {
        analyzerThread.start();
        analyzerThread.join();
    } catch (InterruptedException e) {
        throw new RuntimeException(e);
    }
    stopWatch.stop();
    log.info("Finished analysis of " + applicationContext.getDisplayName() + " in "
            + stopWatch.getLastTaskTimeMillis() + "ms");
    return issues;
}

From source file:com.navercorp.pinpoint.web.controller.ScatterChartController.java

/**
 * @param applicationName/*from  w  w  w. j av a  2 s  . c om*/
 * @param from
 * @param to
 * @param limit           max number of data return. if the requested data exceed this limit, we need additional calls to
 *                        fetch the rest of the data
 * @return
 */
@RequestMapping(value = "/getScatterData", method = RequestMethod.GET)
public ModelAndView getScatterData(@RequestParam("application") String applicationName,
        @RequestParam("from") long from, @RequestParam("to") long to,
        @RequestParam("xGroupUnit") int xGroupUnit, @RequestParam("yGroupUnit") int yGroupUnit,
        @RequestParam("limit") int limit,
        @RequestParam(value = "backwardDirection", required = false, defaultValue = "true") boolean backwardDirection,
        @RequestParam(value = "filter", required = false) String filterText,
        @RequestParam(value = "_callback", required = false) String jsonpCallback,
        @RequestParam(value = "v", required = false, defaultValue = "1") int version) {
    if (xGroupUnit <= 0) {
        throw new IllegalArgumentException("xGroupUnit(" + xGroupUnit + ") must be positive number");
    }
    if (yGroupUnit < 0) {
        throw new IllegalArgumentException("yGroupUnit(" + yGroupUnit + ") may not be negative number");
    }

    limit = LimitUtils.checkRange(limit);

    StopWatch watch = new StopWatch();
    watch.start("getScatterData");

    // TODO range check verification exception occurs. "from" is bigger than "to"
    final Range range = Range.createUncheckedRange(from, to);
    logger.debug(
            "fetch scatter data. RANGE={}, X-Group-Unit:{}, Y-Group-Unit:{}, LIMIT={}, BACKWARD_DIRECTION:{}, FILTER:{}",
            range, xGroupUnit, yGroupUnit, limit, backwardDirection, filterText);

    ModelAndView mv = null;
    if (StringUtils.isEmpty(filterText)) {
        mv = selectScatterData(applicationName, range, xGroupUnit, Math.max(yGroupUnit, 1), limit,
                backwardDirection, version);
    } else {
        mv = selectFilterScatterData(applicationName, range, xGroupUnit, Math.max(yGroupUnit, 1), limit,
                backwardDirection, filterText, version);
    }

    if (jsonpCallback == null) {
        mv.setViewName("jsonView");
    } else {
        mv.setViewName("jsonpView");
    }

    watch.stop();

    logger.info("Fetch scatterData time : {}ms", watch.getLastTaskTimeMillis());

    return mv;
}

From source file:io.mandrel.worker.Loop.java

protected Blob processBlob(Uri uri, StopWatch watch, Requester<? extends Strategy> r) throws Exception {
    Blob blob;/*w  w  w  . ja va2 s . c om*/
    blob = r.get(uri);

    watch.stop();

    log.trace("> Start parsing data for {}", uri);

    blob.getMetadata().getFetchMetadata().setTimeToFetch(watch.getTotalTimeMillis());

    updateMetrics(watch, blob);

    Map<String, Instance<?>> cachedSelectors = new HashMap<>();
    if (spider.getExtractors() != null && spider.getExtractors().getData() != null) {
        log.trace(">  - Extracting documents for {}...", uri);
        spider.getExtractors().getData().forEach(ex -> {
            List<Document> documents = extractorService.extractThenFormatThenStore(spider.getId(),
                    cachedSelectors, blob, ex);

            if (documents != null) {
                spiderAccumulator.incDocumentForExtractor(ex.getName(), documents.size());
            }
        });
        log.trace(">  - Extracting documents for {} done!", uri);
    }

    if (spider.getExtractors().getOutlinks() != null) {
        log.trace(">  - Extracting outlinks for {}...", uri);
        final Uri theUri = uri;
        spider.getExtractors().getOutlinks().forEach(ol -> {
            Set<Link> allFilteredOutlinks = extractorService
                    .extractAndFilterOutlinks(spider, theUri, cachedSelectors, blob, ol).getRight();
            blob.getMetadata().getFetchMetadata().setOutlinks(allFilteredOutlinks);
            add(spider.getId(), allFilteredOutlinks.stream().map(l -> l.getUri()).collect(Collectors.toSet()));
        });
        log.trace(">  - Extracting outlinks done for {}!", uri);
    }

    BlobStores.get(spider.getId()).ifPresent(b -> b.putBlob(blob.getMetadata().getUri(), blob));

    log.trace(">  - Storing metadata for {}...", uri);
    MetadataStores.get(spider.getId()).addMetadata(blob.getMetadata().getUri(), blob.getMetadata());
    log.trace(">  - Storing metadata for {} done!", uri);

    log.trace("> End parsing data for {}", uri);
    return blob;
}

From source file:no.abmu.abmstatistikk.annualstatistic.service.hibernate2.AnnualStatisticServiceHelper.java

protected ReportStatus[] getReportStatusBySchemaTypeAndYear(
        List<OrganisationUnitForBrowsing> orgUnitsForBrodwsing, String schemaTypeName, int reportYear) {

    StopWatch stopWatch = new StopWatch();
    stopWatch.start();/*from  w  w w .  j  a v a2  s .  c  om*/

    List<ReportStatus> reportStatusAsList = new ArrayList<ReportStatus>();
    String finishFieldNumber = getFinishFieldNumberForSchemaTypeAndReportYear(schemaTypeName, reportYear);

    for (OrganisationUnitForBrowsing orgForBrowse : orgUnitsForBrodwsing) {
        Report report = service.getReport(orgForBrowse.getOrganisationUnitId(), schemaTypeName, reportYear,
                false);
        reportStatusAsList.add(createReportStatus(orgForBrowse, report, finishFieldNumber));
    }

    stopWatch.stop();

    logger.info("Finish prosessing of reportStatus for schemaType:" + schemaTypeName + " with "
            + orgUnitsForBrodwsing.size() + " elements in " + stopWatch.getTotalTimeMillis() + " ms");

    return reportStatusAsList.toArray(new ReportStatus[reportStatusAsList.size()]);

}

From source file:no.abmu.abmstatistikk.annualstatistic.service.hibernate2.AnnualStatisticServiceHelper.java

private ReportStatus[] getReportStatusBySchemaTypeAndYear(ReportStatus[] reportStatusSurvey,
        String schemaTypeName, int reportYear) {

    StopWatch stopWatch = new StopWatch();

    Long orgUnitId;/*from ww  w  . j  a  v  a2 s . c  o  m*/
    ReportStatus reportStatus;
    String reportFinish;
    Report report;
    ReportHelper reportHelper;
    Answer answer;
    String reportFinishAnswer;

    int numberOfReports = reportStatusSurvey.length;

    String finishFieldNumber = getFinishFieldNumberForSchemaTypeAndReportYear(schemaTypeName, reportYear);

    if (numberOfReports > 1) {
        logger.info("Start prosessing of reportStatus for schemaType:" + schemaTypeName + " with "
                + numberOfReports + " elements");
    }
    stopWatch.start("getReportStatusBySchemaTypeAndYear");

    for (int row = 0; row < reportStatusSurvey.length; row++) {
        reportStatus = reportStatusSurvey[row];
        orgUnitId = reportStatus.getOrganisationUnitId();

        StopWatch stopWatchForGetReport = new StopWatch();
        stopWatchForGetReport.start("test");

        report = service.getReport(orgUnitId.longValue(), schemaTypeName, reportYear, false);

        stopWatchForGetReport.stop();
        logger.info("Getting report for organisationUnitId: '" + orgUnitId + "' and schemaType: "
                + schemaTypeName + " tok [" + stopWatchForGetReport.getTotalTimeMillis() + "] ms");

        if (report != null) {
            //                reportStatus.setReport("Ja");
            StopWatch stopWatchForCreatingReportHelper = new StopWatch();
            stopWatchForCreatingReportHelper.start("ReportHelper");

            reportHelper = new ReportHelper(report);
            answer = reportHelper.getAnswerByFieldName(finishFieldNumber);

            stopWatchForCreatingReportHelper.stop();
            logger.info("Getting reportHelper and answer for organisationUnitId: '" + orgUnitId
                    + "' and schemaType: " + schemaTypeName + " tok ["
                    + stopWatchForCreatingReportHelper.getTotalTimeMillis() + "] ms");

            if (answer != null) {
                reportFinishAnswer = answer.getValue();
                if (reportFinishAnswer != null) {
                    reportFinish = (reportFinishAnswer.equals("true") ? "Ja" : "Nei");
                    //                        reportStatus.setReportFinish(reportFinish);
                }
            }
        }
        if (((row + 1) % 100) == 0) {
            logger.info("Has processed reportStatus " + (row + 1) + " of " + numberOfReports
                    + " for schemaType:" + schemaTypeName);
        }
    }

    stopWatch.stop();

    if (numberOfReports > 1) {
        logger.info("Finish prosessing of reportStatus for schemaType:" + schemaTypeName + " with "
                + numberOfReports + " elements in " + stopWatch.getTotalTimeMillis() + " ms");
    }

    return reportStatusSurvey;

}

From source file:no.abmu.abmstatistikk.annualstatistic.webflow.AnnualStatisticFormAction.java

protected Object createFormObject(RequestContext context) {
    if (logger.isDebugEnabled()) {
        logger.debug("Executing createFormObject");
    }/*from  www.ja v  a 2s  .c o  m*/
    StopWatch stopWatch = new StopWatch();
    stopWatch.start("createFormObject");

    WebSchemaDefinition webSchema = webFlowService.createWebSchema(context);

    String submitEvent = context.getRequestParameters().get("_eventId_submit.y");
    if (submitEvent == null) {
        // Getting values from database into webSchema 
        // and show these values to user
        // e.g. webSchema --> formObject to user
        if (logger.isDebugEnabled()) {
            logger.debug("[createFormObject] submitEvent == null (webSchema --> formObject to user) ");
        }
    } else {
        // Getting values from user and sending user input 
        // to binding and eventually validation.
        // e.g. webSchema --> formObject from user
        if (logger.isDebugEnabled()) {
            logger.debug("[createFormObject] submitEvent != null (webSchema --> formObject from user)");
        }
    }
    webFlowService.databaseValuesToWebSchema(webSchema);

    stopWatch.stop();
    logger.info("[createFormObject] tok [" + stopWatch.getTotalTimeMillis() + "] ms");

    return webSchema;
}

From source file:no.abmu.abmstatistikk.annualstatistic.webflow.hibernate2.WebFlowServiceImpl.java

/**
 * Getting values from webSchema to an new databaseSchema, e.g. values from
 * user input to database schema./*w w w .j  av  a2 s  . com*/
 * 
 * @param webFlowValidator - WebFlowValidator validator.
 * @param webSchemaDefinition - webSchema
 * @return - SchemaReport database schema. 
 */
public SchemaReport webSchemaValuesToDataBaseSchema(WebFlowValidator webFlowValidator,
        WebSchemaDefinition webSchema) {

    Assert.checkRequiredArgument("webFlowValidator", webFlowValidator);
    Assert.checkRequiredArgument("webSchema", webSchema);

    if (logger.isDebugEnabled()) {
        logger.debug("Executing webSchemaValuesToDataBaseSchema with parameters, WebFlowValidator='"
                + webFlowValidator + ", WebSchemaDefinition='" + webSchema + "'");
    }

    StopWatch stopWatch = new StopWatch();
    stopWatch.start("webSchemaValuesToDataBaseSchema");

    int notPassedValidation = 0;
    Object dataBaseSchema = getDatabaseSchema(webSchema);

    // Set up validation keys
    webFlowValidator.computeValidateFieldKeys();

    Set<String> validateFieldKeys = webFlowValidator.getValidateFieldKeys();
    if (logger.isDebugEnabled()) {
        for (String validateFieldKey : validateFieldKeys) {
            logger.debug("FieldKey to be validated='" + validateFieldKey + "'");
        }
    }

    for (String fieldNumberAsString : validateFieldKeys) {
        String methodGetFieldName = "getField" + fieldNumberAsString;
        String methodGetCommentName = "getComment" + fieldNumberAsString;

        String value = (String) MethodUtil.getValueOfPublicMethod(webSchema, methodGetFieldName);
        String comment = (String) MethodUtil.getValueOfPublicMethod(webSchema, methodGetCommentName);
        Answer answer = (Answer) MethodUtil.getValueOfPublicMethod(dataBaseSchema, methodGetFieldName);
        answer.setValue(value);
        answer.setComment(comment);
        answer.setPassedvalidation(notPassedValidation);

        if (logger.isDebugEnabled()) {
            Answer newAnswer = (Answer) MethodUtil.getValueOfPublicMethod(dataBaseSchema, methodGetFieldName);
            logger.debug("Field '" + fieldNumberAsString + "' method get name '" + methodGetFieldName
                    + "' web value '" + value + "' web comment '" + comment + "'");

            logger.debug("Field '" + fieldNumberAsString + "' validation '" + answer.getPassedvalidation()
                    + "' new db value '" + newAnswer.getValue() + "' new db comment '" + newAnswer.getComment()
                    + "'");
        }

    }

    SchemaReport schemaReport = (SchemaReport) dataBaseSchema;

    stopWatch.stop();
    logger.info("[private:webSchemaValuesToDataBaseSchema] tok [" + stopWatch.getTotalTimeMillis() + "] ms");

    return schemaReport;
}

From source file:no.abmu.abmstatistikk.annualstatistic.webflow.hibernate2.WebFlowServiceImpl.java

/**
 * Getting database schema and values from database.
 * /*from   ww  w.j  a v  a 2 s. co m*/
 * @param webSchema - WebSchemaDefinition, schema which specify database
 * schema and version.
 * @return - Database schema with values fram database.
 */
private Object getDatabaseSchema(WebSchemaDefinition webSchema) {
    if (logger.isDebugEnabled()) {
        logger.debug("Executing getDatabaseSchema");
    }
    Assert.checkRequiredArgument("webSchema", webSchema);

    StopWatch stopWatch = new StopWatch();
    stopWatch.start("getDatabaseSchema");

    Long id = webSchema.getId().longValue();
    String dataBaseSchemaName = webSchema.getDataBaseSchemaName();
    String dataBaseSchemaVersion = webSchema.getDataBaseSchemaVersion();
    Integer year = Integer.valueOf(dataBaseSchemaVersion);

    Assert.assertNotNull("OrganisationUnitId was null ", id);
    Assert.assertNotNull("DataBaseSchemaTypeName was null ", dataBaseSchemaName);
    Assert.assertNotNull("SchemaVersion was null ", dataBaseSchemaVersion);

    Report report = annualStatisticService.getReport(id, dataBaseSchemaName, year.intValue(), true);

    SchemaReport schemaReport;
    if (report == null) {
        logger.error("Couldn't find report for schema " + dataBaseSchemaName + " for Organisation " + id);
        throw new IllegalArgumentException(
                "Couldn't find report for schema " + dataBaseSchemaName + " for Organisation " + id);
    } else {
        schemaReport = new SchemaReport(report);
    }

    Object dataBaseSchema;
    if (dataBaseSchemaName.equals(SchemaTypeNameConst.FOLKEBIBLIOTEK_SHORT_NAME)) {
        dataBaseSchema = new FolkeBibScreen(schemaReport.getReport());
    } else {
        throw new SchemaTypeNameNotFoundException(dataBaseSchemaName);
    }
    stopWatch.stop();
    logger.info("[getDatabaseSchema] tok [" + stopWatch.getTotalTimeMillis() + "] ms");

    return dataBaseSchema;
}