feat(monitor): 增加关于hudi表文件数的监控指标
This commit is contained in:
@@ -205,6 +205,41 @@ public class HudiCommand {
|
||||
fileSystem.close();
|
||||
}
|
||||
|
||||
@ShellMethod("Max meta files")
|
||||
public void maxMetaFiles() throws IOException {
|
||||
MutableList<P> list = Lists.mutable.<P>empty().asSynchronized();
|
||||
FileSystem fileSystem = FileSystem.get(new Configuration());
|
||||
infoService
|
||||
.tableMetaList()
|
||||
.collect(TableMeta::getHudi)
|
||||
.collect(TableMeta.HudiMeta::getTargetHdfsPath)
|
||||
.asParallel(ExecutorProvider.EXECUTORS_20, 1)
|
||||
.forEach(hdfs -> {
|
||||
Path root = new Path(hdfs, ".hoodie");
|
||||
try {
|
||||
FileStatus[] statuses = fileSystem.listStatus(root);
|
||||
long num = 0;
|
||||
for (FileStatus status : statuses) {
|
||||
if (status.isFile()) {
|
||||
num++;
|
||||
}
|
||||
if (StrUtil.containsIgnoreCase(status.getPath().toString(), "INVALID")) {
|
||||
logger.info("{}", status.getPath().toString());
|
||||
}
|
||||
}
|
||||
list.add(new P(num, hdfs));
|
||||
logger.info("Count: {} Hdfs: {}", num, hdfs);
|
||||
} catch (IOException e) {
|
||||
logger.warn("List file error", e);
|
||||
}
|
||||
});
|
||||
MutableList<P> listP = list.select(p -> p.count > 1000);
|
||||
for (P maxP : listP) {
|
||||
logger.info("Max: {} Hdfs: {}", maxP.count, maxP.hdfs);
|
||||
}
|
||||
fileSystem.close();
|
||||
}
|
||||
|
||||
@ShellMethod("Get timeline instants")
|
||||
public void timelineInstant(@ShellOption(help = "root hdfs path") String hdfs) {
|
||||
hudiService.timelineHdfsAllActive(hdfs).forEach(instant -> logger.info(instant.toString()));
|
||||
@@ -229,4 +264,14 @@ public class HudiCommand {
|
||||
public interface Runnable {
|
||||
void run(LongAdder counter);
|
||||
}
|
||||
|
||||
private static final class P {
|
||||
String hdfs;
|
||||
long count;
|
||||
|
||||
public P(long count, String hdfs) {
|
||||
this.count = count;
|
||||
this.hdfs = hdfs;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user