Search in sources :

Example 1 with WorkFlow

use of com.qlangtech.tis.workflow.pojo.WorkFlow in project tis by qlangtech.

the class WorkFlowDAOImpl method deleteByPrimaryKey.

public int deleteByPrimaryKey(Integer id) {
    WorkFlow key = new WorkFlow();
    key.setId(id);
    return this.deleteRecords("work_flow.ibatorgenerated_deleteByPrimaryKey", key);
}
Also used : WorkFlow(com.qlangtech.tis.workflow.pojo.WorkFlow)

Example 2 with WorkFlow

use of com.qlangtech.tis.workflow.pojo.WorkFlow in project tis by qlangtech.

the class OfflineDatasourceAction method doExecuteWorkflow.

/**
 * Do execute workflow. 执行数据流任务<br>
 * 仅仅只执行DataFlow的数据构建
 *
 * @param context the context
 * @throws Exception the exception
 */
@Func(value = PermissionConstant.DATAFLOW_MANAGE)
public void doExecuteWorkflow(Context context) throws Exception {
    Integer id = this.getInt("id");
    List<PostParam> params = Lists.newArrayList();
    WorkFlow df = this.getWorkflowDAOFacade().getWorkFlowDAO().selectByPrimaryKey(id);
    Assert.assertNotNull(df);
    params.add(new PostParam(IFullBuildContext.KEY_WORKFLOW_NAME, df.getName()));
    params.add(new PostParam(IFullBuildContext.KEY_WORKFLOW_ID, String.valueOf(id)));
    // TODO 单独触发的DF执行后期要保证该流程最后的执行的结果数据不能用于索引build
    params.add(new PostParam(IFullBuildContext.KEY_APP_SHARD_COUNT, IFullBuildContext.KEY_APP_SHARD_COUNT_SINGLE));
    params.add(new PostParam(COMPONENT_START, FullbuildPhase.FullDump.getName()));
    params.add(new PostParam(COMPONENT_END, FullbuildPhase.JOIN.getName()));
    if (!CoreAction.triggerBuild(this, context, params).success) {
    // throw new IllegalStateException("dataflowid:" + id + " trigger faild");
    }
}
Also used : PostParam(com.qlangtech.tis.manage.common.HttpUtils.PostParam) WorkFlow(com.qlangtech.tis.workflow.pojo.WorkFlow) Func(com.qlangtech.tis.manage.spring.aop.Func)

Example 3 with WorkFlow

use of com.qlangtech.tis.workflow.pojo.WorkFlow in project tis by qlangtech.

the class OfflineDatasourceAction method getWorkflowId.

private Integer getWorkflowId(String topologyName) {
    // return SqlTaskNodeMeta.getTopologyProfile(topologyName).getDataflowId();
    WorkFlowCriteria wc = new WorkFlowCriteria();
    wc.createCriteria().andNameEqualTo(topologyName);
    List<WorkFlow> workFlows = this.getWorkflowDAOFacade().getWorkFlowDAO().selectByExample(wc);
    for (WorkFlow wf : workFlows) {
        // topologyPojo.setDataflowId(wf.getId());
        return wf.getId();
    }
    throw new IllegalStateException("topology:" + topologyName + " can not find workflow record in db");
}
Also used : WorkFlow(com.qlangtech.tis.workflow.pojo.WorkFlow) WorkFlowCriteria(com.qlangtech.tis.workflow.pojo.WorkFlowCriteria)

Example 4 with WorkFlow

use of com.qlangtech.tis.workflow.pojo.WorkFlow in project tis by qlangtech.

the class OfflineDatasourceAction method doTestTransaction.

public void doTestTransaction(Context context) {
    WorkFlow wf = new WorkFlow();
    wf.setCreateTime(new Date());
    wf.setGitPath("gitpath");
    wf.setName("baisuitest");
    wf.setOpUserId(123);
    wf.setOpUserName("baisui");
    wf.setOpTime(new Date());
    this.offlineDAOFacade.getWorkFlowDAO().insertSelective(wf);
}
Also used : WorkFlow(com.qlangtech.tis.workflow.pojo.WorkFlow)

Example 5 with WorkFlow

use of com.qlangtech.tis.workflow.pojo.WorkFlow in project tis by qlangtech.

the class OfflineDatasourceAction method doSaveErRule.

/**
 * 保存ER关系
 *
 * @param context
 * @throws Exception
 */
@Func(value = PermissionConstant.DATAFLOW_UPDATE)
public void doSaveErRule(Context context) throws Exception {
    com.alibaba.fastjson.JSONObject j = this.parseJsonPost();
    ERRules erRules = new ERRules();
    final String topology = j.getString("topologyName");
    if (StringUtils.isEmpty(topology)) {
        throw new IllegalArgumentException("param 'topology' can not be empty");
    }
    SqlDataFlowTopology df = SqlTaskNodeMeta.getSqlDataFlowTopology(topology);
    com.alibaba.fastjson.JSONArray edges = j.getJSONArray("edges");
    com.alibaba.fastjson.JSONArray nodes = j.getJSONArray("nodes");
    com.alibaba.fastjson.JSONObject edge = null;
    com.alibaba.fastjson.JSONObject sourceNode = null;
    com.alibaba.fastjson.JSONObject targetNode = null;
    com.alibaba.fastjson.JSONObject linkrule = null;
    com.alibaba.fastjson.JSONArray linkKeyList = null;
    com.alibaba.fastjson.JSONObject link = null;
    com.alibaba.fastjson.JSONObject nodeTuple = null;
    com.alibaba.fastjson.JSONObject node = null;
    com.alibaba.fastjson.JSONObject ermeta = null;
    TableRelation erRelation = null;
    for (int i = 0; i < edges.size(); i++) {
        edge = edges.getJSONObject(i);
        sourceNode = edge.getJSONObject("sourceNode");
        // getTableName(sourceNode);
        targetNode = edge.getJSONObject("targetNode");
        // getTableName(targetNode);
        linkrule = edge.getJSONObject("linkrule");
        if (linkrule == null) {
            throw new IllegalStateException("linkrule can not be null");
        }
        erRelation = $(edge.getString("id"), df, getTableName(targetNode), getTableName(sourceNode), TabCardinality.parse(linkrule.getString("cardinality")));
        linkKeyList = linkrule.getJSONArray("linkKeyList");
        for (int jj = 0; jj < linkKeyList.size(); jj++) {
            link = linkKeyList.getJSONObject(jj);
            erRelation.addJoinerKey(link.getString("parentKey"), link.getString("childKey"));
        }
        erRules.addRelation(erRelation);
    }
    com.alibaba.fastjson.JSONObject nodeMeta = null;
    com.alibaba.fastjson.JSONObject colTransfer = null;
    DependencyNode dumpNode = null;
    com.alibaba.fastjson.JSONArray columnTransferList = null;
    TabExtraMeta tabMeta = null;
    String sharedKey = null;
    for (int index = 0; index < nodes.size(); index++) {
        nodeTuple = nodes.getJSONObject(index);
        node = nodeTuple.getJSONObject("node");
        ermeta = node.getJSONObject("extraMeta");
        dumpNode = new DependencyNode();
        if (ermeta != null) {
            tabMeta = new TabExtraMeta();
            tabMeta.setPrimaryIndexTab(ermeta.getBoolean("primaryIndexTab"));
            if (tabMeta.isPrimaryIndexTab()) {
                sharedKey = ermeta.getString("sharedKey");
                tabMeta.setSharedKey(sharedKey);
                com.alibaba.fastjson.JSONArray primaryIndexColumnNames = ermeta.getJSONArray("primaryIndexColumnNames");
                com.alibaba.fastjson.JSONObject primaryIndex = null;
                List<PrimaryLinkKey> names = Lists.newArrayList();
                PrimaryLinkKey plinkKey = null;
                for (int i = 0; i < primaryIndexColumnNames.size(); i++) {
                    primaryIndex = primaryIndexColumnNames.getJSONObject(i);
                    plinkKey = new PrimaryLinkKey();
                    plinkKey.setName(primaryIndex.getString("name"));
                    plinkKey.setPk(primaryIndex.getBoolean("pk"));
                    names.add(plinkKey);
                }
                tabMeta.setPrimaryIndexColumnNames(names);
            }
            tabMeta.setMonitorTrigger(ermeta.getBoolean("monitorTrigger"));
            tabMeta.setTimeVerColName(null);
            if (tabMeta.isMonitorTrigger()) {
                tabMeta.setTimeVerColName(ermeta.getString("timeVerColName"));
            }
            columnTransferList = ermeta.getJSONArray("columnTransferList");
            for (int i = 0; i < columnTransferList.size(); i++) {
                colTransfer = columnTransferList.getJSONObject(i);
                tabMeta.addColumnTransfer(new ColumnTransfer(colTransfer.getString("colKey"), colTransfer.getString("transfer"), colTransfer.getString("param")));
            }
            dumpNode.setExtraMeta(tabMeta);
        }
        dumpNode.setId(node.getString("id"));
        nodeMeta = node.getJSONObject("nodeMeta");
        dumpNode.setTabid(nodeMeta.getString("tabid"));
        dumpNode.setDbid(nodeMeta.getString("dbid"));
        Position pos = new Position();
        pos.setX(node.getIntValue("x"));
        pos.setY(node.getIntValue("y"));
        dumpNode.setPosition(pos);
        dumpNode.setName(nodeMeta.getString("tabname"));
        // dumpNode.setExtraSql(nodeMeta.getString("sqlcontent"));
        erRules.addDumpNode(dumpNode);
    }
    List<PrimaryTableMeta> primaryTabs = erRules.getPrimaryTabs();
    if (primaryTabs.size() < 1) {
        this.addErrorMessage(context, "还没有定义ER主索引表");
        return;
    }
    List<PrimaryLinkKey> pkNames = null;
    for (PrimaryTableMeta meta : primaryTabs) {
        if (StringUtils.isEmpty(meta.getSharedKey())) {
            this.addErrorMessage(context, "主索引表:" + meta.getTabName() + " 还未定义分区键");
        }
        pkNames = meta.getPrimaryKeyNames();
        if (pkNames.size() < 1) {
            this.addErrorMessage(context, "主索引表:" + meta.getTabName() + " 还未定义主键");
        }
    }
    if (this.hasErrors(context)) {
        return;
    }
    // File parent = new File(SqlTaskNode.parent, topology);
    // FileUtils.forceMkdir(parent);
    // FileUtils.write(new File(parent, ERRules.ER_RULES_FILE_NAME), ERRules.serialize(erRules), getEncode(), false);
    ERRules.write(topology, erRules);
    // System.out.println(j.toJSONString());
    long wfId = df.getProfile().getDataflowId();
    if (wfId < 1) {
        throw new IllegalStateException("topology '" + topology + "' relevant wfid can not be null");
    }
    WorkFlow wf = new WorkFlow();
    wf.setOpTime(new Date());
    WorkFlowCriteria wfCriteria = new WorkFlowCriteria();
    wfCriteria.createCriteria().andIdEqualTo((int) wfId);
    this.getWorkflowDAOFacade().getWorkFlowDAO().updateByExampleSelective(wf, wfCriteria);
}
Also used : PrimaryTableMeta(com.qlangtech.tis.sql.parser.er.PrimaryTableMeta) TableRelation(com.qlangtech.tis.sql.parser.er.TableRelation) SqlDataFlowTopology(com.qlangtech.tis.sql.parser.SqlTaskNodeMeta.SqlDataFlowTopology) WorkFlow(com.qlangtech.tis.workflow.pojo.WorkFlow) WorkFlowCriteria(com.qlangtech.tis.workflow.pojo.WorkFlowCriteria) ERRules(com.qlangtech.tis.sql.parser.er.ERRules) Func(com.qlangtech.tis.manage.spring.aop.Func)

Aggregations

WorkFlow (com.qlangtech.tis.workflow.pojo.WorkFlow)10 WorkFlowCriteria (com.qlangtech.tis.workflow.pojo.WorkFlowCriteria)5 Func (com.qlangtech.tis.manage.spring.aop.Func)4 Context (com.alibaba.citrus.turbine.Context)2 JSON (com.alibaba.fastjson.JSON)2 JSONArray (com.alibaba.fastjson.JSONArray)2 JSONException (com.alibaba.fastjson.JSONException)2 JSONObject (com.alibaba.fastjson.JSONObject)2 Maps (com.google.common.collect.Maps)2 TIS (com.qlangtech.tis.TIS)2 Assert (com.qlangtech.tis.common.utils.Assert)2 IDataxProcessor (com.qlangtech.tis.datax.IDataxProcessor)2 ISearchEngineTypeTransfer (com.qlangtech.tis.datax.ISearchEngineTypeTransfer)2 DataxProcessor (com.qlangtech.tis.datax.impl.DataxProcessor)2 DataxReader (com.qlangtech.tis.datax.impl.DataxReader)2 LuceneVersion (com.qlangtech.tis.fullbuild.indexbuild.LuceneVersion)2 ISolrAppSource (com.qlangtech.tis.manage.ISolrAppSource)2 PermissionConstant (com.qlangtech.tis.manage.PermissionConstant)2 Savefilecontent (com.qlangtech.tis.manage.Savefilecontent)2 IServerGroupDAO (com.qlangtech.tis.manage.biz.dal.dao.IServerGroupDAO)2