test_class.declarator: defaultTPSLimiter = new DefaultTPSLimiter()
test_class.modifier: private
test_class.original_string: private DefaultTPSLimiter defaultTPSLimiter = new DefaultTPSLimiter();
test_class.type: DefaultTPSLimiter
test_class.var_name: defaultTPSLimiter
test_class.file: dubbo-rpc/dubbo-rpc-api/src/test/java/org/apache/dubbo/rpc/filter/tps/DefaultTPSLimiterTest.java
test_class.identifier: DefaultTPSLimiterTest
test_case.body: @Test
      public void testIsNotAllowable() throws Exception {
          Invocation invocation = new MockInvocation();
          URL url = URL.valueOf("test://test");
          url = url.addParameter(INTERFACE_KEY, "org.apache.dubbo.rpc.file.TpsService");
          url = url.addParameter(TPS_LIMIT_RATE_KEY, 2);
          url = url.addParameter(TPS_LIMIT_INTERVAL_KEY, 1000);
          for (int i = 0; i < 4; i++) {
              if (i == 3) {
                  Assertions.assertFalse(defaultTPSLimiter.isAllowable(url, invocation));
              } else {
                  Assertions.assertTrue(defaultTPSLimiter.isAllowable(url, invocation));
              }
          }
      }
test_case.class_method_signature: DefaultTPSLimiterTest.testIsNotAllowable()
test_case.full_signature: @Test public void testIsNotAllowable()
test_case.identifier: testIsNotAllowable
test_case.invocations: valueOf addParameter addParameter addParameter assertFalse isAllowable assertTrue isAllowable
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testIsNotAllowable()
focal_class.declarator: stats = new ConcurrentHashMap<String, StatItem>()
focal_class.modifier: private final
focal_class.original_string: private final ConcurrentMap<String, StatItem> stats = new ConcurrentHashMap<String, StatItem>();
focal_class.type: ConcurrentMap<String, StatItem>
focal_class.var_name: stats
focal_class.file: dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/tps/DefaultTPSLimiter.java
focal_class.identifier: DefaultTPSLimiter
focal_class.interfaces: implements TPSLimiter
focal_class.class_method_signature: DefaultTPSLimiter.isAllowable(URL url, Invocation invocation)
focal_class.full_signature: @Override public boolean isAllowable(URL url, Invocation invocation)
focal_class.identifier: isAllowable
focal_class.modifiers: @Override public
focal_class.parameters: (URL url, Invocation invocation)
focal_class.return: boolean
focal_class.signature: boolean isAllowable(URL url, Invocation invocation)
focal_method.body: @Override
      public boolean isAllowable(URL url, Invocation invocation) {
          int rate = url.getParameter(TPS_LIMIT_RATE_KEY, -1);
          long interval = url.getParameter(TPS_LIMIT_INTERVAL_KEY, DEFAULT_TPS_LIMIT_INTERVAL);
          String serviceKey = url.getServiceKey();
          if (rate > 0) {
              StatItem statItem = stats.get(serviceKey);
              if (statItem == null) {
                  stats.putIfAbsent(serviceKey, new StatItem(serviceKey, rate, interval));
                  statItem = stats.get(serviceKey);
              } else {
                  //rate or interval has changed, rebuild
                  if (statItem.getRate() != rate || statItem.getInterval() != interval) {
                      stats.put(serviceKey, new StatItem(serviceKey, rate, interval));
                      statItem = stats.get(serviceKey);
                  }
              }
              return statItem.isAllowable();
          } else {
              StatItem statItem = stats.get(serviceKey);
              if (statItem != null) {
                  stats.remove(serviceKey);
              }
          }
  
          return true;
      }
focal_method.class_method_signature: DefaultTPSLimiter.isAllowable(URL url, Invocation invocation)
focal_method.full_signature: @Override public boolean isAllowable(URL url, Invocation invocation)
focal_method.identifier: isAllowable
focal_method.invocations: getParameter getParameter getServiceKey get putIfAbsent get getRate getInterval put get isAllowable get remove
focal_method.modifiers: @Override public
focal_method.parameters: (URL url, Invocation invocation)
focal_method.return: boolean
focal_method.signature: boolean isAllowable(URL url, Invocation invocation)