fix(exporter): 修复查询未运行flink任务数量不正确

This commit is contained in:
2024-02-04 15:38:27 +08:00
parent b5ac36fd8b
commit c7abcb9e22
4 changed files with 209 additions and 242 deletions

View File

@@ -39,8 +39,9 @@ public class ExporterController {
@Cacheable(value = "un_running_flink_job", sync = true)
public ImmutableList<FlinkJobIdAndName> unRunningFlinkJob() {
ImmutableList<String> locks = zookeeperService.getChildren(NameHelper.ZK_SYNC_RUNNING_LOCK_PATH).collect(ZookeeperNode::getPath);
return infoService.flinkJobList()
.reject(job -> locks.contains(NameHelper.syncFlinkName(job.getId(), job.getName())))
.collect(job -> new FlinkJobIdAndName(job.getId(), job.getName()));
return infoService.simpleTableMetas()
.collect(meta -> new FlinkJobIdAndName(meta.getFlinkJobId(), meta.getFlinkJobName()))
.distinct()
.reject(job -> locks.contains(NameHelper.syncRunningLockPath(job.getId())));
}
}

View File

@@ -21,6 +21,24 @@ public class FlinkJobIdAndName {
return name;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
FlinkJobIdAndName that = (FlinkJobIdAndName) o;
if (!id.equals(that.id)) return false;
return name.equals(that.name);
}
@Override
public int hashCode() {
int result = id.hashCode();
result = 31 * result + name.hashCode();
return result;
}
@Override
public String toString() {
return "FlinkJobIdAndName{" +