Commit 2fe82b29 authored by shenjiaqing's avatar shenjiaqing

提交代码

parent f75177fc
......@@ -38,7 +38,7 @@ allprojects {
}
group = "cn.com.duiba.boot"
version = "0.0.80-sjq-SNAPSHOT"
version = "0.0.43"
}
subprojects {
......
......@@ -26,8 +26,7 @@ public class LimitAspect {
private final static Integer REDIS_NODE_NUM = 4;
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(1L, 18);
redisNodeIndex.put(2L, 296);
......@@ -72,13 +71,10 @@ public class LimitAspect {
return joinPoint.proceed();
}
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("rate.limit:").
append(targetClass.getName()).append("-")
.append(method.getName()).append("-")
.append(rateLimit.key());
String commonRedisKey = stringBuilder.toString();
String commonRedisKey = "rate.limit:" +
targetClass.getName() + "-" +
method.getName() + "-" +
rateLimit.key();
long index = map.get(commonRedisKey).getAndIncrement() % REDIS_NODE_NUM;
......
......@@ -2,7 +2,6 @@ package cn.com.duiba.spring.boot.starter.dsp.rateLimiter;
import com.google.common.collect.Lists;
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.script.DefaultRedisScript;
import javax.annotation.Resource;
......@@ -11,10 +10,10 @@ import java.util.Objects;
@Slf4j
public class TokenBucketLimiter {
@Resource(name = "redis03StringRedisTemplate")
@Resource
private StringRedisTemplate stringRedisTemplate;
@Autowired
@Resource
private DefaultRedisScript<Long> redisLuaScript;
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