本文整理汇总了Java中com.baidu.disconf.client.fetcher.FetcherMgr.getValueFromServer方法的典型用法代码示例。如果您正苦于以下问题:Java FetcherMgr.getValueFromServer方法的具体用法?Java FetcherMgr.getValueFromServer怎么用?Java FetcherMgr.getValueFromServer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.baidu.disconf.client.fetcher.FetcherMgr
的用法示例。
在下文中一共展示了FetcherMgr.getValueFromServer方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testGetValueFromServer
import com.baidu.disconf.client.fetcher.FetcherMgr; //导入方法依赖的package包/类
/**
* 验证获取数据的接口
*
* @throws Exception
*/
@Test
public void testGetValueFromServer() throws Exception {
final RestfulMgr restfulMgr = new RestfulMgrMock().getMockInstance();
FetcherMgr fetcherMgr = new FetcherMgrImpl(restfulMgr, 3, 5, true, "", "", new ArrayList<String>());
try {
String valueString = fetcherMgr.getValueFromServer(requestUrl);
Assert.assertEquals(RestfulMgrMock.defaultValue, valueString);
} catch (Exception e) {
e.printStackTrace();
Assert.assertTrue(false);
}
}
示例2: loadGlobalItem
import com.baidu.disconf.client.fetcher.FetcherMgr; //导入方法依赖的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: getWatchMgr
import com.baidu.disconf.client.fetcher.FetcherMgr; //导入方法依赖的package包/类
/**
* @throws Exception
*/
public static WatchMgr getWatchMgr(FetcherMgr fetcherMgr) throws Exception {
if (!ConfigMgr.isInit()) {
throw new Exception("ConfigMgr should be init before WatchFactory.getWatchMgr");
}
if (hosts == null || zooPrefix == null) {
synchronized(hostsSync) {
if (hosts == null || zooPrefix == null) {
// 获取 Zoo Hosts
try {
hosts = fetcherMgr.getValueFromServer(DisconfWebPathMgr.getZooHostsUrl(DisClientSysConfig
.getInstance()
.CONF_SERVER_ZOO_ACTION));
zooPrefix = fetcherMgr.getValueFromServer(DisconfWebPathMgr.getZooPrefixUrl(DisClientSysConfig
.getInstance
()
.CONF_SERVER_ZOO_ACTION));
WatchMgr watchMgr = new WatchMgrImpl();
watchMgr.init(hosts, zooPrefix, DisClientConfig.getInstance().DEBUG);
return watchMgr;
} catch (Exception e) {
LOGGER.error("cannot get watch module", e);
}
}
}
}
return null;
}