提交 17eeeeab 编写于 作者: 偏锋书生's avatar 偏锋书生

doris改进,22号联调

上级 9409926f
package net.wicp.tams.app.duckula.controller.bean.constant;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import net.wicp.tams.common.constant.dic.intf.IEnumCombobox;
public enum DorisRole implements IEnumCombobox {
BE("数据"), FE("前端");
follower("FE-Follower", "FE", true),
master("FE-Master", "FE", true),
observer("FE-Observer", "FE", false),
be("BE", "BE", true);
private final String desc;
private final String type;// BE/FE
private DorisRole(String desc) {
private final boolean need;// 是否一个集群内必须
private DorisRole(String desc, String type, boolean need) {
this.desc = desc;
this.type = type;
this.need = need;
}
@Override
......@@ -34,6 +48,26 @@ public enum DorisRole implements IEnumCombobox {
return this.name();
}
public String getType() {
return type;
}
public boolean isNeed() {
return need;
}
// 一定需要存在的角色状态
public static Map<DorisRole, Boolean> isExit() {
Map<DorisRole, Boolean> retmap = new HashMap<DorisRole, Boolean>();
DorisRole[] values = DorisRole.values();
for (DorisRole dorisRole : values) {
if (dorisRole.isNeed()) {
retmap.put(dorisRole, Boolean.FALSE);
}
}
return retmap;
}
public static DorisRole find(String name) {
if (StringUtils.isEmpty(name)) {
return null;
......
......@@ -24,44 +24,44 @@ public class DevopsDoris {
* Database Column Remarks: 客户名 This field was generated by MyBatis Generator. This field corresponds to the database column devops_doris.name
* @mbg.generated
*/
@TamsCol(value = "租户名", save = 1, query = 1, showWidth = 100)
@TamsCol(value = "租户名", save = 1, query = 1, showWidth = 100, orderby = 1)
private String name;
/**
* Database Column Remarks: ip1地址 This field was generated by MyBatis Generator. This field corresponds to the database column devops_doris.ip
* @mbg.generated
*/
@TamsCol(value = "IP地址", save = 1, query = 1, showWidth = 150)
private String ip;
/**
* Database Column Remarks: 集群 This field was generated by MyBatis Generator. This field corresponds to the database column devops_doris.cluster
* @mbg.generated
*/
@TamsCol(value = "集群", save = 1, query = 0, showWidth = 150)
@TamsCol(value = "集群", save = 1, query = 0, showWidth = 150, orderby = 2)
private String cluster;
/**
* Database Column Remarks: 服务器的角色 This field was generated by MyBatis Generator. This field corresponds to the database column devops_doris.roles
* Database Column Remarks: ip1地址 This field was generated by MyBatis Generator. This field corresponds to the database column devops_doris.ip
* @mbg.generated
*/
@TamsCol(value = "角色", save = 1, query = -1, showWidth = 150, multiple = true, enumClass = DorisRole.class)
private String roles;
@TamsCol(value = "IP地址", save = 1, query = 1, showWidth = 150, orderby = 3)
private String ip;
/**
* Database Column Remarks: 存储磁盘 This field was generated by MyBatis Generator. This field corresponds to the database column devops_doris.fs
* Database Column Remarks: 服务器的角色 This field was generated by MyBatis Generator. This field corresponds to the database column devops_doris.roles
* @mbg.generated
*/
@TamsCol(value = "存储磁盘", save = 1, query = -1, showWidth = 150)
private String fs;
@TamsCol(value = "角色", save = 1, query = -1, showWidth = 280, multiple = true, enumClass = DorisRole.class, orderby = 5)
private String roles;
/**
* Database Column Remarks: root密码 This field was generated by MyBatis Generator. This field corresponds to the database column devops_doris.root_pwd
* @mbg.generated
*/
@TamsCol(value = "root密码", save = 1, query = -1)
@TamsCol(value = "root密码", save = 1, query = -1, orderby = 4)
private String rootPwd;
/**
* Database Column Remarks: 是否初始化,yes:已初始化 no:未初始化 创建duckula用户,创建环境变量创建目录 This field was generated by MyBatis Generator. This field corresponds to the database column devops_doris.is_init
* @mbg.generated
*/
@TamsCol(value = "初始化", save = 1, query = 0, enumClass = YesOrNo.class, showWidth = 100)
@TamsCol(value = "初始化", save = -1, query = 0, enumClass = YesOrNo.class, showWidth = 100)
private String isInit;
/**
* Database Column Remarks: 已安装 This field was generated by MyBatis Generator. This field corresponds to the database column devops_doris.is_install
* @mbg.generated
*/
@TamsCol(value = "是否安装", save = -1, query = 0, enumClass = YesOrNo.class, showWidth = 100)
private String isInstall;
/**
* Database Column Remarks: 创建时间 This field was generated by MyBatis Generator. This field corresponds to the database column devops_doris.create_time
* @mbg.generated
......@@ -77,16 +77,16 @@ public class DevopsDoris {
* This method was generated by MyBatis Generator. This method corresponds to the database table devops_doris
* @mbg.generated
*/
public DevopsDoris(Long id, String name, String ip, String cluster, String roles, String fs, String rootPwd,
String isInit, Date createTime, Date updateTime) {
public DevopsDoris(Long id, String name, String cluster, String ip, String roles, String rootPwd, String isInit,
String isInstall, Date createTime, Date updateTime) {
this.id = id;
this.name = name;
this.ip = ip;
this.cluster = cluster;
this.ip = ip;
this.roles = roles;
this.fs = fs;
this.rootPwd = rootPwd;
this.isInit = isInit;
this.isInstall = isInstall;
this.createTime = createTime;
this.updateTime = updateTime;
}
......@@ -135,24 +135,6 @@ public class DevopsDoris {
this.name = name;
}
/**
* This method was generated by MyBatis Generator. This method returns the value of the database column devops_doris.ip
* @return the value of devops_doris.ip
* @mbg.generated
*/
public String getIp() {
return ip;
}
/**
* This method was generated by MyBatis Generator. This method sets the value of the database column devops_doris.ip
* @param ip the value for devops_doris.ip
* @mbg.generated
*/
public void setIp(String ip) {
this.ip = ip;
}
/**
* This method was generated by MyBatis Generator. This method returns the value of the database column devops_doris.cluster
* @return the value of devops_doris.cluster
......@@ -172,39 +154,39 @@ public class DevopsDoris {
}
/**
* This method was generated by MyBatis Generator. This method returns the value of the database column devops_doris.roles
* @return the value of devops_doris.roles
* This method was generated by MyBatis Generator. This method returns the value of the database column devops_doris.ip
* @return the value of devops_doris.ip
* @mbg.generated
*/
public String getRoles() {
return roles;
public String getIp() {
return ip;
}
/**
* This method was generated by MyBatis Generator. This method sets the value of the database column devops_doris.roles
* @param roles the value for devops_doris.roles
* This method was generated by MyBatis Generator. This method sets the value of the database column devops_doris.ip
* @param ip the value for devops_doris.ip
* @mbg.generated
*/
public void setRoles(String roles) {
this.roles = roles;
public void setIp(String ip) {
this.ip = ip;
}
/**
* This method was generated by MyBatis Generator. This method returns the value of the database column devops_doris.fs
* @return the value of devops_doris.fs
* This method was generated by MyBatis Generator. This method returns the value of the database column devops_doris.roles
* @return the value of devops_doris.roles
* @mbg.generated
*/
public String getFs() {
return fs;
public String getRoles() {
return roles;
}
/**
* This method was generated by MyBatis Generator. This method sets the value of the database column devops_doris.fs
* @param fs the value for devops_doris.fs
* This method was generated by MyBatis Generator. This method sets the value of the database column devops_doris.roles
* @param roles the value for devops_doris.roles
* @mbg.generated
*/
public void setFs(String fs) {
this.fs = fs;
public void setRoles(String roles) {
this.roles = roles;
}
/**
......@@ -243,6 +225,24 @@ public class DevopsDoris {
this.isInit = isInit;
}
/**
* This method was generated by MyBatis Generator. This method returns the value of the database column devops_doris.is_install
* @return the value of devops_doris.is_install
* @mbg.generated
*/
public String getIsInstall() {
return isInstall;
}
/**
* This method was generated by MyBatis Generator. This method sets the value of the database column devops_doris.is_install
* @param isInstall the value for devops_doris.is_install
* @mbg.generated
*/
public void setIsInstall(String isInstall) {
this.isInstall = isInstall;
}
/**
* This method was generated by MyBatis Generator. This method returns the value of the database column devops_doris.create_time
* @return the value of devops_doris.create_time
......
......@@ -293,76 +293,6 @@ public class DevopsDorisExample {
return (Criteria) this;
}
public Criteria andIpIsNull() {
addCriterion("ip is null");
return (Criteria) this;
}
public Criteria andIpIsNotNull() {
addCriterion("ip is not null");
return (Criteria) this;
}
public Criteria andIpEqualTo(String value) {
addCriterion("ip =", value, "ip");
return (Criteria) this;
}
public Criteria andIpNotEqualTo(String value) {
addCriterion("ip <>", value, "ip");
return (Criteria) this;
}
public Criteria andIpGreaterThan(String value) {
addCriterion("ip >", value, "ip");
return (Criteria) this;
}
public Criteria andIpGreaterThanOrEqualTo(String value) {
addCriterion("ip >=", value, "ip");
return (Criteria) this;
}
public Criteria andIpLessThan(String value) {
addCriterion("ip <", value, "ip");
return (Criteria) this;
}
public Criteria andIpLessThanOrEqualTo(String value) {
addCriterion("ip <=", value, "ip");
return (Criteria) this;
}
public Criteria andIpLike(String value) {
addCriterion("ip like", value, "ip");
return (Criteria) this;
}
public Criteria andIpNotLike(String value) {
addCriterion("ip not like", value, "ip");
return (Criteria) this;
}
public Criteria andIpIn(List<String> values) {
addCriterion("ip in", values, "ip");
return (Criteria) this;
}
public Criteria andIpNotIn(List<String> values) {
addCriterion("ip not in", values, "ip");
return (Criteria) this;
}
public Criteria andIpBetween(String value1, String value2) {
addCriterion("ip between", value1, value2, "ip");
return (Criteria) this;
}
public Criteria andIpNotBetween(String value1, String value2) {
addCriterion("ip not between", value1, value2, "ip");
return (Criteria) this;
}
public Criteria andClusterIsNull() {
addCriterion("cluster is null");
return (Criteria) this;
......@@ -433,143 +363,143 @@ public class DevopsDorisExample {
return (Criteria) this;
}
public Criteria andRolesIsNull() {
addCriterion("roles is null");
public Criteria andIpIsNull() {
addCriterion("ip is null");
return (Criteria) this;
}
public Criteria andRolesIsNotNull() {
addCriterion("roles is not null");
public Criteria andIpIsNotNull() {
addCriterion("ip is not null");
return (Criteria) this;
}
public Criteria andRolesEqualTo(String value) {
addCriterion("roles =", value, "roles");
public Criteria andIpEqualTo(String value) {
addCriterion("ip =", value, "ip");
return (Criteria) this;
}
public Criteria andRolesNotEqualTo(String value) {
addCriterion("roles <>", value, "roles");
public Criteria andIpNotEqualTo(String value) {
addCriterion("ip <>", value, "ip");
return (Criteria) this;
}
public Criteria andRolesGreaterThan(String value) {
addCriterion("roles >", value, "roles");
public Criteria andIpGreaterThan(String value) {
addCriterion("ip >", value, "ip");
return (Criteria) this;
}
public Criteria andRolesGreaterThanOrEqualTo(String value) {
addCriterion("roles >=", value, "roles");
public Criteria andIpGreaterThanOrEqualTo(String value) {
addCriterion("ip >=", value, "ip");
return (Criteria) this;
}
public Criteria andRolesLessThan(String value) {
addCriterion("roles <", value, "roles");
public Criteria andIpLessThan(String value) {
addCriterion("ip <", value, "ip");
return (Criteria) this;
}
public Criteria andRolesLessThanOrEqualTo(String value) {
addCriterion("roles <=", value, "roles");
public Criteria andIpLessThanOrEqualTo(String value) {
addCriterion("ip <=", value, "ip");
return (Criteria) this;
}
public Criteria andRolesLike(String value) {
addCriterion("roles like", value, "roles");
public Criteria andIpLike(String value) {
addCriterion("ip like", value, "ip");
return (Criteria) this;
}
public Criteria andRolesNotLike(String value) {
addCriterion("roles not like", value, "roles");
public Criteria andIpNotLike(String value) {
addCriterion("ip not like", value, "ip");
return (Criteria) this;
}
public Criteria andRolesIn(List<String> values) {
addCriterion("roles in", values, "roles");
public Criteria andIpIn(List<String> values) {
addCriterion("ip in", values, "ip");
return (Criteria) this;
}
public Criteria andRolesNotIn(List<String> values) {
addCriterion("roles not in", values, "roles");
public Criteria andIpNotIn(List<String> values) {
addCriterion("ip not in", values, "ip");
return (Criteria) this;
}
public Criteria andRolesBetween(String value1, String value2) {
addCriterion("roles between", value1, value2, "roles");
public Criteria andIpBetween(String value1, String value2) {
addCriterion("ip between", value1, value2, "ip");
return (Criteria) this;
}
public Criteria andRolesNotBetween(String value1, String value2) {
addCriterion("roles not between", value1, value2, "roles");
public Criteria andIpNotBetween(String value1, String value2) {
addCriterion("ip not between", value1, value2, "ip");
return (Criteria) this;
}
public Criteria andFsIsNull() {
addCriterion("fs is null");
public Criteria andRolesIsNull() {
addCriterion("roles is null");
return (Criteria) this;
}
public Criteria andFsIsNotNull() {
addCriterion("fs is not null");
public Criteria andRolesIsNotNull() {
addCriterion("roles is not null");
return (Criteria) this;
}
public Criteria andFsEqualTo(String value) {
addCriterion("fs =", value, "fs");
public Criteria andRolesEqualTo(String value) {
addCriterion("roles =", value, "roles");
return (Criteria) this;
}
public Criteria andFsNotEqualTo(String value) {
addCriterion("fs <>", value, "fs");
public Criteria andRolesNotEqualTo(String value) {
addCriterion("roles <>", value, "roles");
return (Criteria) this;
}
public Criteria andFsGreaterThan(String value) {
addCriterion("fs >", value, "fs");
public Criteria andRolesGreaterThan(String value) {
addCriterion("roles >", value, "roles");
return (Criteria) this;
}
public Criteria andFsGreaterThanOrEqualTo(String value) {
addCriterion("fs >=", value, "fs");
public Criteria andRolesGreaterThanOrEqualTo(String value) {
addCriterion("roles >=", value, "roles");
return (Criteria) this;
}
public Criteria andFsLessThan(String value) {
addCriterion("fs <", value, "fs");
public Criteria andRolesLessThan(String value) {
addCriterion("roles <", value, "roles");
return (Criteria) this;
}
public Criteria andFsLessThanOrEqualTo(String value) {
addCriterion("fs <=", value, "fs");
public Criteria andRolesLessThanOrEqualTo(String value) {
addCriterion("roles <=", value, "roles");
return (Criteria) this;
}
public Criteria andFsLike(String value) {
addCriterion("fs like", value, "fs");
public Criteria andRolesLike(String value) {
addCriterion("roles like", value, "roles");
return (Criteria) this;
}
public Criteria andFsNotLike(String value) {
addCriterion("fs not like", value, "fs");
public Criteria andRolesNotLike(String value) {
addCriterion("roles not like", value, "roles");
return (Criteria) this;
}
public Criteria andFsIn(List<String> values) {
addCriterion("fs in", values, "fs");
public Criteria andRolesIn(List<String> values) {
addCriterion("roles in", values, "roles");
return (Criteria) this;
}
public Criteria andFsNotIn(List<String> values) {
addCriterion("fs not in", values, "fs");
public Criteria andRolesNotIn(List<String> values) {
addCriterion("roles not in", values, "roles");
return (Criteria) this;
}
public Criteria andFsBetween(String value1, String value2) {
addCriterion("fs between", value1, value2, "fs");
public Criteria andRolesBetween(String value1, String value2) {
addCriterion("roles between", value1, value2, "roles");
return (Criteria) this;
}
public Criteria andFsNotBetween(String value1, String value2) {
addCriterion("fs not between", value1, value2, "fs");
public Criteria andRolesNotBetween(String value1, String value2) {
addCriterion("roles not between", value1, value2, "roles");
return (Criteria) this;
}
......@@ -713,6 +643,76 @@ public class DevopsDorisExample {
return (Criteria) this;
}
public Criteria andIsInstallIsNull() {
addCriterion("is_install is null");
return (Criteria) this;
}
public Criteria andIsInstallIsNotNull() {
addCriterion("is_install is not null");
return (Criteria) this;
}
public Criteria andIsInstallEqualTo(String value) {
addCriterion("is_install =", value, "isInstall");
return (Criteria) this;
}
public Criteria andIsInstallNotEqualTo(String value) {
addCriterion("is_install <>", value, "isInstall");
return (Criteria) this;
}
public Criteria andIsInstallGreaterThan(String value) {
addCriterion("is_install >", value, "isInstall");
return (Criteria) this;
}
public Criteria andIsInstallGreaterThanOrEqualTo(String value) {
addCriterion("is_install >=", value, "isInstall");
return (Criteria) this;
}
public Criteria andIsInstallLessThan(String value) {
addCriterion("is_install <", value, "isInstall");
return (Criteria) this;
}
public Criteria andIsInstallLessThanOrEqualTo(String value) {
addCriterion("is_install <=", value, "isInstall");
return (Criteria) this;
}
public Criteria andIsInstallLike(String value) {
addCriterion("is_install like", value, "isInstall");
return (Criteria) this;
}
public Criteria andIsInstallNotLike(String value) {
addCriterion("is_install not like", value, "isInstall");
return (Criteria) this;
}
public Criteria andIsInstallIn(List<String> values) {
addCriterion("is_install in", values, "isInstall");
return (Criteria) this;
}
public Criteria andIsInstallNotIn(List<String> values) {
addCriterion("is_install not in", values, "isInstall");
return (Criteria) this;
}
public Criteria andIsInstallBetween(String value1, String value2) {
addCriterion("is_install between", value1, value2, "isInstall");
return (Criteria) this;
}
public Criteria andIsInstallNotBetween(String value1, String value2) {
addCriterion("is_install not between", value1, value2, "isInstall");
return (Criteria) this;
}
public Criteria andCreateTimeIsNull() {
addCriterion("create_time is null");
return (Criteria) this;
......
......@@ -39,11 +39,11 @@ public interface DevopsDorisMapper extends BaseMapper<DevopsDoris> {
* This method was generated by MyBatis Generator. This method corresponds to the database table devops_doris
* @mbg.generated
*/
@Insert({ "insert into devops_doris (id, name, ", "ip, cluster, roles, ", "fs, root_pwd, is_init, ",
"create_time, update_time)", "values (#{id,jdbcType=BIGINT}, #{name,jdbcType=VARCHAR}, ",
"#{ip,jdbcType=VARCHAR}, #{cluster,jdbcType=VARCHAR}, #{roles,jdbcType=VARCHAR}, ",
"#{fs,jdbcType=VARCHAR}, #{rootPwd,jdbcType=VARCHAR}, #{isInit,jdbcType=VARCHAR}, ",
"#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP})" })
@Insert({ "insert into devops_doris (id, name, ", "cluster, ip, roles, ", "root_pwd, is_init, ",
"is_install, create_time, ", "update_time)", "values (#{id,jdbcType=BIGINT}, #{name,jdbcType=VARCHAR}, ",
"#{cluster,jdbcType=VARCHAR}, #{ip,jdbcType=VARCHAR}, #{roles,jdbcType=VARCHAR}, ",
"#{rootPwd,jdbcType=VARCHAR}, #{isInit,jdbcType=VARCHAR}, ",
"#{isInstall,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, ", "#{updateTime,jdbcType=TIMESTAMP})" })
int insert(DevopsDoris record);
/**
......@@ -62,7 +62,7 @@ public interface DevopsDorisMapper extends BaseMapper<DevopsDoris> {
* This method was generated by MyBatis Generator. This method corresponds to the database table devops_doris
* @mbg.generated
*/
@Select({ "select", "id, name, ip, cluster, roles, fs, root_pwd, is_init, create_time, update_time",
@Select({ "select", "id, name, cluster, ip, roles, root_pwd, is_init, is_install, create_time, update_time",
"from devops_doris", "where id = #{id,jdbcType=BIGINT}" })
@ResultMap("net.wicp.tams.app.duckula.controller.dao.DevopsDorisMapper.BaseResultMap")
DevopsDoris selectByPrimaryKey(Long id);
......@@ -89,10 +89,10 @@ public interface DevopsDorisMapper extends BaseMapper<DevopsDoris> {
* This method was generated by MyBatis Generator. This method corresponds to the database table devops_doris
* @mbg.generated
*/
@Update({ "update devops_doris", "set name = #{name,jdbcType=VARCHAR},", "ip = #{ip,jdbcType=VARCHAR},",
"cluster = #{cluster,jdbcType=VARCHAR},", "roles = #{roles,jdbcType=VARCHAR},",
"fs = #{fs,jdbcType=VARCHAR},", "root_pwd = #{rootPwd,jdbcType=VARCHAR},",
"is_init = #{isInit,jdbcType=VARCHAR},", "create_time = #{createTime,jdbcType=TIMESTAMP},",
@Update({ "update devops_doris", "set name = #{name,jdbcType=VARCHAR},", "cluster = #{cluster,jdbcType=VARCHAR},",
"ip = #{ip,jdbcType=VARCHAR},", "roles = #{roles,jdbcType=VARCHAR},",
"root_pwd = #{rootPwd,jdbcType=VARCHAR},", "is_init = #{isInit,jdbcType=VARCHAR},",
"is_install = #{isInstall,jdbcType=VARCHAR},", "create_time = #{createTime,jdbcType=TIMESTAMP},",
"update_time = #{updateTime,jdbcType=TIMESTAMP}", "where id = #{id,jdbcType=BIGINT}" })
int updateByPrimaryKey(DevopsDoris record);
}
\ No newline at end of file
package net.wicp.tams.duckula.ops.pages.devops;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Set;
import java.util.Map;
import org.apache.commons.collections.CollectionUtils;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.util.TextStreamResponse;
......@@ -10,18 +13,18 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import lombok.extern.slf4j.Slf4j;
import net.wicp.tams.app.duckula.controller.bean.constant.DorisRole;
import net.wicp.tams.app.duckula.controller.bean.models.DevopsDoris;
import net.wicp.tams.app.duckula.controller.bean.models.DevopsDorisExample;
import net.wicp.tams.app.duckula.controller.bean.models.DevopsDorisExample.Criteria;
import net.wicp.tams.app.duckula.controller.config.constant.DevOpsType;
import net.wicp.tams.app.duckula.controller.dao.DevopsDorisMapper;
import net.wicp.tams.common.Result;
import net.wicp.tams.common.apiext.CollectionUtil;
import net.wicp.tams.common.apiext.IOUtil;
import net.wicp.tams.common.apiext.StringUtil;
import net.wicp.tams.common.apiext.json.JSONUtil;
import net.wicp.tams.common.constant.PathType;
import net.wicp.tams.common.exception.ExceptAll;
import net.wicp.tams.common.exception.ProjectExceptionRuntime;
import net.wicp.tams.common.os.SSHAssit;
import net.wicp.tams.common.os.bean.DiskBean;
import net.wicp.tams.common.os.pool.SSHConnection;
import net.wicp.tams.component.tools.TapestryAssist;
import net.wicp.tams.duckula.ops.pages.ParentPageBean;
......@@ -34,19 +37,18 @@ public class DorisConfig extends ParentPageBean<DevopsDoris> {
@Override
public void doSave(DevopsDoris t, boolean isInsert) {
// 1、登陆
SSHConnection conn = SSHAssit.getConn(t.getIp(), "root", t.getRootPwd());
try {
List<DiskBean> list = conn.fdiskData();
Set<String> paths = CollectionUtil.getColSetFromObj(list, "path");
if (!paths.contains(t.getFs())) {
throw new ProjectExceptionRuntime(ExceptAll.param_error,
"存储磁盘不正确,只能填写:" + CollectionUtil.arrayJoin(paths.toArray(new String[paths.size()]), ","));
}
} finally {
SSHAssit.close(conn);
}
// 由shell命令检查磁盘,程序不写
// SSHConnection conn = SSHAssit.getConn(t.getIp(), "root", t.getRootPwd());
// try {
// List<DiskBean> list = conn.fdiskData();
// Set<String> paths = CollectionUtil.getColSetFromObj(list, "path");
// if (!paths.contains(t.getFs())) {
// throw new ProjectExceptionRuntime(ExceptAll.param_error,
// "存储磁盘不正确,只能填写:" + CollectionUtil.arrayJoin(paths.toArray(new String[paths.size()]), ","));
// }
// } finally {
// SSHAssit.close(conn);
// }
if (isInsert) {
devopsDorisMapper.insert(t);
} else {
......@@ -92,16 +94,46 @@ public class DorisConfig extends ParentPageBean<DevopsDoris> {
* @return
*/
public TextStreamResponse onCheckHost() {
final DevopsDoris DevopsDoris = TapestryAssist.getBeanFromPage(DevopsDoris.class, requestGlobals);
final DevopsDoris devopsDoris = TapestryAssist.getBeanFromPage(DevopsDoris.class, requestGlobals);
List<DevopsDoris> list = queryHostByCluster(devopsDoris.getCluster());
Map<DorisRole, Boolean> exit = DorisRole.isExit();
for (DevopsDoris devopsDoris2 : list) {
if (StringUtil.isNotNull(devopsDoris2.getRoles())) {
String[] splits = devopsDoris2.getRoles().split(",");
for (String split : splits) {
if (exit.containsKey(DorisRole.valueOf(split))) {
exit.put(DorisRole.valueOf(split), true);
}
}
}
}
StringBuffer buff = new StringBuffer();
for (DorisRole dorisRole : exit.keySet()) {
if (!exit.get(dorisRole)) {
buff.append("," + dorisRole.name());
}
}
if (buff.length() > 0) {
return TapestryAssist.getTextStreamResponse(Result.getError("下列角色需要配置:" + buff.substring(1)));
}
// 1、OSS下载
String localPath = PathType.getPath(DevOpsType.flink.getCheckurl());
String localPath = PathType.getPath(DevOpsType.doris.getCheckurl());
// 1、登陆
SSHConnection conn = SSHAssit.getConn(DevopsDoris.getIp(), "root", DevopsDoris.getRootPwd());
SSHConnection conn = SSHAssit.getConn(devopsDoris.getIp(), "root", devopsDoris.getRootPwd());
try {
String fileName = localPath.substring(localPath.lastIndexOf("/") + 1);
conn.scp(localPath, fileName, "~", "0744");
String remoteDir = DevOpsType.doris.getRemoteDirCheckDir();
conn.executeCommand("mkdir -p " + remoteDir);
conn.scpToDir(localPath, remoteDir);
// conn.scp(localPath, DevOpsType.doris.getRelaPathCheck(), "~", "0744");
// echo 11441 > test 覆盖,echo 1234567 >> test追加 touch test 创建一个空文件
String context = configContext(devopsDoris.getCluster());
conn.executeCommand("echo -e \"" + context + "\" > "
+ IOUtil.mergeFolderAndFilePath(DevOpsType.doris.getRemoteDirCheckDir(), "DorisIP.conf"));
// 执行
Result result = conn.executeCommand(String.format("sh ~/%s", fileName));
Result result = conn.executeCommand(
String.format("sh %s", IOUtil.mergeFolderAndFilePath("~/", DevOpsType.doris.getRelaPathCheck())));
log.info(result.getMessage());
return TapestryAssist.getTextStreamResponse(Result.getError("检查结果:" + result.getMessage()));
} finally {
......@@ -109,4 +141,42 @@ public class DorisConfig extends ParentPageBean<DevopsDoris> {
}
}
public String configContext(String cluster) {
List<DevopsDoris> list = queryHostByCluster(cluster);
Map<DorisRole, List<String>> retmap = new HashMap<DorisRole, List<String>>();
for (DevopsDoris ele : list) {
String[] rolesStr = ele.getRoles().split(",", 0);
for (String roleStr : rolesStr) {
DorisRole temp = DorisRole.valueOf(roleStr);
List<String> list2 = retmap.get(temp);
if (CollectionUtils.isEmpty(list2)) {
list2 = new ArrayList<String>();
}
list2.add(ele.getIp());
retmap.put(temp, list2);
}
}
// 添加不设置的角色
for (DorisRole dorisRole : DorisRole.values()) {
if (!retmap.containsKey(dorisRole)) {
retmap.put(dorisRole, new ArrayList<String>());
}
}
StringBuffer buff = new StringBuffer();
for (DorisRole dorisRole : retmap.keySet()) {
buff.append(String.format("\n%s,%s", dorisRole.name(),
StringUtil.hasNull(CollectionUtil.listJoin(retmap.get(dorisRole), ","), "")));
}
return buff.substring(1);
}
// 不排序是以id顺序
private List<DevopsDoris> queryHostByCluster(String cluster) {
DevopsDorisExample example = new DevopsDorisExample();
Criteria criteria = example.createCriteria();
criteria.andClusterEqualTo(cluster);
List<DevopsDoris> list = devopsDorisMapper.selectByExample(example);
return list;
}
}
......@@ -9,12 +9,12 @@
<constructor>
<idArg column="id" javaType="java.lang.Long" jdbcType="BIGINT" />
<arg column="name" javaType="java.lang.String" jdbcType="VARCHAR" />
<arg column="ip" javaType="java.lang.String" jdbcType="VARCHAR" />
<arg column="cluster" javaType="java.lang.String" jdbcType="VARCHAR" />
<arg column="ip" javaType="java.lang.String" jdbcType="VARCHAR" />
<arg column="roles" javaType="java.lang.String" jdbcType="VARCHAR" />
<arg column="fs" javaType="java.lang.String" jdbcType="VARCHAR" />
<arg column="root_pwd" javaType="java.lang.String" jdbcType="VARCHAR" />
<arg column="is_init" javaType="java.lang.String" jdbcType="VARCHAR" />
<arg column="is_install" javaType="java.lang.String" jdbcType="VARCHAR" />
<arg column="create_time" javaType="java.util.Date" jdbcType="TIMESTAMP" />
<arg column="update_time" javaType="java.util.Date" jdbcType="TIMESTAMP" />
</constructor>
......@@ -90,7 +90,7 @@
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
id, name, ip, cluster, roles, fs, root_pwd, is_init, create_time, update_time
id, name, cluster, ip, roles, root_pwd, is_init, is_install, create_time, update_time
</sql>
<select id="selectByExample" parameterType="net.wicp.tams.app.duckula.controller.bean.models.DevopsDorisExample" resultMap="BaseResultMap">
<!--
......@@ -133,24 +133,24 @@
<if test="name != null">
name,
</if>
<if test="ip != null">
ip,
</if>
<if test="cluster != null">
cluster,
</if>
<if test="ip != null">
ip,
</if>
<if test="roles != null">
roles,
</if>
<if test="fs != null">
fs,
</if>
<if test="rootPwd != null">
root_pwd,
</if>
<if test="isInit != null">
is_init,
</if>
<if test="isInstall != null">
is_install,
</if>
<if test="createTime != null">
create_time,
</if>
......@@ -165,24 +165,24 @@
<if test="name != null">
#{name,jdbcType=VARCHAR},
</if>
<if test="ip != null">
#{ip,jdbcType=VARCHAR},
</if>
<if test="cluster != null">
#{cluster,jdbcType=VARCHAR},
</if>
<if test="ip != null">
#{ip,jdbcType=VARCHAR},
</if>
<if test="roles != null">
#{roles,jdbcType=VARCHAR},
</if>
<if test="fs != null">
#{fs,jdbcType=VARCHAR},
</if>
<if test="rootPwd != null">
#{rootPwd,jdbcType=VARCHAR},
</if>
<if test="isInit != null">
#{isInit,jdbcType=VARCHAR},
</if>
<if test="isInstall != null">
#{isInstall,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
......@@ -214,24 +214,24 @@
<if test="record.name != null">
name = #{record.name,jdbcType=VARCHAR},
</if>
<if test="record.ip != null">
ip = #{record.ip,jdbcType=VARCHAR},
</if>
<if test="record.cluster != null">
cluster = #{record.cluster,jdbcType=VARCHAR},
</if>
<if test="record.ip != null">
ip = #{record.ip,jdbcType=VARCHAR},
</if>
<if test="record.roles != null">
roles = #{record.roles,jdbcType=VARCHAR},
</if>
<if test="record.fs != null">
fs = #{record.fs,jdbcType=VARCHAR},
</if>
<if test="record.rootPwd != null">
root_pwd = #{record.rootPwd,jdbcType=VARCHAR},
</if>
<if test="record.isInit != null">
is_init = #{record.isInit,jdbcType=VARCHAR},
</if>
<if test="record.isInstall != null">
is_install = #{record.isInstall,jdbcType=VARCHAR},
</if>
<if test="record.createTime != null">
create_time = #{record.createTime,jdbcType=TIMESTAMP},
</if>
......@@ -251,12 +251,12 @@
update devops_doris
set id = #{record.id,jdbcType=BIGINT},
name = #{record.name,jdbcType=VARCHAR},
ip = #{record.ip,jdbcType=VARCHAR},
cluster = #{record.cluster,jdbcType=VARCHAR},
ip = #{record.ip,jdbcType=VARCHAR},
roles = #{record.roles,jdbcType=VARCHAR},
fs = #{record.fs,jdbcType=VARCHAR},
root_pwd = #{record.rootPwd,jdbcType=VARCHAR},
is_init = #{record.isInit,jdbcType=VARCHAR},
is_install = #{record.isInstall,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=TIMESTAMP},
update_time = #{record.updateTime,jdbcType=TIMESTAMP}
<if test="_parameter != null">
......@@ -273,24 +273,24 @@
<if test="name != null">
name = #{name,jdbcType=VARCHAR},
</if>
<if test="ip != null">
ip = #{ip,jdbcType=VARCHAR},
</if>
<if test="cluster != null">
cluster = #{cluster,jdbcType=VARCHAR},
</if>
<if test="ip != null">
ip = #{ip,jdbcType=VARCHAR},
</if>
<if test="roles != null">
roles = #{roles,jdbcType=VARCHAR},
</if>
<if test="fs != null">
fs = #{fs,jdbcType=VARCHAR},
</if>
<if test="rootPwd != null">
root_pwd = #{rootPwd,jdbcType=VARCHAR},
</if>
<if test="isInit != null">
is_init = #{isInit,jdbcType=VARCHAR},
</if>
<if test="isInstall != null">
is_install = #{isInstall,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册