1
0
Fork 0

Fixed relaunch and shutdown and dsiplay of testPlan if a plan is existent and loading

This commit is contained in:
Michael Hackstein 2014-02-28 09:38:25 +01:00
parent 89c784361c
commit d403e69486
8 changed files with 109 additions and 160 deletions

View File

@ -61,6 +61,56 @@
k.runInfo = config.runInfo;
return k;
},
startUp = function(req, res) {
cleanUp();
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;
});
}
require("console").log(JSON.stringify(config));
result.config = config;
planner = new cluster.Planner(config);
result.plan = planner.getPlan();
starter = new cluster.Kickstarter(planner.getPlan());
tmp = starter.launch();
result.runInfo = tmp.runInfo;
plans.storeConfig(result);
res.json(result);
},
cleanUp = function() {
var k = getStarter();
if (k) {
@ -68,55 +118,8 @@
}
};
// only make these functions available in dispatcher mode!
controller.post("/plan", function(req, res) {
cleanUp();
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;
planner = new cluster.Planner(config);
result.plan = planner.getPlan();
starter = new cluster.Kickstarter(planner.getPlan());
tmp = starter.launch();
result.runInfo = tmp.runInfo;
plans.storeConfig(result);
res.json(result);
});
controller.post("/plan", startUp);
controller.put("/plan", startUp);
controller.get("/plan", function(req, res) {
res.json(plans.loadConfig());
@ -128,7 +131,13 @@
});
controller.get("/healthcheck", function(req, res) {
res.json(!getStarter().isHealthy().error);
var out = getStarter().isHealthy();
var stf = JSON.stringify(out);
if (out.error || stf.indexOf("NOT-FOUND") !== -1) {
res.json(false);
return;
}
res.json(true);
});
controller.get("/shutdown", function(req, res) {

View File

@ -10,10 +10,7 @@
url: "cluster/plan",
isNew : function() {
return true;
},
idAttribute: "config",
getCoordinator: function() {
if (this._coord) {
@ -53,7 +50,6 @@
}
});
return result;
}
});

View File

@ -106,7 +106,7 @@
if (!this.clusterDownView) {
this.clusterDownView = new window.ClusterDownView();
}
this.clusterDownView.render(content);
this.clusterDownView.render();
}
});

View File

@ -7,16 +7,12 @@
window.App = new window.ClusterRouter();
Backbone.history.start();
//für zum testen
// this.clusterPlan.set({"plan": "blub"});
if(window.App.clusterPlan.get("plan")) {
if(window.App.clusterPlan.isAlive()) {
window.App.showCluster();
} else {
window.App.handleClusterDown();
}
} else {
window.App.planScenario();
}

View File

@ -4,60 +4,26 @@
<a class="arangoHeader">Plan a single server test configuration</a>
</div>
</ul>
<%
if (config) {
dispatcher = config.dispatcher;
hostname = dispatcher.split(':')[0];
port = dispatcher.split(':')[1];
numberDBServers = config.numberDBServers;
numberCoordinators = config.numberCoordinators;
}
%>
<form action="javascript:void(0);" autocomplete="on" class="form-horizontal">
<fieldset>
<div class="control-group">
<label for="host" class="control-label">Server:</label>
<div class="controls">
<input type="text" id="host" placeholder="Server" class="input-xlarge"
<%if (config) {%>
value="<%=hostname%>"
<%} else {%>
value="<%=window.location.hostname%>"
<%}%>
></input>
<span class="searchEqualsLabel">:</span>
<input type="text" maxlength="5" class="input-small" id="port" placeholder="port"
<%if (config) {%>
console.log("blub);
value="<%=port%>"
<%} else {%>
value="<%=window.location.port%>"
<%}%>
></input>
<input type="text" id="host" placeholder="Server" class="input-xlarge" value="<%=hostname%>"></input>
<span class="searchEqualsLabel">:</span>
<input type="text" maxlength="5" class="input-small" id="port" placeholder="port" value="<%=port%>" ></input>
</div>
</div>
<div class="control-group">
<label for="coordinators" class="control-label">Coordinators:</label>
<div class="controls">
<input type="text" id="coordinators" placeholder="Number of Coordinators" class="input-xlarge"
<%if (config) {%>
value="<%=numberCoordinators%>"
<%} else {%>
value="1"
<%}%>
></input>
<input type="text" id="coordinators" placeholder="Number of Coordinators" class="input-xlarge" value="<%=coords%>" ></input>
</div>
</div>
<div class="control-group">
<label for="dbs" class="control-label">DB Servers:</label>
<div class="controls">
<input type="text" id="dbs" placeholder="Number of DBServers" class="input-xlarge"
<%if (config) {%>
value="<%=numberDBServers%>"
<%} else {%>
value="2"
<%}%>
></input>
<input type="text" id="dbs" placeholder="Number of DBServers" class="input-xlarge" value="<%=dbs%>"></input>
</div>
</div>
</fieldset>

View File

@ -16,72 +16,37 @@
"click #deletePlan" : "deletePlan"
},
initialize : function() {
this.dbservers = new window.ClusterServers([], {
interval: this.interval
});
this.dbservers.fetch({
async: false
});
this.dbservers.startUpdating();
},
render: function() {
$(this.el).html(this.template.render({}));
},
relaunchCluster: function() {
console.log("relaunchCluster");
var result = false;
$.ajax({
cache: false,
type: "GET",
async: false, // sequential calls!
url: "/cluster/relaunch",
url: "cluster/relaunch",
success: function(data) {
result = data;
},
error: function(data) {
window.App.navigate("showCluster", {trigger: true});
}
});
return result;
},
editPlan: function() {
console.log("editPlan");
//welches Scenario und entsprechende View rendern
//siehe showClusterView.js
var byAddress = this.listByAddress();
if (Object.keys(byAddress).length === 1) {
this.type = "testPlan";
} else {
this.type = "other";
}
if (this.type === "testPlan") {
var config = window.App.clusterPlan.get("config");
if (_.size(config.dispatchers) === 1) {
window.App.navigate("planTest", {trigger : true});
} else {
// window.App.navigate("planSymmetrical", {trigger : true});
window.App.navigate("planAsymmetrical", {trigger : true});
return;
}
//TODO
// window.App.navigate("planSymmetrical", {trigger : true});
window.App.navigate("planAsymmetrical", {trigger : true});
},
deletePlan: function() {
console.log("deletePlan");
//irgendwie löschen
//view planScenario
},
listByAddress: function() {
var byAddress = this.dbservers.byAddress();
byAddress = this.coordinators.byAddress(byAddress);
return byAddress;
window.App.clusterPlan.destroy();
window.App.planScenario();
}
});
}());

View File

@ -19,7 +19,7 @@
var isDBServer;
var isCoordinator;
var self = this;
var data = {dispatcher : []};
var data = {dispatchers: []};
var foundCoordinator = false;
var foundDBServer = false;
$(".dispatcher").each(function(i, dispatcher) {
@ -36,7 +36,7 @@
foundCoordinator = foundCoordinator || hostObject.isCoordinator;
foundDBServer = foundDBServer || hostObject.isDBServer;
data.dispatcher.push(hostObject);
data.dispatchers.push(hostObject);
})
if (!self.isSymmetric) {
if (!foundDBServer) {
@ -48,7 +48,7 @@
return;
}
} else {
if ( data.dispatcher.length === 0) {
if ( data.dispatchers.length === 0) {
alert("Please provide at least one Host");
return;
}
@ -56,12 +56,14 @@
}
data.type = this.isSymmetric ? "symmetricalSetup" : "asymmetricalSetup";
$.ajax("cluster/plan", {
type: "POST",
data: JSON.stringify(data)
}).done(function(info) {
window.App.showDownload(info);
});
this.model.save(
data,
{
success : function(info) {
window.App.navigate("showCluster", {trigger: true});
}
}
);
},
addEntry: function() {

View File

@ -42,17 +42,32 @@
numberDBServers: parseInt(d, 10),
numberCoordinators: parseInt(c, 10)
},
{success : function(info) {
console.log("planTestView.js");
window.App.navigate("showCluster", {trigger: true});
}}
{
success : function(info) {
window.App.navigate("showCluster", {trigger: true});
}
}
);
},
render: function() {
$(this.el).html(this.template.render({
config : this.model.get("config")
}));
var param = {};
var config = this.model.get("config");
if (config) {
param.dbs = config.numberOfDBservers;
param.coords = config.numberOfCoordinators;
var host = config.dispatchers.d1.endpoint;
host = host.split("://")[1];
host = host.split(":");
param.hostname = host[0];
param.port = host[1];
} else {
param.dbs = 2;
param.coords = 1;
param.hostname = window.location.hostname;
param.port = window.location.port;
}
$(this.el).html(this.template.render(param));
}
});