org.apache.commons.lang.time.StopWatch Java Examples

The following examples show how to use org.apache.commons.lang.time.StopWatch. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JdbcEntityDeleterImpl.java    From Eagle with Apache License 2.0 6 votes vote down vote up
private int deleteByCriteria(Criteria criteria) throws Exception {
    String displaySql = SqlBuilder.buildQuery(criteria).getDisplayString();
    StopWatch stopWatch = new StopWatch();
    stopWatch.start();

    if(LOG.isDebugEnabled()) LOG.debug("Deleting by query: " + displaySql);
    try {
        TorqueStatementPeerImpl peer = ConnectionManagerFactory.getInstance().getStatementExecutor();
        int result = peer.delegate().doDelete(criteria);
        LOG.info(String.format("Deleted %s records in %s ms (sql: %s)",result,stopWatch.getTime(),displaySql));
        return result;
    } catch (Exception e) {
        LOG.error("Failed to delete by query: "+displaySql,e);
        throw e;
    } finally {
        stopWatch.stop();
    }
}
 
Example #2
Source File: ErrataManagerTest.java    From spacewalk with GNU General Public License v2.0 6 votes vote down vote up
public void xxxxLookupErrataByAdvisoryType() throws IOException {

        String bugfix = "Bug Fix Advisory";
        String pea = "Product Enhancement Advisory";
        String security = "Security Advisory";

        StopWatch st = new StopWatch();
        st.start();
        List erratas = ErrataManager.lookupErrataByType(bugfix);
        outputErrataList(erratas);
        System.out.println("Got bugfixes: "  + erratas.size() + " time: " + st);
        assertTrue(erratas.size() > 0);
        erratas = ErrataManager.lookupErrataByType(pea);
        outputErrataList(erratas);
        System.out.println("Got pea enhancments: "  + erratas.size() + " time: " + st);
        assertTrue(erratas.size() > 0);
        erratas = ErrataManager.lookupErrataByType(security);
        outputErrataList(erratas);
        assertTrue(erratas.size() > 0);
        System.out.println("Got security advisories: "  + erratas.size() + " time: " + st);
        st.stop();
        System.out.println("TIME: " + st.getTime());
    }
 
Example #3
Source File: ScoreEngineJobsImpl.java    From score with Apache License 2.0 6 votes vote down vote up
/**
 * Job that will handle the joining of finished branches for parallel and non-blocking steps.
 */
@Override
public void joinFinishedSplitsJob() {
    try {
        if (logger.isDebugEnabled()) logger.debug("SplitJoinJob woke up at " + new Date());
        StopWatch stopWatch = new StopWatch();
        stopWatch.start();

        // try sequentially at most 'ITERATIONS' attempts
        // quit when there aren't any more results to process
        boolean moreToJoin = true;
        for (int i = 0; i < SPLIT_JOIN_ITERATIONS && moreToJoin; i++) {
            int joinedSplits = splitJoinService.joinFinishedSplits(SPLIT_JOIN_BULK_SIZE);
            moreToJoin = (joinedSplits == SPLIT_JOIN_BULK_SIZE);
        }

        stopWatch.stop();
        if (logger.isDebugEnabled()) logger.debug("finished SplitJoinJob in " + stopWatch);
    } catch (Exception ex) {
        logger.error("SplitJoinJob failed", ex);
    }
}
 
Example #4
Source File: BaseUpdateChannelCommand.java    From spacewalk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Private helper method to create a new UpdateErrataCacheEvent and publish it to the
 * MessageQueue.
 * @param orgIn The org we're updating.
 */
private void publishUpdateErrataCacheEvent() {
    StopWatch sw = new StopWatch();
    if (log.isDebugEnabled()) {
        log.debug("Updating errata cache");
        sw.start();
    }

    UpdateErrataCacheEvent uece =
        new UpdateErrataCacheEvent(UpdateErrataCacheEvent.TYPE_ORG);
    uece.setOrgId(user.getOrg().getId());
    MessageQueue.publish(uece);

    if (log.isDebugEnabled()) {
        sw.stop();
        log.debug("Finished Updating errata cache. Took [" +
                sw.getTime() + "]");
    }
}
 
Example #5
Source File: LoginHelper.java    From spacewalk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @param orgIn
 */
private static void publishUpdateErrataCacheEvent(Org orgIn) {
    StopWatch sw = new StopWatch();
    if (log.isDebugEnabled()) {
        log.debug("Updating errata cache");
        sw.start();
    }

    UpdateErrataCacheEvent uece = new
        UpdateErrataCacheEvent(UpdateErrataCacheEvent.TYPE_ORG);
    uece.setOrgId(orgIn.getId());
    MessageQueue.publish(uece);

    if (log.isDebugEnabled()) {
        sw.stop();
        log.debug("Finished Updating errata cache. Took [" +
                sw.getTime() + "]");
    }
}
 
Example #6
Source File: ArchaeusPassConfigurationTest.java    From staash with Apache License 2.0 6 votes vote down vote up
void timeConfig(MyConfig config, String name, int count) {
        StopWatch sw = new StopWatch();
        sw.start();
        for (int i = 0; i < count; i++) {
            for (Method method : MyConfig.class.getMethods()) {
                try {
                    Object value = method.invoke(config);
//                    System.out.println(name + " " + method.getName() + " " + value);
                    
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
        
        System.out.println(name + " took " + sw.getTime());
    }
 
Example #7
Source File: PooledPBEWithMD5AndDESStringEncryptorThreadedTest.java    From jasypt with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) {
    try {
        
        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();
    }
}
 
Example #8
Source File: PooledStandardStringDigesterThreadedTest.java    From jasypt with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) {
    try {
        
        final int numThreads = Integer.valueOf(args[0]).intValue();
        final int numIters = Integer.valueOf(args[1]).intValue();
        final int poolSize = Integer.valueOf(args[2]).intValue();
        
        PooledStandardStringDigesterThreadedTest test = 
            new PooledStandardStringDigesterThreadedTest(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();
    }
}
 
Example #9
Source File: StandardStringDigesterThreadedTest.java    From jasypt with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) {
    try {
        
        StandardStringDigesterThreadedTest test = new StandardStringDigesterThreadedTest();
        
        System.out.println("Starting test");
        StopWatch sw = new StopWatch();
        sw.start();
        test.testThreadedDigest();
        sw.stop();
        System.out.println("Test finished in: " + sw.toString());
        
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example #10
Source File: ChannelSoftwareHandler.java    From spacewalk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Private helper method to create a new UpdateErrataCacheEvent and publish it to the
 * MessageQueue.
 * @param orgIn The org we're updating.
 */
private void publishUpdateErrataCacheEvent(Org orgIn) {
    StopWatch sw = new StopWatch();
    if (log.isDebugEnabled()) {
        log.debug("Updating errata cache");
        sw.start();
    }

    UpdateErrataCacheEvent uece =
        new UpdateErrataCacheEvent(UpdateErrataCacheEvent.TYPE_ORG);
    uece.setOrgId(orgIn.getId());
    MessageQueue.publish(uece);

    if (log.isDebugEnabled()) {
        sw.stop();
        log.debug("Finished Updating errata cache. Took [" +
                sw.getTime() + "]");
    }
}
 
Example #11
Source File: StreamWindowBenchmarkTest.java    From eagle with Apache License 2.0 6 votes vote down vote up
private void benchmarkTest(StreamWindow window, StreamWindowRepository.StorageType storageType) {
    StopWatch stopWatch = new StopWatch();
    stopWatch.start();
    LOGGER.info("\n===== Benchmark Test for {} ({}) =====", window.getClass().getSimpleName(), storageType);
    metricReporter.report();
    sendDESCOrderedEventsToWindow(window, storageType, 1000);
    metricReporter.report();
    sendDESCOrderedEventsToWindow(window, storageType, 10000);
    metricReporter.report();
    sendDESCOrderedEventsToWindow(window, storageType, 100000);
    metricReporter.report();
    sendDESCOrderedEventsToWindow(window, storageType, 1000000);
    metricReporter.report();
    stopWatch.stop();
    LOGGER.info("\n===== Finished in total {} ms =====\n", stopWatch.getTime());
}
 
Example #12
Source File: EsServiceMappingStore.java    From soundwave with Apache License 2.0 6 votes vote down vote up
public List<EsServiceMapping> getServiceMappings() throws Exception {
  StopWatch sw = new StopWatch();
  sw.start();
  List<EsServiceMapping> ret = new ArrayList<>();
  SearchResponse result = getByDocType(10000);
  for (SearchHit hit : result.getHits()) {
    try {
      EsServiceMapping
          serviceMapping =
          mapper.readValue(hit.getSourceAsString(), EsServiceMapping.class);
      serviceMapping.buildMatchPatterns();
      ret.add(serviceMapping);
    } catch (Exception ex) {
      logger.error("Cannot create Service mapping from {}", hit.getSourceAsString());
    }
  }
  sw.stop();
  logger.info("Refresh all service mappings in {} ms", sw.getTime());
  return ret;
}
 
Example #13
Source File: CacheService.java    From SkyEye with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 将数据库中的配置表进行缓存
 */
private void loadCache() {
    StopWatch sw = new StopWatch();
    sw.start();
    LOGGER.info("start load config to cache");

    Iterable<NameInfo> nameInfos = this.nameInfoRepository.findAll();

    for (Iterator<NameInfo> it = nameInfos.iterator(); it.hasNext();) {
        NameInfo nameInfo = it.next();
        this.setOps.add(mapping.get(nameInfo.getNameInfoPK().getType()), nameInfo.getNameInfoPK().getName());
    }

    sw.stop();
    LOGGER.info("load config to cache end, cost {} ms", sw.getTime());
}
 
Example #14
Source File: TestJdbcStorage.java    From eagle with Apache License 2.0 6 votes vote down vote up
/**
 * TODO: Investigate why writing performance becomes slower as records count increases
 *
 * 1) Wrote 100000 records in about 18820 ms for empty table
 * 2) Wrote 100000 records in about 35056 ms when 1M records in table
 *
 * @throws IOException
 */
@Test @Ignore("Ignore performance auto testing")
public void testWriterPerformance() throws IOException {
    StopWatch stopWatch = new StopWatch();
    stopWatch.start();
    List<TestTimeSeriesAPIEntity> entityList = new ArrayList<TestTimeSeriesAPIEntity>();
    int i= 0;
    while( i++ < 100000){
        entityList.add(newInstance());
        if(entityList.size()>=1000) {
            ModifyResult<String> result = storage.create(entityList, entityDefinition);
            Assert.assertNotNull(result);
            entityList.clear();
        }
    }
    stopWatch.stop();
    LOG.info("Wrote 100000 records in "+stopWatch.getTime()+" ms");
}
 
Example #15
Source File: FbRunner.java    From freebencher with Apache License 2.0 6 votes vote down vote up
private void doIt() {
	boolean successful = false;

	StopWatch stopWatch = new StopWatch();
	stopWatch.start();
	try {
		successful = job.getTarget().invoke();
	} catch (Exception e) {
		successful = false;
	}
	stopWatch.stop();
	if (successful) {
		job.getResult().getSuccessfulTests().incrementAndGet();
	} else {
		job.getResult().getFailedTests().incrementAndGet();
	}

	job.getResult()
			.addSingleTestResult(successful, stopWatch.getTime());
	int results = job.getResult().getNumOfTests();
	if (results != 0 && !job.getOptions().isQuiet()
			&& (job.getResult().getNumOfTests() % 100 == 0)) {
		System.err.printf("%d/%d are done\n", results, job.getOptions()
				.getNumOfTests());
	}
}
 
Example #16
Source File: JdbcEntityReaderImpl.java    From eagle with Apache License 2.0 6 votes vote down vote up
@Override
public <E> List<E> query(List<String> ids) throws Exception {
    PrimaryKeyCriteriaBuilder criteriaBuilder = new PrimaryKeyCriteriaBuilder(ids,this.jdbcEntityDefinition.getJdbcTableName());
    Criteria criteria = criteriaBuilder.build();
    String displaySql = SqlBuilder.buildQuery(criteria).getDisplayString();
    if(LOG.isDebugEnabled()) LOG.debug("Querying: " + displaySql);
    EntityRecordMapper recordMapper = new EntityRecordMapper(jdbcEntityDefinition);
    final StopWatch stopWatch = new StopWatch();
    List<E> result;
    try {
        stopWatch.start();
        TorqueStatementPeerImpl peer = ConnectionManagerFactory.getInstance().getStatementExecutor();
        criteria.addSelectColumn(new ColumnImpl(jdbcEntityDefinition.getJdbcTableName(),"*"));
        result = peer.delegate().doSelect(criteria, recordMapper);
        LOG.info(String.format("Read %s records in %s ms (sql: %s)",result.size(),stopWatch.getTime(),displaySql));
    }catch (Exception ex){
        LOG.error("Failed to query by: "+displaySql+", due to: "+ex.getMessage(),ex);
        throw new IOException("Failed to query by: "+displaySql,ex);
    }finally {
        stopWatch.stop();
    }
    return result;
}
 
Example #17
Source File: JdbcEntityDeleterImpl.java    From eagle with Apache License 2.0 6 votes vote down vote up
private int deleteByCriteria(Criteria criteria) throws Exception {
    String displaySql = SqlBuilder.buildQuery(criteria).getDisplayString();
    StopWatch stopWatch = new StopWatch();
    stopWatch.start();

    if(LOG.isDebugEnabled()) LOG.debug("Deleting by query: " + displaySql);
    try {
        TorqueStatementPeerImpl peer = ConnectionManagerFactory.getInstance().getStatementExecutor();
        int result = peer.delegate().doDelete(criteria);
        LOG.info(String.format("Deleted %s records in %s ms (sql: %s)",result,stopWatch.getTime(),displaySql));
        return result;
    } catch (Exception e) {
        LOG.error("Failed to delete by query: "+displaySql,e);
        throw e;
    } finally {
        stopWatch.stop();
    }
}
 
Example #18
Source File: DefaultProcedureOperator.java    From ymate-platform-v2 with Apache License 2.0 6 votes vote down vote up
@Override
public void execute() throws Exception {
    if (!this.executed) {
        StopWatch _time = new StopWatch();
        _time.start();
        try {
            __doExecute();
            // 执行过程未发生异常将标记已执行,避免重复执行
            this.executed = true;
        } finally {
            _time.stop();
            this.expenseTime = _time.getTime();
            //
            if (this.getConnectionHolder().getDataSourceCfgMeta().isShowSQL()) {
                _LOG.info(ExpressionUtils.bind("[${sql}]${param}[${count}][${time}]")
                        .set("sql", StringUtils.defaultIfBlank(this.sql, "@NULL"))
                        .set("param", __doSerializeParameters())
                        .set("count", "N/A")
                        .set("time", this.expenseTime + "ms").getResult());
            }
        }
    }
}
 
Example #19
Source File: TestJdbcStorage.java    From Eagle with Apache License 2.0 6 votes vote down vote up
/**
 * TODO: Investigate why writing performance becomes slower as records count increases
 *
 * 1) Wrote 100000 records in about 18820 ms for empty table
 * 2) Wrote 100000 records in about 35056 ms when 1M records in table
 *
 * @throws IOException
 */
//@Test
public void testWriterPerformance() throws IOException {
    StopWatch stopWatch = new StopWatch();
    stopWatch.start();
    List<TestTimeSeriesAPIEntity> entityList = new ArrayList<TestTimeSeriesAPIEntity>();
    int i= 0;
    while( i++ < 100000){
        entityList.add(newInstance());
        if(entityList.size()>=1000) {
            ModifyResult<String> result = storage.create(entityList, entityDefinition);
            Assert.assertNotNull(result);
            entityList.clear();
        }
    }
    stopWatch.stop();
    LOG.info("Wrote 100000 records in "+stopWatch.getTime()+" ms");
}
 
Example #20
Source File: StreamWindowBenchmarkTest.java    From eagle with Apache License 2.0 6 votes vote down vote up
public void sendDESCOrderedEventsToWindow(StreamWindow window, StreamWindowRepository.StorageType storageType, int num) {
    LOGGER.info("Sending {} events to {} ({})", num, window.getClass().getSimpleName(), storageType);
    StopWatch stopWatch = new StopWatch();
    stopWatch.start();
    int i = 0;
    while (i < num) {
        PartitionedEvent event = MockSampleMetadataFactory.createPartitionedEventGroupedByName("sampleStream_1", (window.startTime() + i));
        window.add(event);
        i++;
    }
    stopWatch.stop();
    performanceReport.put(num + "\tInsertTime\t" + storageType, stopWatch.getTime());
    LOGGER.info("Inserted {} events in {} ms", num, stopWatch.getTime());
    stopWatch.reset();
    stopWatch.start();
    window.flush();
    stopWatch.stop();
    performanceReport.put(num + "\tReadTime\t" + storageType, stopWatch.getTime());
}
 
Example #21
Source File: JdbcEntityReaderImpl.java    From Eagle with Apache License 2.0 6 votes vote down vote up
@Override
public <E> List<E> query(List<String> ids) throws Exception {
    PrimaryKeyCriteriaBuilder criteriaBuilder = new PrimaryKeyCriteriaBuilder(ids,this.jdbcEntityDefinition.getJdbcTableName());
    Criteria criteria = criteriaBuilder.build();
    String displaySql = SqlBuilder.buildQuery(criteria).getDisplayString();
    if(LOG.isDebugEnabled()) LOG.debug("Querying: " + displaySql);
    EntityRecordMapper recordMapper = new EntityRecordMapper(jdbcEntityDefinition);
    final StopWatch stopWatch = new StopWatch();
    List<E> result;
    try {
        stopWatch.start();
        TorqueStatementPeerImpl peer = ConnectionManagerFactory.getInstance().getStatementExecutor();
        result = peer.delegate().doSelect(criteria, recordMapper);
        LOG.info(String.format("Read %s records in %s ms (sql: %s)",result.size(),stopWatch.getTime(),displaySql));
    }catch (Exception ex){
        LOG.error("Failed to query by: "+displaySql+", due to: "+ex.getMessage(),ex);
        throw new IOException("Failed to query by: "+displaySql,ex);
    }finally {
        stopWatch.stop();
    }
    return result;
}
 
Example #22
Source File: CacheService.java    From SkyEye with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 将数据库中的配置表进行缓存
 */
private void loadCache() {
    StopWatch sw = new StopWatch();
    sw.start();
    LOGGER.info("start load config to cache");

    Iterable<ServiceInfo> serviceInfos = this.serviceInfoRepository.findAll();

    for (Iterator<ServiceInfo> it = serviceInfos.iterator(); it.hasNext();) {
        ServiceInfo serviceInfo = it.next();
        this.setOps.add(SERVICE_INFO_PREFIX, serviceInfo.getSid());
    }

    sw.stop();
    LOGGER.info("load config to cache end, cost {} ms", sw.getTime());
}
 
Example #23
Source File: LargeInputFileIT.java    From datacollector with Apache License 2.0 5 votes vote down vote up
@Test
public void testLargeFile() throws Exception {
  File inputFile = new File(getInputDir(), "input.avro");
  File outputFile = new File(getOutputDir(), "input.parquet");
  long recordCount = Long.valueOf(System.getProperty(TARGET_RECORD_COUNT, TARGET_RECORD_COUNT_DEFAULT));
  StopWatch stopWatch = new StopWatch();

  stopWatch.start();
  generateAvroFile(AVRO_SCHEMA, inputFile, recordCount);
  stopWatch.stop();

  LOG.info("Created input avro file in {}, contains {} records and have {}.", stopWatch.toString(), recordCount, humanReadableSize(inputFile.length()));


  AvroConversionCommonConfig commonConfig = new AvroConversionCommonConfig();
  AvroParquetConfig conf = new AvroParquetConfig();
  commonConfig.inputFile = inputFile.getAbsolutePath();
  commonConfig.outputDirectory = getOutputDir();

  MapReduceExecutor executor = generateExecutor(commonConfig, conf, Collections.emptyMap());

  ExecutorRunner runner = new ExecutorRunner.Builder(MapReduceDExecutor.class, executor)
    .setOnRecordError(OnRecordError.TO_ERROR)
    .build();
  runner.runInit();

  Record record = RecordCreator.create();
  record.set(Field.create(Collections.<String, Field>emptyMap()));

  stopWatch.reset();
  stopWatch.start();
  runner.runWrite(ImmutableList.of(record));
  stopWatch.stop();
  LOG.info("Generated output parquet file in {} and have {}.", stopWatch.toString(), humanReadableSize(outputFile.length()));

  Assert.assertEquals(0, runner.getErrorRecords().size());
  runner.runDestroy();

  validateParquetFile(new Path(outputFile.getAbsolutePath()), recordCount);
}
 
Example #24
Source File: TestHBaseWriteEntitiesPerformance.java    From eagle with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unused")
@Test
public void testWrite1MLogAPIEntities() {
    Date startTime = new Date();
    LOG.info("Start time: " + startTime);
    StopWatch watch = new StopWatch();
    watch.start();
    List<String> rowKeys = writeEntities(10);
    Assert.assertNotNull(rowKeys);
    watch.stop();
    Date endTime = new Date();
    LOG.info("End time: " + endTime);
    LOG.info("Totally take " + watch.getTime() * 1.0 / 1000 + " s");
}
 
Example #25
Source File: ErrataCacheTaskTest.java    From spacewalk with GNU General Public License v2.0 5 votes vote down vote up
public void aTestExecute() throws Exception {
    StopWatch sw = new StopWatch();

    ErrataCacheTask ect = new ErrataCacheTask();

    sw.start();
    ect.execute(null);
    sw.stop();
    System.out.println("ErrataCacheTask took [" + sw.getTime() + "]");
}
 
Example #26
Source File: MRHistoryJobDailyReporter.java    From eagle with Apache License 2.0 5 votes vote down vote up
private Map<String, Object> buildAlertData(String site, long startTime, long endTime) {
    StopWatch watch = new StopWatch();
    Map<String, Object> data = new HashMap<>();
    this.client = new EagleServiceClientImpl(config);
    String startTimeStr = DateTimeUtil.millisecondsToHumanDateWithSeconds(startTime);
    String endTimeStr = DateTimeUtil.millisecondsToHumanDateWithSeconds(endTime);
    LOG.info("Going to report job summery info for site {} from {} to {}", site, startTimeStr, endTimeStr);
    try {
        watch.start();
        data.putAll(buildJobSummery(site, startTime, endTime));
        data.put(NUM_TOP_USERS_KEY, numTopUsers);
        data.put(JOB_OVERTIME_LIMIT_KEY, jobOvertimeLimit);
        data.put(ALERT_TITLE_KEY, String.format("[%s] Job Report for 12 Hours", site.toUpperCase()));
        data.put(REPORT_RANGE_KEY, String.format("%s ~ %s %s", startTimeStr, endTimeStr, DateTimeUtil.CURRENT_TIME_ZONE.getID()));
        data.put(EAGLE_JOB_LINK_KEY, String.format("http://%s:%d/#/site/%s/jpm/list?startTime=%s&endTime=%s",
                config.getString(SERVICE_HOST), config.getInt(SERVICE_PORT), site, startTimeStr, endTimeStr));
        watch.stop();
        LOG.info("Fetching DailyJobReport tasks {} seconds", watch.getTime() / DateTimeUtil.ONESECOND);
    } finally {
        try {
            client.close();
        } catch (IOException e) {
            LOG.info("fail to close eagle service client");
        }
    }
    return data;
}
 
Example #27
Source File: TestHBaseWriteEntitiesPerformance.java    From Eagle with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unused")
@Test
public void testWrite1MLogAPIEntities(){
	Date startTime = new Date();
	LOG.info("Start time: " + startTime);
	StopWatch watch = new StopWatch();
	watch.start();
	List<String> rowKeys = writeEntities(10);
	Assert.assertNotNull(rowKeys);
	watch.stop();
	Date endTime = new Date();
	LOG.info("End time: " + endTime);
	LOG.info("Totally take " + watch.getTime() * 1.0 / 1000 + " s");
}
 
Example #28
Source File: FileStopWatch.java    From ezScrum with GNU General Public License v2.0 5 votes vote down vote up
public void openFile(String file) {
	watch = new StopWatch();
	try {
		writer = new FileWriter(file);
	} catch (IOException e) {
		log.error("開檔發生錯誤");
		e.printStackTrace();
	}
}
 
Example #29
Source File: ScoreEngineJobsImpl.java    From score with Apache License 2.0 5 votes vote down vote up
@Override
public void miMergeBranchesContexts() {
    try {
        if (logger.isDebugEnabled()) {
            logger.debug("MiMergeBranchesContextsJob woke up at " + new Date());
        }
        StopWatch stopWatch = new StopWatch();
        stopWatch.start();

        // try sequentially at most 'ITERATIONS' attempts
        // quit when there aren't any more results to process
        boolean moreToJoin;

        for (int i = 0; i < SPLIT_JOIN_ITERATIONS; i++) {
            int joinedSplits = splitJoinService.joinFinishedMiBranches(SPLIT_JOIN_BULK_SIZE);
            moreToJoin = (joinedSplits == SPLIT_JOIN_BULK_SIZE);
            if (!moreToJoin) {
                break;
            }
        }

        stopWatch.stop();
        if (logger.isDebugEnabled()) logger.debug("finished MiContextsMediatorJob in " + stopWatch);
    } catch (Exception ex) {
        logger.error("MiContextsMediatorJob failed", ex);
    }
}
 
Example #30
Source File: JdbcEntityUpdaterImpl.java    From eagle with Apache License 2.0 5 votes vote down vote up
@Override
public int update(List<E> entities) throws Exception {
    ConnectionManager cm = ConnectionManagerFactory.getInstance();
    TorqueStatementPeerImpl<E> peer = cm.getStatementExecutor(this.jdbcEntityDefinition.getJdbcTableName());
    Connection connection = cm.getConnection();
    connection.setAutoCommit(false);

    StopWatch stopWatch = new StopWatch();
    stopWatch.start();
    int num = 0;
    try {
        for (E entity : entities) {
            String primaryKey = entity.getEncodedRowkey();
            if(primaryKey==null) {
                primaryKey = ConnectionManagerFactory.getInstance().getStatementExecutor().getPrimaryKeyBuilder().build(entity);
                entity.setEncodedRowkey(primaryKey);
            }
            PrimaryKeyCriteriaBuilder pkBuilder = new PrimaryKeyCriteriaBuilder(Collections.singletonList(primaryKey), this.jdbcEntityDefinition.getJdbcTableName());
            Criteria selectCriteria = pkBuilder.build();
            if(LOG.isDebugEnabled()) LOG.debug("Updating by query: "+SqlBuilder.buildQuery(selectCriteria).getDisplayString());
            ColumnValues columnValues = JdbcEntitySerDeserHelper.buildColumnValues(entity, this.jdbcEntityDefinition);
            num += peer.delegate().doUpdate(selectCriteria, columnValues, connection);
        }
        if(LOG.isDebugEnabled()) LOG.debug("Committing updates");
        connection.commit();
    } catch (Exception ex) {
        LOG.error("Failed to update, rolling back",ex);
        connection.rollback();
        throw ex;
    }finally {
        stopWatch.stop();
        if(LOG.isDebugEnabled()) LOG.debug("Closing connection");
        connection.close();
    }
    LOG.info(String.format("Updated %s records in %s ms",num,stopWatch.getTime()));
    return num;
}