This is an automated email from the ASF dual-hosted git repository. dataroaring pushed a commit to branch branch-3.0 in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-3.0 by this push: new 1ceb91e308f [Enhancement](wal) modify wal api which hard to use (#38895) 1ceb91e308f is described below commit 1ceb91e308fd34f0ba6e08b6807aab641ee10f6e Author: abmdocrt <yukang.lian2...@gmail.com> AuthorDate: Thu Aug 8 12:32:08 2024 +0800 [Enhancement](wal) modify wal api which hard to use (#38895) ## Proposed changes 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}% ``` <!--Describe your changes.--> --- .../doris/httpv2/rest/CheckWalSizeAction.java | 50 ++++++++++++---------- 1 file changed, 27 insertions(+), 23 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 fdc39e8badd..6b52ef3f35a 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,40 @@ public class CheckWalSizeAction extends RestBaseController { checkGlobalAuth(ConnectContext.get().getCurrentUserIdentity(), PrivPredicate.OPERATOR); String hostPorts = request.getParameter(HOST_PORTS); + List<Backend> 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<HostInfo> hostInfos = Lists.newArrayList(); - for (String hostPort : hostPortArr) { try { - HostInfo hostInfo = SystemInfoService.getHostAndPort(hostPort); - hostInfos.add(hostInfo); + backends = Env.getCurrentSystemInfo().getAllBackendsByAllCluster().values().asList(); } catch (AnalysisException e) { - return ResponseEntityBuilder.badRequest(e.getMessage()); + return ResponseEntityBuilder.okWithCommonError(e.getMessage()); + } + } else { + String[] hostPortArr = hostPorts.split(","); + if (hostPortArr.length == 0) { + return ResponseEntityBuilder.badRequest("No host:port specified"); + } + List<HostInfo> 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 { + backends = getBackends(hostInfos); + } catch (DdlException e) { + return ResponseEntityBuilder.okWithCommonError(e.getMessage()); } } - try { - List<Backend> backends = getBackends(hostInfos); - List<String> 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<String> 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<Backend> getBackends(List<HostInfo> hostInfos) throws DdlException { --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org