mirror of https://gitee.com/bigwinds/arangodb
Merge branch 'devel' of https://github.com/triAGENS/ArangoDB into devel
This commit is contained in:
commit
b7654658bd
|
@ -34,6 +34,7 @@
|
||||||
var FoxxController = require("org/arangodb/foxx").Controller,
|
var FoxxController = require("org/arangodb/foxx").Controller,
|
||||||
controller = new FoxxController(applicationContext),
|
controller = new FoxxController(applicationContext),
|
||||||
cluster = require("org/arangodb/cluster"),
|
cluster = require("org/arangodb/cluster"),
|
||||||
|
load = require("internal").download,
|
||||||
_ = require("underscore");
|
_ = require("underscore");
|
||||||
|
|
||||||
/** Plan and start a new cluster
|
/** Plan and start a new cluster
|
||||||
|
@ -49,7 +50,7 @@
|
||||||
res.json(!cluster.dispatcherDisabled());
|
res.json(!cluster.dispatcherDisabled());
|
||||||
});
|
});
|
||||||
|
|
||||||
if (! cluster.dispatcherDisabled()) {
|
if (!cluster.dispatcherDisabled()) {
|
||||||
var Plans = require("./repositories/plans.js"),
|
var Plans = require("./repositories/plans.js"),
|
||||||
plans = new Plans.Repository(
|
plans = new Plans.Repository(
|
||||||
require("internal").db._collection(
|
require("internal").db._collection(
|
||||||
|
@ -78,7 +79,7 @@
|
||||||
return {
|
return {
|
||||||
username: "root",
|
username: "root",
|
||||||
passwd: ""
|
passwd: ""
|
||||||
}
|
};
|
||||||
},
|
},
|
||||||
startUp = function(req, res) {
|
startUp = function(req, res) {
|
||||||
cleanUp();
|
cleanUp();
|
||||||
|
@ -170,6 +171,32 @@
|
||||||
res.json("ok");
|
res.json("ok");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
controller.post("/communicationCheck", function(req, res) {
|
||||||
|
var list = req.body();
|
||||||
|
var options = {};
|
||||||
|
var result = [];
|
||||||
|
var base64Encode = require("internal").base64Encode;
|
||||||
|
_.each(list, function(info) {
|
||||||
|
var host = info.host;
|
||||||
|
var port = info.port;
|
||||||
|
if (info.user) {
|
||||||
|
options.headers = {
|
||||||
|
"Authorization": "Basic " + base64Encode(info.user + ":" +
|
||||||
|
info.passwd)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
var url = "http://" + host + ":" + port + "/_api/version";
|
||||||
|
var resi = load(url, "", options);
|
||||||
|
if (resi.code !== 200) {
|
||||||
|
result.push(false);
|
||||||
|
} else {
|
||||||
|
result.push(true);
|
||||||
|
}
|
||||||
|
delete options.headers;
|
||||||
|
});
|
||||||
|
res.json(result);
|
||||||
|
});
|
||||||
|
|
||||||
controller.del("/plan", function(req, res) {
|
controller.del("/plan", function(req, res) {
|
||||||
plans.clear();
|
plans.clear();
|
||||||
res.json("ok");
|
res.json("ok");
|
||||||
|
|
|
@ -16,10 +16,10 @@
|
||||||
"click .delete" : "removeEntry",
|
"click .delete" : "removeEntry",
|
||||||
"click #cancel" : "cancel",
|
"click #cancel" : "cancel",
|
||||||
"click #test-all-connections" : "checkAllConnections",
|
"click #test-all-connections" : "checkAllConnections",
|
||||||
"focusout .host" : "autoCheckConnections",
|
"focusout .host" : "checkAllConnections",
|
||||||
"focusout .port" : "autoCheckConnections",
|
"focusout .port" : "checkAllConnections",
|
||||||
"focusout .user" : "autoCheckConnections",
|
"focusout .user" : "checkAllConnections",
|
||||||
"focusout .passwd" : "autoCheckConnections"
|
"focusout .passwd" : "checkAllConnections"
|
||||||
},
|
},
|
||||||
|
|
||||||
cancel: function() {
|
cancel: function() {
|
||||||
|
@ -84,7 +84,7 @@
|
||||||
$('.modal-backdrop.fade.in').addClass('waitModalBackdrop');
|
$('.modal-backdrop.fade.in').addClass('waitModalBackdrop');
|
||||||
$('#waitModalMessage').html('Please be patient while your cluster is being launched');
|
$('#waitModalMessage').html('Please be patient while your cluster is being launched');
|
||||||
delete window.App.clusterPlan._coord;
|
delete window.App.clusterPlan._coord;
|
||||||
window.App.clusterPlan.save(
|
window.App.clusterPlan.save(
|
||||||
data,
|
data,
|
||||||
{
|
{
|
||||||
success : function() {
|
success : function() {
|
||||||
|
@ -191,69 +191,64 @@
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
autoCheckConnections: function (e) {
|
readAllConnections: function() {
|
||||||
var host,
|
var res = [];
|
||||||
port,
|
$(".dispatcher").each(function(key, row) {
|
||||||
user,
|
var obj = {
|
||||||
passwd,
|
host: $('.host', row).val(),
|
||||||
parentElement = $(e.currentTarget).parent();
|
port: $('.port', row).val(),
|
||||||
host = $(parentElement).children('.host').val();
|
user: $('.user', row).val(),
|
||||||
port = $(parentElement).children('.port').val();
|
passwd: $('.passwd', row).val()
|
||||||
user = $(parentElement).children('.user').val();
|
};
|
||||||
passwd = $(parentElement).children('.passwd').val();
|
if (obj.host && obj.port) {
|
||||||
|
res.push(obj);
|
||||||
if (host !== '' && port !== '') {
|
}
|
||||||
this.checkAllConnections();
|
});
|
||||||
}
|
return res;
|
||||||
},
|
},
|
||||||
|
|
||||||
checkConnection: function(
|
checkAllConnections: function() {
|
||||||
host,
|
|
||||||
port,
|
|
||||||
user,
|
|
||||||
passwd,
|
|
||||||
target,
|
|
||||||
i,
|
|
||||||
dispatcherArray,
|
|
||||||
connectionValidationKey
|
|
||||||
) {
|
|
||||||
var self = this;
|
var self = this;
|
||||||
$(target).find('.cluster-connection-check-success').remove();
|
var connectionValidationKey = Math.random();
|
||||||
$(target).find('.cluster-connection-check-fail').remove();
|
this.connectionValidationKey = connectionValidationKey;
|
||||||
try {
|
$('.cluster-connection-check-success').remove();
|
||||||
$.ajax({
|
$('.cluster-connection-check-fail').remove();
|
||||||
async: true,
|
var list = this.readAllConnections();
|
||||||
cache: false,
|
if (list.length) {
|
||||||
type: "GET",
|
try {
|
||||||
xhrFields: {
|
$.ajax({
|
||||||
withCredentials: true
|
async: true,
|
||||||
},
|
cache: false,
|
||||||
url: "http://" + host + ":" + port + "/_api/version",
|
type: "POST",
|
||||||
success: function() {
|
url: "/_admin/aardvark/cluster/communicationCheck",
|
||||||
if (connectionValidationKey === self.connectionValidationKey) {
|
data: JSON.stringify(list),
|
||||||
$(target).append(
|
success: function(checkList) {
|
||||||
'<span class="cluster-connection-check-success">Connection: ok</span>'
|
if (connectionValidationKey === self.connectionValidationKey) {
|
||||||
);
|
var dispatcher = $(".dispatcher");
|
||||||
dispatcherArray[i] = true;
|
var i = 0;
|
||||||
self.checkDispatcherArray(dispatcherArray, connectionValidationKey);
|
dispatcher.each(function(key, row) {
|
||||||
|
var host = $(".host", row).val();
|
||||||
|
var port = $(".port", row).val();
|
||||||
|
if (host && port) {
|
||||||
|
if (checkList[i]) {
|
||||||
|
$(".controls:first", row).append(
|
||||||
|
'<span class="cluster-connection-check-success">Connection: ok</span>'
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$(".controls:first", row).append(
|
||||||
|
'<span class="cluster-connection-check-fail">Connection: fail</span>'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
self.checkDispatcherArray(checkList, connectionValidationKey);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
});
|
||||||
error: function(p) {
|
} catch (e) {
|
||||||
if (connectionValidationKey === self.connectionValidationKey) {
|
this.disableLaunchButton();
|
||||||
$(target).append(
|
}
|
||||||
'<span class="cluster-connection-check-fail">Connection: fail</span>'
|
|
||||||
);
|
|
||||||
dispatcherArray[i] = false;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
beforeSend: function(xhr) {
|
|
||||||
xhr.setRequestHeader("Authorization", "Basic " + btoa(user + ":" + passwd));
|
|
||||||
//send this header to prevent the login box
|
|
||||||
xhr.setRequestHeader("X-Omit-Www-Authenticate", "content");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} catch (e) {
|
|
||||||
this.disableLaunchButton();
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -266,39 +261,6 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
checkAllConnections: function() {
|
|
||||||
this.connectionValidationKey = Math.random();
|
|
||||||
this.disableLaunchButton();
|
|
||||||
var numOfDispatcher = $('.dispatcher').length,
|
|
||||||
dispatcherArray = [],
|
|
||||||
idx;
|
|
||||||
for (idx = 0; idx < numOfDispatcher; idx++) {
|
|
||||||
dispatcherArray.push(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Object mit #dispatcher + random key
|
|
||||||
var self = this;
|
|
||||||
$('.dispatcher').each(
|
|
||||||
function(i, dispatcher) {
|
|
||||||
var target = $('.controls', dispatcher)[0];
|
|
||||||
var host = $('.host', dispatcher).val();
|
|
||||||
var port = $('.port', dispatcher).val();
|
|
||||||
var user = $('.user', dispatcher).val();
|
|
||||||
var passwd = $('.passwd', dispatcher).val();
|
|
||||||
self.checkConnection(
|
|
||||||
host,
|
|
||||||
port,
|
|
||||||
user,
|
|
||||||
passwd,
|
|
||||||
target,
|
|
||||||
i,
|
|
||||||
dispatcherArray,
|
|
||||||
self.connectionValidationKey
|
|
||||||
);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
},
|
|
||||||
|
|
||||||
disableLaunchButton: function() {
|
disableLaunchButton: function() {
|
||||||
$('#startSymmetricPlan').attr('disabled', 'disabled');
|
$('#startSymmetricPlan').attr('disabled', 'disabled');
|
||||||
$('#startSymmetricPlan').removeClass('button-success');
|
$('#startSymmetricPlan').removeClass('button-success');
|
||||||
|
|
Loading…
Reference in New Issue