@Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response,
                             Object handler) throws ExecutionException {
        // tenant-level rate limit
        if (trafficConfiguration.isTenantSwitch()) {
            String token = request.getHeader("token");
            if (!StringUtils.isEmpty(token)) {
                RateLimiter tenantRateLimiter = tenantRateLimiterCache.get(token);
                if (!tenantRateLimiter.tryAcquire()) {
                    response.setStatus(HttpStatus.TOO_MANY_REQUESTS.value());
                    log.warn("Too many request, reach tenant rate limit, current tenant:{} qps is {}", token,
                            tenantRateLimiter.getRate());
                    return false;
                }
            }
        }
        // global rate limit
        if (trafficConfiguration.isGlobalSwitch()) {
            if (!globalRateLimiter.tryAcquire()) {
                response.setStatus(HttpStatus.TOO_MANY_REQUESTS.value());
                log.warn("Too many request, reach global rate limit, current qps is {}",
                        globalRateLimiter.getRate());
                return false;
            }
        }
        return true;
    }
@Test
    public void testPreHandleWithoutControl() throws ExecutionException {
        HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
        HttpServletResponse response = Mockito.mock(HttpServletResponse.class);
        RateLimitInterceptor rateLimitInterceptor = new RateLimitInterceptor(new ApiConfig.TrafficConfiguration());
        Assertions.assertTrue(rateLimitInterceptor.preHandle(request, response, null));
        Assertions.assertTrue(rateLimitInterceptor.preHandle(request, response, null));
    }