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


Java FetcherMgr类代码示例

本文整理汇总了Java中com.baidu.disconf.client.fetcher.FetcherMgr的典型用法代码示例。如果您正苦于以下问题:Java FetcherMgr类的具体用法?Java FetcherMgr怎么用?Java FetcherMgr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FetcherMgr类属于com.baidu.disconf.client.fetcher包,在下文中一共展示了FetcherMgr类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getDisconfCoreMgr

import com.baidu.disconf.client.fetcher.FetcherMgr; //导入依赖的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: DisconfCoreMgrImpl

import com.baidu.disconf.client.fetcher.FetcherMgr; //导入依赖的package包/类
public DisconfCoreMgrImpl(WatchMgr watchMgr, FetcherMgr fetcherMgr, Registry registry) {

        this.watchMgr = watchMgr;
        this.fetcherMgr = fetcherMgr;
        this.registry = registry;

        //
        // 在这里添加好配置项、配置文件的处理器
        //
        DisconfCoreProcessor disconfCoreProcessorFile =
                DisconfCoreProcessorFactory.getDisconfCoreProcessorFile(watchMgr, fetcherMgr, registry);
        disconfCoreProcessorList.add(disconfCoreProcessorFile);

        DisconfCoreProcessor disconfCoreProcessorItem =
                DisconfCoreProcessorFactory.getDisconfCoreProcessorItem(watchMgr, fetcherMgr, registry);
        disconfCoreProcessorList.add(disconfCoreProcessorItem);
    }
 
开发者ID:knightliao,项目名称:disconf,代码行数:18,代码来源:DisconfCoreMgrImpl.java

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

示例4: testDownloadFileFromServer

import com.baidu.disconf.client.fetcher.FetcherMgr; //导入依赖的package包/类
/**
 * 验证下载文件的接口
 *
 * @throws Exception
 */
@Test
public void testDownloadFileFromServer() throws Exception {

    final RestfulMgr restfulMgr = new RestfulMgrMock().getMockInstance();

    FetcherMgr fetcherMgr = new FetcherMgrImpl(restfulMgr, 3, 5, true, "", "", new ArrayList<String>());

    try {

        String valueString = fetcherMgr.downloadFileFromServer(requestUrl, RestfulMgrMock.defaultFileName,
                "./disconf");
        Assert.assertEquals(RestfulMgrMock.defaultFileName, valueString);

    } catch (Exception e) {
        e.printStackTrace();
        Assert.assertTrue(false);
    }
}
 
开发者ID:knightliao,项目名称:disconf,代码行数:24,代码来源:FetcherMgrMgrTestCase.java

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

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

示例7: getDisconfCoreProcessorFile

import com.baidu.disconf.client.fetcher.FetcherMgr; //导入依赖的package包/类
/**
 * 获取配置文件核心处理器
 */
public static DisconfCoreProcessor getDisconfCoreProcessorFile(WatchMgr watchMgr, FetcherMgr fetcherMgr, Registry
        registry) {

    return new DisconfFileCoreProcessorImpl(watchMgr, fetcherMgr, registry);
}
 
开发者ID:knightliao,项目名称:disconf,代码行数:9,代码来源:DisconfCoreProcessorFactory.java

示例8: getDisconfCoreProcessorItem

import com.baidu.disconf.client.fetcher.FetcherMgr; //导入依赖的package包/类
/**
 * 获取配置项核心 处理器
 */
public static DisconfCoreProcessor getDisconfCoreProcessorItem(WatchMgr watchMgr, FetcherMgr fetcherMgr, Registry
        registry) {

    return new DisconfItemCoreProcessorImpl(watchMgr, fetcherMgr, registry);
}
 
开发者ID:knightliao,项目名称:disconf,代码行数:9,代码来源:DisconfCoreProcessorFactory.java

示例9: DisconfItemCoreProcessorImpl

import com.baidu.disconf.client.fetcher.FetcherMgr; //导入依赖的package包/类
public DisconfItemCoreProcessorImpl(WatchMgr watchMgr, FetcherMgr fetcherMgr, Registry registry) {
    this.registry = registry;
    this.fetcherMgr = fetcherMgr;
    this.watchMgr = watchMgr;
}
 
开发者ID:knightliao,项目名称:disconf,代码行数:6,代码来源:DisconfItemCoreProcessorImpl.java

示例10: DisconfFileCoreProcessorImpl

import com.baidu.disconf.client.fetcher.FetcherMgr; //导入依赖的package包/类
public DisconfFileCoreProcessorImpl(WatchMgr watchMgr, FetcherMgr fetcherMgr, Registry registry) {

        this.fetcherMgr = fetcherMgr;
        this.watchMgr = watchMgr;
        this.registry = registry;
    }
 
开发者ID:knightliao,项目名称:disconf,代码行数:7,代码来源:DisconfFileCoreProcessorImpl.java

示例11: demo

import com.baidu.disconf.client.fetcher.FetcherMgr; //导入依赖的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.FetcherMgr类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。