Search in sources :

Example 1 with DefaultSparkConnGetter

use of com.qlangtech.tis.config.spark.impl.DefaultSparkConnGetter in project plugins by qlangtech.

the class TestDataXHudiWriter method createDataXWriter.

private static HudiTest createDataXWriter(Optional<FileSystemFactory> fsFactory) {
    final DefaultSparkConnGetter sparkConnGetter = new DefaultSparkConnGetter();
    sparkConnGetter.name = "default";
    sparkConnGetter.master = "spark://sparkmaster:7077";
    DataXHudiWriter writer = new DataXHudiWriter() {

        @Override
        public Class<?> getOwnerClass() {
            return DataXHudiWriter.class;
        }

        @Override
        public IHiveConnGetter getHiveConnMeta() {
            return HdfsFileSystemFactoryTestUtils.createHiveConnGetter();
        }

        @Override
        public ISparkConnGetter getSparkConnGetter() {
            return sparkConnGetter;
        }

        @Override
        public FileSystemFactory getFs() {
            return fsFactory.isPresent() ? fsFactory.get() : HdfsFileSystemFactoryTestUtils.getFileSystemFactory();
        }
    };
    writer.template = DataXHudiWriter.getDftTemplate();
    writer.fsName = HdfsFileSystemFactoryTestUtils.FS_NAME;
    writer.setKey(new KeyedPluginStore.Key(null, HdfsFileSystemFactoryTestUtils.testDataXName.getName(), null));
    writer.tabType = HudiWriteTabType.COW.getValue();
    writer.batchOp = BatchOpMode.BULK_INSERT.getValue();
    writer.shuffleParallelism = 3;
    writer.partitionedBy = "pt";
    // writer.batchByteSize = 3456;
    // writer.batchSize = 9527;
    // writer.dbName = dbName;
    writer.writeMode = "insert";
    // writer.autoCreateTable = true;
    // writer.postSql = "drop table @table";
    // writer.preSql = "drop table @table";
    // writer.dataXName = HdfsFileSystemFactoryTestUtils.testDataXName.getName();
    // writer.dbName = dbName;
    // HudiSelectedTab hudiTab = new HudiSelectedTab() {
    // @Override
    // public List<ColMeta> getCols() {
    // return WriterTemplate.createColMetas();
    // }
    // };
    // //hudiTab.partitionPathField = WriterTemplate.kind;
    // hudiTab.recordField = WriterTemplate.customerregisterId;
    // hudiTab.sourceOrderingField = WriterTemplate.lastVer;
    // hudiTab.setWhere("1=1");
    // hudiTab.name = WriterTemplate.TAB_customer_order_relation;
    List<HdfsColMeta> colsMeta = HdfsColMeta.getColsMeta(Configuration.from(IOUtils.loadResourceFromClasspath(writer.getClass(), hudi_datax_writer_assert_without_optional)).getConfiguration(cfgPathParameter));
    HudiSelectedTab tab = new HudiSelectedTab() {

        @Override
        public List<ColMeta> getCols() {
            return colsMeta.stream().map((c) -> {
                ColMeta col = new ColMeta();
                col.setName(c.getName());
                col.setPk(c.pk);
                col.setType(c.type);
                col.setNullable(c.nullable);
                return col;
            }).collect(Collectors.toList());
        }
    };
    tab.name = WriterTemplate.TAB_customer_order_relation;
    tab.partition = new OffPartition();
    tab.sourceOrderingField = "last_ver";
    tab.recordField = "customerregister_id";
    return new HudiTest(writer, WriterTemplate.createCustomer_order_relationTableMap(Optional.of(tab)), tab);
}
Also used : DefaultSparkConnGetter(com.qlangtech.tis.config.spark.impl.DefaultSparkConnGetter) IExecChainContext(com.qlangtech.tis.exec.IExecChainContext) TISCollectionUtils(com.qlangtech.tis.manage.common.TISCollectionUtils) BeforeClass(org.junit.BeforeClass) HudiWriter(com.alibaba.datax.plugin.writer.hudi.HudiWriter) TargetResName(com.qlangtech.tis.coredefine.module.action.TargetResName) Configuration(com.alibaba.datax.common.util.Configuration) ISparkConnGetter(com.qlangtech.tis.config.spark.ISparkConnGetter) Lists(com.google.common.collect.Lists) CenterResource(com.qlangtech.tis.manage.common.CenterResource) DataxProcessor(com.qlangtech.tis.datax.impl.DataxProcessor) HdfsPath(com.qlangtech.tis.hdfs.impl.HdfsPath) IHiveMetaStore(com.qlangtech.tis.config.hive.meta.IHiveMetaStore) TisUTF8(com.qlangtech.tis.manage.common.TisUTF8) DataxUtils(com.qlangtech.tis.offline.DataxUtils) IDataxProcessor(com.qlangtech.tis.datax.IDataxProcessor) KeyedPluginStore(com.qlangtech.tis.plugin.KeyedPluginStore) ITISFileSystem(com.qlangtech.tis.fs.ITISFileSystem) OffPartition(com.qlangtech.tis.plugin.datax.hudi.partition.OffPartition) DataXCfgGenerator(com.qlangtech.tis.datax.impl.DataXCfgGenerator) HdfsFileSystemFactoryTestUtils(com.qlangtech.tis.hdfs.test.HdfsFileSystemFactoryTestUtils) IStreamIncrGenerateStrategy(com.qlangtech.tis.sql.parser.tuple.creator.IStreamIncrGenerateStrategy) IPath(com.qlangtech.tis.fs.IPath) EntityName(com.qlangtech.tis.sql.parser.tuple.creator.EntityName) DataxWriter(com.qlangtech.tis.datax.impl.DataxWriter) FileUtils(org.apache.commons.io.FileUtils) Test(org.junit.Test) EasyMock(org.easymock.EasyMock) Collectors(java.util.stream.Collectors) FileSystemFactory(com.qlangtech.tis.offline.FileSystemFactory) File(java.io.File) HdfsColMeta(com.alibaba.datax.plugin.writer.hdfswriter.HdfsColMeta) IParamContext(com.qlangtech.tis.order.center.IParamContext) List(java.util.List) IOUtils(com.qlangtech.tis.extension.impl.IOUtils) Rule(org.junit.Rule) MDC(org.slf4j.MDC) HiveTable(com.qlangtech.tis.config.hive.meta.HiveTable) IHiveConnGetter(com.qlangtech.tis.config.hive.IHiveConnGetter) Optional(java.util.Optional) Assert(org.junit.Assert) WriterTemplate(com.qlangtech.tis.plugin.common.WriterTemplate) Collections(java.util.Collections) TemporaryFolder(org.junit.rules.TemporaryFolder) HdfsColMeta(com.alibaba.datax.plugin.writer.hdfswriter.HdfsColMeta) HdfsColMeta(com.alibaba.datax.plugin.writer.hdfswriter.HdfsColMeta) OffPartition(com.qlangtech.tis.plugin.datax.hudi.partition.OffPartition) KeyedPluginStore(com.qlangtech.tis.plugin.KeyedPluginStore) DefaultSparkConnGetter(com.qlangtech.tis.config.spark.impl.DefaultSparkConnGetter)

Aggregations

Configuration (com.alibaba.datax.common.util.Configuration)1 HdfsColMeta (com.alibaba.datax.plugin.writer.hdfswriter.HdfsColMeta)1 HudiWriter (com.alibaba.datax.plugin.writer.hudi.HudiWriter)1 Lists (com.google.common.collect.Lists)1 IHiveConnGetter (com.qlangtech.tis.config.hive.IHiveConnGetter)1 HiveTable (com.qlangtech.tis.config.hive.meta.HiveTable)1 IHiveMetaStore (com.qlangtech.tis.config.hive.meta.IHiveMetaStore)1 ISparkConnGetter (com.qlangtech.tis.config.spark.ISparkConnGetter)1 DefaultSparkConnGetter (com.qlangtech.tis.config.spark.impl.DefaultSparkConnGetter)1 TargetResName (com.qlangtech.tis.coredefine.module.action.TargetResName)1 IDataxProcessor (com.qlangtech.tis.datax.IDataxProcessor)1 DataXCfgGenerator (com.qlangtech.tis.datax.impl.DataXCfgGenerator)1 DataxProcessor (com.qlangtech.tis.datax.impl.DataxProcessor)1 DataxWriter (com.qlangtech.tis.datax.impl.DataxWriter)1 IExecChainContext (com.qlangtech.tis.exec.IExecChainContext)1 IOUtils (com.qlangtech.tis.extension.impl.IOUtils)1 IPath (com.qlangtech.tis.fs.IPath)1 ITISFileSystem (com.qlangtech.tis.fs.ITISFileSystem)1 HdfsPath (com.qlangtech.tis.hdfs.impl.HdfsPath)1 HdfsFileSystemFactoryTestUtils (com.qlangtech.tis.hdfs.test.HdfsFileSystemFactoryTestUtils)1