List of usage examples for org.apache.commons.lang.time StopWatch StopWatch
public StopWatch()
Constructor.
From source file:org.jasypt.encryption.pbe.PooledPBEWithMD5AndDESStringEncryptorThreadedTest.java
public static void main(String[] args) { try {/*from w ww . j av a 2s . c o m*/ final int numThreads = Integer.valueOf(args[0]).intValue(); final int numIters = Integer.valueOf(args[1]).intValue(); final int poolSize = Integer.valueOf(args[2]).intValue(); PooledPBEWithMD5AndDESStringEncryptorThreadedTest test = new PooledPBEWithMD5AndDESStringEncryptorThreadedTest( numThreads, numIters, poolSize); System.out.println("Starting test. NumThreads: " + numThreads + " NumIters: " + numIters + " PoolSize: " + poolSize); StopWatch sw = new StopWatch(); sw.start(); test.testThreadedDigest(); sw.stop(); System.out.println("Test finished in: " + sw.toString()); } catch (Exception e) { e.printStackTrace(); } }
From source file:org.kuali.kra.test.infrastructure.lifecycle.KcUnitTestBaseLifecycle.java
/** {@inheritDoc} */ public void startPerTest(boolean transactional) { if (this.perTestStarted) { throw new IllegalStateException("per test lifecycle already started"); }/*from w w w . j a v a 2 s. c om*/ final StopWatch watch = new StopWatch(); if (LOG.isDebugEnabled()) { watch.start(); LOG.debug("starting per test lifecycle"); } try { doPerTestStart(transactional); perTestStarted = true; } catch (Throwable e) { perTestStarted = false; if (LOG.isErrorEnabled()) { LOG.error("per test lifecycle failed to start cleanly", e); } throw new KcLifecycleException(e); } if (LOG.isDebugEnabled()) { watch.stop(); LOG.debug("per test lifecycle started in " + watch + " time"); } }
From source file:org.kuali.kra.test.infrastructure.lifecycle.KcUnitTestBaseLifecycle.java
/** {@inheritDoc} */ public void stopPerTest() { if (!this.perTestStarted) { throw new IllegalStateException("per test lifecycle already stopped"); }//from w ww . j av a 2 s.c o m final StopWatch watch = new StopWatch(); if (LOG.isDebugEnabled()) { watch.start(); LOG.debug("stopping per test lifecycle"); } try { doPerTestStop(); perTestStarted = false; } catch (Throwable e) { perTestStarted = false; if (LOG.isErrorEnabled()) { LOG.error("per test lifecycle failed to stop cleanly", e); } throw new KcLifecycleException(e); } if (LOG.isDebugEnabled()) { watch.stop(); LOG.debug("per test lifecycle stopped in " + watch + " time"); } }
From source file:org.kuali.kra.test.infrastructure.lifecycle.KcUnitTestBaseLifecycle.java
/** {@inheritDoc} */ public void startPerClass() { if (this.perClassStarted) { throw new IllegalStateException("per class lifecycle already started"); }//from w w w .ja va 2 s . c o m final StopWatch watch = new StopWatch(); if (LOG.isDebugEnabled()) { watch.start(); LOG.debug("starting per class lifecycle"); } try { doPerClassStart(); perClassStarted = true; } catch (Throwable e) { perClassStarted = false; if (LOG.isErrorEnabled()) { LOG.error("per class lifecycle failed to start cleanly", e); } throw new KcLifecycleException(e); } if (LOG.isDebugEnabled()) { watch.stop(); LOG.debug("per class lifecycle started in " + watch + " time"); } }
From source file:org.kuali.kra.test.infrastructure.lifecycle.KcUnitTestBaseLifecycle.java
/** {@inheritDoc} */ public void stopPerClass() { if (!this.perClassStarted) { throw new IllegalStateException("per class lifecycle already stopped"); }//from w w w .j ava 2 s . c om final StopWatch watch = new StopWatch(); if (LOG.isDebugEnabled()) { watch.start(); LOG.debug("stopping per class lifecycle"); } try { doPerClassStop(); perClassStarted = false; } catch (Throwable e) { perClassStarted = false; if (LOG.isErrorEnabled()) { LOG.error("per class lifecycle failed to stop cleanly", e); } throw new KcLifecycleException(e); } if (LOG.isDebugEnabled()) { watch.stop(); LOG.debug("per class lifecycle stopped in " + watch + " time"); } }
From source file:org.kuali.kra.test.infrastructure.lifecycle.KcUnitTestBaseLifecycle.java
/** {@inheritDoc} */ public void startPerSuite() { if (this.perSuiteStarted) { throw new IllegalStateException("per suite lifecycle already started"); }/*from www.ja va2 s . co m*/ final StopWatch watch = new StopWatch(); if (LOG.isDebugEnabled()) { watch.start(); LOG.debug("starting per suite lifecycle"); } try { doPerSuiteStart(); perSuiteStarted = true; } catch (Throwable e) { perSuiteStarted = false; if (LOG.isErrorEnabled()) { LOG.error("per suite lifecycle failed to start cleanly", e); } throw new KcLifecycleException(e); } if (LOG.isDebugEnabled()) { watch.stop(); LOG.debug("per suite lifecycle started in " + watch + " time"); } }
From source file:org.kuali.kra.test.infrastructure.lifecycle.KcUnitTestBaseLifecycle.java
/** {@inheritDoc} */ public void stopPerSuite() { if (!this.perSuiteStarted) { throw new IllegalStateException("per suite lifecycle already stopped"); }/*ww w . j av a 2 s. c o m*/ final StopWatch watch = new StopWatch(); if (LOG.isDebugEnabled()) { watch.start(); LOG.debug("stopping per suite lifecycle"); } try { doPerSuiteStop(); perSuiteStarted = false; } catch (Throwable e) { perSuiteStarted = false; if (LOG.isErrorEnabled()) { LOG.error("per suite lifecycle failed to stop cleanly", e); } throw new KcLifecycleException(e); } if (LOG.isDebugEnabled()) { watch.stop(); LOG.debug("per suite lifecycle stopped in " + watch + " time"); } }
From source file:org.kuali.ole.docstore.indexer.solr.WorkLicenseDocumentIndexer.java
@Override public String indexDocuments(List<RequestDocument> requestDocuments, boolean commit) { BatchIngestStatistics batchStatistics = BulkIngestStatistics.getInstance().getCurrentBatch(); String result = null;//www.ja va2 s. c o m StopWatch timer = new StopWatch(); StopWatch xmlToObjTime = new StopWatch(); xmlToObjTime.start(); xmlToObjTime.suspend(); timer.start(); List<SolrInputDocument> solrInputDocuments = new ArrayList<SolrInputDocument>(); if (requestDocuments != null && requestDocuments.size() > 0) { StopWatch buildSolrInputDocTime = new StopWatch(); StopWatch xmlToPojoTimer = new StopWatch(); buildSolrInputDocTime.start(); buildSolrInputDocTime.suspend(); xmlToPojoTimer.start(); xmlToPojoTimer.suspend(); try { for (RequestDocument requestDocument : requestDocuments) { if (DocFormat.ONIXPL.isEqualTo((requestDocument.getFormat()))) { //onixpl new WorkLicenseOnixplDocBuilder().buildSolrInputDocument(requestDocument, solrInputDocuments); } else if ((DocFormat.PDF.isEqualTo((requestDocument.getFormat()))) || DocFormat.DOC.isEqualTo(requestDocument.getFormat()) || DocFormat.XSLT.isEqualTo(requestDocument.getFormat())) { //pdf new WorkLicenseBinaryDocBuilder().buildSolrInputDocument(requestDocument, solrInputDocuments); } else { throw new Exception( "Unsupported Document Format : " + requestDocument.getFormat() + " Called."); } assignUUIDs(solrInputDocuments, null); } } catch (Exception e1) { result = buildFailureMsg(null, "Indexing failed. " + e1.getMessage()); logger.error(result, e1); } timer.stop(); if ((null == solrInputDocuments) || (solrInputDocuments.isEmpty())) { result = buildFailureMsg(null, "No valid documents found in input."); return result; } int numDocs = solrInputDocuments.size(); batchStatistics.setTimeToConvertXmlToPojo(xmlToPojoTimer.getTime()); batchStatistics.setTimeToConvertToSolrInputDocs(buildSolrInputDocTime.getTime()); logger.info("Conversion to Solr docs- Num:" + numDocs + ": Time taken:" + timer.toString()); result = indexSolrDocuments(solrInputDocuments, commit); } return result; }
From source file:org.kuali.ole.docstore.process.RebuildIndexesHandler.java
private void workEInstanceOLEML(String docCategory, String docType, String docFormat) { long totalCount = 0; long nodeCount = 0; List<RequestDocument> docs = new ArrayList<RequestDocument>(); WorkEInstanceOlemlRecordProcessor workEInstanceOlemlRecordProcessor = new WorkEInstanceOlemlRecordProcessor(); try {//from w w w. j a v a 2 s . com RequestDocument rd = new RequestDocument(); rd.setCategory(docCategory); rd.setType(docType); rd.setFormat(docFormat); List<ReIndexingBatchStatus> batchStatusList = new ArrayList<ReIndexingBatchStatus>(); BusinessObjectService businessObjectService = KRADServiceLocator.getBusinessObjectService(); List<EInstanceRecord> instanceRecords = (List<EInstanceRecord>) businessObjectService .findAll(EInstanceRecord.class); StopWatch loadTimer = new StopWatch(); StopWatch batchTimer = new StopWatch(); loadTimer.start(); batchTimer.start(); for (int i = 0; i < instanceRecords.size(); i++) { if (docs.size() == ProcessParameters.BULK_PROCESSOR_SPLIT_SIZE) { if (!isStop()) { ReIndexingBatchStatus reIndexingBatchStatus = indexBeforeParams(loadTimer); indexDocs(docs, totalCount, nodeCount, batchStatusList, reIndexingBatchStatus); indexAfterParams(batchTimer, reIndexingBatchStatus, batchStatusList); resetTimers(batchTimer, loadTimer); totalCount = 0; logger.info("Rebuild"); } else { return; } } else { EInstanceRecord instanceRecord = instanceRecords.get(i); String uuid = DocumentUniqueIDPrefix.getPrefixedId(instanceRecord.getUniqueIdPrefix(), instanceRecord.geteInstanceIdentifier()); RequestDocument requestDocument = buildRequestDocumentForCheckout(docCategory, docType, docFormat, uuid); ResponseDocument responseDocument = RdbmsWorkEInstanceDocumentManager.getInstance() .checkoutContent(requestDocument, businessObjectService); String content = responseDocument.getContent().getContent(); RequestDocument requestDocumentForIndex = (RequestDocument) rd.clone(); requestDocumentForIndex.setAdditionalAttributes(responseDocument.getAdditionalAttributes()); requestDocumentForIndex.setId(uuid); requestDocumentForIndex.setUuid(uuid); org.kuali.ole.docstore.model.xmlpojo.work.einstance.oleml.InstanceCollection instanceCollection = workEInstanceOlemlRecordProcessor .fromXML(content); content = workEInstanceOlemlRecordProcessor.toXML(instanceCollection); Content contentObj = new Content(); contentObj.setContent(content); contentObj.setContentObject(instanceCollection); requestDocumentForIndex.setContent(contentObj); docs.add(requestDocumentForIndex); totalCount++; } } if (docs.size() > 0 && !isStop()) { ReIndexingBatchStatus reIndexingBatchStatus = indexBeforeParams(loadTimer); indexDocs(docs, totalCount, nodeCount, batchStatusList, reIndexingBatchStatus); indexAfterParams(batchTimer, reIndexingBatchStatus, batchStatusList); } } catch (Exception e) { logger.error( "Rebuild Indexes Process(" + docCategory + " : " + docType + " : " + docFormat + ") Processed(" + (totalCount - docs.size()) + "), Failed @ batch(" + docs.size() + "): Cause: " + e, e); } finally { if (isStop) { ReIndexingStatus.getInstance().getDocTypeList().setStatus("Stopped"); } else { ReIndexingStatus.getInstance().getDocTypeList().setStatus("Done"); } } }
From source file:org.kuali.ole.docstore.process.RebuildIndexesHandler.java
private void indexBibDocs(List<BibTree> bibTreeList, long records, long recCount, List<ReIndexingBatchStatus> batchStatusList, ReIndexingBatchStatus reIndexingBatchStatus) { StopWatch indexTimer = new StopWatch(); DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss:SSS"); try {//w w w .j a v a2s.co m Date startDate = new Date(); reIndexingBatchStatus.setBatchStartTime(dateFormat.format(startDate)); indexTimer.start(); reIndexingBatchStatus.setStatus("Indexing"); reIndexingBatchStatus.setBatchIndexingTime(indexTimer.toString()); reIndexingBatchStatus.setRecordsProcessed(records); reIndexingBatchStatus.setBatchEndTime(" "); batchStatusList.add(reIndexingBatchStatus); ReIndexingStatus.getInstance().getDocTypeList().setReIndBatStatusList(batchStatusList); DocumentIndexer documentIndexer = BibMarcIndexer.getInstance(); BibTrees bibTrees = new BibTrees(); bibTrees.getBibTrees().addAll(bibTreeList); documentIndexer.createTrees(bibTrees); //logger.debug(result); indexTimer.stop(); Date endDate = new Date(); reIndexingBatchStatus.setBatchEndTime(dateFormat.format(endDate)); reIndexingBatchStatus.setBatchIndexingTime(indexTimer.toString()); reIndexingBatchStatus.setRecordsProcessed(records); reIndexingBatchStatus.setStatus("Done"); reIndexingBatchStatus.setRecordsRemaining(recCount - records); ReIndexingStatus.getInstance().getDocTypeList().setReIndBatStatusList(batchStatusList); bibTreeList.clear(); } catch (Exception e) { String firstBibId = bibTreeList.get(0).getBib().getId(); String lastBibId = bibTreeList.get(bibTreeList.size() - 1).getBib().getId(); logger.error("Rebuild Indexes Process(" + docCategory + " : " + docType + " : " + docFormat + ") Processed(" + (records - bibTreeList.size()) + "), Failed @ bibId( First BibId: " + firstBibId + " : Last BibId : " + lastBibId + "): Cause: " + e, e); indexTimer.stop(); Date endDate = new Date(); reIndexingBatchStatus.setBatchEndTime(dateFormat.format(endDate)); reIndexingBatchStatus.setBatchIndexingTime(indexTimer.toString()); reIndexingBatchStatus.setRecordsProcessed(0L); reIndexingBatchStatus.setStatus("Done"); reIndexingBatchStatus.setRecordsRemaining(recCount - records); ReIndexingStatus.getInstance().getDocTypeList().setReIndBatStatusList(batchStatusList); bibTreeList.clear(); } }