Authored by qinchao

系统mysql支持切换

... ... @@ -83,6 +83,9 @@
<button class="btn btn-large btn-primary" id="toqq-btn" onclick="toDoExe('toQcloud')">
所有流量切向qq
</button>
<button class="btn btn-large btn-primary" id="toqq-withmysql-btn" onclick="toDoExeWithMysql('toQcloud')">
所有流量切向qq(包括mysql)
</button>
</div>
</div>
<div class="panel">
... ... @@ -90,7 +93,7 @@
<h4 style="display: inline">切换流程</h4>
</div>
<div class="panel-body">
<button class="btn btn-large" id="switch_mysql-btn" style="background-color: green">mysql</button>
<button class="btn btn-large" id="switch_mysql-btn">mysql</button>
===》
<button class="btn btn-large" id="switch_redis-btn">redis(目标DC)</button>
===》
... ... @@ -156,6 +159,24 @@
</div>
</div>
</div>
<div id="second_confirm_model" class="modal"tabindex="-1" role="dialog" style="padding-top: 12%">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
<h5 class="modal-title"><i class="fa fa-exclamation-circle"></i> <span class="title" style="font-weight: bold;">再次确认</span></h5>
</div>
<div class="modal-body small">
<p ><span class="message">确定执行切换?</span></p><input type="text" disabled id="reconfirm_tocloud"/>
<input type="hidden" id="tokenID">
</div>
<div class="modal-footer" >
<button type="button" class="btn btn-primary ok" onclick="reConfirmSwitchSubmit()">确认</button>
<button type="button" class="btn btn-default cancel" data-dismiss="modal">取消</button>
</div>
</div>
</div>
</div>
<script src="<%=basePath %>script/common/genarate_left_panel.js"></script>
... ... @@ -169,6 +190,7 @@
var array = new Array();
var array_next = new Array();
$(document).ready(function () {
array.push("switch_mysql");
array.push("switch_redis");
array.push("switch_internel_dns");
array.push("switch_cobar");
... ... @@ -182,6 +204,14 @@
//执行切换
function toDoExe(toCloud) {
array.splice(0,array.length);//清空数组
//array.push("switch_mysql");
array.push("switch_redis");
array.push("switch_internel_dns");
array.push("switch_cobar");
array.push("switch_lua");
array.push("switch_dnspod");
switchWait = null;
$("input[name='cloud_name']").val(toCloud);
$("input[name='sms_name']").val('');
... ... @@ -189,8 +219,54 @@
type: 'post',
url: contextPath + "/centerSwitch/doExeAndCheckBefore",
dataType: 'json',
success: function (resp) {
if(resp.code == 200){
$('#confirmSubmitDivId').modal('show');
}else{
var errorMsg="发送短信验证码异常";
if(resp.message){
errorMsg=resp.message;
}
alert(errorMsg);
}
},
error: function () {
alert("发送短信验证码失败");
}
});
}
function toDoExeWithMysql(toCloud){
array.splice(0,array.length);//清空数组
array.push("switch_mysql");
array.push("switch_redis");
array.push("switch_internel_dns");
array.push("switch_cobar");
array.push("switch_lua");
array.push("switch_dnspod");
switchWait = null;
$("input[name='cloud_name']").val(toCloud);
$("input[name='sms_name']").val('');
$.ajax({
type: 'post',
url: contextPath + "/centerSwitch/doExeAndCheckBefore",
dataType: 'json',
success: function (resp) {
if(resp.code == 200){
$('#confirmSubmitDivId').modal('show');
}else{
var errorMsg="发送短信验证码异常";
if(resp.message){
errorMsg=resp.message;
}
alert(errorMsg);
}
},
error: function () {
alert("发送短信验证码失败");
}
});
$('#confirmSubmitDivId').modal('show');
}
function submit(){
... ... @@ -209,19 +285,12 @@
dataType: 'json',
success: function (resp) {
if(resp.code == 200){
$('#confirmSubmitDivId').modal('hide');
$("#detail-div").empty();
for (var i = 0; i < array.length; i++) {
$("#" + array[i] + "-btn").removeClass("btn-success");
}
for (var j = 0; j < array_next.length; j++) {
$("#" + array_next[j] + "-btn").removeClass("btn-success");
}
$("#java-btn").removeClass("btn-success");
$("#java_next-btn").removeClass("btn-success");
switchWait = toWait("正在切换(目标DC),请耐心等候...");
doExe(array, 0, toCloud);
$("#tokenID").val(resp.data);
$("#reconfirm_tocloud").val(toCloud);
$('#second_confirm_model').modal({
keyboard: false,
backdrop:'static'
});
}else{
alert("短信验证码错误或者失效");
}
... ... @@ -231,6 +300,24 @@
});
}
function reConfirmSwitchSubmit(){
var toCloud = $("input[name='cloud_name']").val();
$('#second_confirm_model').modal('hide');
$('#confirmSubmitDivId').modal('hide');
$("#detail-div").empty();
for (var i = 0; i < array.length; i++) {
$("#" + array[i] + "-btn").removeClass("btn-success");
}
for (var j = 0; j < array_next.length; j++) {
$("#" + array_next[j] + "-btn").removeClass("btn-success");
}
$("#java-btn").removeClass("btn-success");
$("#java_next-btn").removeClass("btn-success");
switchWait = toWait("正在切换(目标DC),请耐心等候...");
doExe(array, 0, toCloud);
}
var switchWait;
//执行切换
function doExe(array, i,commond) {
... ... @@ -240,26 +327,37 @@
type: 'post',
url: contextPath + "/centerSwitch/doExeAndCheck",
data: {
'tokenID':$("#tokenID").val(),
'name': name,
'exe': commond
},
dataType: 'json',
success: function (resp) {
$("#"+name+"-btn").removeClass("btn-warning");
$("#"+name+"-btn").addClass("btn-success");
var div = "<div class=\"alert alert-info alert-block\">";
div = div + "<h4 class=\"alert-heading\">" + name + "</h4>";
div = div + resp.data + "</div>";
$("#detail-div").append(div);
i++;
if(i < array.length){
doExe(array,i,commond);
if(resp.code == 200){
$("#"+name+"-btn").removeClass("btn-warning");
$("#"+name+"-btn").addClass("btn-success");
var div = "<div class=\"alert alert-info alert-block\">";
div = div + "<h4 class=\"alert-heading\">" + name + "</h4>";
div = div + resp.data + "</div>";
$("#detail-div").append(div);
i++;
if(i < array.length){
doExe(array,i,commond);
}else{
switchWait.modal('hide');
//重启java
javaRestart(commond);
}
}else{
switchWait.modal('hide');
var div = "<div class=\"alert alert-warning alert-block\">";
div = div + "<h4 class=\"alert-heading\">" + name + "</h4>";
div = div + "发生异常:"+resp.message + "</div>";
$("#detail-div").append(div);
//重启java
javaRestart(commond);
switchWait.modal('hide');
}
},
error: function () {
var div = "<div>切换(目标DC)请求异常</div>";
... ... @@ -318,26 +416,37 @@
type: 'post',
url: contextPath + "/centerSwitch/doExeAndCheck",
data: {
'tokenID':$("#tokenID").val(),
'name': name,
'exe': commond
},
dataType: 'json',
success: function (resp) {
$("#"+name+"-btn").removeClass("btn-warning");
$("#"+name+"-btn").addClass("btn-success");
var div = "<div class=\"alert alert-info alert-block\">";
div = div + "<h4 class=\"alert-heading\">" + name + "</h4>";
div = div + resp.data + "</div>";
$("#detail-div").append(div);
i++;
if(i < array_next.length){
doExeNext(array_next,i,commond);
if(resp.code == 200){
$("#"+name+"-btn").removeClass("btn-warning");
$("#"+name+"-btn").addClass("btn-success");
var div = "<div class=\"alert alert-info alert-block\">";
div = div + "<h4 class=\"alert-heading\">" + name + "</h4>";
div = div + resp.data + "</div>";
$("#detail-div").append(div);
i++;
if(i < array_next.length){
doExeNext(array_next,i,commond);
}else{
switchWait.modal('hide');
//重启java
javaRestartNext(commond);
}
}else{
switchWait.modal('hide');
var div = "<div class=\"alert alert-warning alert-block\">";
div = div + "<h4 class=\"alert-heading\">" + name + "</h4>";
div = div + "发生异常:"+resp.message + "</div>";
$("#detail-div").append(div);
//重启java
javaRestartNext(commond);
switchWait.modal('hide');
}
},
error: function () {
var div = "<div>切换(源DC)请求异常</div>";
... ...