1
0
Fork 0

Merge branch 'devel' of ssh://github.com/ArangoDB/ArangoDB into devel

This commit is contained in:
Max Neunhoeffer 2017-02-08 11:00:36 +01:00
commit 0a31063a35
1 changed files with 62 additions and 0 deletions

View File

@ -60,6 +60,68 @@ var _ = require('lodash');
// / @brief was docuBlock JSF_cluster_test_HEAD
// //////////////////////////////////////////////////////////////////////////////
actions.defineHttp({
url: '_admin/cluster/removeServer',
allowUseDatabase: true,
prefix: false,
callback: function (req, res) {
if (req.requestType !== actions.POST ||
!require('@arangodb/cluster').isCoordinator()) {
actions.resultError(req, res, actions.HTTP_FORBIDDEN, 0,
'only DELETE requests are allowed and only to coordinators');
return;
}
let serverId;
try {
serverId = JSON.parse(req.requestBody);
} catch (e) {
}
if (typeof serverId !== 'string') {
actions.resultError(req, res, actions.HTTP_BAD,
'required parameter ServerID was not given');
return;
}
let agency = ArangoAgency.get('', false, true).arango;
if (agency.Current.DBServers[serverId] !== undefined) {
actions.resultError(req, res, actions.HTTP_BAD,
'removing dbservers not yet supported');
return;
}
let operations = {};
operations['/arango/Coordinators/' + serverId] = {'op': 'delete'};
operations['/arango/DBServers/' + serverId] = {'op': 'delete'};
operations['/arango/ServersRegistered/' + serverId] = {'op': 'delete'};
operations['/arango/Supervision/Health/' + serverId] = {'op': 'delete'};
operations['/arango/MapUniqueToShortID/' + serverId] = {'op': 'delete'};
let preconditions = {};
preconditions['/arango/Supervision/Health/' + serverId + '/Status'] = {'old': 'FAILED'};
try {
global.ArangoAgency.write([[operations, preconditions]]);
} catch (e) {
if (e.code === 412) {
actions.resultError(req, res, actions.HTTP_PRECONDITION_FAILED,
'you can only remove failed servers');
return;
}
throw e;
}
actions.resultOk(req, res, actions.HTTP_OK, true);
/*DBOnly:
Current/Databases/YYY/XXX
*/
}
});
actions.defineHttp({
url: '_admin/cluster-test',
prefix: true,