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

fix comments

parent 0edeebba
Pipeline #42788 failed with stage
in 10 seconds
......@@ -36,16 +36,17 @@ import java.util.Collections;
@Setter
public class BlobStoreRetryConfiguration {
private static final Logger LOGGER = LoggerFactory.getLogger(BlobStoreRetryConfiguration.class.getName());
@Autowired
private ILogger logger;
private static final int DEFAULT_INT_VALUE = -1;
private static final String DEFAULT_STRING_VALUE = "";
private int maxTries = -1;
private int tryTimeoutInSeconds = -1;
private int retryDelayInMs = -1;
private int maxRetryDelayInMs = -1;
private String retryPolicyType = "";
private String secondaryHost = "";
private int maxTries = DEFAULT_INT_VALUE;
private int tryTimeoutInSeconds = DEFAULT_INT_VALUE;
private int retryDelayInMs = DEFAULT_INT_VALUE;
private int maxRetryDelayInMs = DEFAULT_INT_VALUE;
private String retryPolicyTypeValue = DEFAULT_STRING_VALUE;
private String secondaryHost = DEFAULT_STRING_VALUE;
/**
* Checks whether an int variable value is configured or not.
......@@ -81,18 +82,18 @@ public class BlobStoreRetryConfiguration {
// 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 rpt = valueConfigured(retryPolicyType) ? RetryPolicyType.valueOf(retryPolicyType) : RetryPolicyType.EXPONENTIAL;
RetryPolicyType retryPolicyType = valueConfigured(retryPolicyTypeValue) ? RetryPolicyType.valueOf(retryPolicyTypeValue) : RetryPolicyType.EXPONENTIAL;
Integer maxTriesValue = valueConfigured(this.maxTries) ? this.maxTries : null;
Duration tryTimeout = valueConfigured(tryTimeoutInSeconds) ? Duration.ofSeconds((long) tryTimeoutInSeconds) : null;
Duration retryDelay = valueConfigured(retryDelayInMs) ? Duration.ofMillis(retryDelayInMs) : null;
Duration maxRetryDelay = valueConfigured(maxRetryDelayInMs) ? Duration.ofMillis(maxRetryDelayInMs) : null;
String secondaryHostValue = valueConfigured(this.secondaryHost) ? this.secondaryHost : null;
RequestRetryOptions requestRetryOptions = new RequestRetryOptions(rpt, maxTriesValue, tryTimeout, retryDelay, maxRetryDelay, secondaryHostValue);
RequestRetryOptions requestRetryOptions = new RequestRetryOptions(retryPolicyType, maxTriesValue, tryTimeout, retryDelay, maxRetryDelay, secondaryHostValue);
this.logger.info("BlobStoreRetryConfiguration", String.format("Retry Options on BlobStorage with RetryPolicyType = %s , maxTries = %d , tryTimeout = %d , retryDelay = %d , maxRetryDelay = %d , secondaryHost = %s.",
rpt.toString(), requestRetryOptions.getMaxTries(), requestRetryOptions.getTryTimeoutDuration().getSeconds(), requestRetryOptions.getRetryDelay().toMillis(), requestRetryOptions.getMaxRetryDelay().toMillis(), requestRetryOptions.getSecondaryHost()), Collections.emptyMap());
retryPolicyType.toString(), requestRetryOptions.getMaxTries(), requestRetryOptions.getTryTimeoutDuration().getSeconds(), requestRetryOptions.getRetryDelay().toMillis(), requestRetryOptions.getMaxRetryDelay().toMillis(), requestRetryOptions.getSecondaryHost()), Collections.emptyMap());
return requestRetryOptions;
}
......
......@@ -2,7 +2,6 @@ package org.opengroup.osdu.azure.blobstorage;
import com.azure.identity.DefaultAzureCredential;
import com.azure.storage.blob.BlobContainerClient;
import com.azure.storage.common.policy.RequestRetryOptions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
......@@ -10,11 +9,9 @@ import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import org.opengroup.osdu.azure.cache.BlobContainerClientCache;
import org.opengroup.osdu.azure.di.BlobStoreRetryConfiguration;
import org.opengroup.osdu.azure.di.BlobStoreConfiguration;
import org.opengroup.osdu.azure.partition.PartitionInfoAzure;
import org.opengroup.osdu.azure.partition.PartitionServiceClient;
import org.opengroup.osdu.core.common.logging.ILogger;
import org.opengroup.osdu.core.common.partition.Property;
import static org.junit.jupiter.api.Assertions.*;
......@@ -35,7 +32,6 @@ public class BlobContainerClientFactoryImplTest {
@InjectMocks
private BlobContainerClientFactoryImpl sut;
private static final String ACCOUNT_NAME = "testAccount";
private static final String PARTITION_ID = "dataPartitionId";
private static final String STORAGE_CONTAINER_NAME = "containerName";
......@@ -74,6 +70,7 @@ public class BlobContainerClientFactoryImplTest {
PartitionInfoAzure.builder()
.idConfig(Property.builder().value(PARTITION_ID).build())
.storageAccountNameConfig(Property.builder().value(ACCOUNT_NAME).build()).build());
BlobContainerClient containerClient = this.sut.getClient(PARTITION_ID, STORAGE_CONTAINER_NAME);
assertNotNull(containerClient);
}
......
package org.opengroup.osdu.azure.di;
import com.azure.cosmos.ThrottlingRetryOptions;
import com.azure.storage.common.policy.RequestRetryOptions;
import io.jsonwebtoken.lang.Assert;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.platform.commons.util.StringUtils;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import org.opengroup.osdu.core.common.logging.ILogger;
import org.springframework.beans.factory.annotation.Autowired;
import java.time.Duration;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.MockitoAnnotations.openMocks;
@ExtendWith(MockitoExtension.class)
......@@ -28,13 +26,6 @@ public class BlobStoreRetryConfigurationTest {
openMocks(this);
}
boolean compareStrings(String str1, String str2) {
if (str1 == null || str2 == null)
return str1 == str2;
return str1.equals(str2);
}
@Test
public void should_set_default_values() {
RequestRetryOptions requestRetryOptions = blobStoreRetryConfiguration.getRequestRetryOptions();
......@@ -43,7 +34,7 @@ public class BlobStoreRetryConfigurationTest {
Assert.isTrue(requestRetryOptions.getTryTimeoutDuration().equals(defaultRequestRetryOptions.getTryTimeoutDuration()));
Assert.isTrue(requestRetryOptions.getRetryDelay().equals(defaultRequestRetryOptions.getRetryDelay()));
Assert.isTrue(requestRetryOptions.getMaxRetryDelay().equals(defaultRequestRetryOptions.getMaxRetryDelay()));
Assert.isTrue(compareStrings(requestRetryOptions.getSecondaryHost(),defaultRequestRetryOptions.getSecondaryHost()));
assertEquals(requestRetryOptions.getSecondaryHost(),defaultRequestRetryOptions.getSecondaryHost());
}
@Test
......@@ -56,7 +47,7 @@ public class BlobStoreRetryConfigurationTest {
Assert.isTrue(requestRetryOptions.getTryTimeoutDuration().equals(defaultRequestRetryOptions.getTryTimeoutDuration()));
Assert.isTrue(requestRetryOptions.getRetryDelay().equals(defaultRequestRetryOptions.getRetryDelay()));
Assert.isTrue(requestRetryOptions.getMaxRetryDelay().equals(defaultRequestRetryOptions.getMaxRetryDelay()));
Assert.isTrue(compareStrings(requestRetryOptions.getSecondaryHost(),defaultRequestRetryOptions.getSecondaryHost()));
assertEquals(requestRetryOptions.getSecondaryHost(),defaultRequestRetryOptions.getSecondaryHost());
}
@Test
......@@ -69,7 +60,7 @@ public class BlobStoreRetryConfigurationTest {
Assert.isTrue(requestRetryOptions.getTryTimeoutDuration().equals(Duration.ofSeconds(tryTimeoutValue)));
Assert.isTrue(requestRetryOptions.getRetryDelay().equals(defaultRequestRetryOptions.getRetryDelay()));
Assert.isTrue(requestRetryOptions.getMaxRetryDelay().equals(defaultRequestRetryOptions.getMaxRetryDelay()));
Assert.isTrue(compareStrings(requestRetryOptions.getSecondaryHost(),defaultRequestRetryOptions.getSecondaryHost()));
assertEquals(requestRetryOptions.getSecondaryHost(),defaultRequestRetryOptions.getSecondaryHost());
}
@Test
......@@ -84,7 +75,7 @@ public class BlobStoreRetryConfigurationTest {
Assert.isTrue(requestRetryOptions.getTryTimeoutDuration().equals(defaultRequestRetryOptions.getTryTimeoutDuration()));
Assert.isTrue(requestRetryOptions.getRetryDelay().equals(Duration.ofMillis(retryDelayValue)));
Assert.isTrue(requestRetryOptions.getMaxRetryDelay().equals(Duration.ofMillis(maxRetryDelayValue)));
Assert.isTrue(compareStrings(requestRetryOptions.getSecondaryHost(),defaultRequestRetryOptions.getSecondaryHost()));
assertEquals(requestRetryOptions.getSecondaryHost(),defaultRequestRetryOptions.getSecondaryHost());
}
}
Supports Markdown
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