Search in sources :

Example 11 with DataxProcessor

use of com.qlangtech.tis.datax.impl.DataxProcessor in project tis by qlangtech.

the class SchemaAction method doGetEsTplFields.

// private static Logger log = LoggerFactory.getLogger(SchemaAction.class);
/**
 * DataX 创建流程中取得es的默认字段
 *
 * @param context
 * @throws Exception
 */
public void doGetEsTplFields(Context context) throws Exception {
    String dataxName = this.getString(DataxUtils.DATAX_NAME);
    StepType stepType = StepType.parse(this.getString("stepType"));
    // DataxProcessor process = DataxProcessor.load(this, dataxName);
    // IDataxProcessor.TableMap tabMapper = null;
    // ESField field = null;
    ISearchEngineTypeTransfer typeTransfer = ISearchEngineTypeTransfer.load(this, dataxName);
    DataxReader dataxReader = DataxReader.load(this, dataxName);
    // ESField field = null;
    if (stepType.update) {
        DataxProcessor dataxProcessor = DataxProcessor.load(this, dataxName);
        for (Map.Entry<String, IDataxProcessor.TableAlias> e : dataxProcessor.getTabAlias().entrySet()) {
            writerStructFields(context, e.getValue(), typeTransfer);
            return;
        }
    } else {
        for (ISelectedTab tab : dataxReader.getSelectedTabs()) {
            // ESSchema parseResult = new ESSchema();
            SchemaMetaContent tplSchema = typeTransfer.initSchemaMetaContent(tab);
            this.setBizResult(context, tplSchema.toJSON());
            return;
        }
    }
    throw new IllegalStateException("have not find any tab in DataXReader");
}
Also used : IDataxProcessor(com.qlangtech.tis.datax.IDataxProcessor) DataxProcessor(com.qlangtech.tis.datax.impl.DataxProcessor) ISelectedTab(com.qlangtech.tis.plugin.ds.ISelectedTab) ISearchEngineTypeTransfer(com.qlangtech.tis.datax.ISearchEngineTypeTransfer) DataxReader(com.qlangtech.tis.datax.impl.DataxReader)

Example 12 with DataxProcessor

use of com.qlangtech.tis.datax.impl.DataxProcessor in project plugins by qlangtech.

the class HudiSinkFactory method getTableMeta.

private Pair<HudiSelectedTab, HudiTableMeta> getTableMeta(String tableName) {
    if (StringUtils.isEmpty(tableName)) {
        throw new IllegalArgumentException("param tableName can not empty");
    }
    if (tableMetas == null) {
        if (StringUtils.isEmpty(this.dataXName)) {
            throw new IllegalStateException("prop dataXName can not be null");
        }
        tableMetas = Maps.newHashMap();
        DataxProcessor dataXProcessor = DataxProcessor.load(null, this.dataXName);
        IDataxReader reader = dataXProcessor.getReader(null);
        Map<String, HudiSelectedTab> selTabs = reader.getSelectedTabs().stream().map((tab) -> (HudiSelectedTab) tab).collect(Collectors.toMap((tab) -> tab.getName(), (tab) -> tab));
        List<File> dataxCfgFile = dataXProcessor.getDataxCfgFileNames(null);
        Configuration cfg = null;
        Configuration paramCfg = null;
        String table = null;
        HudiTableMeta tableMeta = null;
        for (File f : dataxCfgFile) {
            cfg = Configuration.from(f);
            paramCfg = cfg.getConfiguration("job.content[0].writer.parameter");
            if (paramCfg == null) {
                throw new NullPointerException("paramCfg can not be null,relevant path:" + f.getAbsolutePath());
            }
            table = paramCfg.getString("fileName");
            if (StringUtils.isEmpty(table)) {
                throw new IllegalStateException("table can not be null:" + paramCfg.toJSON());
            }
            tableMetas.put(table, Pair.of(Objects.requireNonNull(selTabs.get(table), "tab:" + table + " relevant 'HudiSelectedTab' can not be null"), new HudiTableMeta(paramCfg)));
        }
    }
    final Pair<HudiSelectedTab, HudiTableMeta> tabMeta = tableMetas.get(tableName);
    if (tabMeta == null || tabMeta.getRight().isColsEmpty()) {
        throw new IllegalStateException("table:" + tableName + " relevant colMetas can not be null,exist tables:" + tableMetas.keySet().stream().collect(Collectors.joining(",")));
    }
    return tabMeta;
}
Also used : StringUtils(org.apache.commons.lang.StringUtils) java.util(java.util) ISelectedTab(com.qlangtech.tis.plugin.ds.ISelectedTab) LoggerFactory(org.slf4j.LoggerFactory) Option(com.qlangtech.tis.manage.common.Option) FormField(com.qlangtech.tis.plugin.annotation.FormField) DTO(com.qlangtech.tis.realtime.transfer.DTO) HudiWriteTabType(com.qlangtech.tis.plugin.datax.hudi.HudiWriteTabType) Context(com.alibaba.citrus.turbine.Context) Configuration(com.alibaba.datax.common.util.Configuration) Lists(com.google.common.collect.Lists) DataxProcessor(com.qlangtech.tis.datax.impl.DataxProcessor) Pair(org.apache.commons.lang3.tuple.Pair) IDataXPluginMeta(com.qlangtech.tis.datax.IDataXPluginMeta) DataXHudiWriter(com.qlangtech.tis.plugin.datax.hudi.DataXHudiWriter) IDataxReader(com.qlangtech.tis.datax.IDataxReader) DataxUtils(com.qlangtech.tis.offline.DataxUtils) Public(org.apache.flink.annotation.Public) IDataxProcessor(com.qlangtech.tis.datax.IDataxProcessor) FormFieldType(com.qlangtech.tis.plugin.annotation.FormFieldType) GroovyShellEvaluate(com.qlangtech.tis.extension.util.GroovyShellEvaluate) Validator(com.qlangtech.tis.plugin.annotation.Validator) TISSinkFactory(com.qlangtech.tis.plugin.incr.TISSinkFactory) HudiTableMeta(com.qlangtech.tis.plugin.datax.hudi.HudiTableMeta) TISExtension(com.qlangtech.tis.extension.TISExtension) Logger(org.slf4j.Logger) BlockScriptBuffer(com.qlangtech.tis.sql.parser.visitor.BlockScriptBuffer) SinkFunction(org.apache.flink.streaming.api.functions.sink.SinkFunction) DataxWriter(com.qlangtech.tis.datax.impl.DataxWriter) HudiSelectedTab(com.qlangtech.tis.plugin.datax.hudi.HudiSelectedTab) CreateTableSqlBuilder(com.qlangtech.tis.plugin.datax.CreateTableSqlBuilder) Maps(com.google.common.collect.Maps) Collectors(java.util.stream.Collectors) File(java.io.File) HdfsColMeta(com.alibaba.datax.plugin.writer.hdfswriter.HdfsColMeta) IParamContext(com.qlangtech.tis.order.center.IParamContext) IExtraHadoopFileSystemGetter(org.apache.hudi.common.fs.IExtraHadoopFileSystemGetter) IControlMsgHandler(com.qlangtech.tis.runtime.module.misc.IControlMsgHandler) DataType(com.qlangtech.tis.plugin.ds.DataType) IHiveConnGetter(com.qlangtech.tis.config.hive.IHiveConnGetter) IStreamTableCreator(com.qlangtech.tis.datax.IStreamTableCreator) HudiSelectedTab(com.qlangtech.tis.plugin.datax.hudi.HudiSelectedTab) Configuration(com.alibaba.datax.common.util.Configuration) HudiTableMeta(com.qlangtech.tis.plugin.datax.hudi.HudiTableMeta) IDataxReader(com.qlangtech.tis.datax.IDataxReader) DataxProcessor(com.qlangtech.tis.datax.impl.DataxProcessor) IDataxProcessor(com.qlangtech.tis.datax.IDataxProcessor) File(java.io.File)

Example 13 with DataxProcessor

use of com.qlangtech.tis.datax.impl.DataxProcessor in project plugins by qlangtech.

the class FlinkTaskNodeController method getIncrJobRecordFile.

private File getIncrJobRecordFile(TargetResName collection) {
    DataxProcessor processor = DataxProcessor.load(null, collection.getName());
    // assertTrue("launchResult must success", launchResult.get());
    // EasyMock.verify(jarLoader);
    File dataXWorkDir = processor.getDataXWorkDir(null);
    return new File(dataXWorkDir, "incrJob.log");
}
Also used : DataxProcessor(com.qlangtech.tis.datax.impl.DataxProcessor) File(java.io.File)

Example 14 with DataxProcessor

use of com.qlangtech.tis.datax.impl.DataxProcessor in project plugins by qlangtech.

the class TestDataXClickhouseWriter method testRealDump.

public void testRealDump() throws Exception {
    ClickHouseTest houseTest = createDataXWriter();
    houseTest.writer.autoCreateTable = true;
    DataxProcessor dataXProcessor = EasyMock.mock("dataXProcessor", DataxProcessor.class);
    File createDDLDir = new File(".");
    File createDDLFile = null;
    try {
        createDDLFile = new File(createDDLDir, targetTableName + IDataxProcessor.DATAX_CREATE_DDL_FILE_NAME_SUFFIX);
        FileUtils.write(createDDLFile, com.qlangtech.tis.extension.impl.IOUtils.loadResourceFromClasspath(DataXClickhouseWriter.class, "create_ddl_customer_order_relation.sql"), TisUTF8.get());
        EasyMock.expect(dataXProcessor.getDataxCreateDDLDir(null)).andReturn(createDDLDir);
        DataxWriter.dataxWriterGetter = (dataXName) -> {
            return houseTest.writer;
        };
        DataxProcessor.processorGetter = (dataXName) -> {
            assertEquals(testDataXName, dataXName);
            return dataXProcessor;
        };
        EasyMock.replay(dataXProcessor);
        DataXClickhouseWriter writer = new DataXClickhouseWriter();
        WriterTemplate.realExecuteDump(clickhouse_datax_writer_assert_without_optional, writer);
        EasyMock.verify(dataXProcessor);
    } finally {
        FileUtils.forceDelete(createDDLFile);
    }
}
Also used : DataxProcessor(com.qlangtech.tis.datax.impl.DataxProcessor) IDataxProcessor(com.qlangtech.tis.datax.IDataxProcessor) File(java.io.File)

Example 15 with DataxProcessor

use of com.qlangtech.tis.datax.impl.DataxProcessor in project plugins by qlangtech.

the class DataXHudiWriter method createPostTask.

@Override
public IRemoteTaskTrigger createPostTask(IExecChainContext execContext, ISelectedTab tab) {
    if (generateCfgs == null) {
        generateCfgs = new AtomicReference<>();
    }
    DataXCfgGenerator.GenerateCfgs genCfg = generateCfgs.updateAndGet((pre) -> {
        if (pre == null) {
            if (dataXName == null) {
                throw new IllegalStateException("prop dataXName can not be null");
            }
            DataxProcessor dataxProcessor = DataxProcessor.load(null, dataXName);
            pre = DataXCfgGenerator.GenerateCfgs.readFromGen(dataxProcessor.getDataxCfgDir(null));
            logger.info("create GenerateCfgs with genTime:" + pre.getGenTime());
            return pre;
        }
        return pre;
    });
    return new HudiDumpPostTask(execContext, (HudiSelectedTab) tab, this, genCfg);
}
Also used : DataxProcessor(com.qlangtech.tis.datax.impl.DataxProcessor) IDataxProcessor(com.qlangtech.tis.datax.IDataxProcessor) DataXCfgGenerator(com.qlangtech.tis.datax.impl.DataXCfgGenerator)

Aggregations

DataxProcessor (com.qlangtech.tis.datax.impl.DataxProcessor)18 File (java.io.File)11 IDataxProcessor (com.qlangtech.tis.datax.IDataxProcessor)9 Lists (com.google.common.collect.Lists)3 ISelectedTab (com.qlangtech.tis.plugin.ds.ISelectedTab)3 Collectors (java.util.stream.Collectors)3 Maps (com.google.common.collect.Maps)2 IHiveConnGetter (com.qlangtech.tis.config.hive.IHiveConnGetter)2 DataXJobSubmit (com.qlangtech.tis.datax.DataXJobSubmit)2 IDataxReader (com.qlangtech.tis.datax.IDataxReader)2 DataXCfgGenerator (com.qlangtech.tis.datax.impl.DataXCfgGenerator)2 DataxReader (com.qlangtech.tis.datax.impl.DataxReader)2 DataxWriter (com.qlangtech.tis.datax.impl.DataxWriter)2 IExecChainContext (com.qlangtech.tis.exec.IExecChainContext)2 IRemoteTaskTrigger (com.qlangtech.tis.fullbuild.indexbuild.IRemoteTaskTrigger)2 IAppSource (com.qlangtech.tis.manage.IAppSource)2 java.util (java.util)2 Test (org.junit.Test)2 Logger (org.slf4j.Logger)2 LoggerFactory (org.slf4j.LoggerFactory)2