Package org.apache.commons.lang.time

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


            return new Lock( file );
        }

        mkdirs( file.getParentFile() );

        StopWatch stopWatch = new StopWatch();
        boolean acquired = false;

        Lock lock = null;

        stopWatch.start();

        while ( !acquired )
        {

            if ( timeout > 0 )
            {
                long delta = stopWatch.getTime();
                log.debug( "delta {}, timeout {}", delta, timeout );
                if ( delta > timeout )
                {
                    log.warn( "Cannot acquire read lock within {} millis. Will skip the file: {}", timeout, file );
                    // we could not get the lock within the timeout period, so throw FileLockTimeoutException
View Full Code Here


        if ( skipLocking )
        {
            return new Lock( file );

        }
        StopWatch stopWatch = new StopWatch();
        boolean acquired = false;
        mkdirs( file.getParentFile() );

        Lock lock = null;

        stopWatch.start();

        while ( !acquired )
        {

            if ( timeout > 0 )
            {
                long delta = stopWatch.getTime();
                log.debug( "delta {}, timeout {}", delta, timeout );
                if ( delta > timeout )
                {
                    log.warn( "Cannot acquire read lock within {} millis. Will skip the file: {}", timeout, file );
                    // we could not get the lock within the timeout period, so  throw  FileLockTimeoutException
View Full Code Here

public class Telemetry {
    private StopWatch generalTimer;
    private StopWatch migrationTimer;

    public Telemetry() {
        this.generalTimer = new StopWatch();
        this.migrationTimer = new StopWatch();
    }
View Full Code Here

        try {
            entityManagerFactory = createEntityManager();
            entityManager = entityManagerFactory.createEntityManager();
            source = new ExistingPostgresDataBulkExportSource(entityManager,
                "SELECT  schedule_id, time_stamp, value, minvalue, maxvalue FROM RHQ_MEASUREMENT_DATA_NUM_1D");
            StopWatch stopWatch = new StopWatch();
            stopWatch.start();
            source.initialize();
            int rowIndex = 0;
            int maxResults = 30000;
            for (;;) {
                List<Object[]> existingData = source.getData(rowIndex, maxResults);
                if (existingData.size() < maxResults) {
                    break;
                } else {
                    rowIndex += maxResults;
                }
            }
            stopWatch.stop();
            System.out.println("Execution: " + stopWatch);
        } finally {
            if (source != null) {
                source.close();
            }
View Full Code Here

        try {
            entityManagerFactory = createEntityManager();
            entityManager = entityManagerFactory.createEntityManager();
            source = new ExistingPostgresDataBulkExportSource(entityManager,
                "SELECT  schedule_id, time_stamp, value, minvalue, maxvalue FROM RHQ_MEASUREMENT_DATA_NUM_1D");
            StopWatch stopWatch = new StopWatch();
            stopWatch.start();
            source.initialize();
            int rowIndex = 0;
            int maxResults = 30000;
            for (;;) {
                List<Object[]> existingData = source.getData(rowIndex, maxResults);
                if (existingData.size() < maxResults) {
                    break;
                } else {
                    rowIndex += maxResults;
                }
            }
            stopWatch.stop();
            System.out.println("Execution: " + stopWatch);
        } finally {
            if (source != null) {
                source.close();
            }
View Full Code Here

   
    /**
     * Creates a new instance of TimeWatcher
     */
    public TimeWatcher() {
        _watch = new StopWatch();
    }
View Full Code Here

    HTableDescriptor tableDesc = table.getTableDescriptor();
    byte[] startKey = null;
    Get get = null;
    Scan scan = null;
    ResultScanner rs = null;
    StopWatch stopWatch = new StopWatch();
    for (HColumnDescriptor column : tableDesc.getColumnFamilies()) {
      stopWatch.reset();
      startKey = region.getStartKey();
      // Can't do a get on empty start row so do a Scan of first element if any instead.
      if (startKey.length > 0) {
        get = new Get(startKey);
        get.addFamily(column.getName());
      } else {
        scan = new Scan();
        scan.setCaching(1);
        scan.addFamily(column.getName());
        scan.setMaxResultSize(1L);
      }

      try {
        if (startKey.length > 0) {
          stopWatch.start();
          table.get(get);
          stopWatch.stop();
          sink.publishReadTiming(region, column, stopWatch.getTime());
        } else {
          stopWatch.start();
          rs = table.getScanner(scan);
          stopWatch.stop();
          sink.publishReadTiming(region, column, stopWatch.getTime());
        }
      } catch (Exception e) {
        sink.publishReadFailure(region, column, e);
      } finally {
        if (rs != null) {
View Full Code Here

      HRegionInfo region = null;
      HTable table = null;
      Get get = null;
      byte[] startKey = null;
      Scan scan = null;
      StopWatch stopWatch = new StopWatch();
      // monitor one region on every region server
      for (Map.Entry<String, List<HRegionInfo>> entry : rsAndRMap.entrySet()) {
        stopWatch.reset();
        serverName = entry.getKey();
        // always get the first region
        region = entry.getValue().get(0);
        try {
          tableName = region.getTable().getNameAsString();
          table = new HTable(this.admin.getConfiguration(), tableName);
          startKey = region.getStartKey();
          // Can't do a get on empty start row so do a Scan of first element if any instead.
          if(startKey.length > 0) {
            get = new Get(startKey);
            stopWatch.start();
            table.get(get);
            stopWatch.stop();
          } else {
            scan = new Scan();
            scan.setCaching(1);
            scan.setMaxResultSize(1L);
            stopWatch.start();
            table.getScanner(scan);
            stopWatch.stop();
          }
          this.getSink().publishReadTiming(tableName, serverName, stopWatch.getTime());
        } catch (TableNotFoundException tnfe) {
          // This is ignored because it doesn't imply that the regionserver is dead
        } catch (TableNotEnabledException tnee) {
          // This is considered a success since we got a response.
          LOG.debug("The targeted table was disabled.  Assuming success.");
View Full Code Here

    return fostream;
  }
 
  private StopWatch getStopWatch() {
    if (stopWatch == null) {
      stopWatch = new StopWatch();
    }
    return stopWatch;
  }
View Full Code Here

    @PostConstruct
    public void startup()
        throws ArchivaException
    {

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

        archivaConfiguration.addListener( this );

        List<ManagedRepositoryConfiguration> repositories =
            archivaConfiguration.getConfiguration().getManagedRepositories();

        RepositorySession repositorySession = repositorySessionFactory.createSession();
        try
        {
            MetadataRepository metadataRepository = repositorySession.getRepository();
            for ( ManagedRepositoryConfiguration repoConfig : repositories )
            {
                if ( repoConfig.isScanned() )
                {
                    try
                    {
                        scheduleRepositoryJobs( repoConfig );
                    }
                    catch ( SchedulerException e )
                    {
                        throw new ArchivaException( "Unable to start scheduler: " + e.getMessage(), e );
                    }

                    try
                    {
                        if ( !isPreviouslyScanned( repoConfig, metadataRepository ) )
                        {
                            queueInitialRepoScan( repoConfig );
                        }
                    }
                    catch ( MetadataRepositoryException e )
                    {
                        log.warn( "Unable to determine if a repository is already scanned, skipping initial scan: {}",
                                  e.getMessage(), e );
                    }
                }
            }
        }
        finally
        {
            repositorySession.close();
        }

        stopWatch.stop();
        log.info( "Time to initalize DefaultRepositoryArchivaTaskScheduler: {} ms", stopWatch.getTime() );
    }
View Full Code Here

TOP

Related Classes of org.apache.commons.lang.time.StopWatch

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.