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


Java ResponseMetadata类代码示例

本文整理汇总了Java中com.amazonaws.ResponseMetadata的典型用法代码示例。如果您正苦于以下问题:Java ResponseMetadata类的具体用法?Java ResponseMetadata怎么用?Java ResponseMetadata使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: populateAndEndSubsegment

import com.amazonaws.ResponseMetadata; //导入依赖的package包/类
private void populateAndEndSubsegment(Subsegment currentSubsegment, Request<?> request, Response<?> response) {
    if (null != response) {
        String requestId = null;
        if (response.getAwsResponse() instanceof AmazonWebServiceResult<?>) { // Not all services return responses extending AmazonWebServiceResult (e.g. S3)
            ResponseMetadata metadata = ((AmazonWebServiceResult<?>) response.getAwsResponse()).getSdkResponseMetadata();
            if (null != metadata) {
                requestId = metadata.getRequestId();
                if (null != requestId) {
                    currentSubsegment.putAws(REQUEST_ID_SUBSEGMENT_KEY, requestId);
                }
            }
        } else if (null != response.getHttpResponse()) { // S3 does not follow request id header convention
            if (null != response.getHttpResponse().getHeader(S3_REQUEST_ID_HEADER_KEY)) {
                currentSubsegment.putAws(REQUEST_ID_SUBSEGMENT_KEY, response.getHttpResponse().getHeader(S3_REQUEST_ID_HEADER_KEY));
            }
            if (null != response.getHttpResponse().getHeader(S3_EXTENDED_REQUEST_ID_HEADER_KEY)) {
                currentSubsegment.putAws(EXTENDED_REQUEST_ID_SUBSEGMENT_KEY, response.getHttpResponse().getHeader(S3_EXTENDED_REQUEST_ID_HEADER_KEY));
            }
        }
        currentSubsegment.putAllAws(extractResponseParameters(request, response.getAwsResponse()));
        currentSubsegment.putAllHttp(extractHttpResponseInformation(response.getHttpResponse()));
    }

    finalizeSubsegment(request);
}
 
开发者ID:aws,项目名称:aws-xray-sdk-java,代码行数:26,代码来源:TracingHandler.java

示例2: get

import com.amazonaws.ResponseMetadata; //导入依赖的package包/类
@Override
public synchronized ResponseMetadata get(Object obj) {
    // System.identityHashCode isn't guaranteed to be unique
    // on all platforms, but should be reasonable enough to use
    // for a few requests at a time.  We can always easily move
    // to our own unique IDs if needed.
    return internalCache.get(System.identityHashCode(obj));
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:9,代码来源:ResponseMetadataCache.java

示例3: testEviction

import com.amazonaws.ResponseMetadata; //导入依赖的package包/类
/** Tests that the cache correctly evicts the oldest entries.  */
@Test
public void testEviction() {
    ResponseMetadataCache cache = new ResponseMetadataCache(3);

    AmazonWebServiceRequest key1 = new TestRequest();
    AmazonWebServiceRequest key2 = new TestRequest();
    AmazonWebServiceRequest key3 = new TestRequest();
    AmazonWebServiceRequest key4 = new TestRequest();
    ResponseMetadata metadata1 = newResponseMetadata();
    ResponseMetadata metadata2 = newResponseMetadata();
    ResponseMetadata metadata3 = newResponseMetadata();
    ResponseMetadata metadata4 = newResponseMetadata();

    // Fill the cache
    cache.add(key1, metadata1);
    cache.add(key2, metadata2);
    cache.add(key3, metadata3);

    // Verify all entries are still there
    assertEquals(metadata1, cache.get(key1));
    assertEquals(metadata2, cache.get(key2));
    assertEquals(metadata3, cache.get(key3));

    // Add another and make sure the oldest is evicted
    cache.add(key4, metadata4);
    assertNull(cache.get(key1));
    assertEquals(metadata2, cache.get(key2));
    assertEquals(metadata3, cache.get(key3));
    assertEquals(metadata4, cache.get(key4));
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:32,代码来源:ResponseMetadataCacheTest.java

示例4: TestEmpty

import com.amazonaws.ResponseMetadata; //导入依赖的package包/类
/** Tests that the cache works correctly with size=0  */
@Test
public void TestEmpty() {
    ResponseMetadataCache cache = new ResponseMetadataCache(0);

    AmazonWebServiceRequest key = new TestRequest();
    ResponseMetadata metadata = newResponseMetadata();
    // Add item to the cache, it should be immediately evicted.
    cache.add(key, metadata);

    // get should return null
    assertNull(cache.get(key));
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:14,代码来源:ResponseMetadataCacheTest.java

示例5: parseResponseMetadata

import com.amazonaws.ResponseMetadata; //导入依赖的package包/类
/**
 * Parses the S3 response metadata (ex: AWS request ID) from the specified
 * response, and returns a AmazonWebServiceResponse<T> object ready for the
 * result to be plugged in.
 *
 * @param response
 *            The response containing the response metadata to pull out.
 *
 * @return A new, populated AmazonWebServiceResponse<T> object, ready for
 *         the result to be plugged in.
 */
protected AmazonWebServiceResponse<T> parseResponseMetadata(HttpResponse response) {
    AmazonWebServiceResponse<T> awsResponse = new AmazonWebServiceResponse<T>();
    String awsRequestId = response.getHeaders().get(Headers.REQUEST_ID);
    String hostId = response.getHeaders().get(Headers.EXTENDED_REQUEST_ID);
    String cloudFrontId = response.getHeaders().get(Headers.CLOUD_FRONT_ID);

    Map<String, String> metadataMap = new HashMap<String, String>();
    metadataMap.put(ResponseMetadata.AWS_REQUEST_ID, awsRequestId);
    metadataMap.put(S3ResponseMetadata.HOST_ID, hostId);
    metadataMap.put(S3ResponseMetadata.CLOUD_FRONT_ID, cloudFrontId);
    awsResponse.setResponseMetadata(new S3ResponseMetadata(metadataMap));

    return awsResponse;
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:26,代码来源:AbstractS3ResponseHandler.java

示例6: getCachedResponseMetadata

import com.amazonaws.ResponseMetadata; //导入依赖的package包/类
@Override
public ResponseMetadata getCachedResponseMetadata(AmazonWebServiceRequest request) {
  Map<String, String> metadata = new HashMap<String, String>();
  ResponseMetadata responseMetadata = new ResponseMetadata(metadata);

  return responseMetadata;
}
 
开发者ID:bizo,项目名称:aws-java-sdk-stubs,代码行数:8,代码来源:AmazonDynamoDBStub.java

示例7: getCachedResponseMetadata

import com.amazonaws.ResponseMetadata; //导入依赖的package包/类
@Override
public ResponseMetadata getCachedResponseMetadata(AmazonWebServiceRequest request) {
    throw new UnsupportedOperationException("Not supported in mock");
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:AmazonEC2Mock.java

示例8: getCachedResponseMetadata

import com.amazonaws.ResponseMetadata; //导入依赖的package包/类
@Override
public ResponseMetadata getCachedResponseMetadata(AmazonWebServiceRequest amazonWebServiceRequest) {
    return null;
}
 
开发者ID:d2si-oss,项目名称:ooso,代码行数:5,代码来源:AWSLambdaAsyncMockClient.java

示例9: handle

import com.amazonaws.ResponseMetadata; //导入依赖的package包/类
/**
 * @see HttpResponseHandler#handle(HttpResponse)
 */
public AmazonWebServiceResponse<T> handle(HttpResponse response) throws Exception {
    log.trace("Parsing service response JSON");

    String CRC32Checksum = response.getHeaders().get("x-amz-crc32");

    JsonParser jsonParser = null;

    if (shouldParsePayloadAsJson()) {
        jsonParser = jsonFactory.createParser(response.getContent());
    }

    try {
        AmazonWebServiceResponse<T> awsResponse = new AmazonWebServiceResponse<T>();
        JsonUnmarshallerContext unmarshallerContext = new JsonUnmarshallerContextImpl(
                jsonParser, simpleTypeUnmarshallers, customTypeMarshallers, response);
        registerAdditionalMetadataExpressions(unmarshallerContext);

        T result = responseUnmarshaller.unmarshall(unmarshallerContext);

        // 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.getContent() != null) {
            IOUtils.drainInputStream(response.getContent());
        }

        if (CRC32Checksum != null) {
            long serverSideCRC = Long.parseLong(CRC32Checksum);
            long clientSideCRC = response.getCRC32Checksum();
            if (clientSideCRC != serverSideCRC) {
                throw new CRC32MismatchException(
                        "Client calculated crc32 checksum didn't match that calculated by server side");
            }
        }

        awsResponse.setResult(result);

        Map<String, String> metadata = unmarshallerContext.getMetadata();
        metadata.put(ResponseMetadata.AWS_REQUEST_ID,
                     response.getHeaders().get(X_AMZN_REQUEST_ID_HEADER));
        awsResponse.setResponseMetadata(new ResponseMetadata(metadata));

        log.trace("Done parsing service response");
        return awsResponse;
    } finally {
        if (shouldParsePayloadAsJson()) {
            try {
                jsonParser.close();
            } catch (IOException e) {
                log.warn("Error closing json parser", e);
            }
        }
    }
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:57,代码来源:JsonResponseHandler.java

示例10: add

import com.amazonaws.ResponseMetadata; //导入依赖的package包/类
@Override
public void add(Object obj, ResponseMetadata metadata) {
    // deliberately left blank
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:5,代码来源:NullResponseMetadataCache.java

示例11: get

import com.amazonaws.ResponseMetadata; //导入依赖的package包/类
@Override
public ResponseMetadata get(Object obj) {
    throw new SdkClientException("Response metadata caching is not enabled");
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:5,代码来源:NullResponseMetadataCache.java

示例12: add

import com.amazonaws.ResponseMetadata; //导入依赖的package包/类
@Override
public synchronized void add(Object obj, ResponseMetadata metadata) {
    if (obj == null) return;
    internalCache.put(System.identityHashCode(obj), metadata);
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:6,代码来源:ResponseMetadataCache.java

示例13: removeEldestEntry

import com.amazonaws.ResponseMetadata; //导入依赖的package包/类
@Override
protected boolean removeEldestEntry(Entry<Integer,ResponseMetadata> eldest) {
    return size() > maxSize;
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:5,代码来源:ResponseMetadataCache.java

示例14: newResponseMetadata

import com.amazonaws.ResponseMetadata; //导入依赖的package包/类
private ResponseMetadata newResponseMetadata() {
    HashMap<String, String> metadata = new HashMap<String, String>();
    metadata.put("foo", "bar-" + new Random().nextLong());
    return new ResponseMetadata(metadata);
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:6,代码来源:ResponseMetadataCacheTest.java

示例15: getCachedResponseMetadata

import com.amazonaws.ResponseMetadata; //导入依赖的package包/类
@Override
public ResponseMetadata getCachedResponseMetadata(AmazonWebServiceRequest arg0) {
    throw new java.lang.UnsupportedOperationException();
}
 
开发者ID:awslabs,项目名称:aws-encryption-sdk-java,代码行数:5,代码来源:MockKMSClient.java


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