test_class.declarator: service
test_class.modifier: static
test_class.original_string: static String service;
test_class.type: String
test_class.var_name: service
test_class.declarator: serviceUrl
test_class.modifier: static
test_class.original_string: static URL serviceUrl;
test_class.type: URL
test_class.var_name: serviceUrl
test_class.declarator: registryUrl
test_class.modifier: static
test_class.original_string: static URL registryUrl;
test_class.type: URL
test_class.var_name: registryUrl
test_class.declarator: registry
test_class.original_string: MockRegistry registry;
test_class.type: MockRegistry
test_class.var_name: registry
test_class.declarator: FAILED_PERIOD = 200
test_class.modifier: private
test_class.original_string: private int FAILED_PERIOD = 200;
test_class.type: int
test_class.var_name: FAILED_PERIOD
test_class.declarator: sleeptime = 100
test_class.modifier: private
test_class.original_string: private int sleeptime = 100;
test_class.type: int
test_class.var_name: sleeptime
test_class.declarator: trytimes = 5
test_class.modifier: private
test_class.original_string: private int trytimes = 5;
test_class.type: int
test_class.var_name: trytimes
test_class.file: dubbo-registry/dubbo-registry-api/src/test/java/org/apache/dubbo/registry/support/FailbackRegistryTest.java
test_class.identifier: FailbackRegistryTest
test_case.body: @Test
      public void testDoRetry_register() throws Exception {
  
          final AtomicReference<Boolean> notified = new AtomicReference<Boolean>(false);
          final CountDownLatch latch = new CountDownLatch(1);//All of them are called 4 times. A successful attempt to lose 1. subscribe will not be done
  
          NotifyListener listner = new NotifyListener() {
              @Override
              public void notify(List<URL> urls) {
                  notified.set(Boolean.TRUE);
              }
          };
          registry = new MockRegistry(registryUrl, latch);
          registry.setBad(true);
          registry.subscribe(serviceUrl.setProtocol(CONSUMER_PROTOCOL).addParameters(CollectionUtils.toStringMap("check", "false")), listner);
  
          //Failure can not be called to listener.
          assertEquals(false, notified.get());
          assertEquals(1, latch.getCount());
  
          registry.setBad(false);
  
          for (int i = 0; i < trytimes; i++) {
              System.out.println("failback registry retry ,times:" + i);
              //System.out.println(latch.getCount());
              if (latch.getCount() == 0)
                  break;
              Thread.sleep(sleeptime);
          }
  //        Thread.sleep(100000);
          assertEquals(0, latch.getCount());
          //The failedsubcribe corresponding key will be cleared when unsubscribing
          assertEquals(true, notified.get());
      }
test_case.class_method_signature: FailbackRegistryTest.testDoRetry_register()
test_case.full_signature: @Test public void testDoRetry_register()
test_case.identifier: testDoRetry_register
test_case.invocations: set setBad subscribe addParameters setProtocol toStringMap assertEquals get assertEquals getCount setBad println getCount sleep assertEquals getCount assertEquals get
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testDoRetry_register()
focal_class.declarator: failedRegistered = new ConcurrentHashMap<URL, FailedRegisteredTask>()
focal_class.modifier: private final
focal_class.original_string: private final ConcurrentMap<URL, FailedRegisteredTask> failedRegistered = new ConcurrentHashMap<URL, FailedRegisteredTask>();
focal_class.type: ConcurrentMap<URL, FailedRegisteredTask>
focal_class.var_name: failedRegistered
focal_class.declarator: failedUnregistered = new ConcurrentHashMap<URL, FailedUnregisteredTask>()
focal_class.modifier: private final
focal_class.original_string: private final ConcurrentMap<URL, FailedUnregisteredTask> failedUnregistered = new ConcurrentHashMap<URL, FailedUnregisteredTask>();
focal_class.type: ConcurrentMap<URL, FailedUnregisteredTask>
focal_class.var_name: failedUnregistered
focal_class.declarator: failedSubscribed = new ConcurrentHashMap<Holder, FailedSubscribedTask>()
focal_class.modifier: private final
focal_class.original_string: private final ConcurrentMap<Holder, FailedSubscribedTask> failedSubscribed = new ConcurrentHashMap<Holder, FailedSubscribedTask>();
focal_class.type: ConcurrentMap<Holder, FailedSubscribedTask>
focal_class.var_name: failedSubscribed
focal_class.declarator: failedUnsubscribed = new ConcurrentHashMap<Holder, FailedUnsubscribedTask>()
focal_class.modifier: private final
focal_class.original_string: private final ConcurrentMap<Holder, FailedUnsubscribedTask> failedUnsubscribed = new ConcurrentHashMap<Holder, FailedUnsubscribedTask>();
focal_class.type: ConcurrentMap<Holder, FailedUnsubscribedTask>
focal_class.var_name: failedUnsubscribed
focal_class.declarator: retryPeriod
focal_class.modifier: private final
focal_class.original_string: private final int retryPeriod;
focal_class.type: int
focal_class.var_name: retryPeriod
focal_class.declarator: retryTimer
focal_class.modifier: private final
focal_class.original_string: private final HashedWheelTimer retryTimer;
focal_class.type: HashedWheelTimer
focal_class.var_name: retryTimer
focal_class.file: dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/support/FailbackRegistry.java
focal_class.identifier: FailbackRegistry
focal_class.class_method_signature: FailbackRegistry.FailbackRegistry(URL url)
focal_class.full_signature: public  FailbackRegistry(URL url)
focal_class.identifier: FailbackRegistry
focal_class.modifiers: public
focal_class.parameters: (URL url)
focal_class.signature:  FailbackRegistry(URL url)
focal_class.class_method_signature: FailbackRegistry.removeFailedRegisteredTask(URL url)
focal_class.full_signature: public void removeFailedRegisteredTask(URL url)
focal_class.identifier: removeFailedRegisteredTask
focal_class.modifiers: public
focal_class.parameters: (URL url)
focal_class.return: void
focal_class.signature: void removeFailedRegisteredTask(URL url)
focal_class.class_method_signature: FailbackRegistry.removeFailedUnregisteredTask(URL url)
focal_class.full_signature: public void removeFailedUnregisteredTask(URL url)
focal_class.identifier: removeFailedUnregisteredTask
focal_class.modifiers: public
focal_class.parameters: (URL url)
focal_class.return: void
focal_class.signature: void removeFailedUnregisteredTask(URL url)
focal_class.class_method_signature: FailbackRegistry.removeFailedSubscribedTask(URL url, NotifyListener listener)
focal_class.full_signature: public void removeFailedSubscribedTask(URL url, NotifyListener listener)
focal_class.identifier: removeFailedSubscribedTask
focal_class.modifiers: public
focal_class.parameters: (URL url, NotifyListener listener)
focal_class.return: void
focal_class.signature: void removeFailedSubscribedTask(URL url, NotifyListener listener)
focal_class.class_method_signature: FailbackRegistry.removeFailedUnsubscribedTask(URL url, NotifyListener listener)
focal_class.full_signature: public void removeFailedUnsubscribedTask(URL url, NotifyListener listener)
focal_class.identifier: removeFailedUnsubscribedTask
focal_class.modifiers: public
focal_class.parameters: (URL url, NotifyListener listener)
focal_class.return: void
focal_class.signature: void removeFailedUnsubscribedTask(URL url, NotifyListener listener)
focal_class.class_method_signature: FailbackRegistry.addFailedRegistered(URL url)
focal_class.full_signature: private void addFailedRegistered(URL url)
focal_class.identifier: addFailedRegistered
focal_class.modifiers: private
focal_class.parameters: (URL url)
focal_class.return: void
focal_class.signature: void addFailedRegistered(URL url)
focal_class.class_method_signature: FailbackRegistry.removeFailedRegistered(URL url)
focal_class.full_signature: private void removeFailedRegistered(URL url)
focal_class.identifier: removeFailedRegistered
focal_class.modifiers: private
focal_class.parameters: (URL url)
focal_class.return: void
focal_class.signature: void removeFailedRegistered(URL url)
focal_class.class_method_signature: FailbackRegistry.addFailedUnregistered(URL url)
focal_class.full_signature: private void addFailedUnregistered(URL url)
focal_class.identifier: addFailedUnregistered
focal_class.modifiers: private
focal_class.parameters: (URL url)
focal_class.return: void
focal_class.signature: void addFailedUnregistered(URL url)
focal_class.class_method_signature: FailbackRegistry.removeFailedUnregistered(URL url)
focal_class.full_signature: private void removeFailedUnregistered(URL url)
focal_class.identifier: removeFailedUnregistered
focal_class.modifiers: private
focal_class.parameters: (URL url)
focal_class.return: void
focal_class.signature: void removeFailedUnregistered(URL url)
focal_class.class_method_signature: FailbackRegistry.addFailedSubscribed(URL url, NotifyListener listener)
focal_class.full_signature: protected void addFailedSubscribed(URL url, NotifyListener listener)
focal_class.identifier: addFailedSubscribed
focal_class.modifiers: protected
focal_class.parameters: (URL url, NotifyListener listener)
focal_class.return: void
focal_class.signature: void addFailedSubscribed(URL url, NotifyListener listener)
focal_class.class_method_signature: FailbackRegistry.removeFailedSubscribed(URL url, NotifyListener listener)
focal_class.full_signature: private void removeFailedSubscribed(URL url, NotifyListener listener)
focal_class.identifier: removeFailedSubscribed
focal_class.modifiers: private
focal_class.parameters: (URL url, NotifyListener listener)
focal_class.return: void
focal_class.signature: void removeFailedSubscribed(URL url, NotifyListener listener)
focal_class.class_method_signature: FailbackRegistry.addFailedUnsubscribed(URL url, NotifyListener listener)
focal_class.full_signature: private void addFailedUnsubscribed(URL url, NotifyListener listener)
focal_class.identifier: addFailedUnsubscribed
focal_class.modifiers: private
focal_class.parameters: (URL url, NotifyListener listener)
focal_class.return: void
focal_class.signature: void addFailedUnsubscribed(URL url, NotifyListener listener)
focal_class.class_method_signature: FailbackRegistry.removeFailedUnsubscribed(URL url, NotifyListener listener)
focal_class.full_signature: private void removeFailedUnsubscribed(URL url, NotifyListener listener)
focal_class.identifier: removeFailedUnsubscribed
focal_class.modifiers: private
focal_class.parameters: (URL url, NotifyListener listener)
focal_class.return: void
focal_class.signature: void removeFailedUnsubscribed(URL url, NotifyListener listener)
focal_class.class_method_signature: FailbackRegistry.getFailedRegistered()
focal_class.full_signature:  ConcurrentMap<URL, FailedRegisteredTask> getFailedRegistered()
focal_class.identifier: getFailedRegistered
focal_class.parameters: ()
focal_class.return: ConcurrentMap<URL, FailedRegisteredTask>
focal_class.signature: ConcurrentMap<URL, FailedRegisteredTask> getFailedRegistered()
focal_class.class_method_signature: FailbackRegistry.getFailedUnregistered()
focal_class.full_signature:  ConcurrentMap<URL, FailedUnregisteredTask> getFailedUnregistered()
focal_class.identifier: getFailedUnregistered
focal_class.parameters: ()
focal_class.return: ConcurrentMap<URL, FailedUnregisteredTask>
focal_class.signature: ConcurrentMap<URL, FailedUnregisteredTask> getFailedUnregistered()
focal_class.class_method_signature: FailbackRegistry.getFailedSubscribed()
focal_class.full_signature:  ConcurrentMap<Holder, FailedSubscribedTask> getFailedSubscribed()
focal_class.identifier: getFailedSubscribed
focal_class.parameters: ()
focal_class.return: ConcurrentMap<Holder, FailedSubscribedTask>
focal_class.signature: ConcurrentMap<Holder, FailedSubscribedTask> getFailedSubscribed()
focal_class.class_method_signature: FailbackRegistry.getFailedUnsubscribed()
focal_class.full_signature:  ConcurrentMap<Holder, FailedUnsubscribedTask> getFailedUnsubscribed()
focal_class.identifier: getFailedUnsubscribed
focal_class.parameters: ()
focal_class.return: ConcurrentMap<Holder, FailedUnsubscribedTask>
focal_class.signature: ConcurrentMap<Holder, FailedUnsubscribedTask> getFailedUnsubscribed()
focal_class.class_method_signature: FailbackRegistry.register(URL url)
focal_class.full_signature: @Override public void register(URL url)
focal_class.identifier: register
focal_class.modifiers: @Override public
focal_class.parameters: (URL url)
focal_class.return: void
focal_class.signature: void register(URL url)
focal_class.class_method_signature: FailbackRegistry.reExportRegister(URL url)
focal_class.full_signature: @Override public void reExportRegister(URL url)
focal_class.identifier: reExportRegister
focal_class.modifiers: @Override public
focal_class.parameters: (URL url)
focal_class.return: void
focal_class.signature: void reExportRegister(URL url)
focal_class.class_method_signature: FailbackRegistry.unregister(URL url)
focal_class.full_signature: @Override public void unregister(URL url)
focal_class.identifier: unregister
focal_class.modifiers: @Override public
focal_class.parameters: (URL url)
focal_class.return: void
focal_class.signature: void unregister(URL url)
focal_class.class_method_signature: FailbackRegistry.reExportUnregister(URL url)
focal_class.full_signature: @Override public void reExportUnregister(URL url)
focal_class.identifier: reExportUnregister
focal_class.modifiers: @Override public
focal_class.parameters: (URL url)
focal_class.return: void
focal_class.signature: void reExportUnregister(URL url)
focal_class.class_method_signature: FailbackRegistry.subscribe(URL url, NotifyListener listener)
focal_class.full_signature: @Override public void subscribe(URL url, NotifyListener listener)
focal_class.identifier: subscribe
focal_class.modifiers: @Override public
focal_class.parameters: (URL url, NotifyListener listener)
focal_class.return: void
focal_class.signature: void subscribe(URL url, NotifyListener listener)
focal_class.class_method_signature: FailbackRegistry.unsubscribe(URL url, NotifyListener listener)
focal_class.full_signature: @Override public void unsubscribe(URL url, NotifyListener listener)
focal_class.identifier: unsubscribe
focal_class.modifiers: @Override public
focal_class.parameters: (URL url, NotifyListener listener)
focal_class.return: void
focal_class.signature: void unsubscribe(URL url, NotifyListener listener)
focal_class.class_method_signature: FailbackRegistry.notify(URL url, NotifyListener listener, List<URL> urls)
focal_class.full_signature: @Override protected void notify(URL url, NotifyListener listener, List<URL> urls)
focal_class.identifier: notify
focal_class.modifiers: @Override protected
focal_class.parameters: (URL url, NotifyListener listener, List<URL> urls)
focal_class.return: void
focal_class.signature: void notify(URL url, NotifyListener listener, List<URL> urls)
focal_class.class_method_signature: FailbackRegistry.doNotify(URL url, NotifyListener listener, List<URL> urls)
focal_class.full_signature: protected void doNotify(URL url, NotifyListener listener, List<URL> urls)
focal_class.identifier: doNotify
focal_class.modifiers: protected
focal_class.parameters: (URL url, NotifyListener listener, List<URL> urls)
focal_class.return: void
focal_class.signature: void doNotify(URL url, NotifyListener listener, List<URL> urls)
focal_class.class_method_signature: FailbackRegistry.recover()
focal_class.full_signature: @Override protected void recover()
focal_class.identifier: recover
focal_class.modifiers: @Override protected
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void recover()
focal_class.class_method_signature: FailbackRegistry.destroy()
focal_class.full_signature: @Override public void destroy()
focal_class.identifier: destroy
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void destroy()
focal_class.class_method_signature: FailbackRegistry.doRegister(URL url)
focal_class.full_signature: public abstract void doRegister(URL url)
focal_class.identifier: doRegister
focal_class.modifiers: public abstract
focal_class.parameters: (URL url)
focal_class.return: void
focal_class.signature: void doRegister(URL url)
focal_class.class_method_signature: FailbackRegistry.doUnregister(URL url)
focal_class.full_signature: public abstract void doUnregister(URL url)
focal_class.identifier: doUnregister
focal_class.modifiers: public abstract
focal_class.parameters: (URL url)
focal_class.return: void
focal_class.signature: void doUnregister(URL url)
focal_class.class_method_signature: FailbackRegistry.doSubscribe(URL url, NotifyListener listener)
focal_class.full_signature: public abstract void doSubscribe(URL url, NotifyListener listener)
focal_class.identifier: doSubscribe
focal_class.modifiers: public abstract
focal_class.parameters: (URL url, NotifyListener listener)
focal_class.return: void
focal_class.signature: void doSubscribe(URL url, NotifyListener listener)
focal_class.class_method_signature: FailbackRegistry.doUnsubscribe(URL url, NotifyListener listener)
focal_class.full_signature: public abstract void doUnsubscribe(URL url, NotifyListener listener)
focal_class.identifier: doUnsubscribe
focal_class.modifiers: public abstract
focal_class.parameters: (URL url, NotifyListener listener)
focal_class.return: void
focal_class.signature: void doUnsubscribe(URL url, NotifyListener listener)
focal_class.superclass: extends AbstractRegistry
focal_method.body: @Override
      public void subscribe(URL url, NotifyListener listener) {
          super.subscribe(url, listener);
          removeFailedSubscribed(url, listener);
          try {
              // Sending a subscription request to the server side
              doSubscribe(url, listener);
          } catch (Exception e) {
              Throwable t = e;
  
              List<URL> urls = getCacheUrls(url);
              if (CollectionUtils.isNotEmpty(urls)) {
                  notify(url, listener, urls);
                  logger.error("Failed to subscribe " + url + ", Using cached list: " + urls + " from cache file: " + getUrl().getParameter(FILE_KEY, System.getProperty("user.home") + "/dubbo-registry-" + url.getHost() + ".cache") + ", cause: " + t.getMessage(), t);
              } else {
                  // If the startup detection is opened, the Exception is thrown directly.
                  boolean check = getUrl().getParameter(Constants.CHECK_KEY, true)
                          && url.getParameter(Constants.CHECK_KEY, true);
                  boolean skipFailback = t instanceof SkipFailbackWrapperException;
                  if (check || skipFailback) {
                      if (skipFailback) {
                          t = t.getCause();
                      }
                      throw new IllegalStateException("Failed to subscribe " + url + ", cause: " + t.getMessage(), t);
                  } else {
                      logger.error("Failed to subscribe " + url + ", waiting for retry, cause: " + t.getMessage(), t);
                  }
              }
  
              // Record a failed registration request to a failed list, retry regularly
              addFailedSubscribed(url, listener);
          }
      }
focal_method.class_method_signature: FailbackRegistry.subscribe(URL url, NotifyListener listener)
focal_method.full_signature: @Override public void subscribe(URL url, NotifyListener listener)
focal_method.identifier: subscribe
focal_method.invocations: subscribe removeFailedSubscribed doSubscribe getCacheUrls isNotEmpty notify error getParameter getUrl getProperty getHost getMessage getParameter getUrl getParameter getCause getMessage error getMessage addFailedSubscribed
focal_method.modifiers: @Override public
focal_method.parameters: (URL url, NotifyListener listener)
focal_method.return: void
focal_method.signature: void subscribe(URL url, NotifyListener listener)