This is an automated email from the ASF dual-hosted git repository.
dataroaring pushed a commit to branch branch-2.1
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.1 by this push:
new cf089d2cbe7 [Cherry-pick](branch-2.1) Pick "[Enhancement](wal) modify
wal api which hard to use (#38895)" (#39188)
cf089d2cbe7 is described below
commit cf089d2cbe7f46c1480f77ce885a2b62ed044007
Author: abmdocrt <[email protected]>
AuthorDate: Thu Aug 15 09:37:10 2024 +0800
[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}%
```
<!--Describe your changes.-->
## Proposed changes
Issue Number: close #xxx
<!--Describe your changes.-->
---
.../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 fdc39e8badd..2f963be8c21 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<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) {
+ backends = Env.getCurrentSystemInfo().getAllBackends();
+ } 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 {
- 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<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: [email protected]
For additional commands, e-mail: [email protected]