本文整理汇总了Java中com.baidu.disconf.client.fetcher.FetcherFactory.getFetcherMgr方法的典型用法代码示例。如果您正苦于以下问题:Java FetcherFactory.getFetcherMgr方法的具体用法?Java FetcherFactory.getFetcherMgr怎么用?Java FetcherFactory.getFetcherMgr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.baidu.disconf.client.fetcher.FetcherFactory
的用法示例。
在下文中一共展示了FetcherFactory.getFetcherMgr方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDisconfCoreMgr
import com.baidu.disconf.client.fetcher.FetcherFactory; //导入方法依赖的package包/类
/**
* @throws Exception
*/
public static DisconfCoreMgr getDisconfCoreMgr(Registry registry) throws Exception {
FetcherMgr fetcherMgr = FetcherFactory.getFetcherMgr();
//
// 不开启disconf,则不要watch了
//
WatchMgr watchMgr = null;
if (DisClientConfig.getInstance().ENABLE_DISCONF) {
// Watch 模块
watchMgr = WatchFactory.getWatchMgr(fetcherMgr);
}
return new DisconfCoreMgrImpl(watchMgr, fetcherMgr, registry);
}
示例2: loadGlobalItem
import com.baidu.disconf.client.fetcher.FetcherFactory; //导入方法依赖的package包/类
/**
* 加载global配置项,获取global文件列表
*/
private String[] loadGlobalItem() {
String keyName = "global";
String value = null;
String[] fileNames = null;
//
// 开启disconf才需要远程下载, 否则就用默认值
//
if (DisClientConfig.getInstance().ENABLE_DISCONF) {
//
// 下载配置
//
try {
FetcherMgr fetcherMgr = FetcherFactory.getFetcherMgr();
// Disconf-web url
String url = DisconfWebPathMgr.getRemoteUrlParameter(DisClientSysConfig.getInstance().CONF_SERVER_STORE_ACTION,
DisClientConfigExt.GLOBAL_APP,
DisClientConfigExt.GLOBAL_VERSION,
DisClientConfig.getInstance().ENV,
DisClientConfigExt.GLOBAL_KEY,
DisConfigTypeEnum.ITEM);
value = fetcherMgr.getValueFromServer(url);
if (value != null) {
log.debug("value: " + value);
//value获取global文件列表
fileNames = value.split(",");
for(int i=0;i<fileNames.length;i++) {
fileNames[i] = "classpath:/" + fileNames[i];
}
}
log.info("loaded global prop ok.");
} catch (Exception e) {
log.error("cannot use remote configuration: " + keyName, e);
log.info("skip variable: " + keyName);
}
}
return fileNames;
}
示例3: demo
import com.baidu.disconf.client.fetcher.FetcherFactory; //导入方法依赖的package包/类
@Test
public void demo() {
//
// mock up factory method
//
new MockUp<DisconfCoreFactory>() {
@Mock
public DisconfCoreMgr getDisconfCoreMgr(Registry registry) throws Exception {
FetcherMgr fetcherMgr = FetcherFactory.getFetcherMgr();
// Watch 模块
final WatchMgr watchMgr = new WatchMgrMock().getMockInstance();
watchMgr.init("", "", true);
// registry
DisconfCoreMgr disconfCoreMgr = new DisconfCoreMgrImpl(watchMgr, fetcherMgr,
registry);
return disconfCoreMgr;
}
};
//
// 正式测试
//
try {
LOGGER.info("================ BEFORE DISCONF ==============================");
LOGGER.info("before disconf values:");
LOGGER.info(String.valueOf("varA: " + confA.getVarA()));
LOGGER.info(String.valueOf("varA2: " + confA.getVarA2()));
LOGGER.info(String.valueOf("varAA: " + serviceA.getVarAA()));
LOGGER.info("================ BEFORE DISCONF ==============================");
//
// start it
//
Set<String> fileSet = new HashSet<String>();
fileSet.add("atomserverl.properties");
fileSet.add("atomserverm_slave.properties");
DisconfCenterHostFilesStore.getInstance().addJustHostFileSet(fileSet);
DisconfMgr.getInstance().setApplicationContext(applicationContext);
DisconfMgr.getInstance().start(StringUtil.parseStringToStringList(ScanPackTestCase.SCAN_PACK_NAME,
DisconfMgrBean.SCAN_SPLIT_TOKEN));
//
LOGGER.info(DisconfStoreProcessorFactory.getDisconfStoreFileProcessor().confToString());
//
LOGGER.info(DisconfStoreProcessorFactory.getDisconfStoreItemProcessor().confToString());
LOGGER.info("================ AFTER DISCONF ==============================");
LOGGER.info(String.valueOf("varA: " + confA.getVarA()));
Assert.assertEquals(new Long(1000), confA.getVarA());
LOGGER.info(String.valueOf("varA2: " + confA.getVarA2()));
Assert.assertEquals(new Long(2000), confA.getVarA2());
LOGGER.info(String.valueOf("varAA: " + serviceA.getVarAA()));
Assert.assertEquals(new Integer(1000).intValue(), serviceA.getVarAA());
LOGGER.info(String.valueOf("static var: " + StaticConf.getStaticvar()));
Assert.assertEquals(new Integer(50).intValue(), StaticConf.getStaticvar());
testDynamicGetter();
LOGGER.info("================ AFTER DISCONF ==============================");
} catch (Exception e) {
e.printStackTrace();
Assert.assertTrue(false);
}
}