当前位置: 首页>>代码示例>>Java>>正文


Java TimerContext.stop方法代码示例

本文整理汇总了Java中com.yammer.metrics.core.TimerContext.stop方法的典型用法代码示例。如果您正苦于以下问题:Java TimerContext.stop方法的具体用法?Java TimerContext.stop怎么用?Java TimerContext.stop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.yammer.metrics.core.TimerContext的用法示例。


在下文中一共展示了TimerContext.stop方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import com.yammer.metrics.core.TimerContext; //导入方法依赖的package包/类
/**
 * Verify measure publication manually.
 */
public static void main(final String[] args) throws Exception {
    final Run run = newRun("test-main");
    for (int param = 0; param < 5; param++) {
        final CaliperMeasure measure = new CaliperMeasure();
        measure.variables().put("param", String.valueOf(param));
        for (int step = 0; step < 5; step++) {
            measure.rate().mark(50 + step);
            final TimerContext time = measure.time().time();
            Thread.sleep(15);
            time.stop();
            measure.size().value(50 + step);
            measure.mark();
        }
        measure.appendTo(run);
    }
    final Result result = newResult(run);
    publish(result);
    System.out.println(json(result));
}
 
开发者ID:wuyinxian124,项目名称:netty4.0.27Learn,代码行数:23,代码来源:CaliperRunner.java

示例2: retrievePendingItem

import com.yammer.metrics.core.TimerContext; //导入方法依赖的package包/类
public DataItem retrievePendingItem(String key, Version version) throws TException {

        TimerContext context = retrievePendingTimer.time();

        try {
            if (!pendingTransactionsMap.containsKey(version)) {
                return null;
            }
            
            for (PendingWrite pendingWrite : pendingTransactionsMap.get(version).pendingWrites) {
                if (key.equals(pendingWrite.getKey())) {
                    return getPendingWrite(pendingWrite.getKey(), pendingWrite.getVersion());
                }
            }
            
            return null;
        } finally {
            context.stop();
        }
    }
 
开发者ID:pbailis,项目名称:hat-vldb2014-code,代码行数:21,代码来源:DependencyResolver.java

示例3: generateKey

import com.yammer.metrics.core.TimerContext; //导入方法依赖的package包/类
/**
 * Hands off to the member KeyPersistenceService to generate a key for the given uniqueIds.
 *
 * @param uniqueIdentifiers the identifiers that all refer to the same occurrence
 *
 * @return a KeyLookupResult with the key for this occurrence
 *
 * @throws IllegalArgumentException if the uniqueIdentifiers set is empty
 */
@Override
public KeyLookupResult generateKey(Set<UniqueIdentifier> uniqueIdentifiers) {
  checkArgument(!uniqueIdentifiers.isEmpty(), "uniqueIdentifiers can't be empty");

  String datasetKey = uniqueIdentifiers.iterator().next().getDatasetKey().toString();
  Set<String> uniqueStrings = Sets.newHashSetWithExpectedSize(uniqueIdentifiers.size());
  for (UniqueIdentifier uniqueIdentifier : uniqueIdentifiers) {
    uniqueStrings.add(uniqueIdentifier.getUnscopedUniqueString());
  }

  lockRequests.mark();
  final TimerContext context = lockWaitTimer.time();
  try {
    return keyPersistenceService.generateKey(uniqueStrings, datasetKey);
  } finally {
    context.stop();
  }
}
 
开发者ID:gbif,项目名称:occurrence,代码行数:28,代码来源:OccurrenceKeyPersistenceServiceImpl.java

示例4: get

import com.yammer.metrics.core.TimerContext; //导入方法依赖的package包/类
public DataItem get(String key) throws TException {
    getCount.mark();

    TimerContext context = getLatencyTimer.time();

    try {
        byte[] byteRet = db.get(key.getBytes());

        if(byteRet == null) {
            nullGetCount.mark();
            return null;
        }

        getSizeHistogram.update(byteRet.length);

        ThriftDataItem tdrRet = new ThriftDataItem();
        deserializer.get().deserialize(tdrRet, byteRet);
        return new DataItem(tdrRet);
    } finally {
        context.stop();
    }
}
 
开发者ID:pbailis,项目名称:hat-vldb2014-code,代码行数:23,代码来源:LevelDBPersistenceEngine.java

示例5: addCounter

import com.yammer.metrics.core.TimerContext; //导入方法依赖的package包/类
/**
 * Atomically adds to the count for this dataset and counterName.
 *
 * @param datasetUuid the dataset key
 * @param counterName the counterName representing a processing phase
 */
public void addCounter(UUID datasetUuid, CounterName counterName) {
  checkNotNull(datasetUuid);
  checkNotNull(counterName);
  final TimerContext context = addTimer.time();
  try {
    try {
      String path = CRAWL_PREFIX + datasetUuid.toString() + counterName.getPath();
      LOG.debug("Updating DAL at path [{}]", path);
      if (!ENSURED_PATHS.contains(path)) {
        curator.newNamespaceAwareEnsurePath(path).ensure(curator.getZookeeperClient());
        ENSURED_PATHS.add(path);
      }
      final TimerContext incContext = incrementTimer.time();
      try {
        dalWrapper.increment(path);
      } finally {
        incContext.stop();
      }
    } catch (Exception e) {
      LOG.warn("Error updating zookeeper", e);
    }
  } finally {
    context.stop();
  }
}
 
开发者ID:gbif,项目名称:occurrence,代码行数:32,代码来源:ZookeeperConnector.java

示例6: handleMessage

import com.yammer.metrics.core.TimerContext; //导入方法依赖的package包/类
@Override
public void handleMessage(DeleteDatasetOccurrencesMessage message) {
  if (message.getDeletionReason() == OccurrenceDeletionReason.NOT_SEEN_IN_LAST_CRAWL) {
    LOG.warn("No support for deleting datasets because of NOT_SEEN_IN_LAST_CRAWL - ignoring message.");
    return;
  }

  final TimerContext context = processTimer.time();
  try {
    LOG.info("Deleting dataset for key [{}]", message.getDatasetUuid());

    Set<Integer> keys = occurrenceKeyService.findKeysByDataset(message.getDatasetUuid().toString());
    for (Integer key : keys) {
      try {
        messagePublisher.send(new DeleteOccurrenceMessage(key, message.getDeletionReason(), null, null));
      } catch (IOException e) {
        LOG.warn("Could not send DeleteOccurrenceMessage for key [{}] while deleting dataset [{}]", key,
                 message.getDatasetUuid(), e);
      }
    }
  } finally {
    context.stop();
  }
}
 
开发者ID:gbif,项目名称:occurrence,代码行数:25,代码来源:DeleteDatasetListener.java

示例7: createReference

import com.yammer.metrics.core.TimerContext; //导入方法依赖的package包/类
public void createReference(String owner, String repository, String ref, String id)
        throws GithubFailure.forReferenceCreation {
    final URI uri = UriBuilder.
            fromPath("/repos/{a}/{b}/git/refs").
            build(owner, repository);

    final ReferenceCreationRequest req = new ReferenceCreationRequest(ref, id);

    final TimerContext time = referenceCreationTimer.time();
    try {
        /* Github wants a Content-Length, and Jersey doesn't fancy doing that */
        final byte[] payload = mapper.writeValueAsBytes(req);

        resource.uri(uri).
                type(MediaType.APPLICATION_JSON_TYPE).
                post(payload);
    } catch (JsonProcessingException | UniformInterfaceException e) {
        throw new GithubFailure.forReferenceCreation(e);
    } finally {
        time.stop();
    }
}
 
开发者ID:airbnb,项目名称:chancery,代码行数:23,代码来源:GithubClient.java

示例8: handleMessage

import com.yammer.metrics.core.TimerContext; //导入方法依赖的package包/类
@Override
public void handleMessage(DeleteOccurrenceMessage message) {
  final TimerContext context = processTimer.time();

  // if the deletion reason is NOT_SEEN_IN_LAST_CRAWL, we need to ensure that the record hasn't changed since
  final Integer targetedCrawlId = OccurrenceDeletionReason.NOT_SEEN_IN_LAST_CRAWL == message.getDeletionReason() ?
          message.getCrawlAttemptLastSeen() : null;

  try {
    Occurrence deleted = occurrenceDeletionService.deleteOccurrence(message.getOccurrenceKey(), targetedCrawlId);
    if (deleted != null) {
      try {
        messagePublisher.send(OccurrenceMutatedMessage
          .buildDeleteMessage(deleted.getDatasetKey(), deleted, message.getDeletionReason(),
            message.getCrawlAttemptLastSeen(), message.getLatestCrawlAttemptForDataset()));
      } catch (IOException e) {
        LOG.error("Unable to send OccurrenceDeletedMessage for key [{}] - ALL DOWNSTREAM COUNTS ARE NOW WRONG",
          deleted.getKey(), e);
      }
    }
  } finally {
    context.stop();
  }
}
 
开发者ID:gbif,项目名称:occurrence,代码行数:25,代码来源:DeleteOccurrenceListener.java

示例9: upload

import com.yammer.metrics.core.TimerContext; //导入方法依赖的package包/类
private void upload(@NotNull File src, @NotNull String key, @NotNull CallbackPayload payload) {
    log.info("Uploading {} to {} in {}", src, key, bucketName);
    final PutObjectRequest request = new PutObjectRequest(bucketName, key, src);
    final ObjectMetadata metadata = request.getMetadata();
    final String commitId = payload.getAfter();
    if (commitId != null) {
        metadata.addUserMetadata("commit-id", commitId);
    }
    final DateTime timestamp = payload.getTimestamp();
    if (timestamp != null) {
        metadata.addUserMetadata("hook-timestamp",
                ISODateTimeFormat.basicTime().print(timestamp));
    }

    final TimerContext time = uploadTimer.time();
    try {
        s3Client.putObject(request);
    } catch (Exception e) {
        log.error("Couldn't upload to {} in {}", key, bucketName, e);
        throw e;
    } finally {
        time.stop();
    }
    log.info("Uploaded to {} in {}", key, bucketName);
}
 
开发者ID:airbnb,项目名称:chancery,代码行数:26,代码来源:S3Archiver.java

示例10: around

import com.yammer.metrics.core.TimerContext; //导入方法依赖的package包/类
@Around(value = "timeChecked()")
public Object around(ProceedingJoinPoint joinPoint) throws Throwable {
    MetricsRegistry registry = Metrics.defaultRegistry();

    Timer timer = registry.newTimer(joinPoint.getThis().getClass(), joinPoint.getSignature().getName());
    TimerContext time = timer.time();
    try {
        return joinPoint.proceed();
    } finally {
        time.stop();
    }
}
 
开发者ID:Flipkart,项目名称:foxtrot,代码行数:13,代码来源:MetricsAspect.java

示例11: handleMessage

import com.yammer.metrics.core.TimerContext; //导入方法依赖的package包/类
@Override
public void handleMessage(OccurrenceMutatedMessage message) {
  LOG.debug("Handling [{}] occurrence", message.getStatus());
  messageCount.inc();
  TimerContext context = writeTimer.time();
  try {
    switch (message.getStatus()) {
      case NEW:
        // create occurrence
        solrOccurrenceWriter.update(message.getNewOccurrence());
        newOccurrencesCount.inc();
        break;
      case UPDATED:
        // update occurrence
        solrOccurrenceWriter.update(message.getNewOccurrence());
        updatedOccurrencesCount.inc();
        break;
      case DELETED:
        // delete occurrence
        solrOccurrenceWriter.delete(message.getOldOccurrence());
        deletedOccurrencesCount.inc();
        break;
      case UNCHANGED:
        break;
    }
  } catch (Exception e) {
    LOG.error("Error while updating occurrence index for [{}], error [{}]", message.getStatus(), e);
  } finally {
    context.stop();
  }
}
 
开发者ID:gbif,项目名称:occurrence,代码行数:32,代码来源:IndexUpdaterCallback.java

示例12: put

import com.yammer.metrics.core.TimerContext; //导入方法依赖的package包/类
@Override
    public boolean put(String key,
                       ThriftDataItem valueThrift) throws TException {
        TimerContext context = putTimer.time();
        try {
            DataItem value = new DataItem(valueThrift);
            if(logger.isTraceEnabled())
                logger.trace("received PUT request for key: '"+key+
                             "' value: '"+value+
                             "' transactionKeys: "+value.getTransactionKeys());
            
            antiEntropyRouter.sendWriteToSiblings(key, valueThrift);
    
            // TODO: Hmm, if siblings included us, we wouldn't even need to do this...

//            persistenceEngine.put_if_newer(key, value);

            if (value.getTransactionKeys() == null || value.getTransactionKeys().isEmpty()) {
                persistenceEngine.put_if_newer(key, value);
            } else {
                dependencyResolver.addPendingWrite(key, value);
            }
    
            putMeter.mark();
    
            // todo: remove this return value--it's really not necessary
        } finally {
            context.stop();
        }
        return true;
    }
 
开发者ID:pbailis,项目名称:hat-vldb2014-code,代码行数:32,代码来源:ReplicaServiceHandler.java

示例13: handleMessage

import com.yammer.metrics.core.TimerContext; //导入方法依赖的package包/类
@Override
public void handleMessage(OccurrenceFragmentedMessage message) {
  final TimerContext context = processTimer.time();
  try {
    processor.buildFragments(message.getDatasetUuid(), message.getFragment(), message.getSchemaType(),
      message.getEndpointType(), message.getAttempt(), message.getValidationReport());
  } finally {
    context.stop();
  }
}
 
开发者ID:gbif,项目名称:occurrence,代码行数:11,代码来源:OccurrenceFragmentedListener.java

示例14: add

import com.yammer.metrics.core.TimerContext; //导入方法依赖的package包/类
/** Add a count object to this batcher */
public void add( Count count ) throws CounterProcessingUnavailableException {
    invocationCounter.inc();
    final TimerContext context = addTimer.time();
    if ( batchSize == 1 ) {
        getBatch().addSerial( count );
    }
    else {
        getBatch().add( count );
    }
    context.stop();
}
 
开发者ID:apache,项目名称:usergrid,代码行数:13,代码来源:AbstractBatcher.java

示例15: get

import com.yammer.metrics.core.TimerContext; //导入方法依赖的package包/类
public DataItem get(String key) {
    TimerContext context = getsTimer.time();
    try {
        DataItem ret = map.get(key);
        if(ret == null)
            ret = nullItem;

        return ret;
    } finally {
        context.stop();
    }
}
 
开发者ID:pbailis,项目名称:hat-vldb2014-code,代码行数:13,代码来源:MemoryPersistenceEngine.java


注:本文中的com.yammer.metrics.core.TimerContext.stop方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。