提交 53e70292 编写于 作者: 偏锋书生's avatar 偏锋书生

temp

上级 17eeeeab
......@@ -73,6 +73,12 @@ public class DevopsFlink {
*/
@TamsCol(value = "免密", save = -1, query = 0, enumClass = YesOrNo.class, showWidth = 100, orderby = 8)
private String isFree;
/**
* Database Column Remarks: 是否已安装 This field was generated by MyBatis Generator. This field corresponds to the database column devops_flink.is_install
* @mbg.generated
*/
@TamsCol(value = "是否安装", save = -1, query = 0, enumClass = YesOrNo.class, showWidth = 100, orderby = 9)
private String isInstall;
/**
* Database Column Remarks: 创建时间 This field was generated by MyBatis Generator. This field corresponds to the database column devops_flink.create_time
* @mbg.generated
......@@ -89,7 +95,8 @@ public class DevopsFlink {
* @mbg.generated
*/
public DevopsFlink(Long id, String name, String cluster, String ip, String hostname, String rootUser,
String rootPwd, String needFree, String isInit, String isFree, Date createTime, Date updateTime) {
String rootPwd, String needFree, String isInit, String isFree, String isInstall, Date createTime,
Date updateTime) {
this.id = id;
this.name = name;
this.cluster = cluster;
......@@ -100,6 +107,7 @@ public class DevopsFlink {
this.needFree = needFree;
this.isInit = isInit;
this.isFree = isFree;
this.isInstall = isInstall;
this.createTime = createTime;
this.updateTime = updateTime;
}
......@@ -292,6 +300,24 @@ public class DevopsFlink {
this.isFree = isFree;
}
/**
* This method was generated by MyBatis Generator. This method returns the value of the database column devops_flink.is_install
* @return the value of devops_flink.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_flink.is_install
* @param isInstall the value for devops_flink.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_flink.create_time
* @return the value of devops_flink.create_time
......
......@@ -853,6 +853,76 @@ public class DevopsFlinkExample {
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;
......
......@@ -12,13 +12,15 @@ import net.wicp.tams.common.constant.dic.intf.IEnumCombobox;
public enum DevOpsType implements IEnumCombobox {
flink("flink流计算", "oss://lc-bigdata/flink", "oss://lc-bigdata/flink/init/frontcheck.sh",
"oss://lc-bigdata/doris/%s/check_system.sh", "v12", "oss://lc-bigdata/flink/init.tar",
new String[] { "oss://lc-bigdata/flink/init/ssh_free.sh" }),
"oss://lc-bigdata/flink/deploy/package.sh", "v12", "oss://lc-bigdata/flink/init.tar",
"oss://lc-bigdata/flink/deploy.tar", new String[] { "oss://lc-bigdata/flink/init/ssh_free.sh" }),
doris("大数据存储", "oss://lc-bigdata/doris", "oss://lc-bigdata/doris/check_system.sh", "", "",
"oss://lc-bigdata/doris/check_system.sh", new String[] {}),
doris("大数据存储", "oss://lc-bigdata/doris", "oss://lc-bigdata/doris/check_system.sh",
"oss://lc-bigdata/doris/doris_setup/setup.sh", "", "oss://lc-bigdata/doris/check_system.sh",
"oss://lc-bigdata/doris/doris_setup.tar", new String[] {}),
dmep("dmep数据平台", "oss://lc-bigdata/dmep", "", "", "", "oss://lc-bigdata/doris/check_system.sh", new String[] {});
dmep("dmep数据平台", "oss://lc-bigdata/dmep", "", "", "", "oss://lc-bigdata/doris/check_system.sh", "",
new String[] {});
private final String desc;
private final String checkurl;
......@@ -27,6 +29,11 @@ public enum DevOpsType implements IEnumCombobox {
private final String lastversion;
private final String[] otherparams;// 其它文件 ,如flink需要在check后要做免密
private final String checkDownFile;// OSS要下载的文件
private final String installDownFile;
public String getInstallDownFile() {
return installDownFile;
}
public String getCheckDownFile() {
return checkDownFile;
......@@ -66,13 +73,14 @@ public enum DevOpsType implements IEnumCombobox {
}
private DevOpsType(String desc, String baseurl, String checkurl, String installurlFormat, String lastversion,
String checkDownFile, String[] otherparams) {
String checkDownFile, String installDownFile, String[] otherparams) {
this.desc = desc;
this.baseurl = baseurl;
this.checkurl = checkurl;
this.installurlFormat = installurlFormat;
this.lastversion = lastversion;
this.checkDownFile = checkDownFile;
this.installDownFile = installDownFile;
this.otherparams = otherparams;
}
......
......@@ -40,12 +40,13 @@ public interface DevopsFlinkMapper extends BaseMapper<DevopsFlink>{
* @mbg.generated
*/
@Insert({ "insert into devops_flink (id, name, ", "cluster, ip, hostname, ", "root_user, root_pwd, ",
"need_free, is_init, ", "is_free, create_time, ", "update_time)",
"need_free, is_init, ", "is_free, is_install, ", "create_time, update_time)",
"values (#{id,jdbcType=BIGINT}, #{name,jdbcType=VARCHAR}, ",
"#{cluster,jdbcType=VARCHAR}, #{ip,jdbcType=VARCHAR}, #{hostname,jdbcType=VARCHAR}, ",
"#{rootUser,jdbcType=VARCHAR}, #{rootPwd,jdbcType=VARCHAR}, ",
"#{needFree,jdbcType=VARCHAR}, #{isInit,jdbcType=VARCHAR}, ",
"#{isFree,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, ", "#{updateTime,jdbcType=TIMESTAMP})" })
"#{isFree,jdbcType=VARCHAR}, #{isInstall,jdbcType=VARCHAR}, ",
"#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP})" })
int insert(DevopsFlink record);
/**
......@@ -65,7 +66,7 @@ public interface DevopsFlinkMapper extends BaseMapper<DevopsFlink>{
* @mbg.generated
*/
@Select({ "select", "id, name, cluster, ip, hostname, root_user, root_pwd, need_free, is_init, is_free, ",
"create_time, update_time", "from devops_flink", "where id = #{id,jdbcType=BIGINT}" })
"is_install, create_time, update_time", "from devops_flink", "where id = #{id,jdbcType=BIGINT}" })
@ResultMap("net.wicp.tams.app.duckula.controller.dao.DevopsFlinkMapper.BaseResultMap")
DevopsFlink selectByPrimaryKey(Long id);
......@@ -95,7 +96,8 @@ public interface DevopsFlinkMapper extends BaseMapper<DevopsFlink>{
"ip = #{ip,jdbcType=VARCHAR},", "hostname = #{hostname,jdbcType=VARCHAR},",
"root_user = #{rootUser,jdbcType=VARCHAR},", "root_pwd = #{rootPwd,jdbcType=VARCHAR},",
"need_free = #{needFree,jdbcType=VARCHAR},", "is_init = #{isInit,jdbcType=VARCHAR},",
"is_free = #{isFree,jdbcType=VARCHAR},", "create_time = #{createTime,jdbcType=TIMESTAMP},",
"update_time = #{updateTime,jdbcType=TIMESTAMP}", "where id = #{id,jdbcType=BIGINT}" })
"is_free = #{isFree,jdbcType=VARCHAR},", "is_install = #{isInstall,jdbcType=VARCHAR},",
"create_time = #{createTime,jdbcType=TIMESTAMP},", "update_time = #{updateTime,jdbcType=TIMESTAMP}",
"where id = #{id,jdbcType=BIGINT}" })
int updateByPrimaryKey(DevopsFlink record);
}
\ No newline at end of file
......@@ -24,6 +24,7 @@ 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.constant.PathType;
import net.wicp.tams.common.constant.dic.YesOrNo;
import net.wicp.tams.common.os.SSHAssit;
import net.wicp.tams.common.os.pool.SSHConnection;
import net.wicp.tams.component.tools.TapestryAssist;
......@@ -50,6 +51,8 @@ public class DorisConfig extends ParentPageBean<DevopsDoris> {
// SSHAssit.close(conn);
// }
if (isInsert) {
t.setIsInit(YesOrNo.no.name());
t.setIsInstall(YesOrNo.no.name());
devopsDorisMapper.insert(t);
} else {
devopsDorisMapper.updateByPrimaryKeySelective(t);
......@@ -76,6 +79,43 @@ public class DorisConfig extends ParentPageBean<DevopsDoris> {
}
}
public TextStreamResponse onInstallHost() {
final DevopsDoris devopsDoris = TapestryAssist.getBeanFromPage(DevopsDoris.class, requestGlobals);
// List<DevopsDoris> list = queryHostByCluster(devopsDoris.getCluster());
// 1、OSS下载
String localPath = PathType.getPath(DevOpsType.doris.getInstallDownFile());
// 1、登陆
SSHConnection conn = SSHAssit.getConn(devopsDoris.getIp(), "root", devopsDoris.getRootPwd());
try {
String remoteDir = "~/doris/doris_setup";
conn.executeCommand("mkdir -p " + remoteDir);
Result result = conn.scpDir(localPath, remoteDir, "0744", new String[] {}, new String[] {});
// 临时方案
if (result.isSuc()) {
devopsDoris.setIsInstall(YesOrNo.yes.name());
devopsDorisMapper.updateByPrimaryKeySelective(devopsDoris);
return TapestryAssist.getTextStreamResponse(
Result.getError("由于doris需要很长下载时间 ,请移步到服务器执行:sh ~/doris/doris_setup/setup.sh 进行安装"));
} else {
return TapestryAssist.getTextStreamResponse(Result.getError(result.getMessage()));
}
// 执行
// Result result = conn
// .executeCommand(String.format("sh %s", IOUtil.mergeFolderAndFilePath(remoteDir, "setup.sh")));
// log.info(result.getMessage());
// if (result.isSuc()) {
// devopsDoris.setIsInstall(YesOrNo.yes.name());
// devopsDorisMapper.updateByPrimaryKeySelective(devopsDoris);
// return TapestryAssist.getTextStreamResponse(Result.getSuc());
// } else {
// return TapestryAssist.getTextStreamResponse(Result.getError(result.getMessage()));
// }
} finally {
SSHAssit.close(conn);
}
}
/***
* <r:combobox id="groupIsEdit" name="isEdit" textField="name1" valueField=
* "name" url="/sys/OptionItemManager:list/YesOrNo" panelHeight="50" value=
......@@ -135,7 +175,13 @@ public class DorisConfig extends ParentPageBean<DevopsDoris> {
Result result = conn.executeCommand(
String.format("sh %s", IOUtil.mergeFolderAndFilePath("~/", DevOpsType.doris.getRelaPathCheck())));
log.info(result.getMessage());
return TapestryAssist.getTextStreamResponse(Result.getError("检查结果:" + result.getMessage()));
if (result.isSuc()) {
devopsDoris.setIsInit(YesOrNo.yes.name());
devopsDorisMapper.updateByPrimaryKeySelective(devopsDoris);
return TapestryAssist.getTextStreamResponse(Result.getSuc());
} else {
return TapestryAssist.getTextStreamResponse(Result.getError(result.getMessage()));
}
} finally {
SSHAssit.close(conn);
}
......
......@@ -4,6 +4,7 @@ import java.util.List;
import java.util.concurrent.CountDownLatch;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.Predicate;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.util.TextStreamResponse;
......@@ -40,6 +41,7 @@ public class FlinkConfig extends ParentPageBean<DevopsFlink> {
if (isInsert) {
t.setIsInit(YesOrNo.no.name());
t.setIsFree(YesOrNo.no.name());
t.setIsInstall(YesOrNo.no.name());
List<DevopsFlink> list = queryHostByCluster(t.getCluster());
int lastindex = 0;
if (CollectionUtils.isNotEmpty(list)) {
......@@ -84,6 +86,59 @@ public class FlinkConfig extends ParentPageBean<DevopsFlink> {
return list;
}
@SuppressWarnings("unchecked")
public TextStreamResponse onInstallHost() {
final DevopsFlink devopsFlink = TapestryAssist.getBeanFromPage(DevopsFlink.class, requestGlobals);
List<DevopsFlink> list = queryHostByCluster(devopsFlink.getCluster());
// StringBuffer installparam = new StringBuffer();
// for (int i = 0; i < list.size(); i++) {
// DevopsFlink flink = list.get(i);
// installparam.append(flink.getHostname());
// }
List<DevopsFlink> select = (List<DevopsFlink>) CollectionUtils.select(list, new Predicate() {
@Override
public boolean evaluate(Object arg0) {
DevopsFlink temp = (DevopsFlink) arg0;
return "prod-bigdata-flink03".equals(temp.getHostname());
}
});
if (CollectionUtils.isEmpty(select) || select.size() > 1) {
return TapestryAssist.getTextStreamResponse(Result.getError("不能安装,需要有且仅有一台主机为prod-bigdata-flink03的服务器"));
}
// 1、OSS下载
String localPath = PathType.getPath(DevOpsType.flink.getInstallDownFile());
DevopsFlink flink03 = select.get(0);
SSHConnection conn = SSHAssit.getConn(flink03.getIp(), flink03.getRootUser(), flink03.getRootPwd());
try {
String remoteDir = "~/flink/deploy";
conn.executeCommand("mkdir -p " + remoteDir);
conn.scpDir(localPath, remoteDir, "0744", new String[] {}, new String[] {});
Result result = conn
.executeCommand("sh " + remoteDir + "/package.sh prod-bigdata-flink01 prod-bigdata-flink02");
// TODO 不能打印日志
if (result.isSuc()) {
String message = result.getMessage();
if (message.contains("请手工执行distributeconf.sh")) {
Result disResult = conn.executeCommand(
"sh " + remoteDir + "/distributeconf.sh prod-bigdata-flink01 prod-bigdata-flink02");
if (disResult.isSuc()) {
// 安装成功改状态
for (DevopsFlink temp : list) {
temp.setIsInstall(YesOrNo.yes.name());
devopsFlinkMapper.updateByPrimaryKeySelective(temp);
}
}
}
}
} finally {
SSHAssit.close(conn);
}
return TapestryAssist.getTextStreamResponse(Result.getSuc());
}
/***
* 测试用后端调用
*
......
......@@ -17,6 +17,7 @@
<arg column="need_free" javaType="java.lang.String" jdbcType="VARCHAR" />
<arg column="is_init" javaType="java.lang.String" jdbcType="VARCHAR" />
<arg column="is_free" 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>
......@@ -93,7 +94,7 @@
This element is automatically generated by MyBatis Generator, do not modify.
-->
id, name, cluster, ip, hostname, root_user, root_pwd, need_free, is_init, is_free,
create_time, update_time
is_install, create_time, update_time
</sql>
<select id="selectByExample" parameterType="net.wicp.tams.app.duckula.controller.bean.models.DevopsFlinkExample" resultMap="BaseResultMap">
<!--
......@@ -160,6 +161,9 @@
<if test="isFree != null">
is_free,
</if>
<if test="isInstall != null">
is_install,
</if>
<if test="createTime != null">
create_time,
</if>
......@@ -198,6 +202,9 @@
<if test="isFree != null">
#{isFree,jdbcType=VARCHAR},
</if>
<if test="isInstall != null">
#{isInstall,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
......@@ -253,6 +260,9 @@
<if test="record.isFree != null">
is_free = #{record.isFree,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>
......@@ -280,6 +290,7 @@
need_free = #{record.needFree,jdbcType=VARCHAR},
is_init = #{record.isInit,jdbcType=VARCHAR},
is_free = #{record.isFree,jdbcType=VARCHAR},
is_install = #{record.isInstall,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=TIMESTAMP},
update_time = #{record.updateTime,jdbcType=TIMESTAMP}
<if test="_parameter != null">
......@@ -320,6 +331,9 @@
<if test="isFree != null">
is_free = #{isFree,jdbcType=VARCHAR},
</if>
<if test="isInstall != null">
is_install = #{isInstall,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
......
<html t:type="rjzjh/layoutQuery" queryButs="[{'id':'checkBut','iconCls':'icon-attach','text':'检查服务器','url':'checkHost','confirm':'你确定要检查此服务器吗?'}]"
<html t:type="rjzjh/layoutQuery" queryButs="[{'id':'checkBut','iconCls':'icon-attach','text':'检查服务器','url':'checkHost','confirm':'你确定要检查此服务器吗?'},{'id':'installBut','iconCls':'icon-attach','text':'安装','url':'installHost','confirm':'你确定要安装doris吗?'}]"
xmlns:t="http://tapestry.apache.org/schema/tapestry_5_4.xsd"
xmlns:r="tapestry-library:rjzjh"
xmlns:s="tapestry-library:tams"
......
<html t:type="rjzjh/layoutQuery" queryButs="[{'id':'checkBut','iconCls':'icon-attach','text':'初始化服务器','url':'checkHost','confirm':'你确定要初始化此服务器吗?'}]"
<html t:type="rjzjh/layoutQuery" queryButs="[{'id':'checkBut','iconCls':'icon-attach','text':'初始化服务器','url':'checkHost','confirm':'你确定要初始化此服务器吗?'},{'id':'installBut','iconCls':'icon-attach','text':'安装','url':'installHost','confirm':'你确定要安装flink吗?'}]"
xmlns:t="http://tapestry.apache.org/schema/tapestry_5_4.xsd"
xmlns:r="tapestry-library:rjzjh"
xmlns:s="tapestry-library:tams"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册