1
0
Fork 0

Cleanup results of launch and friends in kickstarter.

Add allowAgents option for dispatchers.
This commit is contained in:
Max Neunhoeffer 2014-02-28 09:31:16 +01:00
parent 6f26e4fc23
commit b61dfa3c12
2 changed files with 49 additions and 25 deletions

View File

@ -128,7 +128,7 @@ launchActions.startAgent = function (dispatchers, cmd, isRelaunch) {
console.info("Starting agent..."); console.info("Starting agent...");
// First find out our own data directory: // First find out our own data directory:
var myDataDir = fs.normalize(fs.join(ArangoServerState.basePath(), "..")); var myDataDir = fs.normalize(fs.join(ArangoServerState.basePath(),"cluster"));
var dataPath = fs.makeAbsolute(cmd.dataPath); var dataPath = fs.makeAbsolute(cmd.dataPath);
if (dataPath !== cmd.dataPath) { // path was relative if (dataPath !== cmd.dataPath) { // path was relative
dataPath = fs.normalize(fs.join(myDataDir,cmd.dataPath)); dataPath = fs.normalize(fs.join(myDataDir,cmd.dataPath));
@ -216,7 +216,7 @@ launchActions.sendConfiguration = function (dispatchers, cmd, isRelaunch) {
launchActions.startServers = function (dispatchers, cmd, isRelaunch) { launchActions.startServers = function (dispatchers, cmd, isRelaunch) {
// First find out our own data directory to setup base for relative paths: // First find out our own data directory to setup base for relative paths:
var myDataDir = fs.normalize(fs.join(ArangoServerState.basePath(),"..")); var myDataDir = fs.normalize(fs.join(ArangoServerState.basePath(),"cluster"));
var dataPath = fs.makeAbsolute(cmd.dataPath); var dataPath = fs.makeAbsolute(cmd.dataPath);
if (dataPath !== cmd.dataPath) { // path was relative if (dataPath !== cmd.dataPath) { // path was relative
dataPath = fs.normalize(fs.join(myDataDir, cmd.dataPath)); dataPath = fs.normalize(fs.join(myDataDir, cmd.dataPath));
@ -335,6 +335,13 @@ launchActions.createSystemColls = function (dispatchers, cmd) {
'return load("js/server/version-check.js");\n'; 'return load("js/server/version-check.js");\n';
var o = { method: "POST", timeout: 90, headers: hdrs }; var o = { method: "POST", timeout: 90, headers: hdrs };
r = download(url, body, o); r = download(url, body, o);
if (r.code === 200) {
r = JSON.parse(r.body);
r.isCreateSystemColls = true;
return r;
}
r.error = true;
r.isCreateSystemColls = true;
return r; return r;
}; };
@ -371,7 +378,7 @@ cleanupActions.startAgent = function (dispatchers, cmd) {
console.info("Cleaning up agent..."); console.info("Cleaning up agent...");
// First find out our own data directory: // First find out our own data directory:
var myDataDir = fs.normalize(fs.join(ArangoServerState.basePath(),"..")); var myDataDir = fs.normalize(fs.join(ArangoServerState.basePath(),"cluster"));
var dataPath = fs.makeAbsolute(cmd.dataPath); var dataPath = fs.makeAbsolute(cmd.dataPath);
if (dataPath !== cmd.dataPath) { // path was relative if (dataPath !== cmd.dataPath) { // path was relative
dataPath = fs.normalize(fs.join(myDataDir,cmd.dataPath)); dataPath = fs.normalize(fs.join(myDataDir,cmd.dataPath));
@ -388,7 +395,7 @@ cleanupActions.startServers = function (dispatchers, cmd, isRelaunch) {
console.info("Cleaning up DBservers..."); console.info("Cleaning up DBservers...");
// First find out our own data directory to setup base for relative paths: // First find out our own data directory to setup base for relative paths:
var myDataDir = fs.normalize(fs.join(ArangoServerState.basePath(),"..")); var myDataDir = fs.normalize(fs.join(ArangoServerState.basePath(),"cluster"));
var dataPath = fs.makeAbsolute(cmd.dataPath); var dataPath = fs.makeAbsolute(cmd.dataPath);
if (dataPath !== cmd.dataPath) { // path was relative if (dataPath !== cmd.dataPath) { // path was relative
dataPath = fs.normalize(fs.join(myDataDir, cmd.dataPath)); dataPath = fs.normalize(fs.join(myDataDir, cmd.dataPath));
@ -511,7 +518,7 @@ Kickstarter.prototype.launch = function () {
} }
} }
else { else {
results.push({ error: false }); results.push({ error: false, action: cmd.action });
} }
} }
else { else {
@ -605,7 +612,7 @@ Kickstarter.prototype.relaunch = function () {
} }
} }
else { else {
results.push({ error: false }); results.push({ error: false, action: cmd.action });
} }
} }
else { else {
@ -687,7 +694,7 @@ Kickstarter.prototype.shutdown = function() {
results.push(res); results.push(res);
} }
else { else {
results.push({ error: false }); results.push({ error: false, action: cmd.action });
} }
} }
else { else {
@ -766,7 +773,7 @@ Kickstarter.prototype.cleanup = function() {
} }
} }
else { else {
results.push({ error: false }); results.push({ error: false, action: cmd.action });
} }
} }
else { else {
@ -844,7 +851,7 @@ Kickstarter.prototype.isHealthy = function() {
results.push(res); results.push(res);
} }
else { else {
results.push({ error: false }); results.push({ error: false, action: cmd.action });
} }
} }
else { else {

View File

@ -226,6 +226,9 @@ function fillConfigWithDefaults (config, defaultConfig) {
/// - `allowDBservers`, which is a boolean value indicating /// - `allowDBservers`, which is a boolean value indicating
/// whether or not DBservers should be started on this dispatcher, /// whether or not DBservers should be started on this dispatcher,
/// the default is `true` /// the default is `true`
/// - `allowAgents`, which is a boolean value indicating whether or
/// not agents should be started on this dispatcher, the default is
/// `true`
/// - `username`, which is a string that contains the user name /// - `username`, which is a string that contains the user name
/// for authentication with this dispatcher /// for authentication with this dispatcher
/// - `passwd`, which is a string that contains the password /// - `passwd`, which is a string that contains the password
@ -264,12 +267,14 @@ function fillConfigWithDefaults (config, defaultConfig) {
/// data directories. This can either be an absolute path (in which /// data directories. This can either be an absolute path (in which
/// case all machines in the clusters must use the same path), or /// case all machines in the clusters must use the same path), or
/// it can be a relative path. In the latter case it describes the /// it can be a relative path. In the latter case it describes the
/// data path relative to the path under which the dispatcher stores /// data path relative to a directory "cluster" in the directory in
/// its own data directory. For example, if the data directory /// which the dispatcher stores
/// its data. For example, if the data directory
/// given on the command line of the dispatcher is /// given on the command line of the dispatcher is
/// `/etc/arangod/data` and the value of the `dataPath` property is an /// `/var/lib/arangod` and the value of the `dataPath` property is an
/// empty string , then the DBservers started by this dispatcher /// empty string , then the DBservers started by this dispatcher
/// will have their data directories under `/etc/arangod` as well. /// will have their data directories in the directory
/// `/var/lib/arangod/cluster`.
/// These directories will be called `data-PREFIX-ID` where `PREFIX` /// These directories will be called `data-PREFIX-ID` where `PREFIX`
/// is replaced with the agency prefix (see above) and `ID` is the /// is replaced with the agency prefix (see above) and `ID` is the
/// ID of the DBserver or coordinator. /// ID of the DBserver or coordinator.
@ -290,7 +295,7 @@ function fillConfigWithDefaults (config, defaultConfig) {
/// actual executable that will be started for the agents in the /// actual executable that will be started for the agents in the
/// agency. If this is an absolute path, it obviously has to be /// agency. If this is an absolute path, it obviously has to be
/// the same on all machines in the cluster, as described for /// the same on all machines in the cluster, as described for
/// `dataPath`. If it is an empty string, the dispatcher uses `etcd` /// `dataPath`. If it is an empty string, the dispatcher uses `etcd-arango`
/// in the same directory as the executable that was used to start /// in the same directory as the executable that was used to start
/// itself. If it is a non-empty relative path, then this path is /// itself. If it is a non-empty relative path, then this path is
/// meant relative to the directory in which the executable of the /// meant relative to the directory in which the executable of the
@ -374,13 +379,16 @@ Planner.prototype.makePlan = function() {
if (!dispatchers[id].hasOwnProperty("allowDBservers")) { if (!dispatchers[id].hasOwnProperty("allowDBservers")) {
dispatchers[id].allowDBservers = true; dispatchers[id].allowDBservers = true;
} }
if (!dispatchers[id].hasOwnProperty("allowAgents")) {
dispatchers[id].allowAgents = true;
}
} }
} }
// If no dispatcher is there, configure a local one (ourselves): // If no dispatcher is there, configure a local one (ourselves):
if (Object.keys(dispatchers).length === 0) { if (Object.keys(dispatchers).length === 0) {
dispatchers.me = { "id": "me", "endpoint": "tcp://localhost:", dispatchers.me = { "id": "me", "endpoint": "tcp://localhost:",
"avoidPorts": {}, "allowCoordinators": true, "avoidPorts": {}, "allowCoordinators": true,
"allowDBservers": true }; "allowDBservers": true, "allowAgents": true };
config.onlyLocalhost = true; config.onlyLocalhost = true;
} }
else { else {
@ -398,21 +406,30 @@ Planner.prototype.makePlan = function() {
// Distribute agents to dispatchers (round robin, choosing ports) // Distribute agents to dispatchers (round robin, choosing ports)
var d = 0; var d = 0;
var wrap = d;
var agents = []; var agents = [];
pf = []; // will be filled lazily pf = []; // will be filled lazily
pf2 = []; // will be filled lazily pf2 = []; // will be filled lazily
for (i = 0; i < config.numberOfAgents; i++) { i = 0;
// Find two ports: var oldi = i;
if (!pf.hasOwnProperty(d)) { while (i < config.numberOfAgents) {
pf[d] = new PortFinder(config.agentExtPorts, dispatchers[dispList[d]]); if (dispatchers[dispList[d]].allowAgents) {
pf2[d] = new PortFinder(config.agentIntPorts, dispatchers[dispList[d]]); // Find two ports:
if (!pf.hasOwnProperty(d)) {
pf[d] = new PortFinder(config.agentExtPorts, dispatchers[dispList[d]]);
pf2[d] = new PortFinder(config.agentIntPorts, dispatchers[dispList[d]]);
}
agents.push({"dispatcher":dispList[d],
"extPort":pf[d].next(),
"intPort":pf2[d].next()});
i++;
} }
agents.push({"dispatcher":dispList[d],
"extPort":pf[d].next(),
"intPort":pf2[d].next()});
if (++d >= dispList.length) { if (++d >= dispList.length) {
d = 0; d = 0;
} }
if (d === wrap && oldi === i) {
break;
}
} }
// Distribute coordinators to dispatchers // Distribute coordinators to dispatchers
@ -420,8 +437,8 @@ Planner.prototype.makePlan = function() {
pf = []; pf = [];
d = 0; d = 0;
i = 0; i = 0;
var wrap = d; wrap = d;
var oldi = i; oldi = i;
while (i < config.numberOfCoordinators) { while (i < config.numberOfCoordinators) {
if (dispatchers[dispList[d]].allowCoordinators) { if (dispatchers[dispList[d]].allowCoordinators) {
if (!pf.hasOwnProperty(d)) { if (!pf.hasOwnProperty(d)) {