Search in sources :

Example 1 with DependencyNode

use of com.qlangtech.tis.sql.parser.meta.DependencyNode in project plugins by qlangtech.

the class HiveTask method validateDependenciesNode.

protected void validateDependenciesNode(String taskname) {
    Boolean dependencyWorkStatus = null;
    final List<DependencyNodeStatus> lackDependencies = Lists.newArrayList();
    for (DependencyNode depenency : this.nodeMeta.getDependencies()) {
        dependencyWorkStatus = this.getTaskWorkStatus().get(depenency.getId());
        if (dependencyWorkStatus == null || !dependencyWorkStatus) {
            lackDependencies.add(new DependencyNodeStatus(depenency, dependencyWorkStatus));
        }
    }
    if (!lackDependencies.isEmpty()) {
        // 说明有依赖到的node没有被执行
        throw new IllegalStateException("taskname:" + taskname + " lackDependencies:" + lackDependencies.stream().map((r) -> "(" + r.taskNode.getId() + "," + r.taskNode.parseEntityName() + ",status:" + (r.dependencyWorkStatus == null ? "notExecute" : r.dependencyWorkStatus) + ")").collect(Collectors.joining()) + "/n TaskWorkStatus:" + this.getTaskWorkStatus().entrySet().stream().map((e) -> "[" + e.getKey() + "->" + e.getValue() + "]").collect(Collectors.joining(",")));
    }
}
Also used : IDumpTable(com.qlangtech.tis.fullbuild.indexbuild.IDumpTable) ITabPartition(com.qlangtech.tis.fullbuild.indexbuild.ITabPartition) DependencyNode(com.qlangtech.tis.sql.parser.meta.DependencyNode) HiveRemoveHistoryDataTask(com.qlangtech.tis.dump.hive.HiveRemoveHistoryDataTask) Logger(org.slf4j.Logger) Connection(java.sql.Connection) EntityName(com.qlangtech.tis.sql.parser.tuple.creator.EntityName) IAliasTable(com.qlangtech.tis.sql.parser.IAliasTable) TabPartitions(com.qlangtech.tis.sql.parser.TabPartitions) LoggerFactory(org.slf4j.LoggerFactory) IJoinTaskStatus(com.qlangtech.tis.fullbuild.phasestatus.IJoinTaskStatus) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) List(java.util.List) Lists(com.google.common.collect.Lists) ISqlTask(com.qlangtech.tis.sql.parser.ISqlTask) ERRules(com.qlangtech.tis.sql.parser.er.ERRules) IPrimaryTabFinder(com.qlangtech.tis.sql.parser.er.IPrimaryTabFinder) Map(java.util.Map) FullbuildPhase(com.qlangtech.tis.assemble.FullbuildPhase) AdapterTask(com.qlangtech.tis.fullbuild.taskflow.AdapterTask) Joiner(com.google.common.base.Joiner) HiveDBUtils(com.qlangtech.tis.dump.hive.HiveDBUtils) DependencyNode(com.qlangtech.tis.sql.parser.meta.DependencyNode)

Example 2 with DependencyNode

use of com.qlangtech.tis.sql.parser.meta.DependencyNode in project tis by qlangtech.

the class ERRules method hasSetTimestampVerColumn.

public boolean hasSetTimestampVerColumn(EntityName tableName) {
    DependencyNode dumpNode = getDumpNode(tableName);
    TabExtraMeta extraMeta = dumpNode.getExtraMeta();
    return extraMeta == null && StringUtils.isNotEmpty(extraMeta.getTimeVerColName());
}
Also used : TabExtraMeta(com.qlangtech.tis.sql.parser.meta.TabExtraMeta) DependencyNode(com.qlangtech.tis.sql.parser.meta.DependencyNode)

Example 3 with DependencyNode

use of com.qlangtech.tis.sql.parser.meta.DependencyNode in project tis by qlangtech.

the class ERRules method createDefaultErRule.

/**
 * 使用默认DumpNode创建ERRule并且持久化
 *
 * @param topology
 * @throws Exception
 */
public static void createDefaultErRule(SqlTaskNodeMeta.SqlDataFlowTopology topology) throws Exception {
    // 还没有定义erRule
    DependencyNode dumpNode = topology.getFirstDumpNode();
    DataSourceFactoryPluginStore dsStore = TIS.getDataBasePluginStore(new PostedDSProp(dumpNode.getDbName()));
    TISTable tab = dsStore.loadTableMeta(dumpNode.getName());
    // String topologyName, DependencyNode node, TargetColumnMeta targetColMetas
    Optional<ColumnMetaData> firstPK = tab.getReflectCols().stream().filter((col) -> col.isPk()).findFirst();
    if (!firstPK.isPresent()) {
        throw new IllegalStateException("table:" + dumpNode.parseEntityName() + " can not find relevant PK cols");
    }
    createErRule(topology.getName(), dumpNode, firstPK.get());
}
Also used : IDumpTable(com.qlangtech.tis.fullbuild.indexbuild.IDumpTable) StringUtils(org.apache.commons.lang.StringUtils) SqlTaskNode(com.qlangtech.tis.sql.parser.SqlTaskNode) TabExtraMeta(com.qlangtech.tis.sql.parser.meta.TabExtraMeta) DataSourceFactoryPluginStore(com.qlangtech.tis.plugin.ds.DataSourceFactoryPluginStore) TIS(com.qlangtech.tis.TIS) JSONField(com.alibaba.fastjson.annotation.JSONField) PostedDSProp(com.qlangtech.tis.plugin.ds.PostedDSProp) ColumnMetaData(com.qlangtech.tis.plugin.ds.ColumnMetaData) TISTable(com.qlangtech.tis.plugin.ds.TISTable) Yaml(org.yaml.snakeyaml.Yaml) DumperOptions(org.yaml.snakeyaml.DumperOptions) Node(org.yaml.snakeyaml.nodes.Node) Lists(com.google.common.collect.Lists) CenterResource(com.qlangtech.tis.manage.common.CenterResource) Map(java.util.Map) PrimaryLinkKey(com.qlangtech.tis.sql.parser.meta.PrimaryLinkKey) TisUTF8(com.qlangtech.tis.manage.common.TisUTF8) DependencyNode(com.qlangtech.tis.sql.parser.meta.DependencyNode) EntityName(com.qlangtech.tis.sql.parser.tuple.creator.EntityName) Constructor(org.yaml.snakeyaml.constructor.Constructor) Property(org.yaml.snakeyaml.introspector.Property) FileUtils(org.apache.commons.io.FileUtils) Tag(org.yaml.snakeyaml.nodes.Tag) Collectors(java.util.stream.Collectors) File(java.io.File) NodeTuple(org.yaml.snakeyaml.nodes.NodeTuple) Objects(java.util.Objects) List(java.util.List) Representer(org.yaml.snakeyaml.representer.Representer) Optional(java.util.Optional) TypeDescription(org.yaml.snakeyaml.TypeDescription) SqlTaskNodeMeta(com.qlangtech.tis.sql.parser.SqlTaskNodeMeta) PostedDSProp(com.qlangtech.tis.plugin.ds.PostedDSProp) DependencyNode(com.qlangtech.tis.sql.parser.meta.DependencyNode) DataSourceFactoryPluginStore(com.qlangtech.tis.plugin.ds.DataSourceFactoryPluginStore) TISTable(com.qlangtech.tis.plugin.ds.TISTable) ColumnMetaData(com.qlangtech.tis.plugin.ds.ColumnMetaData)

Example 4 with DependencyNode

use of com.qlangtech.tis.sql.parser.meta.DependencyNode in project tis by qlangtech.

the class ERRules method getAllParent.

/**
 * 取得表的所有主表信息
 *
 * @param
 * @return
 */
public List<TableRelation> getAllParent(EntityName entityName) {
    List<TableRelation> parentRefs = Lists.newArrayList();
    DependencyNode child;
    TableRelation resultRel = null;
    for (TableRelation relation : this.getRelationList()) {
        child = relation.getChild();
        if (StringUtils.equals(child.getName(), entityName.getTabName())) {
            resultRel = relation;
            parentRefs.add(resultRel);
        }
    }
    return parentRefs;
}
Also used : DependencyNode(com.qlangtech.tis.sql.parser.meta.DependencyNode)

Example 5 with DependencyNode

use of com.qlangtech.tis.sql.parser.meta.DependencyNode in project tis by qlangtech.

the class SingleTableAppSource method getProcessDataResults.

@Override
public ExecuteResult getProcessDataResults(IExecChainContext execChainContext, ISingleTableDumpFactory singleTableDumpFactory, IDataProcessFeedback dataProcessFeedback, ITaskPhaseInfo taskPhaseInfo) throws Exception {
    // 复杂数据导出
    DumpPhaseStatus dumpPhaseStatus = taskPhaseInfo.getPhaseStatus(execChainContext, FullbuildPhase.FullDump);
    DataflowTask tabDump = null;
    DependencyNode dump = new DependencyNode();
    dump.setId(db.getName() + "." + tabName);
    dump.setName(tabName);
    dump.setDbName(db.getName());
    dump.setTabid(String.valueOf(tabId));
    dump.setDbid(String.valueOf(db.getId()));
    // for (DependencyNode dump : topology.getDumpNodes()) {
    tabDump = singleTableDumpFactory.createSingleTableDump(dump, false, /* isHasValidTableDump */
    "tableDump.getPt()", execChainContext.getZkClient(), execChainContext, dumpPhaseStatus);
    tabDump.run();
    return ExecuteResult.SUCCESS;
}
Also used : DependencyNode(com.qlangtech.tis.sql.parser.meta.DependencyNode) DataflowTask(com.qlangtech.tis.fullbuild.taskflow.DataflowTask) DumpPhaseStatus(com.qlangtech.tis.fullbuild.phasestatus.impl.DumpPhaseStatus)

Aggregations

DependencyNode (com.qlangtech.tis.sql.parser.meta.DependencyNode)16 SqlTaskNodeMeta (com.qlangtech.tis.sql.parser.SqlTaskNodeMeta)5 EntityName (com.qlangtech.tis.sql.parser.tuple.creator.EntityName)5 TabExtraMeta (com.qlangtech.tis.sql.parser.meta.TabExtraMeta)3 Lists (com.google.common.collect.Lists)2 IDumpTable (com.qlangtech.tis.fullbuild.indexbuild.IDumpTable)2 DumpPhaseStatus (com.qlangtech.tis.fullbuild.phasestatus.impl.DumpPhaseStatus)2 DataflowTask (com.qlangtech.tis.fullbuild.taskflow.DataflowTask)2 File (java.io.File)2 List (java.util.List)2 Map (java.util.Map)2 Objects (java.util.Objects)2 Collectors (java.util.stream.Collectors)2 JSONField (com.alibaba.fastjson.annotation.JSONField)1 Joiner (com.google.common.base.Joiner)1 TIS (com.qlangtech.tis.TIS)1 FullbuildPhase (com.qlangtech.tis.assemble.FullbuildPhase)1 HiveDBUtils (com.qlangtech.tis.dump.hive.HiveDBUtils)1 HiveRemoveHistoryDataTask (com.qlangtech.tis.dump.hive.HiveRemoveHistoryDataTask)1 ExecuteResult (com.qlangtech.tis.exec.ExecuteResult)1