DefaultProxyMonitorCollectorManager extends AbstractStartStoppable implements ProxyMonitorCollectorManager { @Override public ProxyMonitorCollector getOrCreate(ProxyModel proxyModel) { return MapUtils.getOrCreate(proxySamples, proxyModel, new ObjectFactory<ProxyMonitorCollector>() { @Override public ProxyMonitorCollector create() { logger.info("[create proxy monitor collector] {}", proxyModel); ProxyMonitorCollector result = new DefaultProxyMonitorCollector( scheduled, keyedObjectPool, proxyModel, ()->consoleConfig.getProxyInfoCollectInterval() ); result.addListener(proxyInfoRecorder); try { result.start(); } catch (Exception e) { logger.error("[getOrCreate]", e); } return result; } }); }  @Override ProxyMonitorCollector getOrCreate(ProxyModel proxyModel); @Override List<ProxyMonitorCollector> getProxyMonitorResults(); @Override void remove(ProxyModel proxyModel); @Override void isleader(); @Override void notLeader();  }
@Test public void testGetOrCreate() { ProxyMonitorCollector collector = manager.getOrCreate( new ProxyModel().setActive(true).setDcName("dc").setId(1L).setUri("PROXYTCP: Assert.assertNotNull(collector); manager.getOrCreate(new ProxyModel().setActive(true).setDcName("dc").setId(1L).setUri("PROXYTCP: Assert.assertEquals(1, manager.getProxyMonitorResults().size()); }