Search in sources :

Example 1 with PathInfo

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

Aggregations

FSHistoryFileUtils (com.qlangtech.tis.fs.FSHistoryFileUtils)1 PathInfo (com.qlangtech.tis.fs.FSHistoryFileUtils.PathInfo)1 IPath (com.qlangtech.tis.fs.IPath)1 IPathInfo (com.qlangtech.tis.fs.IPathInfo)1 ITISFileSystem (com.qlangtech.tis.fs.ITISFileSystem)1 ArrayList (java.util.ArrayList)1 Matcher (java.util.regex.Matcher)1