com.amazonaws.Response Java Examples
The following examples show how to use
com.amazonaws.Response.
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: AbstractSdkMetricsCollector.java From presto with Apache License 2.0 | 6 votes |
@Override public final void collectMetrics(Request<?> request, Response<?> response) { TimingInfo timingInfo = request.getAWSRequestMetrics().getTimingInfo(); Number requestCounts = timingInfo.getCounter(RequestCount.name()); if (requestCounts != null) { recordRequestCount(requestCounts.longValue()); } Number retryCounts = timingInfo.getCounter(HttpClientRetryCount.name()); if (retryCounts != null) { recordRetryCount(retryCounts.longValue()); } Number throttleExceptions = timingInfo.getCounter(ThrottleException.name()); if (throttleExceptions != null) { recordThrottleExceptionCount(throttleExceptions.longValue()); } recordSubTimingDurations(timingInfo, HttpRequestTime, this::recordHttpRequestTime); recordSubTimingDurations(timingInfo, ClientExecuteTime, this::recordClientExecutionTime); recordSubTimingDurations(timingInfo, RetryPauseTime, this::recordRetryPauseTime); }
Example #2
Source File: SpectatorRequestMetricCollectorTest.java From spectator with Apache License 2.0 | 6 votes |
private void execRequest(String endpoint, int status) { AWSRequestMetrics metrics = new AWSRequestMetricsFullSupport(); metrics.addProperty(AWSRequestMetrics.Field.ServiceName, "AmazonCloudWatch"); metrics.addProperty(AWSRequestMetrics.Field.ServiceEndpoint, endpoint); metrics.addProperty(AWSRequestMetrics.Field.StatusCode, "" + status); if (status == 503) { metrics.addProperty(AWSRequestMetrics.Field.AWSErrorCode, "Throttled"); } String counterName = "BytesProcessed"; String timerName = "ClientExecuteTime"; metrics.setCounter(counterName, 12345); metrics.getTimingInfo().addSubMeasurement(timerName, TimingInfo.unmodifiableTimingInfo(100000L, 200000L)); Request<?> req = new DefaultRequest(new ListMetricsRequest(), "AmazonCloudWatch"); req.setAWSRequestMetrics(metrics); req.setEndpoint(URI.create(endpoint)); HttpResponse hr = new HttpResponse(req, new HttpPost(endpoint)); hr.setStatusCode(status); Response<?> resp = new Response<>(null, new HttpResponse(req, new HttpPost(endpoint))); collector.collectMetrics(req, resp); }
Example #3
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 #4
Source File: TracingHandler.java From aws-xray-sdk-java with Apache License 2.0 | 6 votes |
private void populateAndEndSubsegment( Subsegment currentSubsegment, Request<?> request, Response<?> response, AmazonServiceException ase) { if (null != response) { populateAndEndSubsegment(currentSubsegment, request, response); return; } else if (null != ase) { if (null != ase.getRequestId()) { currentSubsegment.putAws(REQUEST_ID_SUBSEGMENT_KEY, ase.getRequestId()); } if (null != ase.getHttpHeaders() && null != ase.getHttpHeaders().get(EntityHeaderKeys.AWS.EXTENDED_REQUEST_ID_HEADER)) { currentSubsegment.putAws(EntityDataKeys.AWS.EXTENDED_REQUEST_ID_KEY, ase.getHttpHeaders().get(EntityHeaderKeys.AWS.EXTENDED_REQUEST_ID_HEADER)); } if (null != ase.getErrorMessage()) { currentSubsegment.getCause().setMessage(ase.getErrorMessage()); } currentSubsegment.putAllHttp(extractHttpResponseInformation(ase)); } finalizeSubsegment(request); }
Example #5
Source File: GettingStartedIntegrationTest.java From getting-started with MIT License | 6 votes |
@Test void testGetCurrencyConversion() { Response<JSONObject> response = GettingStarted.getCurrencyConversion("NOK", "EUR"); assertThat(response.getHttpResponse().getStatusCode()) .as("Test if status code is 200/OK").isEqualTo(200); JSONObject json = response.getAwsResponse(); assertThat(json.length()).as("Check that object contains correct amount of parameters").isEqualTo(12); Set<String> keySet; keySet = json.keySet(); assertThat(keySet.contains("quoteCurrency")).as("That object contains quoteCurrency").isTrue(); assertThat(keySet.contains("country")).as("That object contains country").isTrue(); assertThat(keySet.contains("amount")).as("That object contains amount").isTrue(); assertThat(keySet.contains("buyRateTransfer")).as("That object contains buyRateTransfer").isTrue(); assertThat(keySet.contains("midRate")).as("That object contains midRate").isTrue(); assertThat(keySet.contains("sellRateTransfer")).as("That object contains sellRateTransfer").isTrue(); assertThat(keySet.contains("sellRateCash")).as("That object contains sellRateCash").isTrue(); assertThat(keySet.contains("changeInMidRate")).as("That object contains changeInMidRate").isTrue(); assertThat(keySet.contains("buyRateCash")).as("That object contains buyRateCash").isTrue(); assertThat(keySet.contains("updatedDate")).as("That object contains updatedDate").isTrue(); assertThat(keySet.contains("previousMidRate")).as("That object contains previousMidRate").isTrue(); assertThat(keySet.contains("baseCurrency")).as("That object contains baseCurrency").isTrue(); }
Example #6
Source File: GettingStartedIntegrationTest.java From getting-started with MIT License | 6 votes |
@Test void testGetTestCustomersInfoAPI() { JSONArray expectedTestCustomersResponse = TestUtil.parseJSONFileFromResourceToJSONArray( "GetTestCustomers.json"); Response<JSONArray> actualTestCustomersResponse = GettingStarted.getTestCustomers(); assertThat(actualTestCustomersResponse.getHttpResponse().getStatusCode()) .as("Test if status code is 200/OK").isEqualTo(200); JSONArray actualTestCustomersJSONResponse = actualTestCustomersResponse.getAwsResponse(); assertThat(actualTestCustomersJSONResponse.length()) .as("Check if objects have same amount of fields") .isEqualTo(expectedTestCustomersResponse.length()); JSONAssert.assertEquals(expectedTestCustomersResponse, actualTestCustomersJSONResponse , false); }
Example #7
Source File: IvonaSpeechCloudClient.java From ivona-speechcloud-sdk-java with Apache License 2.0 | 5 votes |
@Override public GetLexiconResult getLexicon(GetLexiconRequest getLexiconRequest) throws AmazonServiceException, AmazonClientException { ExecutionContext executionContext = createExecutionContext(getLexiconRequest); GetLexiconRequestMarshaller marshaller = new GetLexiconPostRequestMarshaller(); Request<GetLexiconRequest> request = marshaller.marshall(getLexiconRequest); Unmarshaller<GetLexiconResult, JsonUnmarshallerContext> unmarshaller = new GetLexiconResultJsonUnmarshaller(); JsonResponseHandler<GetLexiconResult> responseHandler = new JsonResponseHandler<GetLexiconResult>(unmarshaller); Response<GetLexiconResult> response = invoke(request, responseHandler, executionContext); return response.getAwsResponse(); }
Example #8
Source File: SpectatorRequestMetricCollector.java From spectator with Apache License 2.0 | 5 votes |
@Override public void collectMetrics(Request<?> request, Response<?> response) { final AWSRequestMetrics metrics = request.getAWSRequestMetrics(); if (metrics.isEnabled()) { final Map<String, String> allTags = getAllTags(request); final TimingInfo timing = metrics.getTimingInfo(); for (Field counter : COUNTERS) { Optional.ofNullable(timing.getCounter(counter.name())) .filter(v -> v.longValue() > 0) .ifPresent(v -> registry.counter(metricId(counter, allTags)).increment(v.longValue())); } for (Field timer : TIMERS) { Optional.ofNullable(timing.getLastSubMeasurement(timer.name())) .filter(TimingInfo::isEndTimeKnown) .ifPresent(t -> registry.timer(metricId(timer, allTags)) .record(t.getEndTimeNano() - t.getStartTimeNano(), TimeUnit.NANOSECONDS)); } notEmpty(metrics.getProperty(Field.ThrottleException)).ifPresent(throttleExceptions -> { final Id throttling = metricId("throttling", allTags); throttleExceptions.forEach(ex -> registry.counter(throttling.withTag(TAG_THROTTLE_EXCEPTION, ex.getClass().getSimpleName())).increment()); }); } }
Example #9
Source File: EsHttpRequest.java From charles-rest with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Perform this request. */ @Override public T perform() { final Response<T> rsp = new AmazonHttpClient(new ClientConfiguration()) .requestExecutionBuilder() .executionContext(new ExecutionContext(true)) .request(this.request) .errorResponseHandler(this.errHandler) .execute(this.respHandler); return rsp.getAwsResponse(); }
Example #10
Source File: KmsMasterKeyProvider.java From aws-encryption-sdk-java with Apache License 2.0 | 5 votes |
@Override public void afterError(final Request<?> request, final Response<?> response, final Exception e) { if (ranBefore_) return; if (e instanceof AmazonServiceException) { ranBefore_ = true; cache_.putIfAbsent(region_, client_); } }
Example #11
Source File: IvonaSpeechCloudClient.java From ivona-speechcloud-sdk-java with Apache License 2.0 | 5 votes |
@Override public CreateSpeechResult createSpeech(CreateSpeechRequest createSpeechRequest) throws AmazonServiceException, AmazonClientException { ExecutionContext executionContext = createExecutionContext(createSpeechRequest); Request<CreateSpeechRequest> request = CreateSpeechRequestMarshallerFactory.getMarshaller( createSpeechRequest.getMethodType()).marshall(createSpeechRequest); CreateSpeechResultUnmarshaller unmarshaller = new CreateSpeechResultUnmarshaller(); StreamResponseHandler<CreateSpeechResult> responseHandler = new StreamResponseHandler<CreateSpeechResult>(unmarshaller); Response<CreateSpeechResult> response = invoke(request, responseHandler, executionContext); return response.getAwsResponse(); }
Example #12
Source File: IvonaSpeechCloudClient.java From ivona-speechcloud-sdk-java with Apache License 2.0 | 5 votes |
@Override public ListVoicesResult listVoices(ListVoicesRequest listVoicesRequest) throws AmazonServiceException, AmazonClientException { ExecutionContext executionContext = createExecutionContext(listVoicesRequest); Request<ListVoicesRequest> request = ListVoicesRequestMarshallerFactory.getMarshaller( listVoicesRequest.getMethodType()).marshall(listVoicesRequest); Unmarshaller<ListVoicesResult, JsonUnmarshallerContext> unmarshaller = new ListVoicesResultJsonUnmarshaller(); JsonResponseHandler<ListVoicesResult> responseHandler = new JsonResponseHandler<ListVoicesResult>(unmarshaller); Response<ListVoicesResult> response = invoke(request, responseHandler, executionContext); return response.getAwsResponse(); }
Example #13
Source File: FaultInjectionRequestHandler.java From aws-doc-sdk-examples with Apache License 2.0 | 5 votes |
@Override public void afterResponse(Request<?> request, Response<?> response) { /* * The following is a hit and miss for multi-threaded clients as the * cache size is only 50 entries */ String awsRequestId = dynamoDBClient.getCachedResponseMetadata(request.getOriginalRequest()).getRequestId(); logger.info("AWS RequestID: " + awsRequestId); /* * Here you could inspect and alter the response object to see how your * application behaves for specific data */ if (request.getOriginalRequest() instanceof GetItemRequest) { GetItemResult result = (GetItemResult) response.getAwsResponse(); Map<String, AttributeValue> item = result.getItem(); if (item.get("name").getS().equals("Airplane")) { // Alter the item item.put("name", new AttributeValue("newAirplane")); item.put("new attr", new AttributeValue("new attr")); // Add some delay try { Thread.sleep(500); } catch (InterruptedException ie) { logger.info(ie); throw new RuntimeException(ie); } } } }
Example #14
Source File: FaultInjectionRequestHandler.java From aws-dynamodb-examples with Apache License 2.0 | 5 votes |
@Override public void afterResponse(Request<?> request, Response<?> response) { /* * The following is a hit and miss for multi-threaded clients as the * cache size is only 50 entries */ String awsRequestId = dynamoDBClient.getCachedResponseMetadata(request.getOriginalRequest()).getRequestId(); logger.info("AWS RequestID: " + awsRequestId); /* * Here you could inspect and alter the response object to see how your * application behaves for specific data */ if (request.getOriginalRequest() instanceof GetItemRequest) { GetItemResult result = (GetItemResult) response.getAwsResponse(); Map<String, AttributeValue> item = result.getItem(); if (item.get("name").getS().equals("Airplane")) { // Alter the item item.put("name", new AttributeValue("newAirplane")); item.put("new attr", new AttributeValue("new attr")); // Add some delay try { Thread.sleep(500); } catch (InterruptedException ie) { logger.info(ie); throw new RuntimeException(ie); } } } }
Example #15
Source File: TracingRequestHandler.java From zipkin-aws with Apache License 2.0 | 5 votes |
@Override public final void afterError(Request<?> request, Response<?> response, Exception e) { Span applicationSpan = request.getHandlerContext(APPLICATION_SPAN); if (applicationSpan != null) { applicationSpan.error(e); applicationSpan.finish(); } }
Example #16
Source File: GettingStartedIntegrationTest.java From getting-started with MIT License | 5 votes |
@Test void testGetCurrencyConversions() { Response<JSONArray> actualCardDetailsResponse = GettingStarted.getCurrencyConversions("NOK"); assertThat(actualCardDetailsResponse.getHttpResponse().getStatusCode()) .as("Test if status code is 200/OK").isEqualTo(200); JSONArray actualCardDetailsJSONResponse = actualCardDetailsResponse.getAwsResponse(); assertThat(actualCardDetailsJSONResponse.length()) .as("Expecting 46 different currencies") .isEqualTo(46); JSONObject jsonObject; Set<String> keySet; for (int i = 0 ; i < actualCardDetailsJSONResponse.length() ; i++) { jsonObject = actualCardDetailsJSONResponse.getJSONObject(i); keySet = jsonObject.keySet(); assertThat(keySet.size()).as("Check that object contains correct amount of parameters").isEqualTo(12); assertThat(keySet.contains("quoteCurrency")).as("That object contains quoteCurrency").isTrue(); assertThat(keySet.contains("country")).as("That object contains country").isTrue(); assertThat(keySet.contains("amount")).as("That object contains amount").isTrue(); assertThat(keySet.contains("buyRateTransfer")).as("That object contains buyRateTransfer").isTrue(); assertThat(keySet.contains("midRate")).as("That object contains midRate").isTrue(); assertThat(keySet.contains("sellRateTransfer")).as("That object contains sellRateTransfer").isTrue(); assertThat(keySet.contains("sellRateCash")).as("That object contains sellRateCash").isTrue(); assertThat(keySet.contains("changeInMidRate")).as("That object contains changeInMidRate").isTrue(); assertThat(keySet.contains("buyRateCash")).as("That object contains buyRateCash").isTrue(); assertThat(keySet.contains("updatedDate")).as("That object contains updatedDate").isTrue(); assertThat(keySet.contains("previousMidRate")).as("That object contains previousMidRate").isTrue(); assertThat(keySet.contains("baseCurrency")).as("That object contains baseCurrency").isTrue(); } }
Example #17
Source File: IvonaSpeechCloudClient.java From ivona-speechcloud-sdk-java with Apache License 2.0 | 5 votes |
private <X, Y extends AmazonWebServiceRequest> Response<X> invoke( Request<Y> request, HttpResponseHandler<AmazonWebServiceResponse<X>> responseHandler, ExecutionContext executionContext) { JsonErrorResponseHandler errorResponseHandler = new JsonErrorResponseHandler(exceptionUnmarshallers); Response<X> result = client.execute( prepareRequest(request, executionContext), responseHandler, errorResponseHandler, executionContext); return result; }
Example #18
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 #19
Source File: IvonaSpeechCloudClient.java From ivona-speechcloud-sdk-java with Apache License 2.0 | 5 votes |
@Override public ListLexiconsResult listLexicons() { ListLexiconsRequest listLexiconsRequest = new ListLexiconsRequest(); ExecutionContext executionContext = createExecutionContext(listLexiconsRequest); ListLexiconsRequestMarshaller marshaller = new ListLexiconsPostRequestMarshaller(); Request<ListLexiconsRequest> request = marshaller.marshall(listLexiconsRequest); Unmarshaller<ListLexiconsResult, JsonUnmarshallerContext> unmarshaller = new ListLexiconsResultJsonUnmarshaller(); JsonResponseHandler<ListLexiconsResult> responseHandler = new JsonResponseHandler<ListLexiconsResult>(unmarshaller); Response<ListLexiconsResult> response = invoke(request, responseHandler, executionContext); return response.getAwsResponse(); }
Example #20
Source File: TracingHandler.java From aws-xray-sdk-java with Apache License 2.0 | 5 votes |
@Override public void afterResponse(Request<?> request, Response<?> response) { if (isSubsegmentDuplicate(recorder.getCurrentSubsegmentOptional(), request)) { Optional<Subsegment> currentSubsegmentOptional = recorder.getCurrentSubsegmentOptional(); if (!currentSubsegmentOptional.isPresent()) { return; } Subsegment currentSubsegment = currentSubsegmentOptional.get(); populateAndEndSubsegment(currentSubsegment, request, response, null); } }
Example #21
Source File: MemoryOverwritingRequestHandlerTest.java From fernet-java8 with Apache License 2.0 | 5 votes |
@Test public void verifyAfterErrorClearsSecret() { // given final ByteBuffer secretBinary = ByteBuffer.wrap(new byte[] { 1, 1, 2, 3, 5, 8 }); assertTrue(Arrays.equals(secretBinary.array(), new byte[] { 1, 1, 2, 3, 5, 8})); final PutSecretValueRequest originalRequest = new PutSecretValueRequest(); originalRequest.setSecretBinary(secretBinary); final Request<PutSecretValueRequest> request = new DefaultRequest<PutSecretValueRequest>(originalRequest, "AWSSecretsManager"); final PutSecretValueResult result = mock(PutSecretValueResult.class); final HttpResponse httpResponse = mock(HttpResponse.class); final Response<PutSecretValueResult> response = new Response<PutSecretValueResult>(result, httpResponse); // when handler.afterError(request, response, new Exception()); // then assertFalse(Arrays.equals(secretBinary.array(), new byte[] { 1, 1, 2, 3, 5, 8})); }
Example #22
Source File: MemoryOverwritingRequestHandlerTest.java From fernet-java8 with Apache License 2.0 | 5 votes |
@Test public void verifyAfterResponseClearsSecret() { // given final ByteBuffer secretBinary = ByteBuffer.wrap(new byte[] { 1, 1, 2, 3, 5, 8 }); assertTrue(Arrays.equals(secretBinary.array(), new byte[] { 1, 1, 2, 3, 5, 8})); final PutSecretValueRequest originalRequest = new PutSecretValueRequest(); originalRequest.setSecretBinary(secretBinary); final Request<PutSecretValueRequest> request = new DefaultRequest<PutSecretValueRequest>(originalRequest, "AWSSecretsManager"); final PutSecretValueResult result = mock(PutSecretValueResult.class); final HttpResponse httpResponse = mock(HttpResponse.class); final Response<PutSecretValueResult> response = new Response<PutSecretValueResult>(result, httpResponse); // when handler.afterResponse(request, response); // then assertFalse(Arrays.equals(secretBinary.array(), new byte[] { 1, 1, 2, 3, 5, 8})); }
Example #23
Source File: MemoryOverwritingRequestHandler.java From fernet-java8 with Apache License 2.0 | 5 votes |
public void afterError(final Request<?> request, final Response<?> response, final Exception exception) { final Object requestObject = request.getOriginalRequestObject(); if (requestObject instanceof PutSecretValueRequest) { final PutSecretValueRequest putRequest = (PutSecretValueRequest) requestObject; overwriteSecret(putRequest); } }
Example #24
Source File: MemoryOverwritingRequestHandler.java From fernet-java8 with Apache License 2.0 | 5 votes |
public void afterResponse(final Request<?> request, final Response<?> response) { final Object requestObject = request.getOriginalRequestObject(); if (requestObject instanceof PutSecretValueRequest) { final PutSecretValueRequest putRequest = (PutSecretValueRequest) requestObject; overwriteSecret(putRequest); } }
Example #25
Source File: FaultInjectionRequestHandler.java From aws-dynamodb-examples with Apache License 2.0 | 4 votes |
@Override public void afterError(Request<?> request, Response<?> response, Exception e) { // TODO Auto-generated method stub }
Example #26
Source File: KmsMasterKeyProvider.java From aws-encryption-sdk-java with Apache License 2.0 | 4 votes |
@Override public void afterResponse(final Request<?> request, final Response<?> response) { if (ranBefore_) return; ranBefore_ = true; cache_.putIfAbsent(region_, client_); }
Example #27
Source File: FaultInjectionRequestHandler.java From aws-doc-sdk-examples with Apache License 2.0 | 4 votes |
@Override public void afterError(Request<?> request, Response<?> response, Exception e) { // TODO Auto-generated method stub }
Example #28
Source File: TracingRequestHandler.java From zipkin-aws with Apache License 2.0 | 4 votes |
@Override public final void afterResponse(Request<?> request, Response<?> response) { Span applicationSpan = request.getHandlerContext(APPLICATION_SPAN); if (applicationSpan != null) { applicationSpan.finish(); } }
Example #29
Source File: TracingHandler.java From aws-xray-sdk-java with Apache License 2.0 | 4 votes |
@Override public void afterError(Request<?> request, Response<?> response, Exception e) { if (isSubsegmentDuplicate(recorder.getCurrentSubsegmentOptional(), request)) { Optional<Subsegment> currentSubsegmentOptional = recorder.getCurrentSubsegmentOptional(); if (!currentSubsegmentOptional.isPresent()) { return; } Subsegment currentSubsegment = currentSubsegmentOptional.get(); int statusCode = -1; if (null != response) { statusCode = response.getHttpResponse().getStatusCode(); } else { if (e instanceof AmazonServiceException) { AmazonServiceException ase = (AmazonServiceException) e; statusCode = ase.getStatusCode(); // The S3 client will throw and re-swallow AmazonServiceExceptions if they have these status codes. Customers // will never see the exceptions in their application code but they still travel through our // TracingHandler#afterError method. We special case these status codes in order to prevent addition of the // full exception object to the current subsegment. Instead, we'll just add any exception error message to the // current subsegment's cause's message. if ((304 == statusCode || 412 == statusCode) && S3_SERVICE_NAME.equals(ase.getServiceName())) { populateAndEndSubsegment(currentSubsegment, request, response, ase); return; } if (RetryUtils.isThrottlingException(ase)) { currentSubsegment.setError(true); currentSubsegment.setThrottle(true); } } } if (-1 != statusCode) { int statusCodePrefix = statusCode / 100; if (4 == statusCodePrefix) { currentSubsegment.setError(true); if (429 == statusCode) { currentSubsegment.setThrottle(true); } } } currentSubsegment.addException(e); if (e instanceof AmazonServiceException) { populateAndEndSubsegment(currentSubsegment, request, response, (AmazonServiceException) e); } else { populateAndEndSubsegment(currentSubsegment, request, response); } } }
Example #30
Source File: GettingStarted.java From getting-started with MIT License | 4 votes |
public static Response<JSONObject> getCurrencyConversion(String quoteCurrency, String baseCurrency) { final Request currenciesRequest = createRequest(HttpMethodName.GET, "/currencies/v1/" + baseCurrency + "/convert/" + quoteCurrency); return buildRequest(currenciesRequest).execute(new ResponseHandlerJSONObject(false)); }