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


Java Stopwatch.stop方法代码示例

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


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

示例1: doGet

import com.google.common.base.Stopwatch; //导入方法依赖的package包/类
@Override
protected void doGet(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException {

	final Stopwatch stopwatch = Stopwatch.createStarted();
	T agent = null;
	boolean hasResult = false;
	try {
		agent = getAgent(request, response);
		hasResult = server.processExchange(agent);
	} catch (final RequestException e) {
		log.error(e.getMessage());
	} finally {
		stopwatch.stop();
		if (hasResult) {
			SSPLatencyBuffer.getBuffer().bufferValue(stopwatch.elapsed(TimeUnit.MILLISECONDS));
		}
		if (agent != null) {
			agent.cleanUp();
		}
		agent = null;
	}

}
 
开发者ID:ad-tech-group,项目名称:openssp,代码行数:24,代码来源:CoreSupplyServlet.java

示例2: createPointMapping

import com.google.common.base.Stopwatch; //导入方法依赖的package包/类
/**
 * Creates and adds a point mapping to ShardMap.
 *
 * @param creationInfo
 *            Information about mapping to be added.
 * @return Newly created mapping.
 */
public PointMapping createPointMapping(PointMappingCreationInfo creationInfo) {
    ExceptionUtils.disallowNullArgument(creationInfo, "args");

    try (ActivityIdScope activityIdScope = new ActivityIdScope(UUID.randomUUID())) {
        Stopwatch stopwatch = Stopwatch.createStarted();

        String mappingKey = creationInfo.getKey().getRawValue().toString();
        log.info("CreatePointMapping Start; ShardMap name: {}; Point Mapping: {} ", this.getName(), mappingKey);

        PointMapping mapping = lsm.add(new PointMapping(this.getShardMapManager(), creationInfo));

        stopwatch.stop();

        log.info("CreatePointMapping Complete; ShardMap name: {}; Point Mapping: {}; Duration: {}", this.getName(), mappingKey,
                stopwatch.elapsed(TimeUnit.MILLISECONDS));

        return mapping;
    }
}
 
开发者ID:Microsoft,项目名称:elastic-db-tools-for-java,代码行数:27,代码来源:ListShardMap.java

示例3: updateMapping

import com.google.common.base.Stopwatch; //导入方法依赖的package包/类
/**
 * Updates a <see cref="RangeMapping{KeyT}"/> with the updates provided in the <paramref name="update"/> parameter.
 *
 * @param currentMapping
 *            Mapping being updated.
 * @param update
 *            Updated properties of the mapping.
 * @param mappingLockToken
 *            An instance of <see cref="MappingLockToken"/>
 * @return New instance of mapping with updated information.
 */
public RangeMapping updateMapping(RangeMapping currentMapping,
        RangeMappingUpdate update,
        MappingLockToken mappingLockToken) {
    ExceptionUtils.disallowNullArgument(currentMapping, "currentMapping");
    ExceptionUtils.disallowNullArgument(update, "update");
    ExceptionUtils.disallowNullArgument(mappingLockToken, "mappingLockToken");

    try (ActivityIdScope activityIdScope = new ActivityIdScope(UUID.randomUUID())) {
        log.info("UpdateMapping Start; Current mapping shard: {}", currentMapping.getShard().getLocation());

        Stopwatch stopwatch = Stopwatch.createStarted();

        RangeMapping map = this.rsm.update(currentMapping, update, mappingLockToken.getLockOwnerId());

        stopwatch.stop();

        log.info("UpdateMapping Complete; Current mapping shard: {}; Duration: {}", currentMapping.getShard().getLocation(),
                stopwatch.elapsed(TimeUnit.MILLISECONDS));

        return map;
    }
}
 
开发者ID:Microsoft,项目名称:elastic-db-tools-for-java,代码行数:34,代码来源:RangeShardMap.java

示例4: validate

import com.google.common.base.Stopwatch; //导入方法依赖的package包/类
/**
 * Performs validation that the local representation is as up-to-date as the representation on the backing data store.
 *
 * @param shardMap
 *            Shard map to which the shard provider belongs.
 * @param conn
 *            Connection used for validation.
 */
@Override
public void validate(StoreShardMap shardMap,
        Connection conn) {
    try {
        log.info("RangeMapping Validate Start; Connection: {}", conn.getMetaData().getURL());

        Stopwatch stopwatch = Stopwatch.createStarted();

        ValidationUtils.validateMapping(conn, this.getShardMapManager(), shardMap, this.getStoreMapping());

        stopwatch.stop();

        log.info("RangeMapping Validate Complete; Connection: {} Duration:{}", conn.getMetaData().getURL(),
                stopwatch.elapsed(TimeUnit.MILLISECONDS));
    }
    catch (SQLException e) {
        e.printStackTrace();
        throw (ShardManagementException) e.getCause();
    }
}
 
开发者ID:Microsoft,项目名称:elastic-db-tools-for-java,代码行数:29,代码来源:RangeMapping.java

示例5: getMappingForKey

import com.google.common.base.Stopwatch; //导入方法依赖的package包/类
/**
 * Looks up the key value and returns the corresponding mapping.
 *
 * @param key
 *            Input key value.
 * @param lookupOptions
 *            Whether to search in the cache and/or store.
 * @return Mapping that contains the key value.
 */
public RangeMapping getMappingForKey(KeyT key,
        LookupOptions lookupOptions) {
    try (ActivityIdScope activityIdScope = new ActivityIdScope(UUID.randomUUID())) {
        log.info("GetMapping Start; Range Mapping Key Type: {}; Lookup Options: {}", key.getClass(), lookupOptions);

        Stopwatch stopwatch = Stopwatch.createStarted();

        RangeMapping rangeMapping = this.rsm.lookup(key, lookupOptions);

        stopwatch.stop();

        log.info("GetMapping Complete; Range Mapping Key Type: {}; Lookup Options: {} Duration: {}", key.getClass(), lookupOptions,
                stopwatch.elapsed(TimeUnit.MILLISECONDS));

        return rangeMapping;
    }
}
 
开发者ID:Microsoft,项目名称:elastic-db-tools-for-java,代码行数:27,代码来源:RangeShardMap.java

示例6: validateAsync

import com.google.common.base.Stopwatch; //导入方法依赖的package包/类
/**
 * Asynchronously performs validation that the local representation is as up-to-date as the representation on the backing data store.
 *
 * @param shardMap
 *            Shard map to which the shard provider belongs.
 * @param conn
 *            Connection used for validation.
 * @return A task to await validation completion
 */
@Override
public Callable validateAsync(StoreShardMap shardMap,
        Connection conn) {
    Callable returnVal;
    try {
        log.info("RangeMapping ValidateAsync Start; Connection: {}", conn.getMetaData().getURL());

        Stopwatch stopwatch = Stopwatch.createStarted();

        returnVal = ValidationUtils.validateMappingAsync(conn, this.getShardMapManager(), shardMap, this.getStoreMapping());

        stopwatch.stop();

        log.info("RangeMapping ValidateAsync Complete; Connection: {} Duration:{}", conn.getMetaData().getURL(),
                stopwatch.elapsed(TimeUnit.MILLISECONDS));
    }
    catch (SQLException e) {
        e.printStackTrace();
        throw (ShardManagementException) e.getCause();
    }
    return returnVal;
}
 
开发者ID:Microsoft,项目名称:elastic-db-tools-for-java,代码行数:32,代码来源:RangeMapping.java

示例7: getMappings

import com.google.common.base.Stopwatch; //导入方法依赖的package包/类
/**
 * Gets all the mappings that exist within given range and given shard.
 *
 * @param range
 *            Point value, any mapping overlapping with the range will be returned.
 * @param shard
 *            Shard for which the mappings will be returned.
 * @return Read-only collection of mappings that satisfy the given range and shard constraints.
 */
public List<PointMapping> getMappings(Range range,
        Shard shard) {
    ExceptionUtils.disallowNullArgument(range, "range");
    ExceptionUtils.disallowNullArgument(shard, "shard");

    try (ActivityIdScope activityIdScope = new ActivityIdScope(UUID.randomUUID())) {
        log.info("GetPointMappings", "Start; Shard: {}; Range:{}", shard.getLocation(), range);

        Stopwatch stopwatch = Stopwatch.createStarted();

        List<PointMapping> pointMappings = lsm.getMappingsForRange(range, shard, LookupOptions.LOOKUP_IN_STORE);

        stopwatch.stop();

        log.info("GetPointMappings", "Complete; Shard: {}; Range: {}; Duration:{}", shard.getLocation(),
                stopwatch.elapsed(TimeUnit.MILLISECONDS));

        return pointMappings;
    }
}
 
开发者ID:Microsoft,项目名称:elastic-db-tools-for-java,代码行数:30,代码来源:ListShardMap.java

示例8: buildEndpointMap

import com.google.common.base.Stopwatch; //导入方法依赖的package包/类
/**
 * Builds a mapping of SabotNode endpoints to hostnames
 */
private static ImmutableMap<String, NodeEndpoint> buildEndpointMap(Collection<NodeEndpoint> endpoints) {
  Stopwatch watch = Stopwatch.createStarted();
  HashMap<String, NodeEndpoint> endpointMap = Maps.newHashMap();
  for (NodeEndpoint d : endpoints) {
    String hostName = d.getAddress();
    endpointMap.put(hostName, d);
  }
  watch.stop();
  logger.debug("Took {} ms to build endpoint map", watch.elapsed(TimeUnit.MILLISECONDS));
  return ImmutableMap.copyOf(endpointMap);
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:15,代码来源:BlockMapBuilder.java

示例9: saveNowInternal

import com.google.common.base.Stopwatch; //导入方法依赖的package包/类
private void saveNowInternal() throws IOException {
    final Stopwatch watch = Stopwatch.createStarted();
    File directory = file.getAbsoluteFile().getParentFile();
    File temp = File.createTempFile("wallet", null, directory);
    final Listener listener = vListener;
    if (listener != null)
        listener.onBeforeAutoSave(temp);
    wallet.saveToFile(temp, file);
    if (listener != null)
        listener.onAfterAutoSave(file);
    watch.stop();
    log.info("Save completed in {}", watch);
}
 
开发者ID:guodroid,项目名称:okwallet,代码行数:14,代码来源:WalletFiles.java

示例10: tryGetShard

import com.google.common.base.Stopwatch; //导入方法依赖的package包/类
/**
 * Tries to obtains the shard for the specified location.
 *
 * @param location
 *            Location of the shard.
 * @param shard
 *            Shard which has the specified location.
 * @return <c>true</c> if shard with specified location is found, <c>false</c> otherwise.
 */
public final boolean tryGetShard(ShardLocation location,
        ReferenceObjectHelper<Shard> shard) {
    ExceptionUtils.disallowNullArgument(location, "location");

    try (ActivityIdScope activityIdScope = new ActivityIdScope(UUID.randomUUID())) {
        log.info("TryGetShard Start; Shard Location: {} ", location);

        Stopwatch stopwatch = Stopwatch.createStarted();

        shard.argValue = defaultShardMapper.getShardByLocation(location);

        stopwatch.stop();

        log.info("TryGetShard Complete; Shard Location: {}; Duration: {}", location, stopwatch.elapsed(TimeUnit.MILLISECONDS));

        return shard.argValue != null;
    }
}
 
开发者ID:Microsoft,项目名称:elastic-db-tools-for-java,代码行数:28,代码来源:ShardMap.java

示例11: getTableFromDataset

import com.google.common.base.Stopwatch; //导入方法依赖的package包/类
private Table getTableFromDataset(StoragePlugin2 registry, DatasetConfig datasetConfig) {
  Stopwatch stopwatch = Stopwatch.createStarted();

  // we assume for now that the passed dataset was retrieved from the namespace, so it must have
  // a canonized datasetPath (or the source is case sensitive and doesn't really do any special handling
  // to canonize the keys)
  final NamespaceKey canonicalKey = new NamespaceKey(datasetConfig.getFullPathList());

  if (!permissionsCache.hasAccess(registry, schemaConfig.getUserName(), canonicalKey,
      datasetConfig, metadataParam == null ? null : metadataParam.getMetadataPolicy(), metadataStatsCollector)) {
    throw UserException.permissionError()
      .message("Access denied reading dataset %s.", canonicalKey.toString())
      .build(logger);
  }

  if (!isPartialState(datasetConfig)) {
    final NamespaceTable namespaceTable = new NamespaceTable(new TableMetadataImpl(registry.getId(), datasetConfig, schemaConfig.getUserName(), new SplitsPointerImpl(datasetConfig, ns)));
    stopwatch.stop();
    metadataStatsCollector.addDatasetStat(canonicalKey.getSchemaPath(), MetadataAccessType.CACHED_METADATA.name(), stopwatch.elapsed(TimeUnit.MILLISECONDS));
    return namespaceTable;
  }

  try {
    // even though the following call won't assume the key is canonical we will need to hit the source anyway
    // to retrieve the complete dataset
    //TODO maybe I should introduce isCanonical field in the NamespaceKey
    SourceTableDefinition datasetAccessor = registry.getDataset(
      canonicalKey,
      datasetConfig,
      schemaConfig.getIgnoreAuthErrors()
    );

    final DatasetConfig newDatasetConfig = datasetAccessor.getDataset();
    NamespaceUtils.copyFromOldConfig(datasetConfig, newDatasetConfig);
    List<DatasetSplit> splits = datasetAccessor.getSplits();
    setDataset(ns, datasetAccessor.getName(), newDatasetConfig, splits);
    // check permission again.
    if (permissionsCache.hasAccess(registry, schemaConfig.getUserName(), canonicalKey,
        newDatasetConfig, metadataParam == null ? null : metadataParam.getMetadataPolicy(), metadataStatsCollector)) {
      TableMetadata metadata = new TableMetadataImpl(registry.getId(), newDatasetConfig, schemaConfig.getUserName(), new SplitsPointerImpl(splits, splits.size()));
      stopwatch.stop();
      metadataStatsCollector.addDatasetStat(canonicalKey.getSchemaPath(), MetadataAccessType.PARTIAL_METADATA.name(), stopwatch.elapsed(TimeUnit.MILLISECONDS));
      return new NamespaceTable(metadata);
    } else {
      throw UserException.permissionError().message("Access denied reading dataset %s.", canonicalKey.toString()).build(logger);
    }
  } catch (Exception e) {
    throw UserException.dataReadError(e).message("Failure while attempting to read metadata for %s.%s.",  getFullSchemaName(), canonicalKey.getName()).build(logger);
  }
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:51,代码来源:SimpleSchema.java

示例12: markMappingOffline

import com.google.common.base.Stopwatch; //导入方法依赖的package包/类
/**
 * Marks the specified mapping offline.
 *
 * @param mapping
 *            Input point mapping.
 * @return An offline mapping.
 */
public PointMapping markMappingOffline(PointMapping mapping) {
    ExceptionUtils.disallowNullArgument(mapping, "mapping");

    try (ActivityIdScope activityIdScope = new ActivityIdScope(UUID.randomUUID())) {
        log.info("MarkMappingOffline", "Start; ");

        Stopwatch stopwatch = Stopwatch.createStarted();

        PointMapping result = lsm.markMappingOffline(mapping);

        stopwatch.stop();

        log.info("MarkMappingOffline", "Complete; Duration:{}", stopwatch.elapsed(TimeUnit.MILLISECONDS));

        return result;
    }
}
 
开发者ID:Microsoft,项目名称:elastic-db-tools-for-java,代码行数:25,代码来源:ListShardMap.java

示例13: getDistinctShardLocations

import com.google.common.base.Stopwatch; //导入方法依赖的package包/类
/**
 * Obtains distinct shard locations from the shard map manager.
 *
 * @return Collection of shard locations associated with the shard map manager.
 */
public List<ShardLocation> getDistinctShardLocations() {
    try (ActivityIdScope activityIdScope = new ActivityIdScope(UUID.randomUUID())) {
        log.info("ShardMapManager GetDistinctShardLocations Start; ");

        Stopwatch stopwatch = Stopwatch.createStarted();

        List<ShardLocation> result = this.getDistinctShardLocationsFromStore();

        stopwatch.stop();

        log.info("ShardMapManager GetDistinctShardLocations Complete; Duration: {}", stopwatch.elapsed(TimeUnit.MILLISECONDS));

        return result;
    }
}
 
开发者ID:Microsoft,项目名称:elastic-db-tools-for-java,代码行数:21,代码来源:ShardMapManager.java

示例14: createShard

import com.google.common.base.Stopwatch; //导入方法依赖的package包/类
/**
 * Creates a new shard and registers it with the shard map.
 *
 * @param shardCreationArgs
 *            Information about shard to be added.
 * @return A new shard registered with this shard map.
 */
public final Shard createShard(ShardCreationInfo shardCreationArgs) {
    ExceptionUtils.disallowNullArgument(shardCreationArgs, "shardCreationArgs");

    try (ActivityIdScope activityId = new ActivityIdScope(UUID.randomUUID())) {
        log.info("CreateShard Start; Shard: {} ", shardCreationArgs.getLocation());

        Stopwatch stopwatch = Stopwatch.createStarted();

        Shard shard = defaultShardMapper.add(new Shard(this.getShardMapManager(), this, shardCreationArgs));

        stopwatch.stop();

        log.info("CreateShard Complete; Shard: {}; Duration: {}", shard.getLocation(), stopwatch.elapsed(TimeUnit.MILLISECONDS));

        return shard;
    }
}
 
开发者ID:Microsoft,项目名称:elastic-db-tools-for-java,代码行数:25,代码来源:ShardMap.java

示例15: doLocalExecute

import com.google.common.base.Stopwatch; //导入方法依赖的package包/类
/**
 * Execute the operation against LSM in the current transaction scope.
 *
 * @param ts
 *            Transaction scope.
 * @return Results of the operation.
 */
@Override
public StoreResults doLocalExecute(IStoreTransactionScope ts) {
    log.info("ShardMapManagerFactory {} Started upgrading Local Shard Map structures" + "at location {}", this.getOperationName(),
            super.getLocation());

    Stopwatch stopwatch = Stopwatch.createStarted();

    StoreResults checkResult = ts.executeCommandSingle(SqlUtils.getCheckIfExistsLocalScript().get(0));

    if (checkResult.getStoreVersion() == null) {
        // DEVNOTE(apurvs): do we want to throw here if LSM is not already deployed?
        // deploy initial version of LSM, if not found.
        ts.executeCommandBatch(SqlUtils.getCreateLocalScript());
    }

    if (checkResult.getStoreVersion() == null || Version.isFirstGreaterThan(targetVersion, checkResult.getStoreVersion())) {
        if (checkResult.getStoreVersion() == null) {
            ts.executeCommandBatch(SqlUtils.filterUpgradeCommands(SqlUtils.getUpgradeLocalScript(), targetVersion));
        }
        else {
            ts.executeCommandBatch(
                    SqlUtils.filterUpgradeCommands(SqlUtils.getUpgradeLocalScript(), targetVersion, checkResult.getStoreVersion()));
        }

        // Read LSM version again after upgrade.
        checkResult = ts.executeCommandSingle(SqlUtils.getCheckIfExistsLocalScript().get(0));

        stopwatch.stop();

        log.info("ShardMapManagerFactory {} Finished upgrading store at location {}. Duration:{}", this.getOperationName(), super.getLocation(),
                stopwatch.elapsed(TimeUnit.MILLISECONDS));
    }
    else {
        log.error(
                "ShardMapManagerFactory {} Local Shard Map at location {} has version {} equal to"
                        + "or higher than Client library version {}, skipping upgrade.",
                this.getOperationName(), super.getLocation(), checkResult.getStoreVersion(), GlobalConstants.GsmVersionClient);
    }
    return checkResult;
}
 
开发者ID:Microsoft,项目名称:elastic-db-tools-for-java,代码行数:48,代码来源:UpgradeStoreLocalOperation.java


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