From 3f0d9f11dab743d70be1bd8e465092b93dff3bf3 Mon Sep 17 00:00:00 2001 From: lanyuanxiaoyao Date: Sun, 14 May 2023 00:50:54 +0800 Subject: [PATCH] =?UTF-8?q?perf(web):=20=E5=A2=9E=E5=BC=BA=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E5=90=8C=E6=AD=A5=E5=8E=8B=E7=BC=A9=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E5=AD=98=E5=9C=A8=E7=9A=84=E6=80=A7=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 先判断是否有同步压缩锁,有再获取运行指标 --- .../web/controller/TableController.java | 66 ++++++++++--------- 1 file changed, 36 insertions(+), 30 deletions(-) diff --git a/service-web/src/main/java/com/lanyuanxiaoyao/service/web/controller/TableController.java b/service-web/src/main/java/com/lanyuanxiaoyao/service/web/controller/TableController.java index 57df1c4..88bec54 100644 --- a/service-web/src/main/java/com/lanyuanxiaoyao/service/web/controller/TableController.java +++ b/service-web/src/main/java/com/lanyuanxiaoyao/service/web/controller/TableController.java @@ -92,48 +92,54 @@ public class TableController extends BaseController { CompletableFuture flinkJobFuture = CompletableFuture.supplyAsync(() -> infoService.flinkJobDetail(item.getId()), EXECUTOR); CompletableFuture tableMetaFuture = CompletableFuture.supplyAsync(() -> infoService.tableMetaDetail(item.getId(), item.getAlias()), EXECUTOR); CompletableFuture syncStateFuture = CompletableFuture.supplyAsync(() -> infoService.syncStateDetail(item.getId(), item.getAlias()), EXECUTOR); - CompletableFuture syncRunning = CompletableFuture.supplyAsync(() -> zookeeperService.existsPath(NameHelper.syncRunningLockPath(item.getId())), EXECUTOR); - CompletableFuture syncRuntime = CompletableFuture.supplyAsync(() -> { - try { - String data = zookeeperService.getData(NameHelper.syncRunningLockPath(item.getId())); - if (StrUtil.isNotBlank(data)) { - return mapper.readValue(data, RunMeta.class); - } - } catch (Exception e) { - logger.error("Parse sync runtime info for: {}", item.getId()); - } - return null; - }, EXECUTOR); - CompletableFuture compactionRunning = CompletableFuture.supplyAsync(() -> zookeeperService.existsPath(NameHelper.compactionRunningLockPath(item.getId(), item.getAlias())), EXECUTOR); - CompletableFuture compactionRuntime = CompletableFuture.supplyAsync(() -> { - try { - String data = zookeeperService.getData(NameHelper.compactionRunningLockPath(item.getId(), item.getAlias())); - if (StrUtil.isNotBlank(data)) { - return mapper.readValue(data, RunMeta.class); - } - } catch (Exception e) { - logger.error("Parse compaction runtime info for: {}", item.getId()); - } - return null; - }, EXECUTOR); + CompletableFuture syncRuntime = CompletableFuture + .supplyAsync(() -> zookeeperService.existsPath(NameHelper.syncRunningLockPath(item.getId())), EXECUTOR) + .thenApply(running -> { + if (running) { + try { + String data = zookeeperService.getData(NameHelper.syncRunningLockPath(item.getId())); + if (StrUtil.isNotBlank(data)) { + return mapper.readValue(data, RunMeta.class); + } + } catch (Exception e) { + logger.error("Parse sync runtime info for: {}", item.getId()); + } + } + return null; + }); + CompletableFuture compactionRuntime = CompletableFuture + .supplyAsync(() -> zookeeperService.existsPath(NameHelper.compactionRunningLockPath(item.getId(), item.getAlias())), EXECUTOR) + .thenApply(running -> { + if (running) { + try { + String data = zookeeperService.getData(NameHelper.compactionRunningLockPath(item.getId(), item.getAlias())); + if (StrUtil.isNotBlank(data)) { + return mapper.readValue(data, RunMeta.class); + } + } catch (Exception e) { + logger.error("Parse sync runtime info for: {}", item.getId()); + } + } + return null; + }); try { CompletableFuture.allOf( flinkJobFuture, tableMetaFuture, syncStateFuture, - syncRunning, syncRuntime, - compactionRunning, compactionRuntime ).get(); + RunMeta syncRunMeta = syncRuntime.get(); + RunMeta compactionRunMeta = compactionRuntime.get(); return new TableVO( flinkJobFuture.get(), tableMetaFuture.get(), new SyncStateVO(syncStateFuture.get()), - syncRunning.get(), - syncRuntime.get(), - compactionRunning.get(), - compactionRuntime.get() + ObjectUtil.isNotNull(syncRunMeta), + syncRunMeta, + ObjectUtil.isNotNull(compactionRunMeta), + compactionRunMeta ); } catch (InterruptedException | ExecutionException e) { logger.error("Something bad", e);