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
Partition
Commits
362c331c
Commit
362c331c
authored
May 10, 2021
by
Mingyang Zhu
Browse files
config connection timeout in the application.properties
parent
5806afc4
Changes
4
Hide whitespace changes
Inline
Side-by-side
provider/partition-azure/src/main/java/org/opengroup/osdu/partition/provider/azure/di/RedisConfig.java
View file @
362c331c
...
@@ -43,10 +43,13 @@ public class RedisConfig {
...
@@ -43,10 +43,13 @@ public class RedisConfig {
@Value
(
"${redis.database}"
)
@Value
(
"${redis.database}"
)
private
int
database
;
private
int
database
;
@Value
(
"${redis.connection.timeout}"
)
private
long
timeout
;
@Bean
@Bean
public
RedisCache
<
String
,
PartitionInfo
>
partitionServiceCache
(
@Named
(
"REDIS_HOST"
)
String
host
,
@Named
(
"REDIS_PASSWORD"
)
String
password
)
{
public
RedisCache
<
String
,
PartitionInfo
>
partitionServiceCache
(
@Named
(
"REDIS_HOST"
)
String
host
,
@Named
(
"REDIS_PASSWORD"
)
String
password
)
{
ClientOptions
clientOptions
=
ClientOptions
.
builder
()
ClientOptions
clientOptions
=
ClientOptions
.
builder
()
.
socketOptions
(
SocketOptions
.
builder
().
connectTimeout
(
15
,
TimeUnit
.
SECONDS
).
build
())
.
socketOptions
(
SocketOptions
.
builder
().
connectTimeout
(
timeout
,
TimeUnit
.
SECONDS
).
build
())
.
build
();
.
build
();
return
new
RedisCache
<>(
host
,
port
,
password
,
expiration
,
database
,
clientOptions
,
String
.
class
,
PartitionInfo
.
class
);
return
new
RedisCache
<>(
host
,
port
,
password
,
expiration
,
database
,
clientOptions
,
String
.
class
,
PartitionInfo
.
class
);
}
}
...
@@ -54,7 +57,7 @@ public class RedisConfig {
...
@@ -54,7 +57,7 @@ public class RedisConfig {
@Bean
@Bean
public
RedisCache
<
String
,
List
<
String
>>
partitionListCache
(
@Named
(
"REDIS_HOST"
)
String
host
,
@Named
(
"REDIS_PASSWORD"
)
String
password
)
{
public
RedisCache
<
String
,
List
<
String
>>
partitionListCache
(
@Named
(
"REDIS_HOST"
)
String
host
,
@Named
(
"REDIS_PASSWORD"
)
String
password
)
{
ClientOptions
clientOptions
=
ClientOptions
.
builder
()
ClientOptions
clientOptions
=
ClientOptions
.
builder
()
.
socketOptions
(
SocketOptions
.
builder
().
connectTimeout
(
15
,
TimeUnit
.
SECONDS
).
build
())
.
socketOptions
(
SocketOptions
.
builder
().
connectTimeout
(
timeout
,
TimeUnit
.
SECONDS
).
build
())
.
build
();
.
build
();
return
new
RedisCache
(
host
,
port
,
password
,
expiration
,
database
,
clientOptions
,
String
.
class
,
List
.
class
);
return
new
RedisCache
(
host
,
port
,
password
,
expiration
,
database
,
clientOptions
,
String
.
class
,
List
.
class
);
}
}
...
@@ -74,10 +77,13 @@ public class RedisConfig {
...
@@ -74,10 +77,13 @@ public class RedisConfig {
@Value
(
"${redis.database}"
)
@Value
(
"${redis.database}"
)
private
int
database
;
private
int
database
;
@Value
(
"${redis.connection.timeout}"
)
private
long
timeout
;
@Bean
@Bean
public
RedisCache
<
String
,
PartitionInfo
>
partitionServiceCache
(
@Named
(
"REDIS_HOST"
)
String
host
)
{
public
RedisCache
<
String
,
PartitionInfo
>
partitionServiceCache
(
@Named
(
"REDIS_HOST"
)
String
host
)
{
ClientOptions
clientOptions
=
ClientOptions
.
builder
()
ClientOptions
clientOptions
=
ClientOptions
.
builder
()
.
socketOptions
(
SocketOptions
.
builder
().
connectTimeout
(
15
,
TimeUnit
.
SECONDS
).
build
())
.
socketOptions
(
SocketOptions
.
builder
().
connectTimeout
(
timeout
,
TimeUnit
.
SECONDS
).
build
())
.
build
();
.
build
();
return
new
RedisCache
<>(
host
,
port
,
expiration
,
database
,
clientOptions
,
String
.
class
,
PartitionInfo
.
class
);
return
new
RedisCache
<>(
host
,
port
,
expiration
,
database
,
clientOptions
,
String
.
class
,
PartitionInfo
.
class
);
}
}
...
@@ -85,7 +91,7 @@ public class RedisConfig {
...
@@ -85,7 +91,7 @@ public class RedisConfig {
@Bean
@Bean
public
RedisCache
<
String
,
List
<
String
>>
partitionListCache
(
@Named
(
"REDIS_HOST"
)
String
host
)
{
public
RedisCache
<
String
,
List
<
String
>>
partitionListCache
(
@Named
(
"REDIS_HOST"
)
String
host
)
{
ClientOptions
clientOptions
=
ClientOptions
.
builder
()
ClientOptions
clientOptions
=
ClientOptions
.
builder
()
.
socketOptions
(
SocketOptions
.
builder
().
connectTimeout
(
15
,
TimeUnit
.
SECONDS
).
build
())
.
socketOptions
(
SocketOptions
.
builder
().
connectTimeout
(
timeout
,
TimeUnit
.
SECONDS
).
build
())
.
build
();
.
build
();
return
new
RedisCache
(
host
,
port
,
expiration
,
database
,
clientOptions
,
String
.
class
,
List
.
class
);
return
new
RedisCache
(
host
,
port
,
expiration
,
database
,
clientOptions
,
String
.
class
,
List
.
class
);
}
}
...
...
provider/partition-azure/src/main/resources/application.properties
View file @
362c331c
...
@@ -34,8 +34,9 @@ cache.maxSize=1000
...
@@ -34,8 +34,9 @@ cache.maxSize=1000
redis.port
=
6380
redis.port
=
6380
redis.expiration
=
3600
redis.expiration
=
3600
redis.ssl.enabled
=
true
redis.ssl.enabled
=
true
redis.connection.timeout
=
15
redis.database
=
${REDIS_DATABASE}
redis.database
=
${REDIS_DATABASE}
servic
e.cryptography.enabled
=
false
azur
e.cryptography.enabled
=
false
servic
e.eventgrid.topic.enabled
=
false
azur
e.eventgrid.topic.enabled
=
false
servic
e.eventgrid.manager.enabled
=
false
azur
e.eventgrid.manager.enabled
=
false
testing/partition-test-core/src/main/java/org/opengroup/osdu/partition/api/UpdatePartitionTest.java
View file @
362c331c
...
@@ -9,7 +9,6 @@ import org.opengroup.osdu.partition.util.BaseTestTemplate;
...
@@ -9,7 +9,6 @@ import org.opengroup.osdu.partition.util.BaseTestTemplate;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.HttpStatus
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
public
abstract
class
UpdatePartitionTest
extends
BaseTestTemplate
{
public
abstract
class
UpdatePartitionTest
extends
BaseTestTemplate
{
...
@@ -71,8 +70,7 @@ public abstract class UpdatePartitionTest extends BaseTestTemplate {
...
@@ -71,8 +70,7 @@ public abstract class UpdatePartitionTest extends BaseTestTemplate {
deleteResource
();
deleteResource
();
assertEquals
(
response
.
getStatus
(),
HttpStatus
.
NO_CONTENT
.
value
());
assertEquals
(
response
.
getStatus
(),
HttpStatus
.
NO_CONTENT
.
value
());
assertEquals
(
"GET, POST, PUT, DELETE, OPTIONS, HEAD, PATCH"
,
response
.
getHeaders
().
getFirst
(
"Access-Control-Allow-Methods"
));
assertEquals
(
"GET, POST, PUT, DELETE, OPTIONS, HEAD, PATCH"
,
response
.
getHeaders
().
getFirst
(
"Access-Control-Allow-Methods"
));
assertTrue
(
"origin, content-type, accept, authorization, data-partition-id, correlation-id, appkey"
.
equals
(
response
.
getHeaders
().
getFirst
(
"Access-Control-Allow-Headers"
))
||
assertEquals
(
"origin, content-type, accept, authorization, data-partition-id, correlation-id, appkey"
,
response
.
getHeaders
().
getFirst
(
"Access-Control-Allow-Headers"
));
"access-control-allow-origin, origin, content-type, accept, authorization, data-partition-id, correlation-id, appkey"
.
equals
(
response
.
getHeaders
().
getFirst
(
"Access-Control-Allow-Headers"
)));
assertEquals
(
"*"
,
response
.
getHeaders
().
getFirst
(
"Access-Control-Allow-Origin"
));
assertEquals
(
"*"
,
response
.
getHeaders
().
getFirst
(
"Access-Control-Allow-Origin"
));
assertEquals
(
"true"
,
response
.
getHeaders
().
getFirst
(
"Access-Control-Allow-Credentials"
));
assertEquals
(
"true"
,
response
.
getHeaders
().
getFirst
(
"Access-Control-Allow-Credentials"
));
assertEquals
(
"default-src 'self'"
,
response
.
getHeaders
().
getFirst
(
"Content-Security-Policy"
));
assertEquals
(
"default-src 'self'"
,
response
.
getHeaders
().
getFirst
(
"Content-Security-Policy"
));
...
...
testing/partition-test-core/src/main/java/org/opengroup/osdu/partition/util/BaseTestTemplate.java
View file @
362c331c
...
@@ -20,7 +20,6 @@ import com.sun.jersey.api.client.ClientResponse;
...
@@ -20,7 +20,6 @@ import com.sun.jersey.api.client.ClientResponse;
import
org.junit.Test
;
import
org.junit.Test
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
public
abstract
class
BaseTestTemplate
extends
TestBase
{
public
abstract
class
BaseTestTemplate
extends
TestBase
{
...
@@ -70,8 +69,7 @@ public abstract class BaseTestTemplate extends TestBase {
...
@@ -70,8 +69,7 @@ public abstract class BaseTestTemplate extends TestBase {
deleteResource
();
deleteResource
();
assertEquals
(
error
(
response
.
getStatus
()
==
204
?
""
:
response
.
getEntity
(
String
.
class
)),
expectedOkResponseCode
(),
response
.
getStatus
());
assertEquals
(
error
(
response
.
getStatus
()
==
204
?
""
:
response
.
getEntity
(
String
.
class
)),
expectedOkResponseCode
(),
response
.
getStatus
());
assertEquals
(
"GET, POST, PUT, DELETE, OPTIONS, HEAD, PATCH"
,
response
.
getHeaders
().
getFirst
(
"Access-Control-Allow-Methods"
));
assertEquals
(
"GET, POST, PUT, DELETE, OPTIONS, HEAD, PATCH"
,
response
.
getHeaders
().
getFirst
(
"Access-Control-Allow-Methods"
));
assertTrue
(
"origin, content-type, accept, authorization, data-partition-id, correlation-id, appkey"
.
equals
(
response
.
getHeaders
().
getFirst
(
"Access-Control-Allow-Headers"
))
||
assertEquals
(
"origin, content-type, accept, authorization, data-partition-id, correlation-id, appkey"
,
response
.
getHeaders
().
getFirst
(
"Access-Control-Allow-Headers"
));
"access-control-allow-origin, origin, content-type, accept, authorization, data-partition-id, correlation-id, appkey"
.
equals
(
response
.
getHeaders
().
getFirst
(
"Access-Control-Allow-Headers"
)));
assertEquals
(
"*"
,
response
.
getHeaders
().
getFirst
(
"Access-Control-Allow-Origin"
));
assertEquals
(
"*"
,
response
.
getHeaders
().
getFirst
(
"Access-Control-Allow-Origin"
));
assertEquals
(
"true"
,
response
.
getHeaders
().
getFirst
(
"Access-Control-Allow-Credentials"
));
assertEquals
(
"true"
,
response
.
getHeaders
().
getFirst
(
"Access-Control-Allow-Credentials"
));
assertEquals
(
"default-src 'self'"
,
response
.
getHeaders
().
getFirst
(
"Content-Security-Policy"
));
assertEquals
(
"default-src 'self'"
,
response
.
getHeaders
().
getFirst
(
"Content-Security-Policy"
));
...
...
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