mirror of https://gitee.com/bigwinds/arangodb
Added foxx routes for cluster and dispatchers, they are now cluster resp. dispatcher only
This commit is contained in:
parent
076b8f1029
commit
7ed4f7c602
|
@ -43,118 +43,138 @@
|
||||||
* This will plan a new cluster with the information
|
* This will plan a new cluster with the information
|
||||||
* given in the body
|
* given in the body
|
||||||
*/
|
*/
|
||||||
controller.post("/plan", function(req, res) {
|
|
||||||
var config = {},
|
|
||||||
input = req.body(),
|
|
||||||
result = {},
|
|
||||||
starter,
|
|
||||||
i,
|
|
||||||
tmp,
|
|
||||||
planner;
|
|
||||||
|
|
||||||
if (input.type === "testSetup") {
|
|
||||||
config.dispatchers = {
|
if (!cluster.dispatcherDisabled()) {
|
||||||
"d1": {
|
var Plans = require("./repositories/plans.js"),
|
||||||
"endpoint": "tcp://" + input.dispatcher
|
plans = new Plans.Repository(
|
||||||
|
require("internal").db._collection(
|
||||||
|
"_cluster_kickstarter_plans"
|
||||||
|
)),
|
||||||
|
getStarter = function() {
|
||||||
|
require("console").log("load conf");
|
||||||
|
var config = plans.loadConfig(),
|
||||||
|
k;
|
||||||
|
require("console").log("loaded conf");
|
||||||
|
if (!config) {
|
||||||
|
require("console").log("No conf found");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
require("console").log("Conf found");
|
||||||
|
k = new cluster.Kickstarter(config.plan);
|
||||||
|
k.runInfo = config.runInfo;
|
||||||
|
return k;
|
||||||
|
},
|
||||||
|
cleanUp = function() {
|
||||||
|
var k = getStarter();
|
||||||
|
if (k) {
|
||||||
|
k.cleanup();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
config.numberOfDBservers = input.numberDBServers;
|
// only make these functions available in dispatcher mode!
|
||||||
config.numberOfCoordinators = input.numberCoordinators;
|
controller.post("/plan", function(req, res) {
|
||||||
|
require("console").log("Mueller");
|
||||||
|
cleanUp();
|
||||||
|
require("console").log("Peter");
|
||||||
|
var config = {},
|
||||||
|
input = req.body(),
|
||||||
|
result = {},
|
||||||
|
starter,
|
||||||
|
i,
|
||||||
|
tmp,
|
||||||
|
planner;
|
||||||
|
|
||||||
|
if (input.type === "testSetup") {
|
||||||
|
config.dispatchers = {
|
||||||
|
"d1": {
|
||||||
|
"endpoint": "tcp://" + input.dispatcher
|
||||||
|
}
|
||||||
|
};
|
||||||
|
config.numberOfDBservers = input.numberDBServers;
|
||||||
|
config.numberOfCoordinators = input.numberCoordinators;
|
||||||
|
} else {
|
||||||
|
i = 0;
|
||||||
|
config.dispatchers = {};
|
||||||
|
config.numberOfDBservers = 0;
|
||||||
|
config.numberOfCoordinators = 0;
|
||||||
|
_.each(input.dispatcher, function(d) {
|
||||||
|
i++;
|
||||||
|
var inf = {};
|
||||||
|
inf.endpoint = "tcp://" + d.host;
|
||||||
|
if (d.isCoordinator) {
|
||||||
|
config.numberOfCoordinators++;
|
||||||
|
} else {
|
||||||
|
inf.allowCoordinators = false;
|
||||||
|
}
|
||||||
|
if (d.isDBServer) {
|
||||||
|
config.numberOfDBservers++;
|
||||||
|
} else {
|
||||||
|
inf.allowDBservers = false;
|
||||||
|
}
|
||||||
|
config.dispatchers["d" + i] = inf;
|
||||||
|
});
|
||||||
|
}
|
||||||
result.config = config;
|
result.config = config;
|
||||||
planner = new cluster.Planner(config);
|
planner = new cluster.Planner(config);
|
||||||
result.plan = planner.getPlan();
|
result.plan = planner.getPlan();
|
||||||
starter = new cluster.Kickstarter(planner.getPlan());
|
starter = new cluster.Kickstarter(planner.getPlan());
|
||||||
tmp = starter.launch();
|
tmp = starter.launch();
|
||||||
result.runInfo = tmp.runInfo;
|
result.runInfo = tmp.runInfo;
|
||||||
|
plans.storeConfig(result);
|
||||||
res.json(result);
|
res.json(result);
|
||||||
} else {
|
});
|
||||||
i = 0;
|
|
||||||
config.dispatchers = {};
|
controller.get("/plan", function(req, res) {
|
||||||
config.numberOfDBservers = 0;
|
res.json(plans.loadConfig());
|
||||||
config.numberOfCoordinators = 0;
|
});
|
||||||
_.each(input.dispatcher, function(d) {
|
|
||||||
i++;
|
controller.del("/plan", function(req, res) {
|
||||||
var inf = {};
|
plans.clear();
|
||||||
inf.endpoint = "tcp://" + d.host;
|
res.json("ok");
|
||||||
if (d.isCoordinator) {
|
});
|
||||||
config.numberOfCoordinators++;
|
|
||||||
} else {
|
controller.get("/healthcheck", function(req, res) {
|
||||||
inf.allowCoordinators = false;
|
res.json(getStarter().isHealthy());
|
||||||
}
|
});
|
||||||
if (d.isDBServer) {
|
|
||||||
config.numberOfDBservers++;
|
controller.get("/shutdown", function(req, res) {
|
||||||
} else {
|
var k = getStarter();
|
||||||
inf.allowDBservers = false;
|
var shutdownInfo = k.shutdown();
|
||||||
}
|
if (shutdownInfo.error) {
|
||||||
config.dispatchers["d" + i] = inf;
|
res.json(shutdownInfo.results);
|
||||||
});
|
res.status(409);
|
||||||
result.config = config;
|
}
|
||||||
planner = new cluster.Planner(config);
|
});
|
||||||
result.plan = planner.getPlan();
|
|
||||||
starter = new cluster.Kickstarter(planner.getPlan());
|
controller.get("/cleanup", function(req, res) {
|
||||||
tmp = starter.launch();
|
var k = getStarter();
|
||||||
result.runInfo = tmp.runInfo;
|
var shutdownInfo = k.shutdown();
|
||||||
|
cleanUp();
|
||||||
|
if (shutdownInfo.error) {
|
||||||
|
res.json("Unable to shutdown cluster");
|
||||||
|
res.status(409);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
controller.get("/relaunch", function(req, res) {
|
||||||
|
var k = getStarter();
|
||||||
|
var r = k.relaunch();
|
||||||
|
if (r.error) {
|
||||||
|
res.json("Unable to relaunch cluster");
|
||||||
|
res.status(409);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var result = {
|
||||||
|
plan: r.plan,
|
||||||
|
runInfo: r.runInfo
|
||||||
|
};
|
||||||
|
result = plans.updateConfig(result);
|
||||||
res.json(result);
|
res.json(result);
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
controller.post("/healthcheck", function(req, res) {
|
|
||||||
var input = req.body();
|
|
||||||
var k = new cluster.Kickstarter(input.plan);
|
|
||||||
k.runInfo = input.runInfo;
|
|
||||||
res.json(k.isHealthy());
|
|
||||||
});
|
|
||||||
|
|
||||||
controller.post("/shutdown", function(req, res) {
|
|
||||||
var input = req.body();
|
|
||||||
var k = new cluster.Kickstarter(input.plan);
|
|
||||||
k.runInfo = input.runInfo;
|
|
||||||
var shutdownInfo = k.shutdown();
|
|
||||||
if (shutdownInfo.error) {
|
|
||||||
res.json(shutdownInfo.results);
|
|
||||||
res.status(409);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
controller.post("/cleanup", function(req, res) {
|
|
||||||
var input = req.body();
|
|
||||||
var k = new cluster.Kickstarter(input.plan);
|
|
||||||
k.runInfo = input.runInfo;
|
|
||||||
var shutdownInfo = k.shutdown();
|
|
||||||
if (shutdownInfo.error) {
|
|
||||||
res.json("Unable to shutdown cluster");
|
|
||||||
res.status(409);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
k.cleanup();
|
|
||||||
});
|
|
||||||
|
|
||||||
controller.post("/relaunch", function(req, res) {
|
|
||||||
var input = req.body();
|
|
||||||
var k = new cluster.Kickstarter(input.plan);
|
|
||||||
var r = k.relaunch();
|
|
||||||
if (r.error) {
|
|
||||||
res.json("Unable to relaunch cluster");
|
|
||||||
res.status(409);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
res.json({
|
|
||||||
config: input.config,
|
|
||||||
plan: r.plan,
|
|
||||||
runInfo: r.runInfo
|
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
|
|
||||||
// FAKE TO BE REMOVED TODO
|
|
||||||
controller.get("/ClusterType", function(req, res) {
|
|
||||||
res.json({
|
|
||||||
type: "symmetricSetup"
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
if (cluster.isCluster()) {
|
if (cluster.isCluster()) {
|
||||||
// only make these functions available in cluster mode!
|
// only make these functions available in cluster mode!
|
||||||
|
|
||||||
var Communication = require("org/arangodb/cluster/agency-communication"),
|
var Communication = require("org/arangodb/cluster/agency-communication"),
|
||||||
comm = new Communication.Communication(),
|
comm = new Communication.Communication(),
|
||||||
beats = comm.sync.Heartbeats(),
|
beats = comm.sync.Heartbeats(),
|
||||||
|
|
|
@ -414,7 +414,18 @@
|
||||||
// needs to be big enough for assets
|
// needs to be big enough for assets
|
||||||
return createSystemCollection("_routing", { journalSize: 32 * 1024 * 1024 });
|
return createSystemCollection("_routing", { journalSize: 32 * 1024 * 1024 });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @brief _cluster_kickstarter_plans
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// create the _routing collection
|
||||||
|
addTask("createKickstarterConfiguration",
|
||||||
|
"setup _cluster_kickstarter_plans collection", function () {
|
||||||
|
//TODO add check if this is the main dispatcher
|
||||||
|
return createSystemCollection("_cluster_kickstarter_plans");
|
||||||
|
});
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief insertRedirectionsAll
|
/// @brief insertRedirectionsAll
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
Loading…
Reference in New Issue