Search in sources :

Example 11 with ITISFileSystem

use of com.qlangtech.tis.fs.ITISFileSystem in project plugins by qlangtech.

the class HudiDumpPostTask method run.

@Override
public void run() {
    ITISFileSystem fs = this.hudiWriter.getFs().getFileSystem();
    IPath dumpDir = HudiTableMeta.getDumpDir(fs, this.hudiTab.getName(), execContext.getPartitionTimestamp(), this.hiveConnMeta);
    IPath fsSourcePropsPath = fs.getPath(dumpDir, "meta/" + this.hudiTab.getName() + "-source.properties");
    try {
        this.writeSourceProps(fs, dumpDir, fsSourcePropsPath);
        this.launchSparkRddConvert(fs, dumpDir, fsSourcePropsPath);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : IPath(com.qlangtech.tis.fs.IPath) ITISFileSystem(com.qlangtech.tis.fs.ITISFileSystem) IOException(java.io.IOException) TisException(com.qlangtech.tis.lang.TisException)

Example 12 with ITISFileSystem

use of com.qlangtech.tis.fs.ITISFileSystem in project plugins by qlangtech.

the class HudiTableMeta method getHistoryBatchs.

public static List<Option> getHistoryBatchs(ITISFileSystem fs, IHiveConnGetter hiveConn) {
    IPath path = fs.getPath(fs.getRootDir(), hiveConn.getDbName());
    List<IPathInfo> child = fs.listChildren(path);
    return child.stream().map((c) -> new Option(c.getName())).collect(Collectors.toList());
}
Also used : IPathInfo(com.qlangtech.tis.fs.IPathInfo) OutputStream(java.io.OutputStream) IPath(com.qlangtech.tis.fs.IPath) Schema(org.apache.avro.Schema) ISelectedTab(com.qlangtech.tis.plugin.ds.ISelectedTab) Option(com.qlangtech.tis.manage.common.Option) IPathInfo(com.qlangtech.tis.fs.IPathInfo) BasicHdfsWriterJob(com.qlangtech.tis.plugin.datax.BasicHdfsWriterJob) Collectors(java.util.stream.Collectors) Key(com.alibaba.datax.plugin.writer.hdfswriter.Key) Configuration(com.alibaba.datax.common.util.Configuration) HdfsWriterErrorCode(com.alibaba.datax.plugin.writer.hdfswriter.HdfsWriterErrorCode) SchemaBuilder(org.apache.avro.SchemaBuilder) HdfsColMeta(com.alibaba.datax.plugin.writer.hdfswriter.HdfsColMeta) IOUtils(org.apache.commons.io.IOUtils) List(java.util.List) LogicalTypes(org.apache.avro.LogicalTypes) CollectionUtils(org.apache.commons.collections.CollectionUtils) DataType(com.qlangtech.tis.plugin.ds.DataType) IHiveConnGetter(com.qlangtech.tis.config.hive.IHiveConnGetter) TisUTF8(com.qlangtech.tis.manage.common.TisUTF8) DataxUtils(com.qlangtech.tis.offline.DataxUtils) ITISFileSystem(com.qlangtech.tis.fs.ITISFileSystem) IPath(com.qlangtech.tis.fs.IPath) Option(com.qlangtech.tis.manage.common.Option)

Example 13 with ITISFileSystem

use of com.qlangtech.tis.fs.ITISFileSystem in project plugins by qlangtech.

the class TestDataXHdfsWriter method testdataDump.

// @Test
public void testdataDump() throws Exception {
    // final DataxWriter dataxWriter = DataxWriter.load(null, mysql2hdfsDataXName);
    HdfsFileSystemFactory fsFactory = HdfsFileSystemFactoryTestUtils.getFileSystemFactory();
    ITISFileSystem fileSystem = fsFactory.getFileSystem();
    // assertNotNull("fileSystem can not be null", fileSystem);
    // new Path(fsFactory.rootDir
    // , this.cfg.getNecessaryValue(Key.PATH, HdfsWriterErrorCode.REQUIRED_VALUE));
    // 
    // fileSystem.getPath("");
    HdfsPath p = new HdfsPath(fsFactory.rootDir + "/tis/order");
    HdfsPath subWriterPath = new HdfsPath(p, "test");
    try (TISFSDataOutputStream outputStream = fileSystem.create(subWriterPath, true)) {
        org.apache.commons.io.IOUtils.write(IOUtils.loadResourceFromClasspath(DataXHdfsWriter.class, "hdfs-datax-writer-assert-without-option-val.json"), outputStream, TisUTF8.get());
    }
    System.out.println("write file success");
    List<IPathInfo> iPathInfos = fileSystem.listChildren(p);
    for (IPathInfo child : iPathInfos) {
        fileSystem.delete(child.getPath(), true);
    }
    final DataXHdfsWriter hdfsWriter = new DataXHdfsWriter() {

        @Override
        public FileSystemFactory getFs() {
            return fsFactory;
        }

        @Override
        public Class<?> getOwnerClass() {
            return DataXHdfsWriter.class;
        }
    };
    DataxWriter.dataxWriterGetter = (name) -> {
        assertEquals("mysql2hdfs", name);
        return hdfsWriter;
    };
    // IPath path = fileSystem.getPath(fileSystem.getPath(fileSystem.getRootDir()), hdfsRelativePath);
    // System.out.println("clear path:" + path);
    // fileSystem.delete(path, true);
    // 
    WriterTemplate.realExecuteDump("hdfs-datax-writer-assert-without-option-val.json", hdfsWriter);
}
Also used : IPathInfo(com.qlangtech.tis.fs.IPathInfo) HdfsPath(com.qlangtech.tis.hdfs.impl.HdfsPath) ITISFileSystem(com.qlangtech.tis.fs.ITISFileSystem) TISFSDataOutputStream(com.qlangtech.tis.fs.TISFSDataOutputStream) HdfsFileSystemFactory(com.qlangtech.tis.hdfs.impl.HdfsFileSystemFactory)

Example 14 with ITISFileSystem

use of com.qlangtech.tis.fs.ITISFileSystem in project tis by qlangtech.

the class MockTest method testMock.

public void testMock() {
    final String fsPath = "/user/admin/test";
    FileSystemFactory indexBuilderFileSystemFactory = EasyMock.createMock("indexBuildFileSystem", FileSystemFactory.class);
    ITISFileSystem tisFileSystem = EasyMock.createMock("tisFileSystem", ITISFileSystem.class);
    EasyMock.expect(tisFileSystem.getName()).andReturn("mocktest");
    IPath path = EasyMock.createMock("mockpath", IPath.class);
    EasyMock.expect(tisFileSystem.getPath(fsPath)).andReturn(path);
    EasyMock.expect(indexBuilderFileSystemFactory.getFileSystem()).andReturn(tisFileSystem);
    EasyMock.replay(indexBuilderFileSystemFactory, tisFileSystem, path);
    ITISFileSystem fs = indexBuilderFileSystemFactory.getFileSystem();
    assertEquals("mocktest", fs.getName());
    assertNotNull(fs.getPath(fsPath));
}
Also used : IPath(com.qlangtech.tis.fs.IPath) ITISFileSystem(com.qlangtech.tis.fs.ITISFileSystem) FileSystemFactory(com.qlangtech.tis.offline.FileSystemFactory)

Aggregations

ITISFileSystem (com.qlangtech.tis.fs.ITISFileSystem)14 IPath (com.qlangtech.tis.fs.IPath)6 IPathInfo (com.qlangtech.tis.fs.IPathInfo)4 HdfsPath (com.qlangtech.tis.hdfs.impl.HdfsPath)3 FileSystemFactory (com.qlangtech.tis.offline.FileSystemFactory)3 IOException (java.io.IOException)3 Connection (java.sql.Connection)3 HdfsFileSystemFactory (com.qlangtech.tis.hdfs.impl.HdfsFileSystemFactory)2 IJoinTaskContext (com.qlangtech.tis.order.center.IJoinTaskContext)2 EntityName (com.qlangtech.tis.sql.parser.tuple.creator.EntityName)2 File (java.io.File)2 Configuration (com.alibaba.datax.common.util.Configuration)1 HdfsColMeta (com.alibaba.datax.plugin.writer.hdfswriter.HdfsColMeta)1 HdfsWriterErrorCode (com.alibaba.datax.plugin.writer.hdfswriter.HdfsWriterErrorCode)1 Key (com.alibaba.datax.plugin.writer.hdfswriter.Key)1 Queues (com.google.common.collect.Queues)1 Sets (com.google.common.collect.Sets)1 ITISCoordinator (com.qlangtech.tis.cloud.ITISCoordinator)1 MockZKUtils (com.qlangtech.tis.cloud.MockZKUtils)1 DumpJobId (com.qlangtech.tis.cloud.dump.DumpJobId)1