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/com/alibaba/dubbo/registry/support/FailbackRegistryTest.java
test_class.identifier: FailbackRegistryTest
test_case.body: @Test
      public void testDoRetry_nofify() throws Exception {
  
          //Initial value 0
          final AtomicInteger count = new AtomicInteger(0);
  
          NotifyListener listner = new NotifyListener() {
              @Override
              public void notify(List<URL> urls) {
                  count.incrementAndGet();
                  //The exception is thrown for the first time to see if the back will be called again to incrementAndGet
                  if (count.get() == 1l) {
                      throw new RuntimeException("test exception please ignore");
                  }
              }
          };
          registry = new MockRegistry(registryUrl, new CountDownLatch(0));
          registry.subscribe(serviceUrl.setProtocol(Constants.CONSUMER_PROTOCOL).addParameters(CollectionUtils.toStringMap("check", "false")), listner);
  
          assertEquals(1, count.get()); //Make sure that the subscribe call has just been called once count.incrementAndGet after the call is completed
          //Wait for the timer.
          for (int i = 0; i < trytimes; i++) {
              System.out.println("failback notify retry ,times:" + i);
              if (count.get() == 2)
                  break;
              Thread.sleep(sleeptime);
          }
          assertEquals(2, count.get());
      }
test_case.class_method_signature: FailbackRegistryTest.testDoRetry_nofify()
test_case.full_signature: @Test public void testDoRetry_nofify()
test_case.identifier: testDoRetry_nofify
test_case.invocations: incrementAndGet get subscribe addParameters setProtocol toStringMap assertEquals get println get sleep assertEquals get
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testDoRetry_nofify()
focal_class.declarator: retryExecutor = Executors.newScheduledThreadPool(1, new NamedThreadFactory("DubboRegistryFailedRetryTimer", true))
focal_class.modifier: private final
focal_class.original_string: private final ScheduledExecutorService retryExecutor = Executors.newScheduledThreadPool(1, new NamedThreadFactory("DubboRegistryFailedRetryTimer", true));
focal_class.type: ScheduledExecutorService
focal_class.var_name: retryExecutor
focal_class.declarator: retryFuture
focal_class.modifier: private final
focal_class.original_string: private final ScheduledFuture<?> retryFuture;
focal_class.type: ScheduledFuture<?>
focal_class.var_name: retryFuture
focal_class.declarator: failedRegistered = new ConcurrentHashSet<URL>()
focal_class.modifier: private final
focal_class.original_string: private final Set<URL> failedRegistered = new ConcurrentHashSet<URL>();
focal_class.type: Set<URL>
focal_class.var_name: failedRegistered
focal_class.declarator: failedUnregistered = new ConcurrentHashSet<URL>()
focal_class.modifier: private final
focal_class.original_string: private final Set<URL> failedUnregistered = new ConcurrentHashSet<URL>();
focal_class.type: Set<URL>
focal_class.var_name: failedUnregistered
focal_class.declarator: failedSubscribed = new ConcurrentHashMap<URL, Set<NotifyListener>>()
focal_class.modifier: private final
focal_class.original_string: private final ConcurrentMap<URL, Set<NotifyListener>> failedSubscribed = new ConcurrentHashMap<URL, Set<NotifyListener>>();
focal_class.type: ConcurrentMap<URL, Set<NotifyListener>>
focal_class.var_name: failedSubscribed
focal_class.declarator: failedUnsubscribed = new ConcurrentHashMap<URL, Set<NotifyListener>>()
focal_class.modifier: private final
focal_class.original_string: private final ConcurrentMap<URL, Set<NotifyListener>> failedUnsubscribed = new ConcurrentHashMap<URL, Set<NotifyListener>>();
focal_class.type: ConcurrentMap<URL, Set<NotifyListener>>
focal_class.var_name: failedUnsubscribed
focal_class.declarator: failedNotified = new ConcurrentHashMap<URL, Map<NotifyListener, List<URL>>>()
focal_class.modifier: private final
focal_class.original_string: private final ConcurrentMap<URL, Map<NotifyListener, List<URL>>> failedNotified = new ConcurrentHashMap<URL, Map<NotifyListener, List<URL>>>();
focal_class.type: ConcurrentMap<URL, Map<NotifyListener, List<URL>>>
focal_class.var_name: failedNotified
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.file: dubbo-registry/dubbo-registry-api/src/main/java/com/alibaba/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.getRetryFuture()
focal_class.full_signature: public Future<?> getRetryFuture()
focal_class.identifier: getRetryFuture
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: Future<?>
focal_class.signature: Future<?> getRetryFuture()
focal_class.class_method_signature: FailbackRegistry.getFailedRegistered()
focal_class.full_signature: public Set<URL> getFailedRegistered()
focal_class.identifier: getFailedRegistered
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: Set<URL>
focal_class.signature: Set<URL> getFailedRegistered()
focal_class.class_method_signature: FailbackRegistry.getFailedUnregistered()
focal_class.full_signature: public Set<URL> getFailedUnregistered()
focal_class.identifier: getFailedUnregistered
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: Set<URL>
focal_class.signature: Set<URL> getFailedUnregistered()
focal_class.class_method_signature: FailbackRegistry.getFailedSubscribed()
focal_class.full_signature: public Map<URL, Set<NotifyListener>> getFailedSubscribed()
focal_class.identifier: getFailedSubscribed
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: Map<URL, Set<NotifyListener>>
focal_class.signature: Map<URL, Set<NotifyListener>> getFailedSubscribed()
focal_class.class_method_signature: FailbackRegistry.getFailedUnsubscribed()
focal_class.full_signature: public Map<URL, Set<NotifyListener>> getFailedUnsubscribed()
focal_class.identifier: getFailedUnsubscribed
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: Map<URL, Set<NotifyListener>>
focal_class.signature: Map<URL, Set<NotifyListener>> getFailedUnsubscribed()
focal_class.class_method_signature: FailbackRegistry.getFailedNotified()
focal_class.full_signature: public Map<URL, Map<NotifyListener, List<URL>>> getFailedNotified()
focal_class.identifier: getFailedNotified
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: Map<URL, Map<NotifyListener, List<URL>>>
focal_class.signature: Map<URL, Map<NotifyListener, List<URL>>> getFailedNotified()
focal_class.class_method_signature: FailbackRegistry.addFailedSubscribed(URL url, NotifyListener listener)
focal_class.full_signature: private void addFailedSubscribed(URL url, NotifyListener listener)
focal_class.identifier: addFailedSubscribed
focal_class.modifiers: private
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.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.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.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.retry()
focal_class.full_signature: protected void retry()
focal_class.identifier: retry
focal_class.modifiers: protected
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void retry()
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: protected abstract void doRegister(URL url)
focal_class.identifier: doRegister
focal_class.modifiers: protected 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: protected abstract void doUnregister(URL url)
focal_class.identifier: doUnregister
focal_class.modifiers: protected 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: protected abstract void doSubscribe(URL url, NotifyListener listener)
focal_class.identifier: doSubscribe
focal_class.modifiers: protected 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: protected abstract void doUnsubscribe(URL url, NotifyListener listener)
focal_class.identifier: doUnsubscribe
focal_class.modifiers: protected 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 {
              // 向服务器端发送订阅请求
              doSubscribe(url, listener);
          } catch (Exception e) {
              Throwable t = e;
  
              List<URL> urls = getCacheUrls(url);
              if (urls != null && !urls.isEmpty()) {
                  notify(url, listener, urls);
                  logger.error("Failed to subscribe " + url + ", Using cached list: " + urls + " from cache file: " + getUrl().getParameter(Constants.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 isEmpty 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)