Skip to content
GitLab
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
Search
Commits
de45dbf5
Commit
de45dbf5
authored
Aug 23, 2021
by
Bill Wang
Browse files
update
parent
db95783e
Changes
3
Hide whitespace changes
Inline
Side-by-side
provider/search-aws/src/main/java/org/opengroup/osdu/search/provider/aws/cache/CursorCacheImpl.java
View file @
de45dbf5
...
...
@@ -15,7 +15,6 @@
package
org.opengroup.osdu.search.provider.aws.cache
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
org.opengroup.osdu.core.aws.cache.AwsRedisCache
;
import
org.opengroup.osdu.core.aws.cache.DummyCache
;
import
org.opengroup.osdu.core.aws.ssm.K8sLocalParameterProvider
;
import
org.opengroup.osdu.core.aws.ssm.K8sParameterNotFoundException
;
...
...
provider/search-aws/src/main/java/org/opengroup/osdu/search/provider/aws/cache/FieldTypeMappingCacheImpl.java
View file @
de45dbf5
...
...
@@ -15,10 +15,13 @@
package
org.opengroup.osdu.search.provider.aws.cache
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
org.opengroup.osdu.core.aws.cache.AwsRedisCache
;
import
org.opengroup.osdu.core.aws.cache.DummyCache
;
import
org.opengroup.osdu.core.aws.ssm.K8sLocalParameterProvider
;
import
org.opengroup.osdu.core.aws.ssm.K8sParameterNotFoundException
;
import
org.opengroup.osdu.core.common.cache.ICache
;
import
org.opengroup.osdu.core.common.cache.RedisCache
;
import
org.opengroup.osdu.core.common.cache.VmCache
;
import
org.opengroup.osdu.core.common.model.search.CursorSettings
;
import
org.opengroup.osdu.search.cache.IFieldTypeMappingCache
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
...
...
@@ -36,7 +39,20 @@ public class FieldTypeMappingCacheImpl implements IFieldTypeMappingCache {
*
*/
public
FieldTypeMappingCacheImpl
(
@Value
(
"${aws.elasticache.cluster.cursor.expiration}"
)
final
String
INDEX_CACHE_EXPIRATION
)
throws
K8sParameterNotFoundException
,
JsonProcessingException
{
cache
=
AwsRedisCache
.
RedisCache
(
Integer
.
parseInt
(
INDEX_CACHE_EXPIRATION
)
*
60
,
String
.
class
,
Map
.
class
);
int
expTimeSeconds
=
Integer
.
parseInt
(
INDEX_CACHE_EXPIRATION
)
*
60
;
K8sLocalParameterProvider
provider
=
new
K8sLocalParameterProvider
();
if
(
provider
.
getLocalMode
()){
if
(
Boolean
.
parseBoolean
(
System
.
getenv
(
"DISABLE_CACHE"
))){
cache
=
new
DummyCache
();
}
this
.
cache
=
new
VmCache
<>(
expTimeSeconds
,
10
);
}
else
{
String
host
=
provider
.
getParameterAsString
(
"CACHE_CLUSTER_ENDPOINT"
);
int
port
=
Integer
.
parseInt
(
provider
.
getParameterAsString
(
"CACHE_CLUSTER_PORT"
));
String
password
=
provider
.
getCredentialsAsMap
(
"CACHE_CLUSTER_KEY"
).
get
(
"token"
);
cache
=
new
RedisCache
(
host
,
port
,
password
,
expTimeSeconds
,
String
.
class
,
Map
.
class
);
}
local
=
cache
.
getClass
()
!=
RedisCache
.
class
;
}
...
...
provider/search-aws/src/main/java/org/opengroup/osdu/search/provider/aws/cache/IndexCacheImpl.java
View file @
de45dbf5
...
...
@@ -15,10 +15,13 @@
package
org.opengroup.osdu.search.provider.aws.cache
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
org.opengroup.osdu.core.aws.cache.AwsRedisCache
;
import
org.opengroup.osdu.core.aws.cache.DummyCache
;
import
org.opengroup.osdu.core.aws.ssm.K8sLocalParameterProvider
;
import
org.opengroup.osdu.core.aws.ssm.K8sParameterNotFoundException
;
import
org.opengroup.osdu.core.common.cache.ICache
;
import
org.opengroup.osdu.core.common.cache.RedisCache
;
import
org.opengroup.osdu.core.common.cache.VmCache
;
import
org.opengroup.osdu.core.common.model.search.CursorSettings
;
import
org.opengroup.osdu.core.common.provider.interfaces.IIndexCache
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
...
...
@@ -29,7 +32,20 @@ public class IndexCacheImpl implements IIndexCache<String, Boolean>, AutoCloseab
private
ICache
<
String
,
Boolean
>
cache
;
private
Boolean
local
;
public
IndexCacheImpl
(
@Value
(
"${aws.elasticache.cluster.index.expiration}"
)
final
String
INDEX_CACHE_EXPIRATION
)
throws
K8sParameterNotFoundException
,
JsonProcessingException
{
cache
=
cache
=
AwsRedisCache
.
RedisCache
(
Integer
.
parseInt
(
INDEX_CACHE_EXPIRATION
)
*
60
,
String
.
class
,
Boolean
.
class
);
int
expTimeSeconds
=
Integer
.
parseInt
(
INDEX_CACHE_EXPIRATION
)
*
60
;
K8sLocalParameterProvider
provider
=
new
K8sLocalParameterProvider
();
if
(
provider
.
getLocalMode
()){
if
(
Boolean
.
parseBoolean
(
System
.
getenv
(
"DISABLE_CACHE"
))){
cache
=
new
DummyCache
();
}
this
.
cache
=
new
VmCache
<>(
expTimeSeconds
,
10
);
}
else
{
String
host
=
provider
.
getParameterAsString
(
"CACHE_CLUSTER_ENDPOINT"
);
int
port
=
Integer
.
parseInt
(
provider
.
getParameterAsString
(
"CACHE_CLUSTER_PORT"
));
String
password
=
provider
.
getCredentialsAsMap
(
"CACHE_CLUSTER_KEY"
).
get
(
"token"
);
cache
=
new
RedisCache
(
host
,
port
,
password
,
expTimeSeconds
,
String
.
class
,
Boolean
.
class
);
}
local
=
cache
.
getClass
()
!=
RedisCache
.
class
;
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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