Commit 9cb6c9df authored by Krishna Nikhil Vedurumudi's avatar Krishna Nikhil Vedurumudi
Browse files

Merge branch 'table-storage-timeouts' into 'master'

CloudTableClient has no timeouts

See merge request !97
parents f3c5357e ec201ec7
Pipeline #68951 failed with stages
in 33 minutes and 18 seconds
This diff is collapsed.
......@@ -15,12 +15,15 @@
package org.opengroup.osdu.partition.provider.azure.di;
import com.microsoft.azure.storage.CloudStorageAccount;
import com.microsoft.azure.storage.RetryLinearRetry;
import com.microsoft.azure.storage.StorageException;
import com.microsoft.azure.storage.table.CloudTable;
import com.microsoft.azure.storage.table.CloudTableClient;
import lombok.Setter;
import org.apache.http.HttpStatus;
import org.opengroup.osdu.common.Validators;
import org.opengroup.osdu.core.common.model.http.AppException;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;
......@@ -30,10 +33,16 @@ import java.net.URISyntaxException;
import java.security.InvalidKeyException;
@Configuration
@ConfigurationProperties(prefix = "azure.table-storage")
@Setter
public class TableStorageBootstrapConfig {
private final static String CONNECTION_STRING = "DefaultEndpointsProtocol=https;AccountName=%s;AccountKey=%s;EndpointSuffix=core.windows.net";
private int maximumExecutionTimeMs;
private int retryDeltaBackoffMs;
private int retryMaxAttempts;
@Bean
@Lazy
public CloudTableClient getCloudTableClient(
......@@ -45,7 +54,10 @@ public class TableStorageBootstrapConfig {
final String storageConnectionString = String.format(CONNECTION_STRING, storageAccountName, storageAccountKey);
CloudStorageAccount storageAccount = CloudStorageAccount.parse(storageConnectionString);
return storageAccount.createCloudTableClient();
CloudTableClient cloudTableClient = storageAccount.createCloudTableClient();
cloudTableClient.getDefaultRequestOptions().setRetryPolicyFactory(new RetryLinearRetry(retryDeltaBackoffMs, retryMaxAttempts));
cloudTableClient.getDefaultRequestOptions().setMaximumExecutionTimeInMs(maximumExecutionTimeMs);
return cloudTableClient;
} catch (URISyntaxException | InvalidKeyException e) {
throw new AppException(HttpStatus.SC_INTERNAL_SERVER_ERROR, "Error creating cloud table storage client", e.getMessage(), e);
}
......
......@@ -28,6 +28,11 @@ azure.keyvault.url=${KEYVAULT_URI}
# Azure App Insights configuration
azure.application-insights.instrumentation-key=${appinsights_key}
#Azure TableStorage
azure.table-storage.retry-delta-backoff-ms=2000
azure.table-storage.retry-max-attempts=3
azure.table-storage.maximum-execution-time-ms=60000
# Cache configuration, provider [vm or redis]
cache.provider=redis
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment