com.amazonaws.AmazonWebServiceResult Java Examples
The following examples show how to use
com.amazonaws.AmazonWebServiceResult.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AmazonWebServicesClientProxy.java From cloudformation-cli-java-plugin with Apache License 2.0 | 6 votes |
public <RequestT extends AmazonWebServiceRequest, ResultT extends AmazonWebServiceResult<ResponseMetadata>> ResultT injectCredentialsAndInvoke(final RequestT request, final Function<RequestT, ResultT> requestFunction) { request.setRequestCredentialsProvider(v1CredentialsProvider); try { ResultT respose = requestFunction.apply(request); logRequestMetadata(request, respose); return respose; } catch (final Throwable e) { loggerProxy.log(String.format("Failed to execute remote function: {%s}", e.getMessage())); throw e; } finally { request.setRequestCredentialsProvider(null); } }
Example #2
Source File: TracingRequestHandler.java From zipkin-aws with Apache License 2.0 | 6 votes |
static void tagSpanWithRequestId(Span span, Response response) { String requestId = null; if (response != null) { if (response.getAwsResponse() instanceof AmazonWebServiceResult<?>) { ResponseMetadata metadata = ((AmazonWebServiceResult<?>) response.getAwsResponse()).getSdkResponseMetadata(); if (null != metadata) { requestId = metadata.getRequestId(); } } else if (response.getHttpResponse() != null) { if (response.getHttpResponse().getHeader("x-amz-request-id") != null) { requestId = response.getHttpResponse().getHeader("x-amz-request-id"); } } } if (requestId != null) { span.tag("aws.request_id", requestId); } }
Example #3
Source File: AbstractAwsClientWrapper.java From primecloud-controller with GNU General Public License v2.0 | 6 votes |
/** * TODO: メソッドコメント * * @param client * @return */ public AmazonEC2 wrap(final AmazonEC2 client) { InvocationHandler handler = new InvocationHandler() { @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { if (!AmazonWebServiceResult.class.isAssignableFrom(method.getReturnType())) { return method.invoke(client, args); } return doInvoke(client, proxy, method, args); } }; return (AmazonEC2) Proxy.newProxyInstance(LoggingAwsClientWrapper.class.getClassLoader(), new Class[] { AmazonEC2.class }, handler); }
Example #4
Source File: AbstractAwsClientWrapper.java From primecloud-controller with GNU General Public License v2.0 | 6 votes |
/** * TODO: メソッドコメント * * @param client * @return */ public AmazonElasticLoadBalancing wrap(final AmazonElasticLoadBalancing client) { InvocationHandler handler = new InvocationHandler() { @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { if (!AmazonWebServiceResult.class.isAssignableFrom(method.getReturnType())) { return method.invoke(client, args); } return doInvoke(client, proxy, method, args); } }; return (AmazonElasticLoadBalancing) Proxy.newProxyInstance(LoggingAwsClientWrapper.class.getClassLoader(), new Class[] { AmazonElasticLoadBalancing.class }, handler); }
Example #5
Source File: AmazonWebServicesClientProxy.java From cloudformation-cli-java-plugin with Apache License 2.0 | 5 votes |
private <RequestT extends AmazonWebServiceRequest, ResultT extends AmazonWebServiceResult<ResponseMetadata>> void logRequestMetadata(final RequestT request, final ResultT response) { try { String requestName = request.getClass().getSimpleName(); String requestId = (response == null || response.getSdkResponseMetadata() == null) ? "" : response.getSdkResponseMetadata().getRequestId(); loggerProxy .log(String.format("{\"apiRequest\": {\"requestId\": \"%s\", \"requestName\": \"%s\"}}", requestId, requestName)); } catch (final Exception e) { loggerProxy.log(e.getMessage()); } }
Example #6
Source File: UnsignedXrayClient.java From aws-xray-sdk-java with Apache License 2.0 | 5 votes |
@Override public boolean hasIgnoreMarker(AnnotatedMember m) { // This is a somewhat hacky way of having ObjectMapper only serialize the fields in our // model classes instead of the base class that comes from the SDK. In the future, we will // remove the SDK dependency itself and the base classes and this hack will go away. if (m.getDeclaringClass() == AmazonWebServiceRequest.class || m.getDeclaringClass() == AmazonWebServiceResult.class) { return true; } return super.hasIgnoreMarker(m); }
Example #7
Source File: TracingHandler.java From aws-xray-sdk-java with Apache License 2.0 | 5 votes |
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(EntityHeaderKeys.AWS.EXTENDED_REQUEST_ID_HEADER)) { currentSubsegment.putAws(EntityDataKeys.AWS.EXTENDED_REQUEST_ID_KEY, response.getHttpResponse().getHeader( EntityHeaderKeys.AWS.EXTENDED_REQUEST_ID_HEADER)); } } currentSubsegment.putAllAws(extractResponseParameters(request, response.getAwsResponse())); currentSubsegment.putAllHttp(extractHttpResponseInformation(response.getHttpResponse())); } finalizeSubsegment(request); }
Example #8
Source File: DynamoDBResponse.java From dynamo-cassandra-proxy with Apache License 2.0 | 4 votes |
public AmazonWebServiceResult getResult() { return result; }
Example #9
Source File: DynamoDBResponse.java From dynamo-cassandra-proxy with Apache License 2.0 | 4 votes |
public void setResult(AmazonWebServiceResult result) { this.result = result; }
Example #10
Source File: DynamoDBResponse.java From dynamo-cassandra-proxy with Apache License 2.0 | 4 votes |
public DynamoDBResponse(AmazonWebServiceResult result, int statusCode) { this.result = result; this.statusCode = statusCode; }