本文整理汇总了Java中com.taobao.tddl.config.ConfigDataHandlerFactory类的典型用法代码示例。如果您正苦于以下问题:Java ConfigDataHandlerFactory类的具体用法?Java ConfigDataHandlerFactory怎么用?Java ConfigDataHandlerFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ConfigDataHandlerFactory类属于com.taobao.tddl.config包,在下文中一共展示了ConfigDataHandlerFactory类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doInit
import com.taobao.tddl.config.ConfigDataHandlerFactory; //导入依赖的package包/类
@Override
public void doInit() {
String dataId = null;
ConfigDataHandlerFactory factory = null;
// 优先从文件获取
if (sequenceFile == null) {
dataId = TDDL5_SEQUENCE_DATA_ID.format(new Object[] { appName });
factory = ConfigDataHandlerCity.getFactory(appName, unitName);
} else {
factory = ConfigDataHandlerCity.getFileFactory(appName);
dataId = sequenceFile;
}
sequenceCdh = factory.getConfigDataHandler(dataId, new SequenceConfigDataListener());
String data = sequenceCdh.getData();
if (TStringUtil.isEmpty(data)) {
logger.warn("sequence is null, dataId is " + dataId);
return;
}
parseSequence(data);
}
示例2: getFactory
import com.taobao.tddl.config.ConfigDataHandlerFactory; //导入依赖的package包/类
/**
* @param appName
* @param unitName
* @param localValues 从本地配置文件里读出来的值,优先使用这里面的
* @return
*/
public static ConfigDataHandlerFactory getFactory(String appName, String unitName, Map<String, String> localValues) {
if (localValues == null) {
return getFactory(appName, unitName);
}
return new LocalFirstConfigDataHandlerFactory(getFactory(appName, unitName), localValues);
}
示例3: LocalFirstConfigDataHandlerFactory
import com.taobao.tddl.config.ConfigDataHandlerFactory; //导入依赖的package包/类
public LocalFirstConfigDataHandlerFactory(ConfigDataHandlerFactory delegateFactory, Map<String, String> localValues){
this.delegateFactory = delegateFactory;
this.localValues = localValues;
}
示例4: getSimpleFactory
import com.taobao.tddl.config.ConfigDataHandlerFactory; //导入依赖的package包/类
public static ConfigDataHandlerFactory getSimpleFactory() {
return new UnitConfigDataHandlerFactory();
}
示例5: getPreHeatFactory
import com.taobao.tddl.config.ConfigDataHandlerFactory; //导入依赖的package包/类
public static ConfigDataHandlerFactory getPreHeatFactory(String appName, String unitName) {
return new UnitConfigDataHandlerFactory(appName, unitName);
}
示例6: getFileFactory
import com.taobao.tddl.config.ConfigDataHandlerFactory; //导入依赖的package包/类
public static ConfigDataHandlerFactory getFileFactory(String appName) {
return new FileConfigDataHandlerFactory("", appName);
}
示例7: doInit
import com.taobao.tddl.config.ConfigDataHandlerFactory; //导入依赖的package包/类
protected void doInit() throws TddlException {
super.doInit();
ss = new ConcurrentHashMap<String, TableMeta>();
if (this.appName == null) {
logger.warn("schema appname is not assigned");
}
if (this.schemaFilePath == null) {
logger.warn("schema file is not assigned");
}
if (appName == null && schemaFilePath == null) {
return;
}
ConfigDataHandlerFactory factory = null;
String dataId = null;
// 优先从文件获取
if (schemaFilePath == null) {
dataId = TDDL5_SCHEMA_DATA_ID.format(new Object[] { appName });
factory = ConfigDataHandlerCity.getFactory(appName, unitName);
} else {
factory = ConfigDataHandlerCity.getFileFactory(appName);
dataId = schemaFilePath;
}
schemaCdh = factory.getConfigDataHandler(dataId, new SchemaConfigDataListener(this));
String data = schemaCdh.getData(ConfigDataHandler.GET_DATA_TIMEOUT,
ConfigDataHandler.FIRST_CACHE_THEN_SERVER_STRATEGY);
if (data == null) {
schemaCdh.destory();
// 尝试找一下andor的版本配置
dataId = ANDOR_SCHEMA_DATA_ID.format(new Object[] { appName });
schemaCdh = factory.getConfigDataHandler(dataId, new SchemaConfigDataListener(this));
data = schemaCdh.getData(ConfigDataHandler.GET_DATA_TIMEOUT,
ConfigDataHandler.FIRST_CACHE_THEN_SERVER_STRATEGY);
}
if (data == null) {
logger.warn(schemaNullError.format(new Object[] { appName, unitName, schemaFilePath, dataId }));
return;
}
InputStream sis = null;
try {
sis = new ByteArrayInputStream(data.getBytes());
List<TableMeta> schemaList = TableMetaParser.parse(sis);
this.ss.clear();
for (TableMeta table : schemaList) {
this.putTable(table.getTableName(), table);
}
logger.warn("table fetched:");
logger.warn(this.ss.keySet().toString());
} catch (Exception e) {
logger.error("table parser error, schema file is:\n" + data, e);
throw new TddlRuntimeException(e);
} finally {
IOUtils.closeQuietly(sis);
}
}
示例8: getPreHeatFactory
import com.taobao.tddl.config.ConfigDataHandlerFactory; //导入依赖的package包/类
public static ConfigDataHandlerFactory getPreHeatFactory(String appName, String unitName) {
return new UnitConfigDataHandlerFactory(unitName, appName);
}
示例9: getFileFactory
import com.taobao.tddl.config.ConfigDataHandlerFactory; //导入依赖的package包/类
public static ConfigDataHandlerFactory getFileFactory(String appName) {
return new FileConfigDataHandlerFactory("", appName, null);
}