当前位置: 首页>>代码示例>>Java>>正文


Java FetcherFactory.getFetcherMgr方法代码示例

本文整理汇总了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);
}
 
开发者ID:knightliao,项目名称:disconf,代码行数:19,代码来源:DisconfCoreFactory.java

示例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;
}
 
开发者ID:ningyu1,项目名称:disconf-client-ext,代码行数:43,代码来源:ReloadablePropertiesFactoryBeanExt.java

示例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);
    }
}
 
开发者ID:knightliao,项目名称:disconf,代码行数:82,代码来源:DisconfMgrTestCase.java


注:本文中的com.baidu.disconf.client.fetcher.FetcherFactory.getFetcherMgr方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。