本文整理汇总了Java中com.baidu.disconf.client.store.DisconfStoreProcessorFactory类的典型用法代码示例。如果您正苦于以下问题:Java DisconfStoreProcessorFactory类的具体用法?Java DisconfStoreProcessorFactory怎么用?Java DisconfStoreProcessorFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DisconfStoreProcessorFactory类属于com.baidu.disconf.client.store包,在下文中一共展示了DisconfStoreProcessorFactory类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getByFile
import com.baidu.disconf.client.store.DisconfStoreProcessorFactory; //导入依赖的package包/类
@Override
public Map<String, Object> getByFile(String fileName) {
DisconfStoreProcessor disconfStoreProcessor =
DisconfStoreProcessorFactory.getDisconfStoreFileProcessor();
DisconfCenterFile disconfCenterFile = (DisconfCenterFile) disconfStoreProcessor.getConfData(fileName);
if (disconfCenterFile == null) {
return new HashMap<String, Object>();
}
return disconfCenterFile.getKV();
}
示例2: getByItem
import com.baidu.disconf.client.store.DisconfStoreProcessorFactory; //导入依赖的package包/类
@Override
public Object getByItem(String itemName) {
DisconfStoreProcessor disconfStoreProcessor =
DisconfStoreProcessorFactory.getDisconfStoreItemProcessor();
DisconfCenterItem disconfCenterItem = (DisconfCenterItem) disconfStoreProcessor.getConfData(itemName);
if (disconfCenterItem == null) {
return null;
}
return disconfCenterItem.getValue();
}
示例3: scanData2Store
import com.baidu.disconf.client.store.DisconfStoreProcessorFactory; //导入依赖的package包/类
/**
*
*/
public static void scanData2Store(String fileName) {
DisconfCenterBaseModel disconfCenterBaseModel = null;
if(isGlobalFile(fileName)) {
disconfCenterBaseModel =
StaticScannerNonAnnotationFileMgrImplExt.getDisconfCenterFile(fileName);
} else {
disconfCenterBaseModel =
StaticScannerNonAnnotationFileMgrImpl.getDisconfCenterFile(fileName);
}
DisconfStoreProcessorFactory.getDisconfStoreFileProcessor().transformScanData(disconfCenterBaseModel);
}
示例4: transformPipelineService
import com.baidu.disconf.client.store.DisconfStoreProcessorFactory; //导入依赖的package包/类
/**
* 第二次扫描<br/>
* 转换 pipeline 回调函数,将其写到 仓库中
*/
private static void transformPipelineService(IDisconfUpdatePipeline iDisconfUpdatePipeline) {
DisconfStorePipelineProcessor disconfStorePipelineProcessor = DisconfStoreProcessorFactory
.getDisconfStorePipelineProcessor();
disconfStorePipelineProcessor.setDisconfUpdatePipeline(iDisconfUpdatePipeline);
}
示例5: scanData2Store
import com.baidu.disconf.client.store.DisconfStoreProcessorFactory; //导入依赖的package包/类
@Override
public void scanData2Store(ScanStaticModel scanModel) {
// 转换配置项
List<DisconfCenterBaseModel> disconfCenterItems = getDisconfItems(scanModel);
DisconfStoreProcessorFactory.getDisconfStoreItemProcessor().transformScanData(disconfCenterItems);
}
示例6: scanData2Store
import com.baidu.disconf.client.store.DisconfStoreProcessorFactory; //导入依赖的package包/类
/**
*
*/
@Override
public void scanData2Store(ScanStaticModel scanModel) {
// 转换配置文件
List<DisconfCenterBaseModel> disconfCenterFiles = getDisconfFiles(scanModel);
DisconfStoreProcessorFactory.getDisconfStoreFileProcessor().transformScanData(disconfCenterFiles);
}
示例7: scanData2Store
import com.baidu.disconf.client.store.DisconfStoreProcessorFactory; //导入依赖的package包/类
/**
*
*/
@Override
public void scanData2Store(ScanStaticModel scanModel) {
//
//
//
List<DisconfCenterBaseModel> disconfCenterBaseModels = getDisconfCenterFiles(scanModel.getJustHostFiles());
DisconfStoreProcessorFactory.getDisconfStoreFileProcessor().transformScanData(disconfCenterBaseModels);
}
示例8: decideAccess
import com.baidu.disconf.client.store.DisconfStoreProcessorFactory; //导入依赖的package包/类
/**
* 获取配置项数据, 只有开启disconf远程才会进行切面
*
* @throws Throwable
*/
@Around("anyPublicMethod() && @annotation(disconfItem)")
public Object decideAccess(ProceedingJoinPoint pjp, DisconfItem disconfItem) throws Throwable {
if (DisClientConfig.getInstance().ENABLE_DISCONF) {
//
// 请求仓库配置数据
//
DisconfStoreProcessor disconfStoreProcessor = DisconfStoreProcessorFactory.getDisconfStoreItemProcessor();
Object ret = disconfStoreProcessor.getConfig(null, disconfItem.key());
if (ret != null) {
LOGGER.debug("using disconf store value: (" + disconfItem.key() + " , " + ret + ")");
return ret;
}
}
Object rtnOb;
try {
// 返回原值
rtnOb = pjp.proceed();
} catch (Throwable t) {
LOGGER.info(t.getMessage());
throw t;
}
return rtnOb;
}
示例9: secondScan
import com.baidu.disconf.client.store.DisconfStoreProcessorFactory; //导入依赖的package包/类
/**
* 第二次扫描, 动态扫描, for annotation config
*/
protected synchronized void secondScan() {
// 该函数必须第一次运行后才能运行
if (!isFirstInit) {
LOGGER.info("should run First Scan before Second Scan.");
return;
}
// 第二次扫描也只能做一次
if (isSecondInit) {
LOGGER.info("should not run twice.");
return;
}
LOGGER.info("******************************* DISCONF START SECOND SCAN *******************************");
try {
// 扫描回调函数
if (scanMgr != null) {
scanMgr.secondScan();
}
// 注入数据至配置实体中
// 获取数据/注入/Watch
if (disconfCoreMgr != null) {
disconfCoreMgr.inject2DisconfInstance();
}
} catch (Exception e) {
LOGGER.error(e.toString(), e);
}
isSecondInit = true;
//
// 不开启 则不要启动timer和打印变量map
//
if (DisClientConfig.getInstance().ENABLE_DISCONF) {
//
// start timer
//
//startTimer();
//
LOGGER.info("Conf File Map: {}", DisconfStoreProcessorFactory.getDisconfStoreFileProcessor()
.confToString());
//
LOGGER.info("Conf Item Map: {}", DisconfStoreProcessorFactory.getDisconfStoreItemProcessor()
.confToString());
}
LOGGER.info("******************************* DISCONF END *******************************");
}
示例10: transformUpdateService
import com.baidu.disconf.client.store.DisconfStoreProcessorFactory; //导入依赖的package包/类
/**
* 第二次扫描<br/>
* 转换 更新 回调函数,将其写到 仓库中
*/
private static void transformUpdateService(Map<DisconfKey,
List<IDisconfUpdate>> disconfUpdateServiceInverseIndexMap) {
DisconfStoreProcessor disconfStoreProcessorFile = DisconfStoreProcessorFactory.getDisconfStoreFileProcessor();
DisconfStoreProcessor disconfStoreProcessorItem = DisconfStoreProcessorFactory.getDisconfStoreItemProcessor();
for (DisconfKey disconfKey : disconfUpdateServiceInverseIndexMap.keySet()) {
//
//
//
try {
if (disconfKey.getDisConfigTypeEnum().equals(DisConfigTypeEnum.FILE)) {
if (!disconfStoreProcessorFile.hasThisConf(disconfKey.getKey())) {
throw new Exception();
}
disconfStoreProcessorFile.addUpdateCallbackList(disconfKey.getKey(),
disconfUpdateServiceInverseIndexMap
.get(disconfKey));
} else if (disconfKey.getDisConfigTypeEnum().equals(DisConfigTypeEnum.ITEM)) {
if (!disconfStoreProcessorItem.hasThisConf(disconfKey.getKey())) {
throw new Exception();
}
disconfStoreProcessorItem.addUpdateCallbackList(disconfKey.getKey(),
disconfUpdateServiceInverseIndexMap
.get(disconfKey));
}
} catch (Exception e) {
// 找不到回调对应的配置,这是用户配置 错误了
StringBuffer sb = new StringBuffer();
sb.append("cannot find " + disconfKey + "for: ");
for (IDisconfUpdate serClass : disconfUpdateServiceInverseIndexMap.get(disconfKey)) {
sb.append(serClass.toString() + "\t");
}
LOGGER.error(sb.toString());
}
}
}
示例11: exclude
import com.baidu.disconf.client.store.DisconfStoreProcessorFactory; //导入依赖的package包/类
/**
*
*/
@Override
public void exclude(Set<String> keySet) {
DisconfStoreProcessorFactory.getDisconfStoreItemProcessor().exclude(keySet);
}
示例12: exclude
import com.baidu.disconf.client.store.DisconfStoreProcessorFactory; //导入依赖的package包/类
/**
*
*/
@Override
public void exclude(Set<String> keySet) {
DisconfStoreProcessorFactory.getDisconfStoreFileProcessor().exclude(keySet);
}
示例13: secondScan
import com.baidu.disconf.client.store.DisconfStoreProcessorFactory; //导入依赖的package包/类
/**
* 第二次扫描, 动态扫描, for annotation config
*/
protected synchronized void secondScan() {
// 该函数必须第一次运行后才能运行
if (!isFirstInit) {
LOGGER.info("should run First Scan before Second Scan.");
return;
}
// 第二次扫描也只能做一次
if (isSecondInit) {
LOGGER.info("should not run twice.");
return;
}
LOGGER.info("******************************* DISCONF START SECOND SCAN *******************************");
try {
// 扫描回调函数
if (scanMgr != null) {
scanMgr.secondScan();
}
// 注入数据至配置实体中
// 获取数据/注入/Watch
if (disconfCoreMgr != null) {
disconfCoreMgr.inject2DisconfInstance();
}
} catch (Exception e) {
LOGGER.error(e.toString(), e);
}
isSecondInit = true;
//
// 不开启 则不要打印变量map
//
if (DisClientConfig.getInstance().ENABLE_DISCONF) {
//
String data = DisconfStoreProcessorFactory.getDisconfStoreFileProcessor()
.confToString();
if (!StringUtils.isEmpty(data)) {
LOGGER.info("Conf File Map: {}", data);
}
//
data = DisconfStoreProcessorFactory.getDisconfStoreItemProcessor()
.confToString();
if (!StringUtils.isEmpty(data)) {
LOGGER.info("Conf Item Map: {}", data);
}
}
LOGGER.info("******************************* DISCONF END *******************************");
}
示例14: demo
import com.baidu.disconf.client.store.DisconfStoreProcessorFactory; //导入依赖的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);
}
}