Commit 2fe82b29 authored by shenjiaqing's avatar shenjiaqing

提交代码

parent f75177fc
...@@ -38,7 +38,7 @@ allprojects { ...@@ -38,7 +38,7 @@ allprojects {
} }
group = "cn.com.duiba.boot" group = "cn.com.duiba.boot"
version = "0.0.80-sjq-SNAPSHOT" version = "0.0.43"
} }
subprojects { subprojects {
......
...@@ -26,8 +26,7 @@ public class LimitAspect { ...@@ -26,8 +26,7 @@ public class LimitAspect {
private final static Integer REDIS_NODE_NUM = 4; private final static Integer REDIS_NODE_NUM = 4;
static { static {
map.put("rate.limit:com.duiba.tuia.adx.web.service.algo.impl.AdxAlgoServiceImpl-hello-limit", new AtomicLong()); map.put("rate.limit:cn.com.duiba.tuia.algo.engine.adx.service.v4.AdxAlgoService-execute-limit1", new AtomicLong());
redisNodeIndex.put(0L, 14); redisNodeIndex.put(0L, 14);
redisNodeIndex.put(1L, 18); redisNodeIndex.put(1L, 18);
redisNodeIndex.put(2L, 296); redisNodeIndex.put(2L, 296);
...@@ -72,13 +71,10 @@ public class LimitAspect { ...@@ -72,13 +71,10 @@ public class LimitAspect {
return joinPoint.proceed(); return joinPoint.proceed();
} }
StringBuilder stringBuilder = new StringBuilder(); String commonRedisKey = "rate.limit:" +
stringBuilder.append("rate.limit:"). targetClass.getName() + "-" +
append(targetClass.getName()).append("-") method.getName() + "-" +
.append(method.getName()).append("-") rateLimit.key();
.append(rateLimit.key());
String commonRedisKey = stringBuilder.toString();
long index = map.get(commonRedisKey).getAndIncrement() % REDIS_NODE_NUM; long index = map.get(commonRedisKey).getAndIncrement() % REDIS_NODE_NUM;
......
...@@ -2,7 +2,6 @@ package cn.com.duiba.spring.boot.starter.dsp.rateLimiter; ...@@ -2,7 +2,6 @@ package cn.com.duiba.spring.boot.starter.dsp.rateLimiter;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.script.DefaultRedisScript; import org.springframework.data.redis.core.script.DefaultRedisScript;
import javax.annotation.Resource; import javax.annotation.Resource;
...@@ -11,10 +10,10 @@ import java.util.Objects; ...@@ -11,10 +10,10 @@ import java.util.Objects;
@Slf4j @Slf4j
public class TokenBucketLimiter { public class TokenBucketLimiter {
@Resource(name = "redis03StringRedisTemplate") @Resource
private StringRedisTemplate stringRedisTemplate; private StringRedisTemplate stringRedisTemplate;
@Autowired @Resource
private DefaultRedisScript<Long> redisLuaScript; private DefaultRedisScript<Long> redisLuaScript;
boolean acquire(String key, TokenBucketLimiterPolicy policy) { boolean acquire(String key, TokenBucketLimiterPolicy policy) {
......
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