Package com.google.common.base

Examples of com.google.common.base.Stopwatch.stop()


      Stopwatch watch = new Stopwatch().start();
      assertTrue(retry.shouldRetryRequestOnError(command, response, error));
      assertEquals(command.getFailureCount(), 60);
      // allow for slightly inaccurate system timers
      assertTrue(watch.stop().elapsed(TimeUnit.MILLISECONDS) >= 98);
   }
  

  
   public void testQueueDeletedRecentlyRetriesWhen60DoesntTry() {
View Full Code Here


      HttpCommand command = createHttpCommandForFailureCount(60);

      Stopwatch watch = new Stopwatch().start();
      assertFalse(retry.shouldRetryRequestOnError(command, response, error));
      assertEquals(command.getFailureCount(), 61);
      assertTrue(watch.stop().elapsed(TimeUnit.MILLISECONDS) < 100);
   }
  
   HttpCommand createHttpCommandForFailureCount(final int failureCount) {
      HttpCommand command = new HttpCommand(HttpRequest.builder().method("GET").endpoint("http://localhost").build());
      while (command.getFailureCount() != failureCount)
View Full Code Here

        // completely.  So we intentionally handle all possible exceptions here.
        Stopwatch sw = new Stopwatch(_ticker).start();

        try {
            return  _serviceFactory.isHealthy(endPoint)
                    ? new SuccessfulHealthCheckResult(endPoint.getId(), sw.stop().elapsedTime(TimeUnit.NANOSECONDS))
                    : new FailedHealthCheckResult(endPoint.getId(), sw.stop().elapsedTime(TimeUnit.NANOSECONDS));
        } catch (Exception e) {
            return new FailedHealthCheckResult(endPoint.getId(), sw.stop().elapsedTime(TimeUnit.NANOSECONDS), e);
        } finally {
            _healthCheckTime.update(sw.elapsedTime(TimeUnit.NANOSECONDS), TimeUnit.NANOSECONDS);
View Full Code Here

        Stopwatch sw = new Stopwatch(_ticker).start();

        try {
            return  _serviceFactory.isHealthy(endPoint)
                    ? new SuccessfulHealthCheckResult(endPoint.getId(), sw.stop().elapsedTime(TimeUnit.NANOSECONDS))
                    : new FailedHealthCheckResult(endPoint.getId(), sw.stop().elapsedTime(TimeUnit.NANOSECONDS));
        } catch (Exception e) {
            return new FailedHealthCheckResult(endPoint.getId(), sw.stop().elapsedTime(TimeUnit.NANOSECONDS), e);
        } finally {
            _healthCheckTime.update(sw.elapsedTime(TimeUnit.NANOSECONDS), TimeUnit.NANOSECONDS);
        }
View Full Code Here

        try {
            return  _serviceFactory.isHealthy(endPoint)
                    ? new SuccessfulHealthCheckResult(endPoint.getId(), sw.stop().elapsedTime(TimeUnit.NANOSECONDS))
                    : new FailedHealthCheckResult(endPoint.getId(), sw.stop().elapsedTime(TimeUnit.NANOSECONDS));
        } catch (Exception e) {
            return new FailedHealthCheckResult(endPoint.getId(), sw.stop().elapsedTime(TimeUnit.NANOSECONDS), e);
        } finally {
            _healthCheckTime.update(sw.elapsedTime(TimeUnit.NANOSECONDS), TimeUnit.NANOSECONDS);
        }
    }
View Full Code Here

        Stopwatch stopwatch = new Stopwatch();
        for (Function<C, C> function : functions) {
            logger.info("Starting {} ...", function.getClass().getName());
            stopwatch.reset().start();
            context = function.apply(context);
            stopwatch.stop();
            logger.info("{} done. Tooks {} ms.", function.getClass().getName(), stopwatch.elapsed(MILLISECONDS));
        }
        logger.info("Apply done.");
    }
View Full Code Here

    if (result == null) {
      globalStatsCounter.recordLoadException(stopwatch.elapsedTime(NANOSECONDS));
      throw new InvalidCacheLoadException(loader + " returned null map from loadAll");
    }

    stopwatch.stop();
    // TODO(fry): batch by segment
    boolean nullsPresent = false;
    for (Map.Entry<K, V> entry : result.entrySet()) {
      K key = entry.getKey();
      V value = entry.getValue();
View Full Code Here

    curSegment.writeRaw(records, 0, records.length);
    curSegment.setReadyToFlush();
    Stopwatch sw = new Stopwatch();
    sw.start();
    curSegment.flush(shouldFsync);
    sw.stop();
   
    metrics.addSync(sw.elapsedTime(TimeUnit.MICROSECONDS));
    if (sw.elapsedTime(TimeUnit.MILLISECONDS) > WARN_SYNC_MILLIS_THRESHOLD) {
      LOG.warn("Sync of transaction range " + firstTxnId + "-" + lastTxnId +
               " took " + sw.elapsedTime(TimeUnit.MILLISECONDS) + "ms");
View Full Code Here

      sw = new Stopwatch().start();
    }
    MRInputUserPayloadProto userPayloadProto = MRInputHelpers
        .parseMRInputPayload(getContext().getInputUserPayload());
    if (LOG.isDebugEnabled()) {
      sw.stop();
      LOG.debug("Time to parse MRInput payload into prot: "
          + sw.elapsedMillis())
    }
    Configuration conf = TezUtils.createConfFromByteString(userPayloadProto
        .getConfigurationBytes());
View Full Code Here

      sw = new Stopwatch().start();
    }
    MRInputUserPayloadProto userPayloadProto = MRInputHelpers
        .parseMRInputPayload(getContext().getInputUserPayload());
    if (LOG.isDebugEnabled()) {
      sw.stop();
      LOG.debug("Time to parse MRInput payload into prot: "
          + sw.elapsedMillis());
    }
    if (LOG.isDebugEnabled()) {
      sw.reset().start();
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.