Search in sources :

Example 6 with DataxReader

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

the class OfflineManager method getDbConfig.

public DBConfigSuit getDbConfig(IPluginContext pluginContext, DatasourceDb db) {
    Objects.requireNonNull(db, "instance of DatasourceDb can not be null");
    DBDataXReaderDescName dbDataXReaderDesc = this.getDBDataXReaderDescName(db.getName());
    DataxReader dbDataxReader = null;
    if (dbDataXReaderDesc.isSupportDataXReader()) {
        dbDataxReader = getDBDataxReader(pluginContext, db.getName());
    }
    DBConfigSuit dbSuit = new DBConfigSuit(db, dbDataXReaderDesc.isSupportDataXReader(), dbDataxReader != null);
    if (dbDataxReader != null) {
        List<ISelectedTab> selectedTabs = dbDataxReader.getSelectedTabs();
        dbSuit.addTabs(selectedTabs.stream().map((t) -> t.getName()).collect(Collectors.toList()));
    }
    PostedDSProp dbProp = new PostedDSProp(db.getName(), DbScope.DETAILED);
    IPluginStore<DataSourceFactory> dbStore = TIS.getDataBasePluginStore(dbProp);
    DataSourceFactory dsPlugin = dbStore.getPlugin();
    dbSuit.setDetailed(dsPlugin);
    DataSourceFactoryPluginStore facadeStore = TIS.getDataBasePluginStore(new PostedDSProp(db.getName(), DbScope.FACADE));
    if (facadeStore.getPlugin() != null) {
        dbSuit.setFacade(facadeStore.getPlugin());
    }
    return dbSuit;
}
Also used : DBConfigSuit(com.qlangtech.tis.db.parser.DBConfigSuit) DataxReader(com.qlangtech.tis.datax.impl.DataxReader)

Example 7 with DataxReader

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

the class DataxExecutor method startWork.

/**
 * 开始执行数据同步任务
 *
 * @param dataxName
 * @throws IOException
 * @throws Exception
 */
public void startWork(String dataxName, Integer jobId, String jobName, String execTimeStamp, IDataxProcessor dataxProcessor, final JarLoader uberClassLoader) throws IOException, Exception {
    try {
        Objects.requireNonNull(dataxProcessor, "dataxProcessor can not be null");
        KeyedPluginStore<DataxReader> readerStore = DataxReader.getPluginStore(null, dataxName);
        KeyedPluginStore<DataxWriter> writerStore = DataxWriter.getPluginStore(null, dataxName);
        File jobPath = new File(dataxProcessor.getDataxCfgDir(null), jobName);
        ;
        DataxReader reader = readerStore.getPlugin();
        Objects.requireNonNull(reader, "dataxName:" + dataxName + " relevant reader can not be null");
        DataxWriter writer = writerStore.getPlugin();
        Objects.requireNonNull(writer, "dataxName:" + dataxName + " relevant writer can not be null");
        this.readerMeta = reader.getDataxMeta();
        this.writerMeta = writer.getDataxMeta();
        Objects.requireNonNull(readerMeta, "readerMeta can not be null");
        Objects.requireNonNull(writerMeta, "writerMeta can not be null");
        initializeClassLoader(Sets.newHashSet(this.getPluginReaderKey(), this.getPluginWriterKey()), uberClassLoader);
        entry(new DataXJobArgs(jobPath, jobId, "standalone", execTimeStamp), jobName);
    } catch (Throwable e) {
        throw new Exception(e);
    } finally {
        cleanPerfTrace();
    }
}
Also used : DataxWriter(com.qlangtech.tis.datax.impl.DataxWriter) DataxReader(com.qlangtech.tis.datax.impl.DataxReader) File(java.io.File) DataXException(com.alibaba.datax.common.exception.DataXException) IOException(java.io.IOException)

Example 8 with DataxReader

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

the class CoreAction method doGetDataXReaderWriterDesc.

private static IndexIncrStatus doGetDataXReaderWriterDesc(String appName) throws Exception {
    IndexIncrStatus incrStatus = new IndexIncrStatus();
    DataxProcessor dataxProcessor = DataxProcessor.load(null, appName);
    DataxWriter writer = (DataxWriter) dataxProcessor.getWriter(null);
    incrStatus.setWriterDesc(createDescVals(writer.getDescriptor()));
    DataxReader reader = (DataxReader) dataxProcessor.getReader(null);
    incrStatus.setReaderDesc(createDescVals(reader.getDescriptor()));
    return incrStatus;
}
Also used : DataxProcessor(com.qlangtech.tis.datax.impl.DataxProcessor) DataxWriter(com.qlangtech.tis.datax.impl.DataxWriter) DataxReader(com.qlangtech.tis.datax.impl.DataxReader)

Example 9 with DataxReader

use of com.qlangtech.tis.datax.impl.DataxReader 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 10 with DataxReader

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

the class TISFlinkCDCStart method deploy.

private static void deploy(TargetResName dataxName, BasicFlinkSourceHandle tableStreamHandle, ReplicasSpec incrSpec, long timestamp) throws Exception {
    // BasicFlinkSourceHandle tisFlinkSourceHandle = new TISFlinkSourceHandle();
    if (tableStreamHandle == null) {
        throw new IllegalStateException("tableStreamHandle has not been instantiated");
    }
    // ElasticSearchSinkFactory esSinkFactory = new ElasticSearchSinkFactory();
    // IPluginContext pluginContext = IPluginContext.namedContext(dataxName.getName());
    // List<TISSinkFactory> sinkFactories = TISSinkFactory.sinkFactory.getPlugins(pluginContext, null);
    // logger.info("sinkFactories size:" + sinkFactories.size());
    // for (TISSinkFactory factory : sinkFactories) {
    // sinkFactory = factory;
    // break;
    // }
    // Objects.requireNonNull(sinkFactory, "sinkFactories.size():" + sinkFactories.size());
    tableStreamHandle.setSinkFuncFactory(TISSinkFactory.getIncrSinKFactory(dataxName.getName()));
    // List<MQListenerFactory> mqFactories = HeteroEnum.MQ.getPlugins(pluginContext, null);
    MQListenerFactory mqFactory = HeteroEnum.getIncrSourceListenerFactory(dataxName.getName());
    mqFactory.setConsumerHandle(tableStreamHandle);
    // for (MQListenerFactory factory : mqFactories) {
    // factory.setConsumerHandle(tableStreamHandle);
    // mqFactory = factory;
    // }
    // Objects.requireNonNull(mqFactory, "mqFactory can not be null, mqFactories size:" + mqFactories.size());
    IMQListener mq = mqFactory.create();
    IDataxProcessor dataXProcess = DataxProcessor.load(null, dataxName.getName());
    DataxReader reader = (DataxReader) dataXProcess.getReader(null);
    if (reader == null) {
        throw new IllegalStateException("dataXReader is illegal");
    }
    // DBConfigGetter rdbmsReader = (DBConfigGetter) reader;
    List<ISelectedTab> tabs = reader.getSelectedTabs();
    mq.start(dataxName, reader, tabs, dataXProcess);
}
Also used : MQListenerFactory(com.qlangtech.tis.async.message.client.consumer.impl.MQListenerFactory) ISelectedTab(com.qlangtech.tis.plugin.ds.ISelectedTab) IDataxProcessor(com.qlangtech.tis.datax.IDataxProcessor) DataxReader(com.qlangtech.tis.datax.impl.DataxReader) IMQListener(com.qlangtech.tis.async.message.client.consumer.IMQListener)

Aggregations

DataxReader (com.qlangtech.tis.datax.impl.DataxReader)22 ISelectedTab (com.qlangtech.tis.plugin.ds.ISelectedTab)7 File (java.io.File)7 DescriptorsJSON (com.qlangtech.tis.util.DescriptorsJSON)6 Collectors (java.util.stream.Collectors)6 Lists (com.google.common.collect.Lists)5 PluginFormProperties (com.qlangtech.tis.extension.PluginFormProperties)5 SuFormProperties (com.qlangtech.tis.extension.impl.SuFormProperties)5 JsonUtil (com.qlangtech.tis.trigger.util.JsonUtil)5 JSONObject (com.alibaba.fastjson.JSONObject)4 IDataxProcessor (com.qlangtech.tis.datax.IDataxProcessor)4 DataxProcessor (com.qlangtech.tis.datax.impl.DataxProcessor)4 DataxWriter (com.qlangtech.tis.datax.impl.DataxWriter)4 Descriptor (com.qlangtech.tis.extension.Descriptor)4 IOException (java.io.IOException)4 List (java.util.List)4 Optional (java.util.Optional)4 TestCase (junit.framework.TestCase)4 FileUtils (org.apache.commons.io.FileUtils)4 EasyMock (org.easymock.EasyMock)4