Search in sources :

Example 36 with Func

use of com.qlangtech.tis.manage.spring.aop.Func in project tis by qlangtech.

the class DataxAction method doGetWriterPluginInfo.

/**
 * 取得写插件配置
 *
 * @param context
 * @throws Exception
 */
@Func(value = PermissionConstant.DATAX_MANAGE, sideEffect = false)
public void doGetWriterPluginInfo(Context context) throws Exception {
    String dataxName = this.getString(PARAM_KEY_DATAX_NAME);
    JSONObject writerDesc = this.parseJsonPost();
    if (StringUtils.isEmpty(dataxName)) {
        throw new IllegalStateException("param " + PARAM_KEY_DATAX_NAME + " can not be null");
    }
    DataxReader.load(this, dataxName);
    KeyedPluginStore<DataxWriter> writerStore = DataxWriter.getPluginStore(this, dataxName);
    DataxWriter writer = writerStore.getPlugin();
    Map<String, Object> pluginInfo = Maps.newHashMap();
    final String requestDescId = writerDesc.getString("impl");
    if (writer != null && StringUtils.equals(writer.getDescriptor().getId(), requestDescId)) {
        DataxReader readerPlugin = DataxReader.load(this, dataxName);
        DataxWriter.BaseDataxWriterDescriptor writerDescriptor = (DataxWriter.BaseDataxWriterDescriptor) writer.getDescriptor();
        if (!writerDescriptor.isSupportMultiTable() && readerPlugin.getSelectedTabs().size() > 1) {
            // 这种情况是不允许的,例如:elastic这样的writer中对于column的设置比较复杂,需要在writer plugin页面中完成,所以就不能支持在reader中选择多个表了
            throw new IllegalStateException("status is not allowed:!writerDescriptor.isSupportMultiTable() && readerPlugin.hasMulitTable()");
        }
        pluginInfo.put("item", (new DescribableJSON(writer)).getItemJson());
    }
    pluginInfo.put("desc", new DescriptorsJSON(TIS.get().getDescriptor(requestDescId)).getDescriptorsJSON());
    this.setBizResult(context, pluginInfo);
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) JSONObject(com.alibaba.fastjson.JSONObject) Func(com.qlangtech.tis.manage.spring.aop.Func)

Example 37 with Func

use of com.qlangtech.tis.manage.spring.aop.Func in project tis by qlangtech.

the class DataxAction method doGetGenCfgFile.

/**
 * 取得生成的配置文件的内容
 *
 * @param context
 */
@Func(value = PermissionConstant.DATAX_MANAGE, sideEffect = false)
public void doGetGenCfgFile(Context context) throws Exception {
    String dataxName = this.getString(PARAM_KEY_DATAX_NAME);
    String fileName = this.getString("fileName");
    GenCfgFileType fileType = GenCfgFileType.parse(this.getString("fileType"));
    DataxProcessor dataxProcessor = IAppSource.load(this, dataxName);
    Map<String, Object> fileMeta = Maps.newHashMap();
    switch(fileType) {
        case DATAX_CFG:
            File dataxCfgDir = dataxProcessor.getDataxCfgDir(this);
            File cfgFile = new File(dataxCfgDir, fileName);
            if (!cfgFile.exists()) {
                throw new IllegalStateException("target file:" + cfgFile.getAbsolutePath());
            }
            fileMeta.put("content", FileUtils.readFileToString(cfgFile, TisUTF8.get()));
            break;
        case CREATE_TABLE_DDL:
            File ddlDir = dataxProcessor.getDataxCreateDDLDir(this);
            File sqlScript = new File(ddlDir, fileName);
            if (!sqlScript.exists()) {
                throw new IllegalStateException("target file:" + sqlScript.getAbsolutePath());
            }
            fileMeta.put("content", FileUtils.readFileToString(sqlScript, TisUTF8.get()));
            break;
        default:
            throw new IllegalStateException("illegal fileType:" + fileType);
    }
    this.setBizResult(context, fileMeta);
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) File(java.io.File) Func(com.qlangtech.tis.manage.spring.aop.Func)

Example 38 with Func

use of com.qlangtech.tis.manage.spring.aop.Func in project tis by qlangtech.

the class DataxAction method doGetExecStatistics.

@Func(value = PermissionConstant.DATAX_MANAGE, sideEffect = false)
public void doGetExecStatistics(Context context) throws Exception {
    WorkFlowBuildHistoryCriteria historyCriteria = new WorkFlowBuildHistoryCriteria();
    Date from = ManageUtils.getOffsetDate(-7);
    SimpleDateFormat dateFormat = new SimpleDateFormat("MM-dd");
    Map<String, DataXExecStatus> execStatis = Maps.newTreeMap();
    ExecResult execResult = null;
    DataXExecStatus execStatus = null;
    String timeLab = null;
    for (int i = 0; i < 8; i++) {
        timeLab = dateFormat.format(ManageUtils.getOffsetDate(-i));
        execStatis.put(timeLab, new DataXExecStatus(timeLab));
    }
    int successCount = 0;
    int errCount = 0;
    historyCriteria.createCriteria().andAppIdEqualTo(this.getAppDomain().getAppid()).andCreateTimeGreaterThan(from);
    for (WorkFlowBuildHistory h : this.wfDAOFacade.getWorkFlowBuildHistoryDAO().selectByExample(historyCriteria)) {
        execResult = ExecResult.parse(h.getState());
        execStatus = execStatis.get(dateFormat.format(h.getCreateTime()));
        if (execStatus == null) {
            continue;
        }
        if (execResult == ExecResult.SUCCESS) {
            execStatus.successCount++;
            successCount++;
        } else if (execResult == ExecResult.FAILD) {
            execStatus.errCount++;
            errCount++;
        }
    }
    Map<String, Object> bizResult = Maps.newHashMap();
    bizResult.put("data", execStatis.values());
    Map<String, Integer> allStatis = Maps.newHashMap();
    allStatis.put("errCount", errCount);
    allStatis.put("successCount", successCount);
    bizResult.put("statis", allStatis);
    this.setBizResult(context, bizResult);
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) SimpleDateFormat(java.text.SimpleDateFormat) WorkFlowBuildHistory(com.qlangtech.tis.workflow.pojo.WorkFlowBuildHistory) WorkFlowBuildHistoryCriteria(com.qlangtech.tis.workflow.pojo.WorkFlowBuildHistoryCriteria) ExecResult(com.qlangtech.tis.assemble.ExecResult) Func(com.qlangtech.tis.manage.spring.aop.Func)

Example 39 with Func

use of com.qlangtech.tis.manage.spring.aop.Func in project tis by qlangtech.

the class DataxAction method doRelaunchPodProcess.

@Func(value = PermissionConstant.DATAX_MANAGE, sideEffect = false)
public void doRelaunchPodProcess(Context context) throws Exception {
    DataXJobWorker jobWorker = DataXJobWorker.getJobWorker(this.getK8SJobWorkerTargetName());
    String podName = this.getString("podName");
    jobWorker.relaunch(podName);
// PluginStore<IncrStreamFactory> incrStreamStore = getIncrStreamFactoryStore(this, true);
// IncrStreamFactory incrStream = incrStreamStore.getPlugin();
// IRCController incrSync = incrStream.getIncrSync();
// incrSync.relaunch(this.getCollectionName());
}
Also used : DataXJobWorker(com.qlangtech.tis.datax.job.DataXJobWorker) Func(com.qlangtech.tis.manage.spring.aop.Func)

Example 40 with Func

use of com.qlangtech.tis.manage.spring.aop.Func in project tis by qlangtech.

the class DataxAction method doGetWriterColsMeta.

/**
 * 当reader为非RDBMS,writer为RDBMS类型时 需要为writer设置表名称,以及各个列的名称
 *
 * @param context
 */
@Func(value = PermissionConstant.DATAX_MANAGE, sideEffect = false)
public void doGetWriterColsMeta(Context context) {
    final String dataxName = this.getString(PARAM_KEY_DATAX_NAME);
    DataxProcessor.DataXCreateProcessMeta processMeta = DataxProcessor.getDataXCreateProcessMeta(this, dataxName);
    DataxProcessor processor = DataxProcessor.load(this, dataxName);
    if (processMeta.isReaderRDBMS()) {
        throw new IllegalStateException("can not process the flow with:" + processMeta.toString());
    }
    int selectedTabsSize = processMeta.getReader().getSelectedTabs().size();
    if (selectedTabsSize != 1) {
        throw new IllegalStateException("dataX reader getSelectedTabs size must be 1 ,but now is :" + selectedTabsSize);
    }
    Map<String, IDataxProcessor.TableAlias> tabAlias = processor.getTabAlias();
    Optional<IDataxProcessor.TableAlias> findMapper = tabAlias.values().stream().findFirst();
    IDataxProcessor.TableMap tabMapper = null;
    for (ISelectedTab selectedTab : processMeta.getReader().getSelectedTabs()) {
        if (findMapper.isPresent()) {
            if (!(findMapper.get() instanceof IDataxProcessor.TableMap)) {
                throw new IllegalStateException("tableAlias must be type of " + IDataxProcessor.TableMap.class.getName());
            }
            tabMapper = (IDataxProcessor.TableMap) findMapper.get();
        } else {
            tabMapper = new IDataxProcessor.TableMap(selectedTab);
            // tabMapper.setSourceCols(selectedTab.getCols());
            tabMapper.setFrom(selectedTab.getName());
            tabMapper.setTo(selectedTab.getName());
        }
        this.setBizResult(context, tabMapper);
        return;
    }
}
Also used : ISelectedTab(com.qlangtech.tis.plugin.ds.ISelectedTab) Func(com.qlangtech.tis.manage.spring.aop.Func)

Aggregations

Func (com.qlangtech.tis.manage.spring.aop.Func)64 JSONObject (com.alibaba.fastjson.JSONObject)12 DataXJobWorker (com.qlangtech.tis.datax.job.DataXJobWorker)6 File (java.io.File)6 Date (java.util.Date)6 Context (com.alibaba.citrus.turbine.Context)5 Application (com.qlangtech.tis.manage.biz.dal.pojo.Application)5 JSONObject (org.json.JSONObject)5 Validator (com.qlangtech.tis.plugin.annotation.Validator)4 IControlMsgHandler (com.qlangtech.tis.runtime.module.misc.IControlMsgHandler)4 IFieldErrorHandler (com.qlangtech.tis.runtime.module.misc.IFieldErrorHandler)4 DelegateControl4JsonPostMsgHandler (com.qlangtech.tis.runtime.module.misc.impl.DelegateControl4JsonPostMsgHandler)4 WorkFlow (com.qlangtech.tis.workflow.pojo.WorkFlow)4 JSONArray (org.json.JSONArray)4 ExecResult (com.qlangtech.tis.assemble.ExecResult)3 FullbuildPhase (com.qlangtech.tis.assemble.FullbuildPhase)3 IndexStreamCodeGenerator (com.qlangtech.tis.compiler.streamcode.IndexStreamCodeGenerator)3 DescriptorExtensionList (com.qlangtech.tis.extension.DescriptorExtensionList)3 IOException (java.io.IOException)3 Matcher (java.util.regex.Matcher)3