Authored by qinchao

memcache自动伸缩

... ... @@ -355,6 +355,9 @@ public class HttpUriContants {
*/
public static final String GET_CLOUD_UPDATE_ANSIBLE_DEPLOY_FOR_NODE = "/cloud/updateAnsibleDeployForNode";
public static final String GET_CLOUD_UPDATE_MEMCACHE_DEPLOY_FOR_INTERNAL_DOMAIN = "/cloud/updateMemcacheInfoForInternalDomain";
public static final String GET_CLOUD_UPDATE_MEMCACHE_DEPLOY_FOR_MOBJECT = "/cloud/updateMemcacheInfoForMobject";
public static final String GET_CLOUD_ELB_INFO = "cloudLb/getLbInfo";
/**
... ...
... ... @@ -9,6 +9,7 @@ import com.ui.cloud.QcloudModifyScalingGroupReq;
import com.ui.cloud.task.AutoScalingFactory;
import com.ui.contants.HttpUriContants;
import com.ui.http.HttpRestClient;
import com.ui.model.AutoScalingInfoReq;
import com.ui.model.BaseResponse;
import com.ui.model.domain.BuildMessage;
import com.ui.model.domain.HostInfo;
... ... @@ -669,5 +670,26 @@ public class AutoScalingCtrl {
}
/**
* memcache更新:内部dns
*/
@RequestMapping("/updateMemcacheInfoForInternalDomain")
@ResponseBody
public BaseResponse updateMemcacheInfoForInternalDomain(AutoScalingInfoReq infoReq){
BaseResponse resp = null;
resp = httpClient.defaultPost(HttpUriContants.GET_CLOUD_UPDATE_MEMCACHE_DEPLOY_FOR_INTERNAL_DOMAIN ,infoReq,BaseResponse.class);
return resp;
}
/**
* memcache更新:监控对象
*/
@RequestMapping("/updateMemcacheInfoForMobject")
@ResponseBody
public BaseResponse updateMemcacheInfoForMobject(AutoScalingInfoReq infoReq){
BaseResponse resp = null;
resp = httpClient.defaultPost(HttpUriContants.GET_CLOUD_UPDATE_MEMCACHE_DEPLOY_FOR_MOBJECT ,infoReq,BaseResponse.class);
return resp;
}
}
\ No newline at end of file
... ...
package com.ui.model;
import lombok.Data;
/**
* Created by craig.qin on 2017/10/19.
*/
@Data
public class AutoScalingInfoReq {
/**
* 云类型
* 1:亚马逊
* 2:腾讯
*/
private int cloudType;
//新申请到的ip串
private String newInstanceIps;
//java或者pch5
private String memcacheType;
}
... ...
... ... @@ -181,7 +181,7 @@
</div>
<script src="<%=basePath%>script/common/genarate_left_panel.js"></script>
<script src="<%=basePath%>script/autoscaling/autoscaling_new.js?v=20171018-5"></script>
<script src="<%=basePath%>script/autoscaling/autoscaling_new.js?v=20171019-1"></script>
<script>
$("#li_manager").addClass("active open");
$("#li_autoscaling").addClass("active");
... ...
... ... @@ -483,60 +483,14 @@ function deploy(ips){
}
writeToText(">>>正在部署系统,请稍后..."+scalingGroupName);
if(scalingGroupName.indexOf("nginx")>=0){
writeToText(">>>nginx项目,请稍后...");
var nginxPushParam={};
if(scalingGroupName.toUpperCase().indexOf("PCH5")>=0){
nginxPushParam.type=2;
}else{
nginxPushParam.type=1;
}
if($("#cloudType").val()==2){
nginxPushParam.select=2;//qcloud伸缩
}else{
nginxPushParam.select=3;//aws上的nginx伸缩
}
$.ajax({
url: contextPath + "nginxSync/pushTask",
type: "post",
dataType: "json",
data: nginxPushParam,
success: function (response) {
var intervalNginx = setInterval(function () {
$.ajax({
url: contextPath + "nginxSync/getTaskLog",
type: 'POST',
dataType: 'json',
data: {
taskId: response.data.taskId
},
success: function (data3) {
//console.log(data3);
var messagedata = data3.data;
var logList = messagedata.log;
if (logList != "") {
writeToText(logList);
}
//code为2 ,则结束
var code = messagedata.isFinished;
if (code == 1) {
clearInterval(intervalNginx);
writeToText("完毕..........");
}
},
error: function (e) {
requestError(url);
}
});
}, 3000);
},
error: function (e) {
requestError(url);
}
});
if(scalingGroupName=="PCH5-memcache"){
//pch5的memcache:获得镜像机器之后,把ips保存到mobject_info(监控对象)和internal_domain
updateMemcacheInfo("PC/H5");
}else if(scalingGroupName=="java-gateway-memcache"){
//java-gateway的memcache:获得镜像机器之后,把ips保存到mobject_info(监控对象)和internal_domain
updateMemcacheInfo("java");
}else if(scalingGroupName.indexOf("nginx")>=0){
updateNginxInfo();
}else if(scalingGroupName.indexOf("ELASTICSEARCH")>=0){
//伸缩ELASTICSEARCH机器
updateEsConfig();
... ... @@ -558,6 +512,121 @@ function deploy(ips){
}
}
function updateMemcacheInfo(memcacheType){
var paramFront={};
paramFront.newInstanceIps = newInstanceIps;
paramFront.cloudType=$("#cloudType").val();
paramFront.memcacheType=memcacheType;
//1.更新internal_domain
writeToText("开始更新内部dns:internal_domain.......");
var url=contextPath+'autoScalingTool/updateMemcacheInfoForInternalDomain';
$.ajax({
url: url,
type: 'POST',
data: paramFront,
dataType: 'json',
async: false,
success: function (data) {
if (!data || data.code != 200) {
responseError(data);
}else{
writeToText(" ");
}
},
error: function (e) {
requestError(url);
}
});
writeToText("开始更新内部dns结束.......");
//2.更新监控对象
writeToText("开始更新监控对象:mobject_info.......");
url=contextPath+'autoScalingTool/updateMemcacheInfoForMobject';
$.ajax({
url: url,
type: 'POST',
data: paramFront,
dataType: 'json',
async: false,
success: function (data) {
if (!data || data.code != 200) {
responseError(data);
}else{
writeToText(" ");
}
},
error: function (e) {
requestError(url);
}
});
writeToText("开始更新监控对象结束.......");
//更新主机标签
upHostCmdbInfo();
}
//nginx类型机器伸之后
function updateNginxInfo(){
writeToText(">>>nginx项目,请稍后...");
var nginxPushParam={};
if(scalingGroupName.toUpperCase().indexOf("PCH5")>=0){
nginxPushParam.type=2;
}else{
nginxPushParam.type=1;
}
if($("#cloudType").val()==2){
nginxPushParam.select=2;//qcloud伸缩
}else{
nginxPushParam.select=3;//aws上的nginx伸缩
}
var url=contextPath + "nginxSync/pushTask";
$.ajax({
url: url,
type: "post",
dataType: "json",
data: nginxPushParam,
success: function (response) {
var intervalNginx = setInterval(function () {
var urlNext=contextPath + "nginxSync/getTaskLog";
$.ajax({
url: urlNext,
type: 'POST',
dataType: 'json',
data: {
taskId: response.data.taskId
},
success: function (data3) {
//console.log(data3);
var messagedata = data3.data;
var logList = messagedata.log;
if (logList != "") {
writeToText(logList);
}
//code为2 ,则结束
var code = messagedata.isFinished;
if (code == 1) {
clearInterval(intervalNginx);
writeToText("完毕..........");
upHostCmdbInfo();
}
},
error: function (e) {
requestError(urlNext);
}
});
}, 3000);
},
error: function (e) {
requestError(url);
}
});
}
//更新es
function updateEsConfig(showMessage){
//elasticsearch项目,更新后台ssh
... ... @@ -986,7 +1055,13 @@ function getDeployProjectNames(groupName){
//缩容成功后执行
function unDeploy(showMessage){
if(scalingGroupName.indexOf("nginx")>=0){
if(scalingGroupName=="PCH5-memcache"){
//pch5的memcache
}else if(scalingGroupName=="java-gateway-memcache"){
//java-gateway的memcache
}else if(scalingGroupName.indexOf("nginx")>=0){
//什么都不用做
//发布完之后,显示关闭按钮
deployLaster();
... ...