@Test public void testAddDbConf() { DataSourceConfiguration conf = new DataSourceConfiguration( DataSourceTypeEnum.DRUID, "testdb"); Properties pro = new Properties(); pro.put("test", "test"); conf.setEndPoint(Lists.newArrayList("testEndpoint")); conf.setProperties(pro); assertEquals("testdb", conf.getDataSourceName()); assertEquals(DataSourceTypeEnum.DRUID, conf.getDataSourceType()); metaRepo.addDbConf("testdb", conf); assertFalse(metaRepo.getActiveDbConfMap().containsKey("testdb")); assertFalse(metaRepo.getDbConfMap().containsKey("testdb")); }
public void addDbConf(String datasourceName, DataSourceConfiguration conf) { DataSourceProviderFactory factory = DataSourceTypeRegistry.getDataSourceFactory(conf.getDataSourceType()); if(factory == null){ logger.error("Invalid DataSourceConfiguration: " + datasourceName); return; } if(factory.validate(conf)){ dbConfMap.put(datasourceName.toLowerCase(), conf); }else{ logger.error("Invalid DataSourceConfiguration: " + datasourceName); } }
DataSourceMetaRepo { public void addDbConf(String datasourceName, DataSourceConfiguration conf) { DataSourceProviderFactory factory = DataSourceTypeRegistry.getDataSourceFactory(conf.getDataSourceType()); if(factory == null){ logger.error("Invalid DataSourceConfiguration: " + datasourceName); return; } if(factory.validate(conf)){ dbConfMap.put(datasourceName.toLowerCase(), conf); }else{ logger.error("Invalid DataSourceConfiguration: " + datasourceName); } } }
DataSourceMetaRepo { public void addDbConf(String datasourceName, DataSourceConfiguration conf) { DataSourceProviderFactory factory = DataSourceTypeRegistry.getDataSourceFactory(conf.getDataSourceType()); if(factory == null){ logger.error("Invalid DataSourceConfiguration: " + datasourceName); return; } if(factory.validate(conf)){ dbConfMap.put(datasourceName.toLowerCase(), conf); }else{ logger.error("Invalid DataSourceConfiguration: " + datasourceName); } } private  DataSourceMetaRepo(); }
DataSourceMetaRepo { public void addDbConf(String datasourceName, DataSourceConfiguration conf) { DataSourceProviderFactory factory = DataSourceTypeRegistry.getDataSourceFactory(conf.getDataSourceType()); if(factory == null){ logger.error("Invalid DataSourceConfiguration: " + datasourceName); return; } if(factory.validate(conf)){ dbConfMap.put(datasourceName.toLowerCase(), conf); }else{ logger.error("Invalid DataSourceConfiguration: " + datasourceName); } } private  DataSourceMetaRepo(); static DataSourceMetaRepo getInstance(); DataSourceConfiguration getDbConf(String datasourceName); void addDbConf(String datasourceName, DataSourceConfiguration conf); Map<String, DataSourceProvider> getAllDBMeta(); Map<String, DataSourceProvider> getAllActiveDBMeta(); Map<String, DataSourceConfiguration> getDbConfMap(); Map<String, DataSourceConfiguration> getActiveDbConfMap(); DataSourceProvider getDBMetaFromCache(String datasourceName); Map<String, DataSourceProvider> getDBMetaFromCache(Iterable<? extends String> datasourceNames); void disableDBMetaFromCache(String datasourceName); void disableMultiDBMetaFromCache(Iterable<? extends String> datasourceNames); Map<String, Object> getStats(); }
DataSourceMetaRepo { public void addDbConf(String datasourceName, DataSourceConfiguration conf) { DataSourceProviderFactory factory = DataSourceTypeRegistry.getDataSourceFactory(conf.getDataSourceType()); if(factory == null){ logger.error("Invalid DataSourceConfiguration: " + datasourceName); return; } if(factory.validate(conf)){ dbConfMap.put(datasourceName.toLowerCase(), conf); }else{ logger.error("Invalid DataSourceConfiguration: " + datasourceName); } } private  DataSourceMetaRepo(); static DataSourceMetaRepo getInstance(); DataSourceConfiguration getDbConf(String datasourceName); void addDbConf(String datasourceName, DataSourceConfiguration conf); Map<String, DataSourceProvider> getAllDBMeta(); Map<String, DataSourceProvider> getAllActiveDBMeta(); Map<String, DataSourceConfiguration> getDbConfMap(); Map<String, DataSourceConfiguration> getActiveDbConfMap(); DataSourceProvider getDBMetaFromCache(String datasourceName); Map<String, DataSourceProvider> getDBMetaFromCache(Iterable<? extends String> datasourceNames); void disableDBMetaFromCache(String datasourceName); void disableMultiDBMetaFromCache(Iterable<? extends String> datasourceNames); Map<String, Object> getStats();  }