test_class.declarator: balance = new AbstractLoadBalance() {
          @Override
          protected <T> Invoker<T> doSelect(List<Invoker<T>> invokers, URL url, Invocation invocation) {
              return null;
          }
      }
test_class.modifier: private
test_class.original_string: private AbstractLoadBalance balance = new AbstractLoadBalance() {
          @Override
          protected <T> Invoker<T> doSelect(List<Invoker<T>> invokers, URL url, Invocation invocation) {
              return null;
          }
      };
test_class.type: AbstractLoadBalance
test_class.var_name: balance
test_class.file: dubbo-cluster/src/test/java/org/apache/dubbo/rpc/cluster/loadbalance/AbstractLoadBalanceTest.java
test_class.identifier: AbstractLoadBalanceTest
test_case.body: @Test
      public void testGetRegistryWeight() {
          RpcInvocation invocation = new RpcInvocation();
          invocation.setMethodName("say");
  
          Invoker invoker1 = mock(Invoker.class, Mockito.withSettings().stubOnly());
          URL url1 = new URL("", "", 0, "DemoService", new HashMap<>());
          url1 = url1.addParameter(REGISTRY_KEY + "." + WEIGHT_KEY, 10);
          given(invoker1.getUrl()).willReturn(url1);
  
          Invoker invoker2 = mock(Invoker.class, Mockito.withSettings().stubOnly());
          URL url2 = new URL("", "", 0, "org.apache.dubbo.registry.RegistryService", new HashMap<>());
          url2 = url2.addParameter(REGISTRY_KEY + "." + WEIGHT_KEY, 20);
          given(invoker2.getUrl()).willReturn(url2);
  
          Assertions.assertEquals(100, balance.getWeight(invoker1, invocation));
          Assertions.assertEquals(20, balance.getWeight(invoker2, invocation));
      }
test_case.class_method_signature: AbstractLoadBalanceTest.testGetRegistryWeight()
test_case.full_signature: @Test public void testGetRegistryWeight()
test_case.identifier: testGetRegistryWeight
test_case.invocations: setMethodName mock stubOnly withSettings addParameter willReturn given getUrl mock stubOnly withSettings addParameter willReturn given getUrl assertEquals getWeight assertEquals getWeight
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testGetRegistryWeight()
focal_class.file: dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/loadbalance/AbstractLoadBalance.java
focal_class.identifier: AbstractLoadBalance
focal_class.interfaces: implements LoadBalance
focal_class.class_method_signature: AbstractLoadBalance.calculateWarmupWeight(int uptime, int warmup, int weight)
focal_class.full_signature: static int calculateWarmupWeight(int uptime, int warmup, int weight)
focal_class.identifier: calculateWarmupWeight
focal_class.modifiers: static
focal_class.parameters: (int uptime, int warmup, int weight)
focal_class.return: int
focal_class.signature: int calculateWarmupWeight(int uptime, int warmup, int weight)
focal_class.class_method_signature: AbstractLoadBalance.select(List<Invoker<T>> invokers, URL url, Invocation invocation)
focal_class.full_signature: @Override public Invoker<T> select(List<Invoker<T>> invokers, URL url, Invocation invocation)
focal_class.identifier: select
focal_class.modifiers: @Override public
focal_class.parameters: (List<Invoker<T>> invokers, URL url, Invocation invocation)
focal_class.return: Invoker<T>
focal_class.signature: Invoker<T> select(List<Invoker<T>> invokers, URL url, Invocation invocation)
focal_class.class_method_signature: AbstractLoadBalance.doSelect(List<Invoker<T>> invokers, URL url, Invocation invocation)
focal_class.full_signature: protected abstract Invoker<T> doSelect(List<Invoker<T>> invokers, URL url, Invocation invocation)
focal_class.identifier: doSelect
focal_class.modifiers: protected abstract
focal_class.parameters: (List<Invoker<T>> invokers, URL url, Invocation invocation)
focal_class.return: Invoker<T>
focal_class.signature: Invoker<T> doSelect(List<Invoker<T>> invokers, URL url, Invocation invocation)
focal_class.class_method_signature: AbstractLoadBalance.getWeight(Invoker<?> invoker, Invocation invocation)
focal_class.full_signature:  int getWeight(Invoker<?> invoker, Invocation invocation)
focal_class.identifier: getWeight
focal_class.parameters: (Invoker<?> invoker, Invocation invocation)
focal_class.return: int
focal_class.signature: int getWeight(Invoker<?> invoker, Invocation invocation)
focal_method.body: int getWeight(Invoker<?> invoker, Invocation invocation) {
          int weight;
          URL url = invoker.getUrl();
          // Multiple registry scenario, load balance among multiple registries.
          if (REGISTRY_SERVICE_REFERENCE_PATH.equals(url.getServiceInterface())) {
              weight = url.getParameter(REGISTRY_KEY + "." + WEIGHT_KEY, DEFAULT_WEIGHT);
          } else {
              weight = url.getMethodParameter(invocation.getMethodName(), WEIGHT_KEY, DEFAULT_WEIGHT);
              if (weight > 0) {
                  long timestamp = invoker.getUrl().getParameter(TIMESTAMP_KEY, 0L);
                  if (timestamp > 0L) {
                      long uptime = System.currentTimeMillis() - timestamp;
                      if (uptime < 0) {
                          return 1;
                      }
                      int warmup = invoker.getUrl().getParameter(WARMUP_KEY, DEFAULT_WARMUP);
                      if (uptime > 0 && uptime < warmup) {
                          weight = calculateWarmupWeight((int)uptime, warmup, weight);
                      }
                  }
              }
          }
          return Math.max(weight, 0);
      }
focal_method.class_method_signature: AbstractLoadBalance.getWeight(Invoker<?> invoker, Invocation invocation)
focal_method.full_signature:  int getWeight(Invoker<?> invoker, Invocation invocation)
focal_method.identifier: getWeight
focal_method.invocations: getUrl equals getServiceInterface getParameter getMethodParameter getMethodName getParameter getUrl currentTimeMillis getParameter getUrl calculateWarmupWeight max
focal_method.parameters: (Invoker<?> invoker, Invocation invocation)
focal_method.return: int
focal_method.signature: int getWeight(Invoker<?> invoker, Invocation invocation)