netease-im / camellia

Camellia provide easy-to-use server toolkits, such as: redis proxy、delay queue、id gen、hot key and more
MIT License
593 stars 137 forks source link

troubleTrickKeys doc fix #316

Open lirulei opened 1 week ago

lirulei commented 1 week ago

Module: [camellia-redis-proxy] Version: [v1.2.29 ] Content: [e.g. doc has a error]

https://github.com/netease-im/camellia/blob/master/docs/camellia-redis-proxy/plugin/trouble-trick-keys.md

the config file application.yml , plugins field has a error,the correct config like this:

server:
  port: 6380
spring:
  application:
    name: camellia-redis-proxy-server

camellia-redis-proxy:
  console-port: 16379 #console端口,默认是16379,如果设置为-16379则会随机一个可用端口,如果设置为0,则不启动console
  password: pass123   #proxy的密码,如果设置了自定义的client-auth-provider-class-name,则密码参数无效
  monitor-enable: true  #是否开启监控
  monitor-interval-seconds: 60 #监控回调的间隔
  plugins: #使用yml配置插件,内置插件可以直接使用别名启用,自定义插件需要配置全类名
    - troubleTrickKeysPlugin  
  transpond:
    type: local #使用本地配置
    local:
      type: simple
      resource: redis://@127.0.0.1:6379 #转发的redis地址

also,the config file camellia-redis-proxy.properties , proxy.plugin.list field has a error,the correct config like this:

proxy.plugin.list=troubleTrickKeysPlugin
caojiajun commented 1 week ago

any error log?

lirulei commented 1 week ago

$ cat application.yml | egrep -v '^#|^$'

server:
  port: 6380
spring:
  application:
    name: camellia-redis-proxy-server
camellia-redis-proxy:
  port: 6380
  application-name: camellia-redis-proxy-server
  console-port: 16379
  password: pass123
  monitor-enable: true
  monitor-interval-seconds: 60
  plugins:
    - monitorPlugin
    - troubleTrickKeys
  transpond:
    type: local
    local:
      type: simple
      resource: redis://@127.0.0.1:6379

$ cat camellia-redis-proxy.properties | egrep -v '^#|^$'

monitor.enable=true
proxy.plugin.list=monitorPlugin,troubleTrickKeys
trouble.trick.keys=ZREVRANGEBYSCORE:["key1","key2"];GET:["key3","key4"]

$ ./start.sh

_________                       .__  .__  .__        
\_   ___ \_____    _____   ____ |  | |  | |__|____   
/    \  \/\__  \  /     \_/ __ \|  | |  | |  \__  \  
\     \____/ __ \|  Y Y  \  ___/|  |_|  |_|  |/ __ \_
 \______  (____  /__|_|  /\___  >____/____/__(____  /
        \/     \/      \/     \/                  \/ 
 :: Camellia-Redis-Proxy-Server ::          (1.2.29)

2024-09-10 16:14:43,315 INFO  main  c.n.n.c.r.p.b.Application:50 - Starting Application on mxtest1004 with PID 61919 (/root/camellia-redis-proxy-1.2.29/BOOT-INF/classes started by root in /root/camellia-redis-proxy-1.2.29)
2024-09-10 16:14:43,319 INFO  main  c.n.n.c.r.p.b.Application:654 - No active profile set, falling back to default profiles: default
2024-09-10 16:14:43,370 INFO  main  o.s.c.a.AnnotationConfigApplicationContext:592 - Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@1761e840: startup date [Tue Sep 10 16:14:43 CST 2024]; root of context hierarchy
2024-09-10 16:14:44,011 INFO  main  c.n.n.c.r.p.n.GlobalRedisProxyEnv:320 - epoll available = true
2024-09-10 16:14:44,023 INFO  main  c.n.n.c.r.p.p.DefaultBeanFactory:41 - try init com.netease.nim.camellia.redis.proxy.command.DefaultQueueFactory
2024-09-10 16:14:44,027 INFO  main  c.n.n.c.r.p.p.DefaultBeanFactory:43 - init com.netease.nim.camellia.redis.proxy.command.DefaultQueueFactory success
2024-09-10 16:14:44,030 INFO  main  c.n.n.c.r.p.p.DefaultBeanFactory:41 - try init com.netease.nim.camellia.redis.proxy.conf.FileBasedProxyDynamicConfLoader
2024-09-10 16:14:44,030 INFO  main  c.n.n.c.r.p.p.DefaultBeanFactory:43 - init com.netease.nim.camellia.redis.proxy.conf.FileBasedProxyDynamicConfLoader success
2024-09-10 16:14:44,037 INFO  main  c.n.n.c.r.p.c.ProxyDynamicConf:90 - ProxyDynamicConf updated, conf.size = 35, conf = {hot.key.cache.key.prefix=["dao_c", "kkk"], hot.key.monitor.enable=true, ip.check.mode=1, hot.key.cache.counter.capacity=100000, big.key.monitor.string.threshold=2097152, big.key.monitor.set.threshold=5000, hot.key.cache.null=true, hot.key.cache.key.checker.className=com.netease.nim.camellia.redis.proxy.plugin.hotkeycache.PrefixMatchHotKeyCacheKeyChecker, command.spend.time.monitor.enable=true, hot.key.cache.expire.millis=10000, big.key.monitor.hash.threshold=5000, hot.key.monitor.cache.max.capacity=100000, disabled.commands=EVAL,KEYS, monitor.enable=true, hot.key.monitor.counter.check.millis=1000, slow.command.monitor.callback.className=com.netease.nim.camellia.redis.proxy.plugin.monitor.DummySlowCommandMonitorCallback, hot.key.monitor.max.hot.key.count=32, hot.key.cache.counter.check.millis=1000, trouble.trick.keys=ZREVRANGEBYSCORE:["key1","key2"];GET:["key3","key4"], hot.key.cache.enable=true, big.key.monitor.enable=true, hot.key.monitor.callback.className=com.netease.nim.camellia.redis.proxy.plugin.hotkey.DummyHotKeyMonitorCallback, ip.black.list=192.168.3.12, hot.key.monitor.counter.check.threshold=1, big.key.monitor.zset.threshold=5000, slow.command.threshold.millis=2000, hot.key.cache.max.capacity=1000, hot.key.cache.stats.callback.interval.seconds=10, command.task.queue.capacity=32768, reader.idle.client.connection.force.close.enable=false, hot.key.cache.check.threshold=100, big.key.monitor.callback.className=com.netease.nim.camellia.redis.proxy.plugin.bigkey.DummyBigKeyMonitorCallback, proxy.plugin.list=monitorPlugin,hotKeyCachePlugin,hotKeyPlugin,bigKeyPlugin,commandDisablePlugin,troubleTrickKeys, big.key.monitor.list.threshold=5000, hot.key.cache.stats.callback.className=com.netease.nim.camellia.redis.proxy.plugin.hotkeycache.DummyHotKeyCacheStatsCallback}
2024-09-10 16:14:44,054 INFO  main  c.n.n.c.r.p.c.ProxyDynamicConf:54 - ProxyDynamicConf init, loader = com.netease.nim.camellia.redis.proxy.conf.FileBasedProxyDynamicConfLoader, reloadIntervalSeconds = 600
2024-09-10 16:14:44,063 INFO  main  c.n.n.c.r.p.u.c.RedisConnectionHub:95 - RedisConnectionHub, connectTimeoutMillis = 1000, heartbeatIntervalSeconds = 60, heartbeatTimeoutMillis = 10000
2024-09-10 16:14:44,065 INFO  main  c.n.n.c.r.p.n.GlobalRedisProxyEnv:320 - epoll available = true
2024-09-10 16:14:44,066 INFO  main  c.n.n.c.r.p.u.c.RedisConnectionHub:119 - RedisConnectionHub, failCountThreshold = 5, failBanMillis = 5000
2024-09-10 16:14:44,066 INFO  main  c.n.n.c.r.p.u.c.RedisConnectionHub:123 - RedisConnectionHub, closeIdleConnection = true, checkIdleConnectionThresholdSeconds = 600, closeIdleConnectionDelaySeconds = 60
2024-09-10 16:14:44,066 INFO  main  c.n.n.c.r.p.u.c.RedisConnectionHub:134 - RedisConnectionHub, so_keepalive = true, tcp_no_delay = true, tcp_quick_ack = false, so_rcvbuf = 6291456, so_sndbuf = 6291456, write_buffer_water_mark_Low = 131072, write_buffer_water_mark_high = 524288
2024-09-10 16:14:44,067 INFO  main  c.n.n.c.r.p.p.DefaultBeanFactory:41 - try init com.netease.nim.camellia.redis.proxy.tls.upstream.DefaultProxyUpstreamTlsProvider
2024-09-10 16:14:44,067 INFO  main  c.n.n.c.r.p.p.DefaultBeanFactory:43 - init com.netease.nim.camellia.redis.proxy.tls.upstream.DefaultProxyUpstreamTlsProvider success
2024-09-10 16:14:44,067 INFO  main  c.n.n.c.r.p.u.c.RedisConnectionHub:141 - RedisConnectionHub, ProxyUpstreamTlsProvider = com.netease.nim.camellia.redis.proxy.tls.upstream.DefaultProxyUpstreamTlsProvider, init = true
2024-09-10 16:14:44,068 INFO  main  c.n.n.c.r.p.p.DefaultBeanFactory:41 - try init com.netease.nim.camellia.redis.proxy.upstream.connection.DefaultUpstreamAddrConverter
2024-09-10 16:14:44,073 INFO  main  c.n.n.c.r.p.p.DefaultBeanFactory:43 - init com.netease.nim.camellia.redis.proxy.upstream.connection.DefaultUpstreamAddrConverter success
2024-09-10 16:14:44,073 INFO  main  c.n.n.c.r.p.u.c.RedisConnectionHub:146 - RedisConnectionHub, UpstreamAddrConverter = com.netease.nim.camellia.redis.proxy.upstream.connection.DefaultUpstreamAddrConverter
2024-09-10 16:14:44,094 INFO  main  c.n.n.c.r.p.u.u.ScheduledResourceChecker:32 - ScheduledResourceChecker start, intervalSeconds = 5
2024-09-10 16:14:44,094 INFO  main  c.n.n.c.r.p.u.UpstreamRedisClientTemplateFactory:307 - CamelliaRedisProxy init, type = LOCAL
2024-09-10 16:14:44,109 INFO  main  c.n.n.c.r.p.u.UpstreamRedisClientTemplate:78 - UpstreamRedisClientTemplate multiWriteMode init, bid = -1, bgroup = local, multiWriteMode = FIRST_RESOURCE_ONLY
2024-09-10 16:14:44,124 INFO  main  c.n.n.c.r.p.u.s.RedisStandaloneClient:36 - RedisStandaloneClient start success, resource = redis://@127.0.0.1:6379
2024-09-10 16:14:44,127 INFO  main  c.n.n.c.r.p.u.UpstreamRedisClientTemplate:757 - multiDBSupport update for route conf update, bid = -1, bgroup = local, multiDBSupport = false->true
2024-09-10 16:14:44,182 INFO  main  c.n.n.c.r.p.u.UpstreamRedisClientTemplate:130 - UpstreamRedisClientTemplate init success, api-version = v1, bid = -1, bgroup = local, md5 = f38edc3efc75484a87013d7bae54d121, resourceTable = redis://@127.0.0.1:6379
2024-09-10 16:14:44,183 INFO  main  c.n.n.c.r.p.u.s.AbstractSimpleRedisClient:61 - try preheat, resource = redis://@127.0.0.1:6379
2024-09-10 16:14:44,184 INFO  main  c.n.n.c.r.p.u.c.RedisConnectionHub:327 - try preheat, addr = @127.0.0.1:6379
2024-09-10 16:14:44,211 INFO  main  c.n.n.c.r.p.u.c.RedisConnection:185 - RedisConnection[@127.0.0.1:6379][id=1] try connect...
2024-09-10 16:14:44,312 INFO  camellia-work-group-3-1  c.n.n.c.r.p.u.c.RedisConnection:206 - RedisConnection[@127.0.0.1:6379][id=1] connect success
2024-09-10 16:14:44,316 INFO  camellia-redis-connection-initialize-12-1  c.n.n.c.r.p.u.c.RedisConnection:484 - RedisConnection[@127.0.0.1:6379][id=1] send `PING` command
2024-09-10 16:14:44,365 INFO  camellia-redis-connection-initialize-12-1  c.n.n.c.r.p.u.c.RedisConnection:493 - RedisConnection[@127.0.0.1:6379][id=1] send `PING` command success, reply = PONG
2024-09-10 16:14:44,373 INFO  camellia-redis-connection-initialize-12-1  c.n.n.c.r.p.u.c.RedisConnection:432 - RedisConnection[@127.0.0.1:6379][id=1] flushCachedCommands, size = 1
2024-09-10 16:14:44,374 INFO  camellia-redis-connection-initialize-12-1  c.n.n.c.r.p.u.c.RedisConnection:438 - RedisConnection[@127.0.0.1:6379][id=1] initialize success
2024-09-10 16:14:44,375 INFO  main  c.n.n.c.r.p.u.c.RedisConnection:185 - RedisConnection[@127.0.0.1:6379][id=2] try connect...
2024-09-10 16:14:44,384 INFO  camellia-work-group-3-2  c.n.n.c.r.p.u.c.RedisConnection:206 - RedisConnection[@127.0.0.1:6379][id=2] connect success
2024-09-10 16:14:44,385 INFO  camellia-redis-connection-initialize-12-2  c.n.n.c.r.p.u.c.RedisConnection:484 - RedisConnection[@127.0.0.1:6379][id=2] send `PING` command
2024-09-10 16:14:44,389 INFO  camellia-redis-connection-initialize-12-2  c.n.n.c.r.p.u.c.RedisConnection:493 - RedisConnection[@127.0.0.1:6379][id=2] send `PING` command success, reply = PONG
2024-09-10 16:14:44,391 INFO  camellia-redis-connection-initialize-12-2  c.n.n.c.r.p.u.c.RedisConnection:432 - RedisConnection[@127.0.0.1:6379][id=2] flushCachedCommands, size = 1
2024-09-10 16:14:44,392 INFO  camellia-redis-connection-initialize-12-2  c.n.n.c.r.p.u.c.RedisConnection:438 - RedisConnection[@127.0.0.1:6379][id=2] initialize success
2024-09-10 16:14:44,392 INFO  main  c.n.n.c.r.p.u.c.RedisConnectionHub:350 - preheat success, addr = @127.0.0.1:6379
2024-09-10 16:14:44,393 INFO  main  c.n.n.c.r.p.u.s.AbstractSimpleRedisClient:66 - preheat result = true, resource = redis://@127.0.0.1:6379
2024-09-10 16:14:44,393 INFO  main  c.n.n.c.r.p.u.UpstreamRedisClientTemplateFactory:64 - UpstreamRedisClientTemplateFactory init success
2024-09-10 16:14:44,394 INFO  main  c.n.n.c.r.p.p.DefaultBeanFactory:41 - try init com.netease.nim.camellia.redis.proxy.monitor.LoggingMonitorCallback
2024-09-10 16:14:44,395 INFO  main  c.n.n.c.r.p.p.DefaultBeanFactory:43 - init com.netease.nim.camellia.redis.proxy.monitor.LoggingMonitorCallback success
2024-09-10 16:14:44,486 INFO  main  c.n.n.c.r.p.m.ProxyMonitorCollector:52 - proxy monitor collector init success, intervalSeconds = 60, monitorEnable = true
2024-09-10 16:14:44,512 WARN  main  o.s.c.a.AnnotationConfigApplicationContext:559 - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'redisProxyBoot' defined in class path resource [com/netease/nim/camellia/redis/proxy/springboot/CamelliaRedisProxyConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.netease.nim.camellia.redis.proxy.springboot.CamelliaRedisProxyBoot]: Factory method 'redisProxyBoot' threw exception; nested exception is java.lang.IllegalArgumentException: init ProxyPlugin[troubleTrickKeys] error
2024-09-10 16:14:44,526 INFO  main  o.s.b.a.l.ConditionEvaluationReportLoggingListener:142 - 

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2024-09-10 16:14:44,539 ERROR main  o.s.b.SpringApplication:837 - Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'redisProxyBoot' defined in class path resource [com/netease/nim/camellia/redis/proxy/springboot/CamelliaRedisProxyConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.netease.nim.camellia.redis.proxy.springboot.CamelliaRedisProxyBoot]: Factory method 'redisProxyBoot' threw exception; nested exception is java.lang.IllegalArgumentException: init ProxyPlugin[troubleTrickKeys] error
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:591)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1246)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1096)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:535)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:495)
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:762)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:881)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:551)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754)
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:386)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:307)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1242)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1230)
    at com.netease.nim.camellia.redis.proxy.bootstrap.Application.main(Application.java:12)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)
    at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
    at org.springframework.boot.loader.Launcher.launch(Launcher.java:50)
    at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.netease.nim.camellia.redis.proxy.springboot.CamelliaRedisProxyBoot]: Factory method 'redisProxyBoot' threw exception; nested exception is java.lang.IllegalArgumentException: init ProxyPlugin[troubleTrickKeys] error
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185)
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:583)
    ... 25 common frames omitted
Caused by: java.lang.IllegalArgumentException: init ProxyPlugin[troubleTrickKeys] error
    at com.netease.nim.camellia.redis.proxy.plugin.DefaultProxyPluginFactory.initProxyPlugin(DefaultProxyPluginFactory.java:146)
    at com.netease.nim.camellia.redis.proxy.plugin.DefaultProxyPluginFactory.getOrInitProxyPlugin(DefaultProxyPluginFactory.java:119)
    at com.netease.nim.camellia.redis.proxy.plugin.DefaultProxyPluginFactory.initPlugins(DefaultProxyPluginFactory.java:80)
    at com.netease.nim.camellia.redis.proxy.command.CommandInvoker.<init>(CommandInvoker.java:73)
    at com.netease.nim.camellia.redis.proxy.springboot.CamelliaRedisProxyConfiguration.redisProxyBoot(CamelliaRedisProxyConfiguration.java:68)
    at com.netease.nim.camellia.redis.proxy.springboot.CamelliaRedisProxyConfiguration$$EnhancerBySpringCGLIB$$67e8fb01.CGLIB$redisProxyBoot$0(<generated>)
    at com.netease.nim.camellia.redis.proxy.springboot.CamelliaRedisProxyConfiguration$$EnhancerBySpringCGLIB$$67e8fb01$$FastClassBySpringCGLIB$$97772cbd.invoke(<generated>)
    at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
    at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:365)
    at com.netease.nim.camellia.redis.proxy.springboot.CamelliaRedisProxyConfiguration$$EnhancerBySpringCGLIB$$67e8fb01.redisProxyBoot(<generated>)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)
    ... 26 common frames omitted
Caused by: java.lang.IllegalArgumentException: java.lang.ClassNotFoundException: troubleTrickKeys
    at com.netease.nim.camellia.redis.proxy.util.BeanInitUtils.parseClass(BeanInitUtils.java:18)
    at com.netease.nim.camellia.redis.proxy.plugin.DefaultProxyPluginFactory.initProxyPlugin(DefaultProxyPluginFactory.java:142)
    ... 40 common frames omitted
Caused by: java.lang.ClassNotFoundException: troubleTrickKeys
    at java.net.URLClassLoader.findClass(URLClassLoader.java:387)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
    at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:93)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
    at com.netease.nim.camellia.redis.proxy.util.BeanInitUtils.parseClass(BeanInitUtils.java:14)
    ... 41 common frames omitted
caojiajun commented 5 days ago

alias should be troubleTrickKeysPlugin

caojiajun commented 5 days ago

you can make a pull-request to fix doc, thank you very much