This reverts commit f509e936573f8d6fdaf4de036bc3c6abef26a182.
This commit is contained in:
@ -17,30 +17,27 @@
|
||||
|
||||
package org.apache.doris.httpv2.rest.manager;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import org.apache.doris.catalog.Catalog;
|
||||
import org.apache.doris.common.Config;
|
||||
import org.apache.doris.common.Pair;
|
||||
import org.apache.doris.common.UserException;
|
||||
import org.apache.doris.httpv2.entity.ResponseEntityBuilder;
|
||||
import org.apache.doris.httpv2.rest.RestBaseController;
|
||||
import org.apache.doris.mysql.privilege.PrivPredicate;
|
||||
import org.apache.doris.qe.ConnectContext;
|
||||
import org.apache.doris.system.Frontend;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/*
|
||||
* Used to return the cluster information for the manager.
|
||||
*/
|
||||
@ -48,8 +45,6 @@ import java.util.stream.Collectors;
|
||||
@RequestMapping("/rest/v2/manager/cluster")
|
||||
public class ClusterAction extends RestBaseController {
|
||||
|
||||
private static final Logger LOG = LogManager.getLogger(ClusterAction.class);
|
||||
|
||||
// Returns mysql and http connection information for the cluster.
|
||||
// {
|
||||
// "mysql":[
|
||||
@ -74,28 +69,4 @@ public class ClusterAction extends RestBaseController {
|
||||
result.put("http", frontends.stream().map(ip -> ip + ":" + Config.http_port).collect(Collectors.toList()));
|
||||
return ResponseEntityBuilder.ok(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* add backend like execute alter system add backend "host:port"
|
||||
*/
|
||||
@RequestMapping(path = "/add_backends", method = RequestMethod.POST)
|
||||
public Object addBackends(HttpServletRequest request, HttpServletResponse response,
|
||||
@RequestBody Map<String, Integer> hostPorts) {
|
||||
executeCheckPassword(request, response);
|
||||
checkGlobalAuth(ConnectContext.get().getCurrentUserIdentity(), PrivPredicate.ADMIN);
|
||||
|
||||
Map<String, Boolean> result = Maps.newHashMap();
|
||||
for (Map.Entry<String, Integer> backend : hostPorts.entrySet()) {
|
||||
List<Pair<String, Integer>> newBackend = Lists.newArrayList();
|
||||
newBackend.add(Pair.create(backend.getKey(), backend.getValue()));
|
||||
try {
|
||||
Catalog.getCurrentSystemInfo().addBackends(newBackend, false);
|
||||
result.put(backend.getKey(), true);
|
||||
} catch (UserException e) {
|
||||
LOG.error("Failed to add backend node: {}:{}", backend.getKey(), backend.getValue(), e);
|
||||
result.put(backend.getKey(), false);
|
||||
}
|
||||
}
|
||||
return ResponseEntityBuilder.ok(result);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user