Commit b4b24da7 authored by Ronak Sakhuja's avatar Ronak Sakhuja
Browse files

Merge branch 'master' of...

Merge branch 'master' of https://community.opengroup.org/osdu/platform/system/lib/cloud/azure/os-core-lib-azure into rosakhuj/crypto
parents bae56ae8 d1b230de
......@@ -87,3 +87,11 @@ Enabled transaction logger and slf4jlogger
| --- | --- | --- |
| `azure.blobStore.required` | `true` | - |
| `azure.storage.account-name` | ex `testStorage` | storage account name |
# Default retry and timeout values for service-to-service communication
| name | default value |
| --- | --- |
| `maxRetry` | `3` |
| `connectTimeout` | `60000` |
| `requestTimeout` | `60000` |
| `socketTimeout` | `60000` |
......@@ -20,7 +20,7 @@
<groupId>org.opengroup.osdu</groupId>
<artifactId>core-lib-azure</artifactId>
<packaging>jar</packaging>
<version>0.9.0-SNAPSHOT</version>
<version>0.10.0-SNAPSHOT</version>
<name>core-lib-azure</name>
<properties>
......@@ -37,7 +37,7 @@
<azure.appinsights.log4j.version>2.6.3</azure.appinsights.log4j.version>
<azure.spring.boot.version>3.4.0</azure.spring.boot.version>
<lombok.version>1.18.16</lombok.version>
<osdu.oscorecommon.version>0.9.0-rc13</osdu.oscorecommon.version>
<osdu.oscorecommon.version>0.9.0</osdu.oscorecommon.version>
<azure-mgmt-eventgrid.version>1.0.0-beta-3</azure-mgmt-eventgrid.version>
<azure-security-keyvault-keys.version>4.2.3</azure-security-keyvault-keys.version>
<documentdb-bulkexecutor.version>2.12.0</documentdb-bulkexecutor.version>
......
......@@ -17,10 +17,13 @@ package org.opengroup.osdu.azure.blobstorage;
import com.azure.identity.DefaultAzureCredential;
import com.azure.storage.blob.BlobServiceClient;
import com.azure.storage.blob.BlobServiceClientBuilder;
import com.azure.storage.common.policy.RequestRetryOptions;
import org.opengroup.osdu.azure.cache.BlobServiceClientCache;
import org.opengroup.osdu.azure.di.BlobStoreRetryConfiguration;
import org.opengroup.osdu.azure.partition.PartitionInfoAzure;
import org.opengroup.osdu.azure.partition.PartitionServiceClient;
import org.opengroup.osdu.common.Validators;
import org.springframework.beans.factory.annotation.Autowired;
/**
* Implementation for IBlobServiceClientFactory.
......@@ -30,6 +33,9 @@ public class BlobServiceClientFactoryImpl implements IBlobServiceClientFactory {
private PartitionServiceClient partitionService;
private BlobServiceClientCache clientCache;
@Autowired
private BlobStoreRetryConfiguration blobStoreRetryConfiguration;
/**
* Constructor to initialize instance of {@link BlobServiceClientFactoryImpl}.
* @param credentials Azure Credentials to use
......@@ -61,9 +67,12 @@ public class BlobServiceClientFactoryImpl implements IBlobServiceClientFactory {
PartitionInfoAzure pi = this.partitionService.getPartition(dataPartitionId);
String endpoint = String.format("https://%s.blob.core.windows.net", pi.getStorageAccountName());
RequestRetryOptions requestRetryOptions = blobStoreRetryConfiguration.getRequestRetryOptions();
BlobServiceClient blobServiceClient = new BlobServiceClientBuilder()
.endpoint(endpoint)
.credential(defaultAzureCredential)
.retryOptions(requestRetryOptions)
.buildClient();
this.clientCache.put(cacheKey, blobServiceClient);
......
......@@ -21,6 +21,7 @@ import com.azure.storage.blob.models.BlobCopyInfo;
import com.azure.storage.blob.models.BlobErrorCode;
import com.azure.storage.blob.models.BlobStorageException;
import com.azure.storage.blob.models.CopyStatusType;
import com.azure.storage.blob.models.UserDelegationKey;
import com.azure.storage.blob.sas.BlobContainerSasPermission;
import com.azure.storage.blob.sas.BlobSasPermission;
import com.azure.storage.blob.sas.BlobServiceSasSignatureValues;
......@@ -114,7 +115,7 @@ public class BlobStore {
int statusCode = HttpStatus.SC_OK;
try (ByteArrayOutputStream downloadStream = new ByteArrayOutputStream()) {
blockBlobClient.download(downloadStream);
CoreLoggerFactory.getInstance().getLogger(LOGGER_NAME).info("{}", MessageFormatter.format("Done reading from {}", filePath).getMessage());
CoreLoggerFactory.getInstance().getLogger(LOGGER_NAME).debug("{}", MessageFormatter.format("Done reading from {}", filePath).getMessage());
return downloadStream.toString(StandardCharsets.UTF_8.name());
} catch (BlobStorageException ex) {
statusCode = ex.getStatusCode();
......@@ -151,7 +152,7 @@ public class BlobStore {
int statusCode = HttpStatus.SC_OK;
try {
blockBlobClient.delete();
CoreLoggerFactory.getInstance().getLogger(LOGGER_NAME).info("{}", MessageFormatter.format("Done deleting blob at {}", filePath).getMessage());
CoreLoggerFactory.getInstance().getLogger(LOGGER_NAME).debug("{}", MessageFormatter.format("Done deleting blob at {}", filePath).getMessage());
return true;
} catch (BlobStorageException ex) {
statusCode = ex.getStatusCode();
......@@ -186,7 +187,7 @@ public class BlobStore {
int statusCode = HttpStatus.SC_OK;
try (ByteArrayInputStream dataStream = new ByteArrayInputStream(bytes)) {
blockBlobClient.upload(dataStream, bytesSize, true);
CoreLoggerFactory.getInstance().getLogger(LOGGER_NAME).info("{}", MessageFormatter.format("Done uploading file content to {}", filePath).getMessage());
CoreLoggerFactory.getInstance().getLogger(LOGGER_NAME).debug("{}", MessageFormatter.format("Done uploading file content to {}", filePath).getMessage());
} catch (BlobStorageException ex) {
statusCode = ex.getStatusCode();
throw handleBlobStoreException(500, "Failed to upload file content.", ex);
......@@ -212,7 +213,7 @@ public class BlobStore {
BlobServiceClient blobServiceClient = blobServiceClientFactory.getBlobServiceClient(dataPartitionId);
try {
blobServiceClient.createBlobContainer(containerName);
CoreLoggerFactory.getInstance().getLogger(LOGGER_NAME).info("{}", MessageFormatter.format("Done creating container with name {}", containerName).getMessage());
CoreLoggerFactory.getInstance().getLogger(LOGGER_NAME).debug("{}", MessageFormatter.format("Done creating container with name {}", containerName).getMessage());
return true;
} catch (BlobStorageException ex) {
throw handleBlobStoreException(500, "Failed to create blob container", ex);
......@@ -231,7 +232,7 @@ public class BlobStore {
BlobServiceClient blobServiceClient = blobServiceClientFactory.getBlobServiceClient(dataPartitionId);
try {
blobServiceClient.deleteBlobContainer(containerName);
CoreLoggerFactory.getInstance().getLogger(LOGGER_NAME).info("{}", MessageFormatter.format("Done deleting container with name {}", containerName).getMessage());
CoreLoggerFactory.getInstance().getLogger(LOGGER_NAME).debug("{}", MessageFormatter.format("Done deleting container with name {}", containerName).getMessage());
return true;
} catch (BlobStorageException ex) {
throw handleBlobStoreException(500, "Failed to delete blob container", ex);
......@@ -253,6 +254,8 @@ public class BlobStore {
}
/**
* This method is used to generate pre-signed url for file (blob).
* NOTE: Using the below method will require BlobServiceClient to be instantiated using StorageSharedKeyCredential
* @param dataPartitionId Data partition id
* @param filePath Path of file (blob) for which SAS token needs to be generated
* @param containerName Name of the storage container
......@@ -267,8 +270,8 @@ public class BlobStore {
}
/**
* Generates pre-signed url to a blob container.
*
* This method is used to generate pre-signed url for blob container.
* NOTE: Using the below method will require BlobServiceClient to be instantiated using StorageSharedKeyCredential
* @param dataPartitionId data partition id
* @param containerName Name of the storage container
* @param expiryTime Time after which the token expires
......@@ -280,6 +283,30 @@ public class BlobStore {
return blobContainerClient.getBlobContainerUrl() + "?" + generateSASToken(blobContainerClient, expiryTime, permissions);
}
/**
* Generates pre-signed url to a blob container using the user delegation key.
*
* @param dataPartitionId data partition id
* @param containerName Name of the storage container
* @param startTime Time after which the token is activated (null in case of instant activation)
* @param expiryTime Time after which the token expires
* @param permissions permissions for the given container
* @return Generates pre-signed url for a given container
*/
public String generatePreSignedUrlWithUserDelegationSas(final String dataPartitionId, final String containerName, final OffsetDateTime startTime, final OffsetDateTime expiryTime, final BlobContainerSasPermission permissions) {
BlobContainerClient blobContainerClient = getBlobContainerClient(dataPartitionId, containerName);
BlobServiceClient blobServiceClient = blobServiceClientFactory.getBlobServiceClient(dataPartitionId);
UserDelegationKey userDelegationKey = blobServiceClient.getUserDelegationKey(startTime, expiryTime);
BlobServiceSasSignatureValues blobServiceSasSignatureValues = new BlobServiceSasSignatureValues(expiryTime, permissions).setStartTime(startTime);
final long start = System.currentTimeMillis();
String sasToken = blobContainerClient.generateUserDelegationSas(blobServiceSasSignatureValues, userDelegationKey);
final long timeTaken = System.currentTimeMillis() - start;
logDependency("GENERATE_PRESIGNED_URL_USER_DELEGATION_SAS", blobContainerClient.getBlobContainerName(), blobContainerClient.getBlobContainerUrl(), timeTaken, String.valueOf(HttpStatus.SC_OK), true);
return blobContainerClient.getBlobContainerUrl() + "?" + sasToken;
}
/**
* Method is used to copy a file specified at Source URL to the provided destination.
*
......
......@@ -2,11 +2,14 @@ package org.opengroup.osdu.azure.cosmosdb;
import com.azure.cosmos.CosmosClient;
import com.azure.cosmos.CosmosClientBuilder;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import javax.annotation.PostConstruct;
import com.azure.cosmos.ThrottlingRetryOptions;
import org.opengroup.osdu.azure.logging.CoreLoggerFactory;
import org.opengroup.osdu.azure.di.CosmosRetryConfiguration;
import org.opengroup.osdu.azure.partition.PartitionInfoAzure;
import org.opengroup.osdu.azure.partition.PartitionServiceClient;
import org.opengroup.osdu.common.Validators;
......@@ -27,6 +30,9 @@ public class CosmosClientFactoryImpl implements ICosmosClientFactory {
private Map<String, CosmosClient> cosmosClientMap;
@Autowired
private CosmosRetryConfiguration cosmosRetryConfiguration;
/**
* Initializes the private variables as required.
*/
......@@ -58,9 +64,13 @@ public class CosmosClientFactoryImpl implements ICosmosClientFactory {
*/
private CosmosClient createCosmosClient(final String dataPartitionId) {
PartitionInfoAzure pi = this.partitionService.getPartition(dataPartitionId);
ThrottlingRetryOptions throttlingRetryOptions = cosmosRetryConfiguration.getThrottlingRetryOptions();
CosmosClient cosmosClient = new CosmosClientBuilder()
.endpoint(pi.getCosmosEndpoint())
.key(pi.getCosmosPrimaryKey())
.throttlingRetryOptions(throttlingRetryOptions)
.buildClient();
CoreLoggerFactory.getInstance().getLogger(LOGGER_NAME)
.info("Created CosmosClient for dataPartition {}.", dataPartitionId);
......
......@@ -111,7 +111,7 @@ public class CosmosStore {
CosmosItemRequestOptions options = new CosmosItemRequestOptions();
PartitionKey key = new PartitionKey(partitionKey);
T item = container.readItem(id, key, options, clazz).getItem();
CoreLoggerFactory.getInstance().getLogger(LOGGER_NAME).info(String.format("READ_ITEM with id=%s and partition_key=%s", id, partitionKey));
CoreLoggerFactory.getInstance().getLogger(LOGGER_NAME).debug(String.format("READ_ITEM with id=%s and partition_key=%s", id, partitionKey));
return Optional.ofNullable((T) item);
} catch (NotFoundException e) {
statusCode = HttpStatus.SC_NOT_FOUND;
......@@ -151,7 +151,7 @@ public class CosmosStore {
PartitionKey key = new PartitionKey(partitionKey);
CosmosItemRequestOptions options = new CosmosItemRequestOptions();
container.deleteItem(id, key, options);
CoreLoggerFactory.getInstance().getLogger(LOGGER_NAME).info(String.format("DELETE_ITEM with id=%s and partition_key=%s", id, partitionKey));
CoreLoggerFactory.getInstance().getLogger(LOGGER_NAME).debug(String.format("DELETE_ITEM with id=%s and partition_key=%s", id, partitionKey));
} catch (NotFoundException e) {
statusCode = HttpStatus.SC_NOT_FOUND;
String errorMessage = "Item was unexpectedly not found";
......@@ -191,7 +191,7 @@ public class CosmosStore {
PartitionKey key = new PartitionKey(partitionKey);
CosmosItemRequestOptions options = new CosmosItemRequestOptions();
cosmosContainer.upsertItem(item, key, options);
CoreLoggerFactory.getInstance().getLogger(LOGGER_NAME).info(String.format("UPSERT_ITEM with partition_key=%s", partitionKey));
CoreLoggerFactory.getInstance().getLogger(LOGGER_NAME).debug(String.format("UPSERT_ITEM with partition_key=%s", partitionKey));
} catch (CosmosException e) {
statusCode = e.getStatusCode();
String errorMessage = "Unexpectedly failed to put item into CosmosDB";
......@@ -267,7 +267,7 @@ public class CosmosStore {
PartitionKey key = new PartitionKey(partitionKey);
CosmosItemRequestOptions options = new CosmosItemRequestOptions();
cosmosContainer.createItem(item, key, options);
CoreLoggerFactory.getInstance().getLogger(LOGGER_NAME).info(String.format("CREATE_ITEM with partition_key=%s", partitionKey));
CoreLoggerFactory.getInstance().getLogger(LOGGER_NAME).debug(String.format("CREATE_ITEM with partition_key=%s", partitionKey));
} catch (ConflictException e) {
statusCode = e.getStatusCode();
String errorMessage = "Resource with specified id or name already exists.";
......@@ -328,14 +328,14 @@ public class CosmosStore {
final long start = System.currentTimeMillis();
CosmosPagedIterable<T> paginatedResponse = cosmosContainer.queryItems(query, options, clazz);
paginatedResponse.iterableByPage(PREFERRED_PAGE_SIZE).forEach(cosmosItemPropertiesFeedResponse -> {
CoreLoggerFactory.getInstance().getLogger(LOGGER_NAME).info("Got a page of query result with {} items(s)",
CoreLoggerFactory.getInstance().getLogger(LOGGER_NAME).debug("Got a page of query result with {} items(s)",
cosmosItemPropertiesFeedResponse.getResults().size());
results.addAll(cosmosItemPropertiesFeedResponse.getResults());
});
final long timeTaken = System.currentTimeMillis() - start;
final String dependencyTarget = getDependencyTarget(dataPartitionId, cosmosDBName, collection);
final String dependencyData = String.format("query=%s", query.getQueryText());
CoreLoggerFactory.getInstance().getLogger(LOGGER_NAME).info("Done. Retrieved {} results", results.size());
CoreLoggerFactory.getInstance().getLogger(LOGGER_NAME).debug("Done. Retrieved {} results", results.size());
logDependency("QUERY_ITEMS", dependencyData, dependencyTarget, timeTaken, HttpStatus.SC_OK, true);
return results;
......@@ -389,8 +389,8 @@ public class CosmosStore {
List<T> results = new ArrayList<>();
CosmosContainer container = getCosmosContainer(dataPartitionId, cosmosDBName, collection);
CoreLoggerFactory.getInstance().getLogger(LOGGER_NAME).info("Receiving a set of query response pages.");
CoreLoggerFactory.getInstance().getLogger(LOGGER_NAME).info("Continuation Token: " + internalcontinuationToken + "\n");
CoreLoggerFactory.getInstance().getLogger(LOGGER_NAME).debug("Receiving a set of query response pages.");
CoreLoggerFactory.getInstance().getLogger(LOGGER_NAME).debug("Continuation Token: " + internalcontinuationToken + "\n");
CosmosQueryRequestOptions queryOptions = new CosmosQueryRequestOptions();
......@@ -401,7 +401,7 @@ public class CosmosStore {
Iterator<FeedResponse<T>> iterator = feedResponseIterator.iterator();
if (iterator.hasNext()) {
FeedResponse<T> page = feedResponseIterator.iterator().next();
CoreLoggerFactory.getInstance().getLogger(LOGGER_NAME).info(String.format("Current page number: %d", currentPageNumber));
CoreLoggerFactory.getInstance().getLogger(LOGGER_NAME).debug(String.format("Current page number: %d", currentPageNumber));
// Access all of the documents in this result page
for (T item : page.getResults()) {
documentNumber++;
......@@ -409,7 +409,7 @@ public class CosmosStore {
}
// Page count so far
CoreLoggerFactory.getInstance().getLogger(LOGGER_NAME).info(String.format("Total documents received so far: %d", documentNumber));
CoreLoggerFactory.getInstance().getLogger(LOGGER_NAME).debug(String.format("Total documents received so far: %d", documentNumber));
// Along with page results, get a continuation token
// which enables the client to "pick up where it left off"
......@@ -422,7 +422,7 @@ public class CosmosStore {
final long timeTaken = System.currentTimeMillis() - start;
final String dependencyTarget = getDependencyTarget(dataPartitionId, cosmosDBName, collection);
final String dependencyData = String.format("query=%s", query.getQueryText());
CoreLoggerFactory.getInstance().getLogger(LOGGER_NAME).info("Done. Retrieved {} results", results.size());
CoreLoggerFactory.getInstance().getLogger(LOGGER_NAME).debug("Done. Retrieved {} results", results.size());
logDependency("QUERY_ITEMS_PAGE", dependencyData, dependencyTarget, timeTaken, HttpStatus.SC_OK, true);
CosmosStorePageRequest pageRequest = CosmosStorePageRequest.of(currentPageNumber, pageSize, internalcontinuationToken);
......
// Copyright © Microsoft Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package org.opengroup.osdu.azure.di;
import com.azure.storage.common.policy.RequestRetryOptions;
import com.azure.storage.common.policy.RetryPolicyType;
import lombok.Getter;
import lombok.Setter;
import org.opengroup.osdu.azure.logging.CoreLoggerFactory;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import java.time.Duration;
/**
* Config for BlogStorage Retry.
*/
@Configuration
@ConfigurationProperties("azure.blobstore")
@Getter
@Setter
public class BlobStoreRetryConfiguration {
public static final String LOGGER_NAME = BlobStoreRetryConfiguration.class.getName();
private final RequestRetryOptions defaultRequestRetryOptions = new RequestRetryOptions();
private static final String DEFAULT_STRING_VALUE = "";
private int maxTries = defaultRequestRetryOptions.getMaxTries();
private long tryTimeoutInSeconds = defaultRequestRetryOptions.getTryTimeoutDuration().getSeconds();
private long retryDelayInMs = defaultRequestRetryOptions.getRetryDelay().toMillis();
private long maxRetryDelayInMs = defaultRequestRetryOptions.getMaxRetryDelay().toMillis();
private String retryPolicyTypeValue = DEFAULT_STRING_VALUE;
/**
* Checks whether an string variable value is configured or not.
* @param val string value to be checked
* @return true if value is configured in app.properties
*/
private boolean valueConfigured(final String val) {
if (val == null || val.equals(DEFAULT_STRING_VALUE)) {
return false;
}
return true;
}
/**
* Method to get RequestRetryOptions object based on configuration set in applicaiton.properties.
* @return RequestRetryOption object with appropriate configurations.
*/
public RequestRetryOptions getRequestRetryOptions() {
// Check whether the variables have been set, else keep them as null.
// Value has to be sent as null incase where they are not configured to use the default configurations (As specified in RequestRetryOptions.class)
// https://azure.github.io/azure-storage-java-async/com/microsoft/azure/storage/blob/RequestRetryOptions.html
RetryPolicyType retryPolicyType;
try {
retryPolicyType = valueConfigured(retryPolicyTypeValue) ? RetryPolicyType.valueOf(retryPolicyTypeValue) : RetryPolicyType.EXPONENTIAL;
} catch (Exception ex) { // For wrong values of Retry Policy, it will default to Exponential.
retryPolicyType = RetryPolicyType.EXPONENTIAL;
}
RequestRetryOptions requestRetryOptions = new RequestRetryOptions(retryPolicyType, maxTries, Duration.ofSeconds(tryTimeoutInSeconds), Duration.ofMillis(retryDelayInMs), Duration.ofMillis(maxRetryDelayInMs), null);
CoreLoggerFactory.getInstance().getLogger(LOGGER_NAME).info(String.format("Retry Options on BlobStorage with RetryPolicyType = %s , maxTries = %d , tryTimeout = %d , retryDelay = %d , maxRetryDelay = %d .",
retryPolicyType, requestRetryOptions.getMaxTries(), requestRetryOptions.getTryTimeoutDuration().getSeconds(), requestRetryOptions.getRetryDelay().toMillis(), requestRetryOptions.getMaxRetryDelay().toMillis()));
return requestRetryOptions;
}
}
/** Copyright © Microsoft Corporation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
**/
package org.opengroup.osdu.azure.di;
import com.azure.cosmos.ThrottlingRetryOptions;
import lombok.Getter;
import lombok.Setter;
import org.opengroup.osdu.azure.logging.CoreLoggerFactory;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import java.time.Duration;
/**
* CosmosRetryConfiguration settings.
*/
@Configuration
@ConfigurationProperties("azure.cosmos")
@Getter
@Setter
public class CosmosRetryConfiguration {
public static final String LOGGER_NAME = CosmosRetryConfiguration.class.getName();
private ThrottlingRetryOptions defaultThrottlingRetryOptions = new ThrottlingRetryOptions();
/**
* Value for max Retry Count on Throttled Requests for Cosmos.
*/
private int maxRetryCount = defaultThrottlingRetryOptions.getMaxRetryAttemptsOnThrottledRequests(); // Sets the default value for axRetryAttemptsOnThrottledRequests
/**
* Value for max retry wait time for Cosmos (Value in seconds).
*/
private long retryWaitTimeout = defaultThrottlingRetryOptions.getMaxRetryWaitTime().getSeconds(); // Sets the default value for MaxRetryWaitTime in seconds
/**
* Set's the Throttling retry options based on application.properties configuration.
* @return Throttling retry options
*/
public ThrottlingRetryOptions getThrottlingRetryOptions() {
ThrottlingRetryOptions throttlingRetryOptions = new ThrottlingRetryOptions();
throttlingRetryOptions.setMaxRetryAttemptsOnThrottledRequests(this.getMaxRetryCount());
throttlingRetryOptions.setMaxRetryWaitTime(Duration.ofSeconds(this.getRetryWaitTimeout()));
CoreLoggerFactory.getInstance().getLogger(LOGGER_NAME).info("Retry Options on CosmosClient with maxRetryAttempts = {} , MaxRetryWaitTime = {}.", throttlingRetryOptions.getMaxRetryAttemptsOnThrottledRequests(), throttlingRetryOptions.getMaxRetryWaitTime());
return throttlingRetryOptions;
}
}
// Copyright © Microsoft Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License
package org.opengroup.osdu.azure.di;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
/**
* Configuration bean for setting up retry and timeouts variables.
*/
@Data
@Component
@ConfigurationProperties(prefix = "azure.service.retry.config")
public class RetryAndTimeoutConfiguration {
private int maxRetry = 3;
private int connectTimeout = 60000;
private int requestTimeout = 60000;
private int socketTimeout = 60000;
}
// Copyright © Microsoft Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License
package org.opengroup.osdu.azure.entitlements;
import lombok.Data;
import org.opengroup.osdu.core.common.entitlements.EntitlementsAPIConfig;
import org.springframework.beans.factory.config.AbstractFactoryBean;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
/**
* Creates bean of EntitlementsAPIConfig.
*/
@Data
@Component
@ConfigurationProperties
public class EntilementsAPIConfigBean extends AbstractFactoryBean<EntitlementsAPIConfig> {
private String authorizeAPI;
private String authorizeAPIKey;
/**
* Abstract method of AbstractBeanFactory<T>.
*
* @return class type
*/
@Override
public Class<?> getObjectType() {
return EntitlementsAPIConfig.class;
}
/**
* Abstract method of AbstractBeanFactory<T> type.
*
* @return EntitlementsAPIConfig
* @throws Exception
*/
@Override
protected EntitlementsAPIConfig createInstance() throws Exception {
return EntitlementsAPIConfig
.builder()
.rootUrl(authorizeAPI)
.apiKey(authorizeAPIKey)
.build();
}
}
// Copyright © Microsoft Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License
package org.opengroup.osdu.azure.entitlements;
import org.opengroup.osdu.core.common.entitlements.EntitlementsAPIConfig;
import org.opengroup.osdu.core.common.entitlements.EntitlementsService;
import org.opengroup.osdu.core.common.entitlements.IEntitlementsFactory;
import org.opengroup.osdu.core.common.entitlements.IEntitlementsService;
import org.opengroup.osdu.core.common.http.IHttpClient;
import org.opengroup.osdu.core.common.http.json.HttpResponseBodyMapper;
import org.opengroup.osdu.core.common.model.http.DpsHeaders;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;
import java.util.Objects;
/**
* Implements IEntitlementsFactory.
*/
@Component
@Primary