/** * Sets the maximum number of retry attempts for failed retryable requests (ex: 5xx error * responses from services), and returns the updated ClientConfiguration object. * * @param maxErrorRetry * The maximum number of retry attempts for failed retryable requests. This value * should not be negative. * @return The updated ClientConfiguration object. */ public ClientConfiguration withMaxErrorRetry(int maxErrorRetry) { setMaxErrorRetry(maxErrorRetry); return this; }
static ClientConfiguration s3ClientCfg() { ClientConfiguration cfg = new ClientConfiguration(); Properties prop = System.getProperties(); if( prop.containsKey(S3_SOCKET_TIMEOUT_PROP) ) cfg.setSocketTimeout(Integer.getInteger(S3_SOCKET_TIMEOUT_PROP)); if( prop.containsKey(S3_CONNECTION_TIMEOUT_PROP) ) cfg.setConnectionTimeout(Integer .getInteger(S3_CONNECTION_TIMEOUT_PROP)); if( prop.containsKey(S3_MAX_ERROR_RETRY_PROP) ) cfg.setMaxErrorRetry(Integer.getInteger(S3_MAX_ERROR_RETRY_PROP)); if( prop.containsKey(S3_MAX_HTTP_CONNECTIONS_PROP) ) cfg.setMaxConnections(Integer .getInteger(S3_MAX_HTTP_CONNECTIONS_PROP)); cfg.setProtocol(Protocol.HTTP); return cfg; }
s3Credentials = new BasicAWSCredentials(accessKeyId, secretKey); clientConfig = new ClientConfiguration(); clientConfig.setMaxErrorRetry(Integer.parseInt(maxErrorRetry)); if(protocol.equals("HTTP")) { clientConfig.setProtocol(Protocol.HTTP);
/** * Sets the maximum number of retry attempts for failed retryable requests (ex: 5xx error * responses from services), and returns the updated ClientConfiguration object. * * @param maxErrorRetry * The maximum number of retry attempts for failed retryable requests. This value * should not be negative. * @return The updated ClientConfiguration object. */ public ClientConfiguration withMaxErrorRetry(int maxErrorRetry) { setMaxErrorRetry(maxErrorRetry); return this; }
/** * Sets the maximum number of retry attempts for failed retryable requests * (ex: 5xx error responses from services), and returns the updated * ClientConfiguration object. * * @param maxErrorRetry The maximum number of retry attempts for failed * retryable requests. This value should not be negative. * @return The updated ClientConfiguration object. */ @SuppressWarnings("checkstyle:hiddenfield") public ClientConfiguration withMaxErrorRetry(int maxErrorRetry) { setMaxErrorRetry(maxErrorRetry); return this; }
protected ClientConfiguration createConfiguration(final ProcessContext context) { final ClientConfiguration config = new ClientConfiguration(); config.setMaxConnections(context.getMaxConcurrentTasks()); config.setMaxErrorRetry(0); config.setUserAgent(DEFAULT_USER_AGENT);
/** * Sets the maximum number of retry attempts for failed retryable requests * (ex: 5xx error responses from services), and returns the updated * ClientConfiguration object. * * @param maxErrorRetry The maximum number of retry attempts for failed * retryable requests. This value should not be negative. * @return The updated ClientConfiguration object. */ @SuppressWarnings("checkstyle:hiddenfield") public ClientConfiguration withMaxErrorRetry(int maxErrorRetry) { setMaxErrorRetry(maxErrorRetry); return this; }
/** * Sets the maximum number of retry attempts for failed retryable requests (ex: 5xx error * responses from services), and returns the updated ClientConfiguration object. * * @param maxErrorRetry * The maximum number of retry attempts for failed retryable requests. This value * should not be negative. * @return The updated ClientConfiguration object. */ public ClientConfiguration withMaxErrorRetry(int maxErrorRetry) { setMaxErrorRetry(maxErrorRetry); return this; }
/** * Sets the maximum number of retry attempts for failed retryable requests * (ex: 5xx error responses from services), and returns the updated * ClientConfiguration object. * * @param maxErrorRetry The maximum number of retry attempts for failed * retryable requests. This value should not be negative. * @return The updated ClientConfiguration object. */ @SuppressWarnings("checkstyle:hiddenfield") public ClientConfiguration withMaxErrorRetry(int maxErrorRetry) { setMaxErrorRetry(maxErrorRetry); return this; }
configuration.setMaxErrorRetry(clientOptions.getMaxErrorRetry());
@Override protected ClientConfiguration buildClientConfiguration() { ClientConfiguration clientConfiguration = new ClientConfiguration(); if (maxErrorRetry > 0) { clientConfiguration.setMaxErrorRetry(maxErrorRetry); } return clientConfiguration; }
/** * -- Explicitly set maxErrorRetry in ClientConfiguration level; -- * Default/custom RetryPolicy's that don't override such setting. */ @Test public void testClientConfigLevelMaxErrorRetry() { int CLIENT_CONFIG_LEVEL_MAX_RETRY = random.nextInt(3); clientConfiguration.setMaxErrorRetry(CLIENT_CONFIG_LEVEL_MAX_RETRY); // SDK default policy should honor the ClientConfig level maxErrorRetry testActualRetries(CLIENT_CONFIG_LEVEL_MAX_RETRY); // DynamoDB default policy should also honor that clientConfiguration.setRetryPolicy(PredefinedRetryPolicies.DYNAMODB_DEFAULT); testActualRetries(CLIENT_CONFIG_LEVEL_MAX_RETRY); // A custom policy that honors the ClientConfig level maxErrorRetry clientConfiguration.setRetryPolicy(new RetryPolicy(null, null, 5, true)); testActualRetries(CLIENT_CONFIG_LEVEL_MAX_RETRY); }
/** * -- Explicitly set maxErrorRetry in ClientConfiguration level; -- Custom * RetryPolicy's that want to override such setting. */ @Test public void testRetryPolicyLevelMaxErrorRetry() { // This should be ignored clientConfiguration.setMaxErrorRetry(random.nextInt(3)); // A custom policy that doesn't honor the ClientConfig level // maxErrorRetry int RETRY_POLICY_LEVEL_MAX_ERROR_RETRY = 5; clientConfiguration.setRetryPolicy(new RetryPolicy(null, null, RETRY_POLICY_LEVEL_MAX_ERROR_RETRY, false)); testActualRetries(RETRY_POLICY_LEVEL_MAX_ERROR_RETRY); // A custom policy that "honors" the ClientConfig level maxErrorRetry, // but actually denies any retry in its condition. clientConfiguration.setRetryPolicy(new RetryPolicy( new RetryPolicy.RetryCondition() { @Override public boolean shouldRetry( AmazonWebServiceRequest originalRequest, AmazonClientException exception, int retriesAttempted) { return false; } }, null, RETRY_POLICY_LEVEL_MAX_ERROR_RETRY, true) ); // No retry is expected testActualRetries(0); }
private void static createSnsClient() { Region region = Region.getRegion(Regions.AP_SOUTHEAST_1); AWSCredentials credentials = new BasicAWSCredentials(AwsPropertyLoader.getInstance().getAccessKey(), AwsPropertyLoader.getInstance().getSecretKey()); ClientConfiguration clientConfiguration = new ClientConfiguration(); clientConfiguration.setMaxErrorRetry(25); clientConfiguration.setRetryPolicy(new RetryPolicy(null, null, 25, true)); mSnsClient = new AmazonSNSClient(credentials, clientConfiguration); mSnsClient.setRegion(region); }
static ClientConfiguration s3ClientCfg() { ClientConfiguration cfg = new ClientConfiguration(); Properties prop = System.getProperties(); if (prop.containsKey(S3_SOCKET_TIMEOUT_PROP)) cfg.setSocketTimeout(Integer.getInteger(S3_SOCKET_TIMEOUT_PROP)); if (prop.containsKey(S3_CONNECTION_TIMEOUT_PROP)) cfg.setConnectionTimeout(Integer.getInteger(S3_CONNECTION_TIMEOUT_PROP)); if (prop.containsKey(S3_MAX_ERROR_RETRY_PROP)) cfg.setMaxErrorRetry(Integer.getInteger(S3_MAX_ERROR_RETRY_PROP)); if (prop.containsKey(S3_MAX_HTTP_CONNECTIONS_PROP)) cfg.setMaxConnections(Integer.getInteger(S3_MAX_HTTP_CONNECTIONS_PROP)); if (prop.containsKey(S3_FORCE_HTTP)) cfg.setProtocol(Protocol.HTTP); return cfg; }
@Override public void start(ILifecycleProgressMonitor monitor) throws SiteWhereException { super.start(monitor); ClientConfiguration config = new ClientConfiguration(); config.setMaxConnections(250); config.setMaxErrorRetry(5); if (getAccessKey() == null) { throw new SiteWhereException("Amazon access key not provided."); } if (getSecretKey() == null) { throw new SiteWhereException("Amazon secret key not provided."); } sqs = new AmazonSQSClient(new BasicAWSCredentials(getAccessKey(), getSecretKey()), config); Region usEast1 = Region.getRegion(Regions.US_EAST_1); sqs.setRegion(usEast1); }
@Override public void start(ILifecycleProgressMonitor monitor) throws SiteWhereException { super.start(monitor); ClientConfiguration config = new ClientConfiguration(); config.setMaxConnections(250); config.setMaxErrorRetry(5); if (getAccessKey() == null) { throw new SiteWhereException("Amazon access key not provided."); } if (getSecretKey() == null) { throw new SiteWhereException("Amazon secret key not provided."); } sqs = new AmazonSQSClient(new BasicAWSCredentials(getAccessKey(), getSecretKey()), config); Region usEast1 = Region.getRegion(Regions.US_EAST_1); sqs.setRegion(usEast1); }
public static ClientConfiguration createClientConfiguration(final String host) { ClientConfiguration config = new ClientConfiguration(); config.setMaxErrorRetry(16); // Default retry limit (3) is low and often // cause problems. Raise it a bit. // See: https://issues.jenkins-ci.org/browse/JENKINS-26800 config.setSignerOverride("AWS4SignerType"); ProxyConfiguration proxyConfig = Jenkins.getInstance().proxy; Proxy proxy = proxyConfig == null ? Proxy.NO_PROXY : proxyConfig.createProxy(host); if (!proxy.equals(Proxy.NO_PROXY) && proxy.address() instanceof InetSocketAddress) { InetSocketAddress address = (InetSocketAddress) proxy.address(); config.setProxyHost(address.getHostName()); config.setProxyPort(address.getPort()); if (null != proxyConfig.getUserName()) { config.setProxyUsername(proxyConfig.getUserName()); config.setProxyPassword(proxyConfig.getPassword()); } } return config; }
public AmazonIdentityConfiguration(final Host bookmark, final int timeout) { this.bookmark = bookmark; this.configuration = new ClientConfiguration(); this.configuration.setConnectionTimeout(timeout); this.configuration.setSocketTimeout(timeout); final UseragentProvider ua = new PreferencesUseragentProvider(); this.configuration.setUserAgentPrefix(ua.get()); this.configuration.setMaxErrorRetry(0); this.configuration.setMaxConnections(1); this.configuration.setUseGzip(PreferencesFactory.get().getBoolean("http.compression.enable")); final Proxy proxy = ProxyFactory.get().find(bookmark); switch(proxy.getType()) { case HTTP: case HTTPS: this.configuration.setProxyHost(proxy.getHostname()); this.configuration.setProxyPort(proxy.getPort()); } }
c.setMaxErrorRetry(2); assertEquals(c.getMaxErrorRetry(), 2);