/** * Attempts to acquire a single capacity unit. * If acquired, capacity will be consumed from the available pool. * @return true if capacity can be acquired, false if not */ public boolean acquire() { return acquire(1); }
/** * Adds Retry information to the {@link #HEADER_SDK_RETRY_INFO} header. Used for analysis of * retry policy. * * @param request Request to add header to * @param execOneRequestParams Request context containing retry information */ private void updateRetryHeaderInfo(Request<?> request, ExecOneRequestParams execOneRequestParams) { int availableRetryCapacity = retryCapacity.availableCapacity(); String headerValue = String.format("%s/%s/%s", execOneRequestParams.requestCount - 1, execOneRequestParams.lastBackoffDelay, availableRetryCapacity >= 0 ? availableRetryCapacity : ""); request.addHeader(HEADER_SDK_RETRY_INFO, headerValue); }
/** * Releases a single unit of capacity back to the pool, making it available * to consumers. */ public void release() { release(1); }
publishProgress(listener, ProgressEventType.HTTP_REQUEST_STARTED_EVENT); awsRequestMetrics.startEvent(Field.HttpRequestTime); awsRequestMetrics.setCounter(Field.RetryCapacityConsumed, retryCapacity.consumedCapacity()); retryCapacity.release(THROTTLED_RETRY_COST); } else { retryCapacity.release();
private AmazonHttpClient(ClientConfiguration clientConfig, RetryPolicy retryPolicy, RequestMetricCollector requestMetricCollector, HttpClientSettings httpClientSettings) { this.config = clientConfig; this.retryPolicy = retryPolicy == null ? new RetryPolicyAdapter(clientConfig.getRetryPolicy(), clientConfig) : retryPolicy; this.httpClientSettings = httpClientSettings; this.requestMetricCollector = requestMetricCollector; this.responseMetadataCache = clientConfig.getCacheResponseMetadata() ? new ResponseMetadataCache(clientConfig.getResponseMetadataCacheSize()) : new NullResponseMetadataCache(); this.httpRequestTimer = new HttpRequestTimer(); this.clientExecutionTimer = new ClientExecutionTimer(); // When enabled, total retry capacity is computed based on retry cost // and desired number of retries. int throttledRetryMaxCapacity = clientConfig.useThrottledRetries() ? THROTTLED_RETRY_COST * config.getMaxConsecutiveRetriesBeforeThrottling() : -1; this.retryCapacity = new CapacityManager(throttledRetryMaxCapacity); }
publishProgress(listener, ProgressEventType.HTTP_REQUEST_STARTED_EVENT); awsRequestMetrics.startEvent(Field.HttpRequestTime); awsRequestMetrics.setCounter(Field.RetryCapacityConsumed, retryCapacity.consumedCapacity()); retryCapacity.release(THROTTLED_RETRY_COST); } else { retryCapacity.release();
private AmazonHttpClient(ClientConfiguration clientConfig, RetryPolicy retryPolicy, RequestMetricCollector requestMetricCollector, HttpClientSettings httpClientSettings) { this.config = clientConfig; this.retryPolicy = retryPolicy == null ? new RetryPolicyAdapter(clientConfig.getRetryPolicy(), clientConfig) : retryPolicy; this.httpClientSettings = httpClientSettings; this.requestMetricCollector = requestMetricCollector; this.responseMetadataCache = clientConfig.getCacheResponseMetadata() ? new ResponseMetadataCache(clientConfig.getResponseMetadataCacheSize()) : new NullResponseMetadataCache(); this.httpRequestTimer = new HttpRequestTimer(); this.clientExecutionTimer = new ClientExecutionTimer(); // When enabled, total retry capacity is computed based on retry cost // and desired number of retries. int throttledRetryMaxCapacity = clientConfig.useThrottledRetries() ? THROTTLED_RETRY_COST * config.getMaxConsecutiveRetriesBeforeThrottling() : -1; this.retryCapacity = new CapacityManager(throttledRetryMaxCapacity); }
publishProgress(listener, ProgressEventType.HTTP_REQUEST_STARTED_EVENT); awsRequestMetrics.startEvent(Field.HttpRequestTime); awsRequestMetrics.setCounter(Field.RetryCapacityConsumed, retryCapacity.consumedCapacity()); retryCapacity.release(THROTTLED_RETRY_COST); } else { retryCapacity.release();
/** * Attempts to acquire a single capacity unit. * If acquired, capacity will be consumed from the available pool. * @return true if capacity can be acquired, false if not */ public boolean acquire() { return acquire(1); }
/** * Releases a single unit of capacity back to the pool, making it available * to consumers. */ public void release() { release(1); }
/** * Adds Retry information to the {@link #HEADER_SDK_RETRY_INFO} header. Used for analysis of * retry policy. * * @param request Request to add header to * @param execOneRequestParams Request context containing retry information */ private void updateRetryHeaderInfo(Request<?> request, ExecOneRequestParams execOneRequestParams) { int availableRetryCapacity = retryCapacity.availableCapacity(); String headerValue = String.format("%s/%s/%s", execOneRequestParams.requestCount - 1, execOneRequestParams.lastBackoffDelay, availableRetryCapacity >= 0 ? availableRetryCapacity : ""); request.addHeader(HEADER_SDK_RETRY_INFO, headerValue); }
private AmazonHttpClient(ClientConfiguration clientConfig, RetryPolicy retryPolicy, RequestMetricCollector requestMetricCollector, HttpClientSettings httpClientSettings) { this.config = clientConfig; this.retryPolicy = retryPolicy == null ? new RetryPolicyAdapter(clientConfig.getRetryPolicy(), clientConfig) : retryPolicy; this.httpClientSettings = httpClientSettings; this.requestMetricCollector = requestMetricCollector; this.responseMetadataCache = clientConfig.getCacheResponseMetadata() ? new ResponseMetadataCache(clientConfig.getResponseMetadataCacheSize()) : new NullResponseMetadataCache(); this.httpRequestTimer = new HttpRequestTimer(); this.clientExecutionTimer = new ClientExecutionTimer(); // When enabled, total retry capacity is computed based on retry cost // and desired number of retries. int throttledRetryMaxCapacity = clientConfig.useThrottledRetries() ? THROTTLED_RETRY_COST * config.getMaxConsecutiveRetriesBeforeThrottling() : -1; this.retryCapacity = new CapacityManager(throttledRetryMaxCapacity); }
/** * Attempts to acquire a single capacity unit. * If acquired, capacity will be consumed from the available pool. * @return true if capacity can be acquired, false if not */ public boolean acquire() { return acquire(1); }
/** * Releases a single unit of capacity back to the pool, making it available * to consumers. */ public void release() { release(1); }
/** * Adds Retry information to the {@link #HEADER_SDK_RETRY_INFO} header. Used for analysis of * retry policy. * * @param request Request to add header to * @param execOneRequestParams Request context containing retry information */ private void updateRetryHeaderInfo(Request<?> request, ExecOneRequestParams execOneRequestParams) { int availableRetryCapacity = retryCapacity.availableCapacity(); String headerValue = String.format("%s/%s/%s", execOneRequestParams.requestCount - 1, execOneRequestParams.lastBackoffDelay, availableRetryCapacity >= 0 ? availableRetryCapacity : ""); request.addHeader(HEADER_SDK_RETRY_INFO, headerValue); }