Search in sources :

Example 31 with Func

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

the class DataxAction method doGetDataxWorkerHpa.

@Func(value = PermissionConstant.DATAX_MANAGE, sideEffect = false)
public void doGetDataxWorkerHpa(Context context) {
    DataXJobWorker jobWorker = DataXJobWorker.getJobWorker(this.getK8SJobWorkerTargetName());
    if (jobWorker.getHpa() != null) {
        RcHpaStatus hpaStatus = jobWorker.getHpaStatus();
        this.setBizResult(context, hpaStatus);
    }
}
Also used : DataXJobWorker(com.qlangtech.tis.datax.job.DataXJobWorker) Func(com.qlangtech.tis.manage.spring.aop.Func)

Example 32 with Func

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

the class DataxAction method doSaveWriterColsMeta.

/**
 * @param context
 */
@Func(value = PermissionConstant.DATAX_MANAGE)
public void doSaveWriterColsMeta(Context context) {
    String dataxName = this.getString(PARAM_KEY_DATAX_NAME);
    DataxProcessor.DataXCreateProcessMeta processMeta = DataxProcessor.getDataXCreateProcessMeta(this, dataxName);
    if ((processMeta.isReaderRDBMS())) {
        throw new IllegalStateException("can not process the flow with:" + processMeta.toString());
    }
    List<ISelectedTab.ColMeta> writerCols = Lists.newArrayList();
    IDataxProcessor.TableMap tableMapper = new IDataxProcessor.TableMap(new ISelectedTab() {

        @Override
        public List<ColMeta> getCols() {
            return writerCols;
        }
    });
    // tableMapper.setSourceCols(writerCols);
    // //////////////////
    final String keyColsMeta = "colsMeta";
    IControlMsgHandler handler = new DelegateControl4JsonPostMsgHandler(this, this.parseJsonPost());
    if (!Validator.validate(handler, context, // 
    Validator.fieldsValidator(// 
    "writerTargetTabName", new Validator.FieldValidators(Validator.require, Validator.db_col_name) {

        @Override
        public void setFieldVal(String val) {
            tableMapper.setTo(val);
        }
    }, "writerFromTabName", new Validator.FieldValidators(Validator.require, Validator.db_col_name) {

        @Override
        public void setFieldVal(String val) {
            tableMapper.setFrom(val);
        }
    }, // 
    keyColsMeta, new Validator.FieldValidators(Validator.require) {

        @Override
        public void setFieldVal(String val) {
        }
    }, new Validator.IFieldValidator() {

        @Override
        public boolean validate(IFieldErrorHandler msgHandler, Context context, String fieldKey, String fieldData) {
            ISelectedTab.ColMeta colMeta = null;
            JSONArray targetCols = JSON.parseArray(fieldData);
            JSONObject targetCol = null;
            int index;
            String targetColName = null;
            if (targetCols.size() < 1) {
                msgHandler.addFieldError(context, fieldKey, "Writer目标表列不能为空");
                return false;
            }
            Map<String, Integer> existCols = Maps.newHashMap();
            boolean validateFaild = false;
            Integer previousColIndex = null;
            for (int i = 0; i < targetCols.size(); i++) {
                targetCol = targetCols.getJSONObject(i);
                index = targetCol.getInteger("index");
                targetColName = targetCol.getString("name");
                if (StringUtils.isNotBlank(targetColName) && (previousColIndex = existCols.put(targetColName, index)) != null) {
                    msgHandler.addFieldError(context, keyColsMeta + "[" + previousColIndex + "]", "内容不能与第" + index + "行重复");
                    msgHandler.addFieldError(context, keyColsMeta + "[" + index + "]", "内容不能与第" + previousColIndex + "行重复");
                    return false;
                }
                if (!Validator.require.validate(DataxAction.this, context, keyColsMeta + "[" + index + "]", targetColName)) {
                    validateFaild = true;
                } else if (!Validator.db_col_name.validate(DataxAction.this, context, keyColsMeta + "[" + index + "]", targetColName)) {
                    validateFaild = true;
                }
                colMeta = new ISelectedTab.ColMeta();
                colMeta.setName(targetColName);
                DataType dataType = targetCol.getObject("type", DataType.class);
                // colMeta.setType(ISelectedTab.DataXReaderColType.parse(targetCol.getString("type")));
                colMeta.setType(dataType);
                writerCols.add(colMeta);
            }
            return !validateFaild;
        }
    }))) {
        return;
    }
    this.saveTableMapper(this, dataxName, Collections.singletonList(tableMapper));
}
Also used : ServletActionContext(org.apache.struts2.ServletActionContext) Context(com.alibaba.citrus.turbine.Context) IParamContext(com.qlangtech.tis.order.center.IParamContext) DelegateControl4JsonPostMsgHandler(com.qlangtech.tis.runtime.module.misc.impl.DelegateControl4JsonPostMsgHandler) ISelectedTab(com.qlangtech.tis.plugin.ds.ISelectedTab) IFieldErrorHandler(com.qlangtech.tis.runtime.module.misc.IFieldErrorHandler) JSONArray(com.alibaba.fastjson.JSONArray) JSONObject(com.alibaba.fastjson.JSONObject) DataType(com.qlangtech.tis.plugin.ds.DataType) DescriptorExtensionList(com.qlangtech.tis.extension.DescriptorExtensionList) IControlMsgHandler(com.qlangtech.tis.runtime.module.misc.IControlMsgHandler) Validator(com.qlangtech.tis.plugin.annotation.Validator) Func(com.qlangtech.tis.manage.spring.aop.Func)

Example 33 with Func

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

the class DataxAction method doLaunchDataxWorker.

/**
 * 启动DataX执行器
 *
 * @param context
 */
@Func(value = PermissionConstant.DATAX_MANAGE)
public void doLaunchDataxWorker(Context context) {
    DataXJobWorker dataxJobWorker = DataXJobWorker.getJobWorker(this.getK8SJobWorkerTargetName());
    if (dataxJobWorker == null) {
        throw new IllegalStateException("dataxJobWorker can not be null,relevant target type:" + this.getK8SJobWorkerTargetName());
    }
    if (dataxJobWorker.inService()) {
        throw new IllegalStateException("dataxJobWorker is in serivce ,can not launch repeat");
    }
    dataxJobWorker.launchService();
    try {
        Thread.sleep(4000l);
    } catch (InterruptedException e) {
    }
    this.doGetJobWorkerMeta(context);
    AjaxValve.ActionExecResult actionExecResult = MockContext.getActionExecResult();
    DataXJobWorkerStatus jobWorkerStatus = (DataXJobWorkerStatus) actionExecResult.getBizResult();
    if (jobWorkerStatus == null || !jobWorkerStatus.isK8sReplicationControllerCreated()) {
        throw new IllegalStateException("Job Controller launch faild please contract administer");
    }
    this.addActionMessage(context, "已经成功启动DataX执行器");
}
Also used : DataXJobWorker(com.qlangtech.tis.datax.job.DataXJobWorker) AjaxValve(com.qlangtech.tis.manage.common.valve.AjaxValve) Func(com.qlangtech.tis.manage.spring.aop.Func)

Example 34 with Func

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

the class DataxAction method doSaveDataxWorker.

/**
 * 保存K8S dataX worker
 *
 * @param context
 */
@Func(value = PermissionConstant.DATAX_MANAGE)
public void doSaveDataxWorker(Context context) {
    JSONObject postContent = this.parseJsonPost();
    JSONObject k8sSpec = postContent.getJSONObject("k8sSpec");
    IncrUtils.IncrSpecResult incrSpecResult = IncrUtils.parseIncrSpec(context, k8sSpec, this);
    if (!incrSpecResult.isSuccess()) {
        return;
    }
    TargetResName resName = this.getK8SJobWorkerTargetName();
    DataXJobWorker worker = DataXJobWorker.getJobWorker(resName);
    worker.setReplicasSpec(incrSpecResult.getSpec());
    if (incrSpecResult.hpa != null) {
        worker.setHpa(incrSpecResult.hpa);
    }
    DataXJobWorker.setJobWorker(resName, worker);
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) DataXJobWorker(com.qlangtech.tis.datax.job.DataXJobWorker) Func(com.qlangtech.tis.manage.spring.aop.Func)

Example 35 with Func

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

the class DataxAction method doSaveTableMapper.

/**
 * 保存表映射
 *
 * @param context
 */
@Func(value = PermissionConstant.DATAX_MANAGE)
public void doSaveTableMapper(Context context) {
    String dataxName = this.getString(PARAM_KEY_DATAX_NAME);
    // 表别名列表
    JSONArray tabAliasList = this.parseJsonArrayPost();
    Objects.requireNonNull(tabAliasList, "tabAliasList can not be null");
    JSONObject alias = null;
    IDataxProcessor.TableAlias tabAlias = null;
    List<IDataxProcessor.TableAlias> tableMaps = Lists.newArrayList();
    String mapperToVal = null;
    for (int i = 0; i < tabAliasList.size(); i++) {
        alias = tabAliasList.getJSONObject(i);
        tabAlias = new IDataxProcessor.TableAlias();
        tabAlias.setFrom(alias.getString("from"));
        mapperToVal = alias.getString("to");
        String mapper2FieldKey = "tabMapperTo[" + i + "]";
        if (Validator.require.validate(this, context, mapper2FieldKey, mapperToVal)) {
            Validator.db_col_name.validate(this, context, mapper2FieldKey, mapperToVal);
        }
        tabAlias.setTo(mapperToVal);
        tableMaps.add(tabAlias);
    }
    if (context.hasErrors()) {
        return;
    }
    this.saveTableMapper(this, dataxName, tableMaps);
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) JSONArray(com.alibaba.fastjson.JSONArray) 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