software.amazon.awssdk.utils.Logger.trace()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(12.1k)|赞(0)|评价(0)|浏览(186)

本文整理了Java中software.amazon.awssdk.utils.Logger.trace()方法的一些代码示例,展示了Logger.trace()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Logger.trace()方法的具体详情如下:
包路径:software.amazon.awssdk.utils.Logger
类名称:Logger
方法名:trace

Logger.trace介绍

[英]Checks if trace is enabled and if so logs the supplied message
[中]检查跟踪是否启用,如果启用,则记录提供的消息

代码示例

代码示例来源:origin: aws/aws-sdk-java-v2

@Override
public void connect(SocketAddress endpoint) throws IOException {
  log.trace(() -> "connecting to: " + endpoint);
  sock.connect(endpoint);
  log.debug(() -> "connected to: " + endpoint);
}

代码示例来源:origin: aws/aws-sdk-java-v2

@Override
public void connect(SocketAddress endpoint, int timeout) throws IOException {
  log.trace(() -> "connecting to: " + endpoint);
  sock.connect(endpoint, timeout);
  log.debug(() -> "connected to: " + endpoint);
}

代码示例来源:origin: aws/aws-sdk-java-v2

@Override
public void connect(SocketAddress endpoint, int timeout) throws IOException {
  log.trace(() -> "connecting to: " + endpoint);
  sock.connect(endpoint, timeout);
  log.debug(() -> "connected to: " + endpoint);
}

代码示例来源:origin: software.amazon.awssdk/sdk-core

/**
 * Validate the result of calling an interceptor method that is attempting to modify the message to make sure its result is
 * valid.
 */
private void validateInterceptorResult(Object originalMessage, Object newMessage,
                    ExecutionInterceptor interceptor, String methodName) {
  if (!Objects.equals(originalMessage, newMessage)) {
    LOG.debug(() -> "Interceptor '" + interceptor + "' modified the message with its " + methodName + " method.");
    LOG.trace(() -> "Old: " + originalMessage + "\nNew: " + newMessage);
  }
  Validate.validState(newMessage != null,
            "Request interceptor '%s' returned null from its %s interceptor.",
            interceptor, methodName);
  Validate.isInstanceOf(originalMessage.getClass(), newMessage,
             "Request interceptor '%s' returned '%s' from its %s method, but '%s' was expected.",
             interceptor, newMessage.getClass(), methodName, originalMessage.getClass());
}

代码示例来源:origin: aws/aws-sdk-java-v2

@Override
public void connect(SocketAddress endpoint) throws IOException {
  log.trace(() -> "connecting to: " + endpoint);
  sock.connect(endpoint);
  log.debug(() -> "connected to: " + endpoint);
}

代码示例来源:origin: aws/aws-sdk-java-v2

@SuppressWarnings("unchecked")
private T unmarshallResponse(SdkHttpFullResponse response) throws Exception {
  SdkStandardLogger.REQUEST_LOGGER.trace(() -> "Parsing service response XML.");
  T result = unmarshaller.unmarshall(pojoSupplier.apply(response), response);
  SdkStandardLogger.REQUEST_LOGGER.trace(() -> "Done parsing service response.");
  AwsResponseMetadata responseMetadata = generateResponseMetadata(response);
  return (T) result.toBuilder().responseMetadata(responseMetadata).build();
}

代码示例来源:origin: aws/aws-sdk-java-v2

@Override
public Socket connectSocket(
    final int connectTimeout,
    final Socket socket,
    final HttpHost host,
    final InetSocketAddress remoteAddress,
    final InetSocketAddress localAddress,
    final HttpContext context) throws IOException {
  log.trace(() -> String.format("Connecting to %s:%s", remoteAddress.getAddress(), remoteAddress.getPort()));
  Socket connectedSocket = super.connectSocket(connectTimeout, socket, host, remoteAddress, localAddress, context);
  if (connectedSocket instanceof SSLSocket) {
    return new SdkSslSocket((SSLSocket) connectedSocket);
  }
  return new SdkSocket(connectedSocket);
}

代码示例来源:origin: software.amazon.awssdk/aws-xml-protocol

@SuppressWarnings("unchecked")
private T unmarshallResponse(SdkHttpFullResponse response) throws Exception {
  SdkStandardLogger.REQUEST_LOGGER.trace(() -> "Parsing service response XML.");
  T result = unmarshaller.unmarshall(pojoSupplier.apply(response), response);
  SdkStandardLogger.REQUEST_LOGGER.trace(() -> "Done parsing service response.");
  AwsResponseMetadata responseMetadata = generateResponseMetadata(response);
  return (T) result.toBuilder().responseMetadata(responseMetadata).build();
}

代码示例来源:origin: software.amazon.awssdk/aws-query-protocol

@SuppressWarnings("unchecked")
private T unmarshallResponse(SdkHttpFullResponse response) throws Exception {
  SdkStandardLogger.REQUEST_LOGGER.trace(() -> "Parsing service response XML.");
  Pair<T, Map<String, String>> result = unmarshaller.unmarshall(pojoSupplier.apply(response), response);
  SdkStandardLogger.REQUEST_LOGGER.trace(() -> "Done parsing service response.");
  AwsResponseMetadata responseMetadata = generateResponseMetadata(response, result.right());
  return (T) result.left().toBuilder().responseMetadata(responseMetadata).build();
}

代码示例来源:origin: aws/aws-sdk-java-v2

@SuppressWarnings("unchecked")
private T unmarshallResponse(SdkHttpFullResponse response) throws Exception {
  SdkStandardLogger.REQUEST_LOGGER.trace(() -> "Parsing service response XML.");
  Pair<T, Map<String, String>> result = unmarshaller.unmarshall(pojoSupplier.apply(response), response);
  SdkStandardLogger.REQUEST_LOGGER.trace(() -> "Done parsing service response.");
  AwsResponseMetadata responseMetadata = generateResponseMetadata(response, result.right());
  return (T) result.left().toBuilder().responseMetadata(responseMetadata).build();
}

代码示例来源:origin: aws/aws-sdk-java-v2

@Override
public int read(byte[] b, int off, int len) throws IOException {
  abortIfNeeded();
  if (b == null) {
    throw new NullPointerException();
  } else if (off < 0 || len < 0 || len > b.length - off) {
    throw new IndexOutOfBoundsException();
  } else if (len == 0) {
    return 0;
  }
  if (null == currentChunkIterator || !currentChunkIterator.hasNext()) {
    if (isTerminating) {
      return -1;
    } else {
      isTerminating = setUpNextChunk();
    }
  }
  int count = currentChunkIterator.read(b, off, len);
  if (count > 0) {
    isAtStart = false;
    log.trace(() -> count + " byte read from the stream.");
  }
  return count;
}

代码示例来源:origin: aws/aws-sdk-java-v2

/**
 * @see HttpResponseHandler#handle(SdkHttpFullResponse, ExecutionAttributes)
 */
public T handle(SdkHttpFullResponse response, ExecutionAttributes executionAttributes) throws Exception {
  SdkStandardLogger.REQUEST_LOGGER.trace(() -> "Parsing service response JSON.");
  SdkStandardLogger.REQUEST_ID_LOGGER.debug(() -> X_AMZN_REQUEST_ID_HEADER + " : " +
                          response.firstMatchingHeader(X_AMZN_REQUEST_ID_HEADER)
                              .orElse("not available"));
  try {
    T result = unmarshaller.unmarshall(pojoSupplier.apply(response), response);
    // Make sure we read all the data to get an accurate CRC32 calculation.
    // See https://github.com/aws/aws-sdk-java/issues/1018
    if (shouldParsePayloadAsJson() && response.content().isPresent()) {
      IoUtils.drainInputStream(response.content().get());
    }
    SdkStandardLogger.REQUEST_LOGGER.trace(() -> "Done parsing service response.");
    return result;
  } finally {
    if (!needsConnectionLeftOpen) {
      response.content().ifPresent(i -> FunctionalUtils.invokeSafely(i::close));
    }
  }
}

代码示例来源:origin: software.amazon.awssdk/aws-json-protocol

/**
 * @see HttpResponseHandler#handle(SdkHttpFullResponse, ExecutionAttributes)
 */
public T handle(SdkHttpFullResponse response, ExecutionAttributes executionAttributes) throws Exception {
  SdkStandardLogger.REQUEST_LOGGER.trace(() -> "Parsing service response JSON.");
  SdkStandardLogger.REQUEST_ID_LOGGER.debug(() -> X_AMZN_REQUEST_ID_HEADER + " : " +
                          response.firstMatchingHeader(X_AMZN_REQUEST_ID_HEADER)
                              .orElse("not available"));
  try {
    T result = unmarshaller.unmarshall(pojoSupplier.apply(response), response);
    // Make sure we read all the data to get an accurate CRC32 calculation.
    // See https://github.com/aws/aws-sdk-java/issues/1018
    if (shouldParsePayloadAsJson() && response.content().isPresent()) {
      IoUtils.drainInputStream(response.content().get());
    }
    SdkStandardLogger.REQUEST_LOGGER.trace(() -> "Done parsing service response.");
    return result;
  } finally {
    if (!needsConnectionLeftOpen) {
      response.content().ifPresent(i -> FunctionalUtils.invokeSafely(i::close));
    }
  }
}

代码示例来源:origin: software.amazon.awssdk/auth

@Override
public int read(byte[] b, int off, int len) throws IOException {
  abortIfNeeded();
  if (b == null) {
    throw new NullPointerException();
  } else if (off < 0 || len < 0 || len > b.length - off) {
    throw new IndexOutOfBoundsException();
  } else if (len == 0) {
    return 0;
  }
  if (null == currentChunkIterator || !currentChunkIterator.hasNext()) {
    if (isTerminating) {
      return -1;
    } else {
      isTerminating = setUpNextChunk();
    }
  }
  int count = currentChunkIterator.read(b, off, len);
  if (count > 0) {
    isAtStart = false;
    log.trace(() -> count + " byte read from the stream.");
  }
  return count;
}

代码示例来源:origin: software.amazon.awssdk/auth

/**
 * Step 3 of the AWS Signature version 4 calculation. It involves deriving
 * the signing key and computing the signature. Refer to
 * http://docs.aws.amazon
 * .com/general/latest/gr/sigv4-calculate-signature.html
 */
protected byte[] deriveSigningKey(AwsCredentials credentials, Aws4SignerRequestParams signerRequestParams) {
  String cacheKey = computeSigningCacheKeyName(credentials, signerRequestParams);
  long daysSinceEpochSigningDate = numberOfDaysSinceEpoch(signerRequestParams.getSigningDateTimeMilli());
  SignerKey signerKey = SIGNER_CACHE.get(cacheKey);
  if (signerKey != null && daysSinceEpochSigningDate == signerKey.getNumberOfDaysSinceEpoch()) {
    return signerKey.getSigningKey();
  }
  LOG.trace(() -> "Generating a new signing key as the signing key not available in the cache for the date: " +
    TimeUnit.DAYS.toMillis(daysSinceEpochSigningDate));
  byte[] signingKey = newSigningKey(credentials,
    signerRequestParams.getFormattedSigningDate(),
    signerRequestParams.getRegionName(),
    signerRequestParams.getServiceSigningName());
  SIGNER_CACHE.add(cacheKey, new SignerKey(daysSinceEpochSigningDate, signingKey));
  return signingKey;
}

代码示例来源:origin: aws/aws-sdk-java-v2

/**
 * Step 3 of the AWS Signature version 4 calculation. It involves deriving
 * the signing key and computing the signature. Refer to
 * http://docs.aws.amazon
 * .com/general/latest/gr/sigv4-calculate-signature.html
 */
protected byte[] deriveSigningKey(AwsCredentials credentials, Aws4SignerRequestParams signerRequestParams) {
  String cacheKey = computeSigningCacheKeyName(credentials, signerRequestParams);
  long daysSinceEpochSigningDate = numberOfDaysSinceEpoch(signerRequestParams.getSigningDateTimeMilli());
  SignerKey signerKey = SIGNER_CACHE.get(cacheKey);
  if (signerKey != null && daysSinceEpochSigningDate == signerKey.getNumberOfDaysSinceEpoch()) {
    return signerKey.getSigningKey();
  }
  LOG.trace(() -> "Generating a new signing key as the signing key not available in the cache for the date: " +
    TimeUnit.DAYS.toMillis(daysSinceEpochSigningDate));
  byte[] signingKey = newSigningKey(credentials,
    signerRequestParams.getFormattedSigningDate(),
    signerRequestParams.getRegionName(),
    signerRequestParams.getServiceSigningName());
  SIGNER_CACHE.add(cacheKey, new SignerKey(daysSinceEpochSigningDate, signingKey));
  return signingKey;
}

代码示例来源:origin: aws/aws-sdk-java-v2

/**
 * Step 1 of the AWS Signature version 4 calculation. Refer to
 * http://docs.aws
 * .amazon.com/general/latest/gr/sigv4-create-canonical-request.html to
 * generate the canonical request.
 */
private String createCanonicalRequest(SdkHttpFullRequest.Builder request,
                   String contentSha256,
                   boolean doubleUrlEncode) {
  String canonicalRequest = request.method().toString() +
               SignerConstant.LINE_SEPARATOR +
               // This would optionally double url-encode the resource path
               getCanonicalizedResourcePath(request.encodedPath(), doubleUrlEncode) +
               SignerConstant.LINE_SEPARATOR +
               getCanonicalizedQueryString(request.rawQueryParameters()) +
               SignerConstant.LINE_SEPARATOR +
               getCanonicalizedHeaderString(request.headers()) +
               SignerConstant.LINE_SEPARATOR +
               getSignedHeadersString(request.headers()) +
               SignerConstant.LINE_SEPARATOR +
               contentSha256;
  LOG.trace(() -> "AWS4 Canonical Request: " + canonicalRequest);
  return canonicalRequest;
}

代码示例来源:origin: software.amazon.awssdk/auth

/**
 * Step 1 of the AWS Signature version 4 calculation. Refer to
 * http://docs.aws
 * .amazon.com/general/latest/gr/sigv4-create-canonical-request.html to
 * generate the canonical request.
 */
private String createCanonicalRequest(SdkHttpFullRequest.Builder request,
                   String contentSha256,
                   boolean doubleUrlEncode) {
  String canonicalRequest = request.method().toString() +
               SignerConstant.LINE_SEPARATOR +
               // This would optionally double url-encode the resource path
               getCanonicalizedResourcePath(request.encodedPath(), doubleUrlEncode) +
               SignerConstant.LINE_SEPARATOR +
               getCanonicalizedQueryString(request.rawQueryParameters()) +
               SignerConstant.LINE_SEPARATOR +
               getCanonicalizedHeaderString(request.headers()) +
               SignerConstant.LINE_SEPARATOR +
               getSignedHeadersString(request.headers()) +
               SignerConstant.LINE_SEPARATOR +
               contentSha256;
  LOG.trace(() -> "AWS4 Canonical Request: " + canonicalRequest);
  return canonicalRequest;
}

相关文章