|
|
@ -8,6 +8,7 @@ import com.google.common.collect.Maps;
|
|
|
|
import com.google.common.util.concurrent.RateLimiter;
|
|
|
|
import com.google.common.util.concurrent.RateLimiter;
|
|
|
|
import lombok.Data;
|
|
|
|
import lombok.Data;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
|
|
import org.opsli.common.thread.refuse.AsyncProcessQueueReFuse;
|
|
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
import java.time.Duration;
|
|
|
|
import java.time.Duration;
|
|
|
@ -161,12 +162,12 @@ public final class RateLimiterUtil {
|
|
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
|
public static void main(String[] args) {
|
|
|
|
RateLimiterUtil.removeIp("127.0.0.1");
|
|
|
|
RateLimiterUtil.removeIp("127.0.0.1");
|
|
|
|
for (int i = 0; i < 1000; i++) {
|
|
|
|
for (int i = 0; i < 500; i++) {
|
|
|
|
int j = i;
|
|
|
|
int j = i;
|
|
|
|
new Thread(()->{
|
|
|
|
AsyncProcessQueueReFuse.execute(()->{
|
|
|
|
boolean enter = RateLimiterUtil.enter("127.0.0.1","/api/v1", RateLimiterUtil.DEFAULT_QPS);
|
|
|
|
boolean enter = RateLimiterUtil.enter("127.0.0.1","/api/v1", 2d);
|
|
|
|
System.out.println(enter);
|
|
|
|
System.out.println(enter);
|
|
|
|
}).start();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|