use of com.qlangtech.tis.plugin.incr.IncrStreamFactory in project tis by qlangtech.
the class HeteroEnum method getIncrStreamFactory.
public static IncrStreamFactory getIncrStreamFactory(String dataxName) {
IPluginContext pluginContext = IPluginContext.namedContext(dataxName);
List<IncrStreamFactory> streamFactories = HeteroEnum.INCR_STREAM_CONFIG.getPlugins(pluginContext, null);
for (IncrStreamFactory factory : streamFactories) {
return factory;
}
throw new IllegalStateException("stream app:" + dataxName + " incrController can not not be null");
}
use of com.qlangtech.tis.plugin.incr.IncrStreamFactory in project tis by qlangtech.
the class GenerateDAOAndIncrScript method generateIncrScript.
public void generateIncrScript(Context context, IndexIncrStatus incrStatus, boolean compilerAndPackage, Map<DBNode, List<String>> dbNameMap) {
try {
// final Map<DBNode, List<String>> dbNameMap = Collections.unmodifiableMap(indexStreamCodeGenerator.getDbTables());
File sourceRoot = StreamContextConstant.getStreamScriptRootDir(indexStreamCodeGenerator.collection, indexStreamCodeGenerator.incrScriptTimestamp);
if (// 检查Faild Token文件是否存在
!indexStreamCodeGenerator.isIncrScriptDirCreated() || incrStreamCodeCompileFaild(sourceRoot)) {
/**
* *********************************************************************************
* 自动生成scala代码
* ***********************************************************************************
*/
indexStreamCodeGenerator.generateStreamScriptCode();
// 生成依赖dao依赖元数据信息
DBNode.dump(dbNameMap.keySet().stream().collect(Collectors.toList()), StreamContextConstant.getDbDependencyConfigMetaFile(indexStreamCodeGenerator.collection, indexStreamCodeGenerator.incrScriptTimestamp));
/**
* *********************************************************************************
* 生成spring相关配置文件
* ***********************************************************************************
*/
indexStreamCodeGenerator.generateConfigFiles();
}
incrStatus.setIncrScriptMainFileContent(indexStreamCodeGenerator.readIncrScriptMainFileContent());
// TODO 真实生产环境中需要 和 代码build阶段分成两步
if (compilerAndPackage) {
IPluginStore pluginStore = HeteroEnum.INCR_STREAM_CONFIG.getPluginStore(IPluginContext.namedContext(this.indexStreamCodeGenerator.collection), null);
IncrStreamFactory streamFactory = (IncrStreamFactory) pluginStore.getPlugin();
Objects.requireNonNull(streamFactory, "relevant streamFactory can not be null,collection:" + this.indexStreamCodeGenerator.collection);
// CompileAndPackage packager = new CompileAndPackage();
streamFactory.getCompileAndPackageManager().process(context, this.msgHandler, indexStreamCodeGenerator.collection, dbNameMap.entrySet().stream().collect(Collectors.toMap((e) -> e.getKey(), (e) -> e.getValue())), sourceRoot, indexStreamCodeGenerator.getSpringXmlConfigsObjectsContext());
}
} catch (Exception e) {
// 将原始文件删除干净
try {
FileUtils.forceDelete(indexStreamCodeGenerator.getStreamCodeGenerator().getIncrScriptDir());
} catch (Throwable ex) {
// ex.printStackTrace();
}
throw new RuntimeException(e);
}
}
Aggregations