test_class.declarator: monitorFactory = new AbstractMonitorFactory() {
  
          protected Monitor createMonitor(final URL url) {
              return new Monitor() {
  
                  public URL getUrl() {
                      return url;
                  }
  
                  @Override
                  public boolean isAvailable() {
                      return true;
                  }
  
                  @Override
                  public void destroy() {
                  }
  
                  public void collect(URL statistics) {
                  }
  
                  public List<URL> lookup(URL query) {
                      return null;
                  }
  
              };
          }
      }
test_class.modifier: private
test_class.original_string: private MonitorFactory monitorFactory = new AbstractMonitorFactory() {
  
          protected Monitor createMonitor(final URL url) {
              return new Monitor() {
  
                  public URL getUrl() {
                      return url;
                  }
  
                  @Override
                  public boolean isAvailable() {
                      return true;
                  }
  
                  @Override
                  public void destroy() {
                  }
  
                  public void collect(URL statistics) {
                  }
  
                  public List<URL> lookup(URL query) {
                      return null;
                  }
  
              };
          }
      };
test_class.type: MonitorFactory
test_class.var_name: monitorFactory
test_class.file: dubbo-monitor/dubbo-monitor-api/src/test/java/com/alibaba/dubbo/monitor/support/AbstractMonitorFactoryTest.java
test_class.identifier: AbstractMonitorFactoryTest
test_case.body: @Test
      public void testMonitorFactoryCache() throws Exception {
          URL url = URL.valueOf("dubbo://" + NetUtils.getLocalAddress().getHostAddress() + ":2233");
          Monitor monitor1 = monitorFactory.getMonitor(url);
          Monitor monitor2 = monitorFactory.getMonitor(url);
          if (monitor1 == null || monitor2 == null) {
              Thread.sleep(2000);
              monitor1 = monitorFactory.getMonitor(url);
              monitor2 = monitorFactory.getMonitor(url);
          }
          Assert.assertEquals(monitor1, monitor2);
      }
test_case.class_method_signature: AbstractMonitorFactoryTest.testMonitorFactoryCache()
test_case.full_signature: @Test public void testMonitorFactoryCache()
test_case.identifier: testMonitorFactoryCache
test_case.invocations: valueOf getHostAddress getLocalAddress getMonitor getMonitor sleep getMonitor getMonitor assertEquals
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testMonitorFactoryCache()
focal_class.declarator: logger = LoggerFactory.getLogger(AbstractMonitorFactory.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger logger = LoggerFactory.getLogger(AbstractMonitorFactory.class);
focal_class.type: Logger
focal_class.var_name: logger
focal_class.declarator: LOCK = new ReentrantLock()
focal_class.modifier: private static final
focal_class.original_string: private static final ReentrantLock LOCK = new ReentrantLock();
focal_class.type: ReentrantLock
focal_class.var_name: LOCK
focal_class.declarator: MONITORS = new ConcurrentHashMap<String, Monitor>()
focal_class.modifier: private static final
focal_class.original_string: private static final Map<String, Monitor> MONITORS = new ConcurrentHashMap<String, Monitor>();
focal_class.type: Map<String, Monitor>
focal_class.var_name: MONITORS
focal_class.declarator: FUTURES = new ConcurrentHashMap<String, ListenableFuture<Monitor>>()
focal_class.modifier: private static final
focal_class.original_string: private static final Map<String, ListenableFuture<Monitor>> FUTURES = new ConcurrentHashMap<String, ListenableFuture<Monitor>>();
focal_class.type: Map<String, ListenableFuture<Monitor>>
focal_class.var_name: FUTURES
focal_class.declarator: executor = new ThreadPoolExecutor(0, 10, 60L, TimeUnit.SECONDS, new SynchronousQueue<Runnable>(), new NamedThreadFactory("DubboMonitorCreator", true))
focal_class.modifier: private static final
focal_class.original_string: private static final ExecutorService executor = new ThreadPoolExecutor(0, 10, 60L, TimeUnit.SECONDS, new SynchronousQueue<Runnable>(), new NamedThreadFactory("DubboMonitorCreator", true));
focal_class.type: ExecutorService
focal_class.var_name: executor
focal_class.file: dubbo-monitor/dubbo-monitor-api/src/main/java/com/alibaba/dubbo/monitor/support/AbstractMonitorFactory.java
focal_class.identifier: AbstractMonitorFactory
focal_class.interfaces: implements MonitorFactory
focal_class.class_method_signature: AbstractMonitorFactory.getMonitors()
focal_class.full_signature: public static Collection<Monitor> getMonitors()
focal_class.identifier: getMonitors
focal_class.modifiers: public static
focal_class.parameters: ()
focal_class.return: Collection<Monitor>
focal_class.signature: Collection<Monitor> getMonitors()
focal_class.class_method_signature: AbstractMonitorFactory.getMonitor(URL url)
focal_class.full_signature: @Override public Monitor getMonitor(URL url)
focal_class.identifier: getMonitor
focal_class.modifiers: @Override public
focal_class.parameters: (URL url)
focal_class.return: Monitor
focal_class.signature: Monitor getMonitor(URL url)
focal_class.class_method_signature: AbstractMonitorFactory.createMonitor(URL url)
focal_class.full_signature: protected abstract Monitor createMonitor(URL url)
focal_class.identifier: createMonitor
focal_class.modifiers: protected abstract
focal_class.parameters: (URL url)
focal_class.return: Monitor
focal_class.signature: Monitor createMonitor(URL url)
focal_method.body: @Override
      public Monitor getMonitor(URL url) {
          url = url.setPath(MonitorService.class.getName()).addParameter(Constants.INTERFACE_KEY, MonitorService.class.getName());
          String key = url.toServiceStringWithoutResolving();
          Monitor monitor = MONITORS.get(key);
          Future<Monitor> future = FUTURES.get(key);
          if (monitor != null || future != null) {
              return monitor;
          }
  
          LOCK.lock();
          try {
              monitor = MONITORS.get(key);
              future = FUTURES.get(key);
              if (monitor != null || future != null) {
                  return monitor;
              }
  
              final URL monitorUrl = url;
              final ListenableFutureTask<Monitor> listenableFutureTask = ListenableFutureTask.create(new MonitorCreator(monitorUrl));
              listenableFutureTask.addListener(new MonitorListener(key));
              executor.execute(listenableFutureTask);
              FUTURES.put(key, listenableFutureTask);
  
              return null;
          } finally {
              // unlock
              LOCK.unlock();
          }
      }
focal_method.class_method_signature: AbstractMonitorFactory.getMonitor(URL url)
focal_method.full_signature: @Override public Monitor getMonitor(URL url)
focal_method.identifier: getMonitor
focal_method.invocations: addParameter setPath getName getName toServiceStringWithoutResolving get get lock get get create addListener execute put unlock
focal_method.modifiers: @Override public
focal_method.parameters: (URL url)
focal_method.return: Monitor
focal_method.signature: Monitor getMonitor(URL url)