类java.util.concurrent.ConcurrentHashMap.KeySetView源码实例Demo

下面列出了怎么用java.util.concurrent.ConcurrentHashMap.KeySetView的API类实例代码及写法,或者点击链接到github查看源代码。

/** Processes failed copy requests */
private void onCopyFailure(
    KeySetView<IOException, Boolean> innerExceptions,
    GoogleJsonError jsonError,
    HttpHeaders responseHeaders,
    String srcBucketName,
    String srcObjectName) {
  GoogleJsonResponseException cause = createJsonResponseException(jsonError, responseHeaders);
  innerExceptions.add(
      errorExtractor.itemNotFound(cause)
          ? createFileNotFoundException(srcBucketName, srcObjectName, cause)
          : new IOException(
              String.format(
                  "Error copying '%s'", StringPaths.fromComponents(srcBucketName, srcObjectName)),
              cause));
}
 
/**
 * See {@link GoogleCloudStorage#copy(String, List, String, List)} for details about expected
 * behavior.
 */
@Override
public void copy(
    String srcBucketName, List<String> srcObjectNames,
    String dstBucketName, List<String> dstObjectNames)
    throws IOException {
  validateCopyArguments(srcBucketName, srcObjectNames, dstBucketName, dstObjectNames, this);

  if (srcObjectNames.isEmpty()) {
    return;
  }

  // Gather FileNotFoundExceptions for individual objects,
  // but only throw a single combined exception at the end.
  KeySetView<IOException, Boolean> innerExceptions = ConcurrentHashMap.newKeySet();

  // Perform the copy operations.
  BatchHelper batchHelper =
      batchFactory.newBatchHelper(
          httpRequestInitializer,
          gcs,
          storageOptions.getCopyMaxRequestsPerBatch(),
          srcObjectNames.size(),
          storageOptions.getCopyBatchThreads());

  for (int i = 0; i < srcObjectNames.size(); i++) {
    if (storageOptions.isCopyWithRewriteEnabled()) {
      // Rewrite request has the same effect as Copy, but it can handle moving
      // large objects that may potentially timeout a Copy request.
      rewriteInternal(
          batchHelper,
          innerExceptions,
          srcBucketName, srcObjectNames.get(i),
          dstBucketName, dstObjectNames.get(i));
    } else {
      copyInternal(
          batchHelper,
          innerExceptions,
          srcBucketName, srcObjectNames.get(i),
          dstBucketName, dstObjectNames.get(i));
    }
  }

  // Execute any remaining requests not divisible by the max batch size.
  batchHelper.flush();

  if (!innerExceptions.isEmpty()) {
    throw GoogleCloudStorageExceptions.createCompositeException(innerExceptions);
  }
}
 
 类所在包
 同包方法