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);
}
Aggregations