Search in sources :

Example 1 with IPathInfo

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

the class TestHdfsFileSystemFactory method testCreate.

public void testCreate() {
    PluginStore pluginStore = TIS.getPluginStore(FileSystemFactory.class);
    assertNotNull(pluginStore);
    Describable<FileSystemFactory> plugin = pluginStore.getPlugin();
    assertNotNull(plugin);
    FileSystemFactory fsFactory = (FileSystemFactory) plugin;
    ITISFileSystem fileSystem = fsFactory.getFileSystem();
    List<IPathInfo> paths = fileSystem.listChildren(fileSystem.getPath("/"));
    for (IPathInfo i : paths) {
        System.out.println(i.getName());
    }
// plugin.
// 
// assertTrue("real class:" + plugin.getClass().getName(), plugin instanceof HdfsFileSystemFactory);
// HdfsFileSystemFactory fsFactory = (HdfsFileSystemFactory) plugin;
// ITISFileSystem fileSystem = fsFactory.getFileSystem();
// List<IPathInfo> paths = fileSystem.listChildren(fileSystem.getPath(fsFactory.getRootDir() + "/"));
// for (IPathInfo i : paths) {
// System.out.println(i.getName());
// }
}
Also used : PluginStore(com.qlangtech.tis.plugin.PluginStore) IPathInfo(com.qlangtech.tis.fs.IPathInfo) ITISFileSystem(com.qlangtech.tis.fs.ITISFileSystem) FileSystemFactory(com.qlangtech.tis.offline.FileSystemFactory)

Example 2 with IPathInfo

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

the class RemoveJoinHistoryDataTask method deleteHistoryJoinTable.

/**
 * 删除宽表历史数据
 *
 * @param dumpTable
 * @throws Exception
 */
public static void deleteHistoryJoinTable(EntityName dumpTable, ITISFileSystem fileSys, Integer partitionRetainNum) throws Exception {
    final String path = FSHistoryFileUtils.getJoinTableStorePath(fileSys.getRootDir(), dumpTable).replaceAll("\\.", Path.SEPARATOR);
    if (fileSys == null) {
        throw new IllegalStateException("fileSys can not be null");
    }
    ITISFileSystem fs = fileSys;
    // new Path(hdfsPath);
    IPath parent = fs.getPath(path);
    if (!fs.exists(parent)) {
        return;
    }
    List<IPathInfo> child = fs.listChildren(parent);
    FSHistoryFileUtils.PathInfo pathinfo;
    List<PathInfo> timestampList = new ArrayList<>();
    Matcher matcher;
    for (IPathInfo c : child) {
        matcher = ITISFileSystem.DATE_PATTERN.matcher(c.getPath().getName());
        if (matcher.find()) {
            pathinfo = new PathInfo();
            pathinfo.setPathName(c.getPath().getName());
            pathinfo.setTimeStamp(Long.parseLong(matcher.group()));
            timestampList.add(pathinfo);
        }
    }
    FSHistoryFileUtils.deleteOldHdfsfile(fs, parent, timestampList, partitionRetainNum);
}
Also used : IPathInfo(com.qlangtech.tis.fs.IPathInfo) IPath(com.qlangtech.tis.fs.IPath) Matcher(java.util.regex.Matcher) ITISFileSystem(com.qlangtech.tis.fs.ITISFileSystem) ArrayList(java.util.ArrayList) PathInfo(com.qlangtech.tis.fs.FSHistoryFileUtils.PathInfo) IPathInfo(com.qlangtech.tis.fs.IPathInfo) PathInfo(com.qlangtech.tis.fs.FSHistoryFileUtils.PathInfo) FSHistoryFileUtils(com.qlangtech.tis.fs.FSHistoryFileUtils)

Example 3 with IPathInfo

use of com.qlangtech.tis.fs.IPathInfo 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 4 with IPathInfo

use of com.qlangtech.tis.fs.IPathInfo 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)

Aggregations

IPathInfo (com.qlangtech.tis.fs.IPathInfo)4 ITISFileSystem (com.qlangtech.tis.fs.ITISFileSystem)4 IPath (com.qlangtech.tis.fs.IPath)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 IHiveConnGetter (com.qlangtech.tis.config.hive.IHiveConnGetter)1 FSHistoryFileUtils (com.qlangtech.tis.fs.FSHistoryFileUtils)1 PathInfo (com.qlangtech.tis.fs.FSHistoryFileUtils.PathInfo)1 TISFSDataOutputStream (com.qlangtech.tis.fs.TISFSDataOutputStream)1 HdfsFileSystemFactory (com.qlangtech.tis.hdfs.impl.HdfsFileSystemFactory)1 HdfsPath (com.qlangtech.tis.hdfs.impl.HdfsPath)1 Option (com.qlangtech.tis.manage.common.Option)1 TisUTF8 (com.qlangtech.tis.manage.common.TisUTF8)1 DataxUtils (com.qlangtech.tis.offline.DataxUtils)1 FileSystemFactory (com.qlangtech.tis.offline.FileSystemFactory)1 PluginStore (com.qlangtech.tis.plugin.PluginStore)1 BasicHdfsWriterJob (com.qlangtech.tis.plugin.datax.BasicHdfsWriterJob)1 DataType (com.qlangtech.tis.plugin.ds.DataType)1