Search in sources :

Example 6 with IncrStreamFactory

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");
}
Also used : IncrStreamFactory(com.qlangtech.tis.plugin.incr.IncrStreamFactory)

Example 7 with IncrStreamFactory

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);
    }
}
Also used : IPluginStore(com.qlangtech.tis.plugin.IPluginStore) File(java.io.File) IncrStreamFactory(com.qlangtech.tis.plugin.incr.IncrStreamFactory) IOException(java.io.IOException)

Aggregations

IncrStreamFactory (com.qlangtech.tis.plugin.incr.IncrStreamFactory)7 IndexStreamCodeGenerator (com.qlangtech.tis.compiler.streamcode.IndexStreamCodeGenerator)2 GenerateDAOAndIncrScript (com.qlangtech.tis.compiler.streamcode.GenerateDAOAndIncrScript)1 TargetResName (com.qlangtech.tis.coredefine.module.action.TargetResName)1 FlinkJobDeploymentDetails (com.qlangtech.tis.coredefine.module.action.impl.FlinkJobDeploymentDetails)1 RcDeployment (com.qlangtech.tis.coredefine.module.action.impl.RcDeployment)1 Application (com.qlangtech.tis.manage.biz.dal.pojo.Application)1 IPluginStore (com.qlangtech.tis.plugin.IPluginStore)1 BasicFlinkSourceHandle (com.qlangtech.tis.realtime.BasicFlinkSourceHandle)1 StreamCodeContext (com.qlangtech.tis.sql.parser.stream.generate.StreamCodeContext)1 File (java.io.File)1 IOException (java.io.IOException)1