Commit 52ccca36 authored by Mingyang Zhu's avatar Mingyang Zhu
Browse files

Merge branch 'redis-connection-keep-alive' into 'master'

set redisson keep alive as true and fix the unit tests await bug

See merge request !67
parents d1fbe352 84386e97
Pipeline #36681 passed with stages
in 15 minutes and 17 seconds
......@@ -92,6 +92,8 @@ The following software have components provided under the terms of this license:
- J2ObjC Annotations (from https://github.com/google/j2objc/)
- JBoss Logging 3 (from http://www.jboss.org)
- JBoss Marshalling API (from )
- JBoss Marshalling API (from )
- JBoss Marshalling River (from )
- JBoss Marshalling River (from )
- JBoss Threads (from )
- JCIP Annotations under Apache License (from http://stephenc.github.com/jcip-annotations)
......@@ -125,7 +127,6 @@ The following software have components provided under the terms of this license:
- Java UUID Generator (from http://wiki.fasterxml.com/JugHome)
- JavaPoet (from http://github.com/square/javapoet/)
- Javassist (from http://www.javassist.org/)
- Javassist (from http://www.javassist.org/)
- Joda-Time (from http://www.joda.org/joda-time/)
- Json Path (from https://github.com/jayway/JsonPath)
- KeePassJava2 :: All (from https://repo1.maven.org/maven2/org/linguafranca/pwdb/KeePassJava2)
......@@ -198,6 +199,7 @@ The following software have components provided under the terms of this license:
- Redisson (from http://redisson.org)
- Redisson (from http://redisson.org)
- Retrofit (from )
- RxJava (from https://github.com/ReactiveX/RxJava)
- SnakeYAML (from http://www.snakeyaml.org)
- SnakeYAML (from http://www.snakeyaml.org)
- Spring AOP (from https://github.com/spring-projects/spring-framework)
......@@ -254,7 +256,6 @@ The following software have components provided under the terms of this license:
- error-prone annotations (from )
- error-prone annotations (from )
- exp4j (from http://www.objecthunter.net/exp4j)
- fst (from http://ruedigermoeller.github.io/fast-serialization/)
- io.grpc:grpc-alts (from https://github.com/grpc/grpc-java)
- io.grpc:grpc-api (from https://github.com/grpc/grpc-java)
- io.grpc:grpc-auth (from https://github.com/grpc/grpc-java)
......@@ -340,6 +341,8 @@ The following software have components provided under the terms of this license:
- Hamcrest library (from )
- JLine (from )
- Jodd BeanUtil (from http://jodd.org)
- Jodd BeanUtil (from http://jodd.org)
- Jodd Core (from http://jodd.org)
- Jodd Core (from http://jodd.org)
- Lucene Common Analyzers (from )
- Lucene Core (from )
......@@ -369,6 +372,8 @@ The following software have components provided under the terms of this license:
- JLine (from )
- JavaBeans Activation Framework API jar (from )
- Jodd BeanUtil (from http://jodd.org)
- Jodd BeanUtil (from http://jodd.org)
- Jodd Core (from http://jodd.org)
- Jodd Core (from http://jodd.org)
- Lucene Common Analyzers (from )
- Lucene Core (from )
......@@ -559,14 +564,12 @@ The following software have components provided under the terms of this license:
- Java Native Access (from https://github.com/java-native-access/jna)
- Java Native Access Platform (from https://github.com/java-native-access/jna)
- Javassist (from http://www.javassist.org/)
- Javassist (from http://www.javassist.org/)
- Logback Classic Module (from )
- Logback Core Module (from )
- Microsoft Application Insights Java SDK Core (from https://github.com/Microsoft/ApplicationInsights-Java)
- Microsoft Application Insights Java SDK Spring Boot starter (from https://github.com/Microsoft/ApplicationInsights-Java)
- Microsoft Application Insights Java SDK Web Module (from https://github.com/Microsoft/ApplicationInsights-Java)
- Microsoft Application Insights Log4j 2 Appender (from https://github.com/Microsoft/ApplicationInsights-Java)
- fst (from http://ruedigermoeller.github.io/fast-serialization/)
========================================================================
LGPL-2.1-or-later
......@@ -650,7 +653,6 @@ MPL-1.1
========================================================================
The following software have components provided under the terms of this license:
- Javassist (from http://www.javassist.org/)
- Javassist (from http://www.javassist.org/)
========================================================================
......@@ -658,7 +660,6 @@ MPL-2.0
========================================================================
The following software have components provided under the terms of this license:
- Javassist (from http://www.javassist.org/)
- Javassist (from http://www.javassist.org/)
- OkHttp (from )
......@@ -728,6 +729,8 @@ The following software have components provided under the terms of this license:
- JUnit (from http://junit.org)
- JUnit Jupiter (Aggregator) (from https://junit.org/junit5/)
- JavaBeans Activation Framework API jar (from )
- Jodd BeanUtil (from http://jodd.org)
- Jodd Core (from http://jodd.org)
- Spongy Castle (from http://rtyley.github.io/spongycastle/)
- jakarta.xml.bind-api (from )
- org.junit.jupiter:junit-jupiter-api (from http://junit.org/junit5/)
......
......@@ -18,7 +18,7 @@
<reactor.core.version>3.3.0.RELEASE</reactor.core.version>
<springfox-version>3.0.0</springfox-version>
<gremlin.version>3.4.10</gremlin.version>
<redisson.version>3.11.6</redisson.version>
<redisson.version>3.15.3</redisson.version>
<resilience4j.version>1.7.0</resilience4j.version>
<embedded-resdis.version>0.7.1</embedded-resdis.version>
<awaitility.version>3.0.0</awaitility.version>
......
......@@ -27,9 +27,6 @@ public class CacheConfig {
@Value("${app.redis.ttl.seconds}")
private int redisTtlSeconds;
@Value("${redisson.connection.timeout}")
private int redissonConnectionTimeout;
@Value("${spring.application.name}")
private String applicationName;
......@@ -45,7 +42,7 @@ public class CacheConfig {
config.useSingleServer().setAddress(String.format("rediss://%s:%d",getRedisHostname(), redisPort))
.setPassword(getRedisPassword())
.setDatabase(redisDatabase)
.setTimeout(redissonConnectionTimeout)
.setKeepAlive(true)
.setClientName(applicationName);
return Redisson.create(config);
}
......
......@@ -37,11 +37,12 @@ public class GroupCacheServiceAzure implements GroupCacheService {
@Override
public Set<ParentReference> getFromPartitionCache(String requesterId, String partitionId) {
String key = String.format("%s-%s", requesterId, partitionId);
ParentReferences parentReferences = redisGroupCache.get(key);
String cacheKey = String.format("%s-%s", requesterId, partitionId);
ParentReferences parentReferences = redisGroupCache.get(cacheKey);
if (parentReferences == null) {
RLock cacheEntryLock = redissonClient.getLock(key);
return lockCacheEntryAndRebuild(cacheEntryLock, key, requesterId, partitionId);
String lockKey = String.format("lock-%s", cacheKey);
RLock cacheEntryLock = redissonClient.getLock(lockKey);
return lockCacheEntryAndRebuild(cacheEntryLock, cacheKey, requesterId, partitionId);
} else {
metricService.sendHitsMetric();
return parentReferences.getParentReferencesOfUser();
......
......@@ -50,7 +50,6 @@ app.redis.ttl.seconds=${redis_ttl_seconds}
# Cache
redis.port=6380
redis.database=8
redisson.connection.timeout=100000
redisson.lock.acquisition.timeout=10
redisson.lock.expiration=5000
cache.retry.max=15
......
......@@ -68,7 +68,7 @@ public class GroupCacheServiceAzureTest {
config.useSingleServer().setAddress(String.format("redis://%s:%d", "localhost", 7000))
.setPassword("pass")
.setDatabase(0)
.setTimeout(100000)
.setKeepAlive(true)
.setClientName("test");
return Redisson.create(config);
}
......@@ -165,7 +165,7 @@ public class GroupCacheServiceAzureTest {
cacheValues.add(this.parentReferences);
when(this.redisGroupCache.get("requesterId-dp")).thenAnswer(AdditionalAnswers.returnsElementsOf(cacheValues));
when(this.retrieveGroupRepo.loadAllParents(this.requester)).thenAnswer((Answer<ParentTreeDto>) invocationOnMock -> {
await().atLeast(Duration.FIVE_SECONDS);
await().pollDelay(Duration.FIVE_SECONDS).until(() -> true);
return parentTreeDto;
});
when(this.parentTreeDto.getParentReferences()).thenReturn(this.parents);
......@@ -193,10 +193,10 @@ public class GroupCacheServiceAzureTest {
}
@Test
public void shouldReturnEmptyIfTimeout() throws InterruptedException {
public void shouldThrowExceptionIfTimeout() throws InterruptedException {
when(this.redisGroupCache.get("requesterId-dp")).thenReturn(null);
when(this.retrieveGroupRepo.loadAllParents(this.requester)).thenAnswer((Answer<ParentTreeDto>) invocationOnMock -> {
await().atLeast(Duration.FIVE_SECONDS);
await().pollDelay(Duration.FIVE_SECONDS).until(() -> true);
return parentTreeDto;
});
when(this.parentTreeDto.getParentReferences()).thenReturn(this.parents);
......
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