Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Open Subsurface Data Universe Software
Platform
System
Lib
cloud
azure
OS Core Lib Azure
Commits
b3890735
Commit
b3890735
authored
May 27, 2021
by
Ronak Sakhuja
Browse files
fix comments
parent
0edeebba
Pipeline
#42788
failed with stage
in 10 seconds
Changes
3
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/opengroup/osdu/azure/di/BlobStoreRetryConfiguration.java
View file @
b3890735
...
...
@@ -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
retryPolicyType
Value
=
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
r
pt
=
valueConfigured
(
retryPolicyType
)
?
RetryPolicyType
.
valueOf
(
retryPolicyType
)
:
RetryPolicyType
.
EXPONENTIAL
;
RetryPolicyType
r
etryPolicyType
=
valueConfigured
(
retryPolicyType
Value
)
?
RetryPolicyType
.
valueOf
(
retryPolicyType
Value
)
:
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
(
r
pt
,
maxTriesValue
,
tryTimeout
,
retryDelay
,
maxRetryDelay
,
secondaryHostValue
);
RequestRetryOptions
requestRetryOptions
=
new
RequestRetryOptions
(
r
etryPolicyType
,
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
;
}
...
...
src/test/java/org/opengroup/osdu/azure/blobstorage/BlobContainerClientFactoryImplTest.java
View file @
b3890735
...
...
@@ -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
);
}
...
...
src/test/java/org/opengroup/osdu/azure/di/BlobStoreRetryConfigurationTest.java
View file @
b3890735
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
()));
A
ssert
.
isTrue
(
compareString
s
(
requestRetryOptions
.
getSecondaryHost
(),
defaultRequestRetryOptions
.
getSecondaryHost
())
)
;
a
ssert
Equal
s
(
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
()));
A
ssert
.
isTrue
(
compareString
s
(
requestRetryOptions
.
getSecondaryHost
(),
defaultRequestRetryOptions
.
getSecondaryHost
())
)
;
a
ssert
Equal
s
(
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
()));
A
ssert
.
isTrue
(
compareString
s
(
requestRetryOptions
.
getSecondaryHost
(),
defaultRequestRetryOptions
.
getSecondaryHost
())
)
;
a
ssert
Equal
s
(
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
)));
A
ssert
.
isTrue
(
compareString
s
(
requestRetryOptions
.
getSecondaryHost
(),
defaultRequestRetryOptions
.
getSecondaryHost
())
)
;
a
ssert
Equal
s
(
requestRetryOptions
.
getSecondaryHost
(),
defaultRequestRetryOptions
.
getSecondaryHost
());
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment