Commit f9c511a8 by 郑冰晶

1.1.12支持redis集群拓扑刷新

parent 24bf589f
......@@ -5,7 +5,7 @@
<parent>
<artifactId>matrix</artifactId>
<groupId>com.secoo.mall</groupId>
<version>1.1.11.RELEASE</version>
<version>1.1.12.RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>
......
......@@ -5,7 +5,7 @@
<parent>
<artifactId>matrix</artifactId>
<groupId>com.secoo.mall</groupId>
<version>1.1.11.RELEASE</version>
<version>1.1.12.RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>
......
......@@ -5,7 +5,7 @@
<parent>
<artifactId>matrix</artifactId>
<groupId>com.secoo.mall</groupId>
<version>1.1.11.RELEASE</version>
<version>1.1.12.RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>
......
......@@ -5,7 +5,7 @@
<parent>
<artifactId>matrix</artifactId>
<groupId>com.secoo.mall</groupId>
<version>1.1.11.RELEASE</version>
<version>1.1.12.RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>
......
......@@ -5,7 +5,7 @@
<parent>
<artifactId>matrix</artifactId>
<groupId>com.secoo.mall</groupId>
<version>1.1.11.RELEASE</version>
<version>1.1.12.RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>
......
......@@ -5,7 +5,7 @@
<parent>
<artifactId>matrix-datasource</artifactId>
<groupId>com.secoo.mall</groupId>
<version>1.1.11.RELEASE</version>
<version>1.1.12.RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>
......
......@@ -5,7 +5,7 @@
<parent>
<artifactId>matrix-datasource</artifactId>
<groupId>com.secoo.mall</groupId>
<version>1.1.11.RELEASE</version>
<version>1.1.12.RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>
......
......@@ -5,7 +5,7 @@
<parent>
<artifactId>matrix</artifactId>
<groupId>com.secoo.mall</groupId>
<version>1.1.11.RELEASE</version>
<version>1.1.12.RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>
......@@ -21,7 +21,7 @@
<dependency>
<groupId>com.secoo.mall</groupId>
<artifactId>matrix-datasource-core</artifactId>
<version>1.1.11.RELEASE</version>
<version>1.1.12.RELEASE</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
......
......@@ -5,7 +5,7 @@
<parent>
<artifactId>matrix-mybatis</artifactId>
<groupId>com.secoo.mall</groupId>
<version>1.1.11.RELEASE</version>
<version>1.1.12.RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>
......
......@@ -5,7 +5,7 @@
<parent>
<artifactId>matrix-mybatis</artifactId>
<groupId>com.secoo.mall</groupId>
<version>1.1.11.RELEASE</version>
<version>1.1.12.RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>
......
......@@ -5,7 +5,7 @@
<parent>
<artifactId>matrix</artifactId>
<groupId>com.secoo.mall</groupId>
<version>1.1.11.RELEASE</version>
<version>1.1.12.RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>
......@@ -25,12 +25,12 @@
<dependency>
<groupId>com.secoo.mall</groupId>
<artifactId>matrix-mybatis-core</artifactId>
<version>1.1.11.RELEASE</version>
<version>1.1.12.RELEASE</version>
</dependency>
<dependency>
<groupId>com.secoo.mall</groupId>
<artifactId>matrix-mybatis-starter</artifactId>
<version>1.1.11.RELEASE</version>
<version>1.1.12.RELEASE</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
......@@ -46,7 +46,7 @@
<dependency>
<groupId>com.secoo.mall</groupId>
<artifactId>matrix-datasource-druid</artifactId>
<version>1.1.11.RELEASE</version>
<version>1.1.12.RELEASE</version>
</dependency>
</dependencies>
</dependencyManagement>
......
......@@ -5,7 +5,7 @@
<parent>
<artifactId>matrix</artifactId>
<groupId>com.secoo.mall</groupId>
<version>1.1.11.RELEASE</version>
<version>1.1.12.RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>
......
......@@ -5,7 +5,7 @@
<parent>
<artifactId>matrix</artifactId>
<groupId>com.secoo.mall</groupId>
<version>1.1.11.RELEASE</version>
<version>1.1.12.RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>
......
......@@ -5,7 +5,7 @@
<parent>
<artifactId>matrix</artifactId>
<groupId>com.secoo.mall</groupId>
<version>1.1.11.RELEASE</version>
<version>1.1.12.RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>
......
......@@ -6,7 +6,7 @@
<groupId>com.secoo.mall</groupId>
<artifactId>matrix</artifactId>
<version>1.1.11.RELEASE</version>
<version>1.1.12.RELEASE</version>
<packaging>pom</packaging>
......@@ -48,62 +48,62 @@
<dependency>
<groupId>com.secoo.mall</groupId>
<artifactId>logger-starter</artifactId>
<version>1.1.11.RELEASE</version>
<version>1.1.12.RELEASE</version>
</dependency>
<dependency>
<groupId>com.secoo.mall</groupId>
<artifactId>monitor-starter</artifactId>
<version>1.1.11.RELEASE</version>
<version>1.1.12.RELEASE</version>
</dependency>
<dependency>
<groupId>com.secoo.mall</groupId>
<artifactId>common-core</artifactId>
<version>1.1.11.RELEASE</version>
<version>1.1.12.RELEASE</version>
</dependency>
<dependency>
<groupId>com.secoo.mall</groupId>
<artifactId>config-starter</artifactId>
<version>1.1.11.RELEASE</version>
<version>1.1.12.RELEASE</version>
</dependency>
<dependency>
<groupId>com.secoo.mall</groupId>
<artifactId>common-util</artifactId>
<version>1.1.11.RELEASE</version>
<version>1.1.12.RELEASE</version>
</dependency>
<dependency>
<groupId>com.secoo.mall</groupId>
<artifactId>redis-starter</artifactId>
<version>1.1.11.RELEASE</version>
<version>1.1.12.RELEASE</version>
</dependency>
<dependency>
<groupId>com.secoo.mall</groupId>
<artifactId>matrix-mybatis-starter</artifactId>
<version>1.1.11.RELEASE</version>
<version>1.1.12.RELEASE</version>
</dependency>
<dependency>
<groupId>com.secoo.mall</groupId>
<artifactId>mongodb-starter</artifactId>
<version>1.1.11.RELEASE</version>
<version>1.1.12.RELEASE</version>
</dependency>
<dependency>
<groupId>com.secoo.mall</groupId>
<artifactId>elasticsearch-starter</artifactId>
<version>1.1.11.RELEASE</version>
<version>1.1.12.RELEASE</version>
</dependency>
<dependency>
<groupId>com.secoo.mall</groupId>
<artifactId>protocol-starter</artifactId>
<version>1.1.11.RELEASE</version>
<version>1.1.12.RELEASE</version>
</dependency>
<dependency>
<groupId>com.secoo.mall</groupId>
<artifactId>rocketmq-starter</artifactId>
<version>1.1.11.RELEASE</version>
<version>1.1.12.RELEASE</version>
</dependency>
<dependency>
<groupId>com.secoo.mall</groupId>
<artifactId>openfeign-starter</artifactId>
<version>1.1.11.RELEASE</version>
<version>1.1.12.RELEASE</version>
</dependency>
<dependency>
......
......@@ -5,7 +5,7 @@
<parent>
<artifactId>matrix</artifactId>
<groupId>com.secoo.mall</groupId>
<version>1.1.11.RELEASE</version>
<version>1.1.12.RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>
......
......@@ -5,7 +5,7 @@
<parent>
<artifactId>matrix</artifactId>
<groupId>com.secoo.mall</groupId>
<version>1.1.11.RELEASE</version>
<version>1.1.12.RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>
......
package com.secoo.mall.redis.config;
import io.lettuce.core.ClientOptions;
import io.lettuce.core.TimeoutOptions;
import io.lettuce.core.cluster.ClusterClientOptions;
import io.lettuce.core.cluster.ClusterTopologyRefreshOptions;
import org.springframework.boot.autoconfigure.data.redis.LettuceClientConfigurationBuilderCustomizer;
import org.springframework.boot.autoconfigure.data.redis.RedisProperties;
import org.springframework.data.redis.connection.lettuce.LettuceClientConfiguration;
import java.time.Duration;
public class MatrixLettuceClientConfigurationBuilderCustomizer implements LettuceClientConfigurationBuilderCustomizer {
private final RedisProperties properties;
private final Boolean adapt;
private final Duration period;
MatrixLettuceClientConfigurationBuilderCustomizer(RedisProperties properties, Boolean adapt, Duration period) {
this.properties = properties;
this.adapt = adapt;
this.period = period;
}
@Override
public void customize(LettuceClientConfiguration.LettuceClientConfigurationBuilder clientConfigurationBuilder) {
ClientOptions.Builder builder = ClientOptions.builder();
if (this.properties.getCluster() != null) {
ClusterTopologyRefreshOptions.Builder refreshBuilder = ClusterTopologyRefreshOptions.builder();
if (this.period != null) {
refreshBuilder.enablePeriodicRefresh(this.period);
}
if (this.adapt != null && this.adapt) {
refreshBuilder.enableAllAdaptiveRefreshTriggers();
}
builder = ClusterClientOptions.builder().topologyRefreshOptions(refreshBuilder.build());
}
clientConfigurationBuilder.clientOptions(builder.timeoutOptions(TimeoutOptions.enabled()).build());
}
}
......@@ -2,13 +2,18 @@ package com.secoo.mall.redis.config;
import com.secoo.mall.redis.utils.MatrixRedisClusterUtils;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.data.redis.LettuceClientConfigurationBuilderCustomizer;
import org.springframework.boot.autoconfigure.data.redis.RedisProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.RedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;
import java.time.Duration;
/**
* Created by QIANG
......@@ -36,5 +41,10 @@ public class MatrixeRedisAutoConfiguration {
return new MatrixRedisClusterUtils();
}
@Bean
public LettuceClientConfigurationBuilderCustomizer customizer(RedisProperties properties, Environment env) {
Duration period = env.getProperty("spring.redis.lettuce.cluster.refresh.period", Duration.class);
Boolean adapt = env.getProperty("spring.redis.lettuce.cluster.refresh.adaptive", Boolean.class, Boolean.FALSE);
return new MatrixLettuceClientConfigurationBuilderCustomizer(properties, adapt,period);
}
}
......@@ -5,7 +5,7 @@
<parent>
<artifactId>matrix</artifactId>
<groupId>com.secoo.mall</groupId>
<version>1.1.11.RELEASE</version>
<version>1.1.12.RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>
......
Markdown is supported
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