From 7b2b38388360fd691c3fcf307a9696a770be2817 Mon Sep 17 00:00:00 2001 From: hengyunabc Date: Thu, 26 Nov 2020 19:31:00 +0800 Subject: [PATCH] tunnel server embedded redis support settgins. #1592 --- .../server/app/configuration/ArthasProperties.java | 12 ++++++++++++ .../configuration/EmbeddedRedisConfiguration.java | 10 +++++++--- .../src/main/resources/application.properties | 3 ++- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/tunnel-server/src/main/java/com/alibaba/arthas/tunnel/server/app/configuration/ArthasProperties.java b/tunnel-server/src/main/java/com/alibaba/arthas/tunnel/server/app/configuration/ArthasProperties.java index 4b4c41ee79a..927328f33e7 100644 --- a/tunnel-server/src/main/java/com/alibaba/arthas/tunnel/server/app/configuration/ArthasProperties.java +++ b/tunnel-server/src/main/java/com/alibaba/arthas/tunnel/server/app/configuration/ArthasProperties.java @@ -1,5 +1,8 @@ package com.alibaba.arthas.tunnel.server.app.configuration; +import java.util.ArrayList; +import java.util.List; + import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.stereotype.Component; @@ -114,6 +117,7 @@ public static class EmbeddedRedis { private boolean enabled = false; private String host = "127.0.0.1"; private int port = 6379; + private List settings = new ArrayList(); public boolean isEnabled() { return enabled; @@ -138,6 +142,14 @@ public int getPort() { public void setPort(int port) { this.port = port; } + + public List getSettings() { + return settings; + } + + public void setSettings(List settings) { + this.settings = settings; + } } } diff --git a/tunnel-server/src/main/java/com/alibaba/arthas/tunnel/server/app/configuration/EmbeddedRedisConfiguration.java b/tunnel-server/src/main/java/com/alibaba/arthas/tunnel/server/app/configuration/EmbeddedRedisConfiguration.java index 83452acf185..2321e95e5d8 100644 --- a/tunnel-server/src/main/java/com/alibaba/arthas/tunnel/server/app/configuration/EmbeddedRedisConfiguration.java +++ b/tunnel-server/src/main/java/com/alibaba/arthas/tunnel/server/app/configuration/EmbeddedRedisConfiguration.java @@ -9,6 +9,7 @@ import com.alibaba.arthas.tunnel.server.app.configuration.ArthasProperties.EmbeddedRedis; import redis.embedded.RedisServer; +import redis.embedded.RedisServerBuilder; /** * @@ -25,10 +26,13 @@ public class EmbeddedRedisConfiguration { public RedisServer embeddedRedisServer(ArthasProperties arthasProperties) { EmbeddedRedis embeddedRedis = arthasProperties.getEmbeddedRedis(); - RedisServer redisServer = RedisServer.builder().port(embeddedRedis.getPort()).bind(embeddedRedis.getHost()) - .build(); - return redisServer; + RedisServerBuilder builder = RedisServer.builder().port(embeddedRedis.getPort()).bind(embeddedRedis.getHost()); + for (String setting : embeddedRedis.getSettings()) { + builder.setting(setting); + } + RedisServer redisServer = builder.build(); + return redisServer; } public static void main(String[] args) { diff --git a/tunnel-server/src/main/resources/application.properties b/tunnel-server/src/main/resources/application.properties index c56becb64c1..cf5ffd7b34d 100755 --- a/tunnel-server/src/main/resources/application.properties +++ b/tunnel-server/src/main/resources/application.properties @@ -12,4 +12,5 @@ spring.security.user.name=arthas #arthas.enable-detatil-pages=true #arthas.embedded-redis.enabled=true -#spring.redis.host=127.0.0.1 \ No newline at end of file +#arthas.embedded-redis.settings=maxmemory 128M +#spring.redis.host=127.0.0.1