List of usage examples for org.springframework.util StopWatch start
public void start() throws IllegalStateException
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(); 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//from w w w. j ava 2 s .c o m 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:eu.databata.Propagator.java
public void init() { LOG.info(this.moduleName + " starting propagation (" + new Date() + ")"); StopWatch stopwatch = new StopWatch(); stopwatch.start(); if (isPropagatorDisabled()) { LOG.info("Changes propagation is disabled."); return;//from ww w .j a v a2 s .c o m } // if (!simulationMode && !propagatorLock.lock()) { // return; // } while (!checkPreconditions()) { try { Thread.sleep(5000); } catch (InterruptedException e) { throw new RuntimeException(); } } try { collectStructureAndPropagate(); } finally { if (!simulationMode) { propagatorLock.unlock(); finished = true; } } LOG.info(this.moduleName + " finishing propagation (" + new Date() + ")," + " took " + Math.round(stopwatch.getTotalTimeSeconds()) + " seconds overall."); }
From source file:io.mandrel.worker.Loop.java
@Override public void run() { while (true) { try {/*w w w. java 2 s. c om*/ if (!run.get()) { log.trace("Waiting..."); try { TimeUnit.MILLISECONDS.sleep(2000); } catch (InterruptedException e) { // Don't care log.trace("", e); } continue; } log.trace("> Asking for uri..."); Next next = clients.onRandomFrontier().map(frontier -> frontier.next(spider.getId())).get(20000, TimeUnit.MILLISECONDS); Uri uri = next.getUri(); if (uri != null) { log.trace("> Getting uri {} !", uri); // StopWatch watch = new StopWatch(); watch.start(); // Optional<Requester<? extends Strategy>> requester = Requesters.of(spider.getId(), uri.getScheme()); if (requester.isPresent()) { Requester<? extends Strategy> r = requester.get(); Blob blob = null; try { blob = processBlob(uri, watch, r); } catch (Exception t) { // TODO create and use internal exception instead... if (t instanceof ConnectTimeoutException) { spiderAccumulator.incConnectTimeout(); add(spider.getId(), uri); } else if (t instanceof ReadTimeoutException) { spiderAccumulator.incReadTimeout(); add(spider.getId(), uri); } else { log.debug("Error while looping", t); } } finally { barrier.passOrWait( blob != null && blob.getMetadata() != null ? blob.getMetadata().getSize() : null); } } else { // TODO Unknown protocol log.debug("Unknown protocol, can not find requester for '{}'", uri.getScheme()); } } else { log.trace("Frontier returned null Uri, waiting"); try { TimeUnit.MILLISECONDS.sleep(10000); } catch (InterruptedException e) { // Don't care log.trace("", e); } } } catch (RemoteException e) { switch (e.getError()) { case G_UNKNOWN: log.warn("Got a problem, waiting 2 sec...", e); try { TimeUnit.MILLISECONDS.sleep(2000); } catch (InterruptedException ie) { // Don't care log.trace("", ie); } } } catch (Exception e) { log.warn("Got a problem, waiting 2 sec...", e); try { TimeUnit.MILLISECONDS.sleep(2000); } catch (InterruptedException ie) { // Don't care log.trace("", ie); } } } }
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(); List<ReportStatus> reportStatusAsList = new ArrayList<ReportStatus>(); String finishFieldNumber = getFinishFieldNumberForSchemaTypeAndReportYear(schemaTypeName, reportYear); for (OrganisationUnitForBrowsing orgForBrowse : orgUnitsForBrodwsing) { Report report = service.getReport(orgForBrowse.getOrganisationUnitId(), schemaTypeName, reportYear, false);//from w ww .j av a 2 s . c o m 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.finances.service.hibernate3.FinanceServiceHelperH3Impl.java
public ReportStatus[] getReportStatusBySchemaTypeAndVersion( List<OrganisationUnitForBrowsing> orgUnitsForBrodwsing, String schemaTypeName, String version) { StopWatch stopWatch = new StopWatch(); stopWatch.start(); String finishFieldNumber = getFinishFieldNumberForSchemaTypeAndVersion(schemaTypeName, version); List<ReportStatus> reportStatusAsList = new ArrayList<ReportStatus>(); for (OrganisationUnitForBrowsing orgForBrowse : orgUnitsForBrodwsing) { ReportDataH3FinderSpecification finderSpecification = new ReportDataH3FinderSpecification( schemaTypeName, version, orgForBrowse.getOrganisationUnitId()); MainReportData reportData = (MainReportData) financeService.findSingle(finderSpecification); reportStatusAsList.add(createReportStatus(orgForBrowse, reportData, finishFieldNumber)); }//w w w . ja v a2 s. co m 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.lise.service.AbstractLiseImportService.java
private boolean checkOrganisationUnits(OrganisationRegisterBaseService baseService, ExcelParser excelParser, Map<String, String> excelColumnNames, boolean printWarningMessage) { StopWatch stopWatch = new StopWatch(); stopWatch.start(); int rowsWithOutMatch = 0; int numOfRowsWithData = excelParser.countNumberOfRowsInSheetBeforeStopTag(); // Get organisationUnit column name String organisationUnitExcelColumnName = excelColumnNames .get(DataLoaderUtils.KEY_ORGANISATIONUNIT_NAME_EXCEL_COLUMN); // First get a unique set of organisationUnit names Set<String> organisationUnitNames = new LinkedHashSet<String>(); Set<String> foundOrganisationUnitNames = new LinkedHashSet<String>(); Set<String> notFoundOrganisationUnitNames = new LinkedHashSet<String>(); excelParser.load();/*from w w w .ja va2 s . com*/ for (; excelParser.hasNext(); excelParser.next()) { String orgUnitName = excelParser.getCellValueAsString(organisationUnitExcelColumnName); organisationUnitNames.add(orgUnitName); OrganisationUnit organisationUnit = DataLoaderUtils.checkForAndGetOneAndOnlyOneOrganisationUnit( excelParser, baseService, excelColumnNames, printWarningMessage); if (organisationUnit != null) { foundOrganisationUnitNames.add(orgUnitName); } else { notFoundOrganisationUnitNames.add(orgUnitName); rowsWithOutMatch++; } } // Report result in log. String resultToLog = "The processed excel sheet had " + numOfRowsWithData + " rows with " + organisationUnitNames.size() + " distinkt organisationUnitNames, of which " + foundOrganisationUnitNames.size() + " have exact match, and " + notFoundOrganisationUnitNames.size() + " do not have exact match. We have " + rowsWithOutMatch + " rows without match."; logger.info(resultToLog); // System.out.println(resultToLog); stopWatch.stop(); String timeMessage = "Testing for organisationUnit matches tok " + stopWatch.getTotalTimeMillis() + " ms."; logger.info(timeMessage); // System.out.println(timeMessage); return (rowsWithOutMatch == 0); }
From source file:no.abmu.lise.util.LiseImportExcelParser.java
/** * Check for necessary input values.//from w ww. j a v a 2s . c o m * * Returns null if OK, else error message with description of missing * input values. * * @return - errorMessage equals Null if OK, else description of * missing input values. */ public String checkInputValues() { logger.info("Start testing for nessesary input values ..."); StopWatch stopWatch = new StopWatch(); stopWatch.start(); String[] notNullNamesSheet1 = { SUPPLIER_NAME, CONSORTIUM_NAME, C_AGREEMENT_START_DATE, PRODUCT_NAME, // P_DESCRIPTION, C_CURRENCY, RelationCustomerProduct_NAME }; String[] notNullNamesSheet2 = { CONSORTIUM_NAME, C_AGREEMENT_START_DATE, SP_PAYMENT_YEAR, SP_PAYMENT_CURRENCY, SP_PAYMENT_AMOUNT }; String[] notNullNamesSheet3 = { PRODUCT_NAME, CUSTOMER_NAME, CUSTOMERPAYMENT_INVOICE_YEAR }; StringBuffer resBuffer = new StringBuffer(); checkSheetForNotNullNames("Sheet1", notNullNamesSheet1, resBuffer); checkSheetForNotNullNames("Sheet2", notNullNamesSheet2, resBuffer); checkSheetForNotNullNames("Sheet3", notNullNamesSheet3, resBuffer); String errorMessage = resBuffer.toString(); if (StringUtil.notEmpty(errorMessage)) { logger.error(errorMessage); } else { logger.info("All nessesary input values were present ..."); } stopWatch.stop(); logger.info("Testing nessesary input values took " + stopWatch.getTotalTimeMillis() + " ms."); return errorMessage; }
From source file:no.abmu.lise.util.LiseImportExcelParser.java
public boolean checkExistenceOfOrganisations() { logger.info("Executing checkExistenceOfOrganisations"); boolean missingOrganisations = false; Set<String> organisationNames = new HashSet<String>(); StopWatch stopWatch = new StopWatch(); stopWatch.start(); load();// w w w . j av a 2 s . c o m for (; hasNext(); next()) { String name = getRelationCustomerProductname(); if (!organisationNames.contains(name)) { organisationNames.add(name); } String supplierName = getSupplierName(); if (!organisationNames.contains(supplierName)) { organisationNames.add(supplierName); } } setSheetName("Sheet3"); load(); for (; hasNext(); next()) { String name = getCustomerName(); if (!organisationNames.contains(name)) { organisationNames.add(name); } } logger.info("Found a total of (" + organisationNames.size() + ") organisationunits in the excel file ..."); StopWatch stopWatchGetOrgunits = new StopWatch(); stopWatchGetOrgunits.start(); Object[] allOrganisations = baseService.findAll(no.abmu.organisationregister.domain.OrganisationUnit.class); stopWatchGetOrgunits.stop(); logger.info("Getting '" + allOrganisations.length + "' OrganisationUnits from db took '" + stopWatchGetOrgunits.getTotalTimeMillis() + "' ms."); for (int i = 0; i < allOrganisations.length; i++) { OrganisationUnit organisationUnit = (OrganisationUnit) allOrganisations[i]; String name = organisationUnit.getName().getReference(); if (!organisationNames.contains(name)) { logger.error("NO OrganisationUnit is registered for (" + name + ") this should be registered !"); missingOrganisations = true; } } stopWatch.stop(); logger.info("Testing for existence of organisations took " + stopWatch.getTotalTimeMillis() + " ms."); return missingOrganisations; }
From source file:no.abmu.organisationregister.service.AbstractOrganisationUnitImportService.java
private boolean checkOrganisationUnits(ExcelParser excelParser, Map<String, String> excelColumnNames, boolean printWarningMessage) { StopWatch stopWatch = new StopWatch(); stopWatch.start(); int rowsWithOutMatch = 0; int numOfRowsWithData = excelParser.countNumberOfRowsInSheetBeforeStopTag(); // Get organisationUnit column name String organisationUnitExcelColumnName = excelColumnNames .get(DataLoaderUtils.KEY_ORGANISATIONUNIT_NAME_EXCEL_COLUMN); // First get a unique set of organisationUnit names Set<String> organisationUnitNames = new LinkedHashSet<String>(); Set<String> foundOrganisationUnitNames = new LinkedHashSet<String>(); Set<String> notFoundOrganisationUnitNames = new LinkedHashSet<String>(); excelParser.load();//from w ww .j av a 2 s . c o m for (; excelParser.hasNext(); excelParser.next()) { String orgUnitName = excelParser.getCellValueAsString(organisationUnitExcelColumnName); organisationUnitNames.add(orgUnitName); OrganisationUnit organisationUnit = DataLoaderUtils.checkForAndGetOneAndOnlyOneOrganisationUnit( excelParser, baseService, excelColumnNames, printWarningMessage); if (organisationUnit != null) { foundOrganisationUnitNames.add(orgUnitName); } else { notFoundOrganisationUnitNames.add(orgUnitName); rowsWithOutMatch++; } } // Report result in log. logger.info( "The processed excel sheet had " + numOfRowsWithData + " rows with " + organisationUnitNames.size() + " distinkt organisationUnitNames, of which " + foundOrganisationUnitNames.size() + " have exact match, and " + notFoundOrganisationUnitNames.size() + " do not have exact match. We have " + rowsWithOutMatch + " rows without match."); stopWatch.stop(); logger.info("Testing for organisationUnit matches tok " + stopWatch.getTotalTimeMillis() + " ms."); return (rowsWithOutMatch == 0); }
From source file:no.abmu.organisationregister.util.OrganisationUnitImportExcelParser.java
/** * Check for necessary input values./* w ww .j a v a 2s. c o m*/ * * Returns null if OK, else error message with description of missing * input values. * * @return - errorMessage equals Null if OK, else description of * missing input values. */ public String checkInputValues() { logger.info("Start testing for nessesary input values ..."); StopWatch stopWatch = new StopWatch(); stopWatch.start(); String[] notNullNames = { ORG_TYPE, NAVN_BOKMAL }; // {ORG_TYPE, NAVN_BOKMAL, ADRESSE_POST, POSTNR, POST_STED}; String errorMessage = checkInputValues(notNullNames); if (errorMessage != null) { logger.error(errorMessage); } else { logger.info("All nessesary input values were present ..."); } stopWatch.stop(); logger.info("Testing nessesary input values tok " + stopWatch.getTotalTimeMillis() + " ms."); return errorMessage; }