From cf089d2cbe7f46c1480f77ce885a2b62ed044007 Mon Sep 17 00:00:00 2001 From: abmdocrt Date: Thu, 15 Aug 2024 09:37:10 +0800 Subject: [PATCH] [Cherry-pick](branch-2.1) Pick "[Enhancement](wal) modify wal api which hard to use (#38895)" (#39188) ## Proposed changes Pick #38895 Before this pr, this api needs backends' ip and port as param, which is hard to use. This pr modify it. If there is no param, doris will print all backends WAL info. The acceptable usage are as follows ``` curl -u root: "127.0.0.1:8038/api/get_wal_size?host_ports=127.0.0.1:9058" {"msg":"success","code":0,"data":["127.0.0.1:9058:0"],"count":0}% curl -u root: "127.0.0.1:8038/api/get_wal_size?host_ports=" {"msg":"success","code":0,"data":["127.0.0.1:9058:0"],"count":0}% curl -u root: "127.0.0.1:8038/api/get_wal_size" {"msg":"success","code":0,"data":["127.0.0.1:9058:0"],"count":0}% ``` ## Proposed changes Issue Number: close #xxx --- .../doris/httpv2/rest/CheckWalSizeAction.java | 48 +++++++++---------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/CheckWalSizeAction.java b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/CheckWalSizeAction.java index fdc39e8bad..2f963be8c2 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/CheckWalSizeAction.java +++ b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/CheckWalSizeAction.java @@ -61,36 +61,36 @@ public class CheckWalSizeAction extends RestBaseController { checkGlobalAuth(ConnectContext.get().getCurrentUserIdentity(), PrivPredicate.OPERATOR); String hostPorts = request.getParameter(HOST_PORTS); + List backends = new ArrayList<>(); if (Strings.isNullOrEmpty(hostPorts)) { - return ResponseEntityBuilder.badRequest("No host:port specified"); - } - - String[] hostPortArr = hostPorts.split(","); - if (hostPortArr.length == 0) { - return ResponseEntityBuilder.badRequest("No host:port specified"); - } - - List hostInfos = Lists.newArrayList(); - for (String hostPort : hostPortArr) { + backends = Env.getCurrentSystemInfo().getAllBackends(); + } else { + String[] hostPortArr = hostPorts.split(","); + if (hostPortArr.length == 0) { + return ResponseEntityBuilder.badRequest("No host:port specified"); + } + List hostInfos = new ArrayList<>(); + for (String hostPort : hostPortArr) { + try { + HostInfo hostInfo = SystemInfoService.getHostAndPort(hostPort); + hostInfos.add(hostInfo); + } catch (AnalysisException e) { + return ResponseEntityBuilder.badRequest(e.getMessage()); + } + } try { - HostInfo hostInfo = SystemInfoService.getHostAndPort(hostPort); - hostInfos.add(hostInfo); - } catch (AnalysisException e) { - return ResponseEntityBuilder.badRequest(e.getMessage()); + backends = getBackends(hostInfos); + } catch (DdlException e) { + return ResponseEntityBuilder.okWithCommonError(e.getMessage()); } } - try { - List backends = getBackends(hostInfos); - List backendsList = new ArrayList<>(); - for (Backend backend : backends) { - long size = Env.getCurrentEnv().getGroupCommitManager().getAllWalQueueSize(backend); - backendsList.add(backend.getHost() + ":" + backend.getHeartbeatPort() + ":" + size); - } - return ResponseEntityBuilder.ok(backendsList); - } catch (DdlException e) { - return ResponseEntityBuilder.okWithCommonError(e.getMessage()); + List backendsList = new ArrayList<>(); + for (Backend backend : backends) { + long size = Env.getCurrentEnv().getGroupCommitManager().getAllWalQueueSize(backend); + backendsList.add(backend.getHost() + ":" + backend.getHeartbeatPort() + ":" + size); } + return ResponseEntityBuilder.ok(backendsList); } private List getBackends(List hostInfos) throws DdlException {