mirror of https://gitee.com/bigwinds/arangodb
Added download for the startup configuration and implemented the start of the cluster
This commit is contained in:
parent
bb0f591349
commit
dfd03e33ad
|
@ -44,7 +44,55 @@
|
|||
* given in the body
|
||||
*/
|
||||
controller.post("/plan", function(req, res) {
|
||||
require("console").log(JSON.stringify(req.body()));
|
||||
var config = {},
|
||||
input = req.body(),
|
||||
result = {},
|
||||
starter,
|
||||
i,
|
||||
planner;
|
||||
|
||||
if (input.type === "testSetup") {
|
||||
config.dispatchers = {
|
||||
"d1": {
|
||||
"endpoint": "tcp://" + input.dispatcher
|
||||
}
|
||||
};
|
||||
config.numberOfDBservers = input.numberDBServers;
|
||||
config.numberOfCoordinators = input.numberCoordinators;
|
||||
result.config = config;
|
||||
planner = new cluster.Planner(config);
|
||||
result.plan = planner.getPlan();
|
||||
starter = new cluster.Kickstarter(planner.getPlan());
|
||||
result.runInfo = starter.launch();
|
||||
res.json(result);
|
||||
} 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());
|
||||
result.runInfo = starter.launch();
|
||||
res.json(result);
|
||||
}
|
||||
});
|
||||
|
||||
if (cluster.isCluster()) {
|
||||
|
|
|
@ -35,10 +35,17 @@
|
|||
},
|
||||
|
||||
planScenarioSelector: function() {
|
||||
if (!this.PlanScenarioSelector) {
|
||||
this.PlanScenarioSelector = new window.PlanScenarioSelectorView();
|
||||
if (!this.planScenarioSelector) {
|
||||
this.planScenarioSelector = new window.PlanScenarioSelectorView();
|
||||
}
|
||||
this.PlanScenarioSelector.render();
|
||||
this.planScenarioSelector.render();
|
||||
},
|
||||
|
||||
showDownload: function(content) {
|
||||
if (!this.downloadView) {
|
||||
this.downloadView = new window.DownloadView();
|
||||
}
|
||||
this.downloadView.render(content);
|
||||
},
|
||||
|
||||
initialize: function () {
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
<ul class="thumbnails2">
|
||||
<div class="headerBar">
|
||||
<a class="arangoHeader">Cluster Started - Download Configuration</a>
|
||||
</div>
|
||||
</ul>
|
||||
|
||||
<div class="thumbnails">
|
||||
<legend class="gv_inner">Your cluster has been started.</legend>
|
||||
|
||||
<div class="important">
|
||||
<p>
|
||||
In order to manage your cluster later you have to save this configuration.
|
||||
Without this configuration you cannot shutdown or restart your cluster using this interface.
|
||||
</p>
|
||||
<button class="btn btn-success" id="startDownload">Save Configuration</button>
|
||||
</div>
|
||||
|
||||
<legend class="gv_inner">The following ArangoDBs have been started</legend>
|
||||
<% for(var i = 0; i < endpoints.length; ++i) { %>
|
||||
<div class="control-group">
|
||||
<label for="host" class="control-label"><%= roles[i] %>:</label>
|
||||
<div class="controls">
|
||||
<% if(roles[i] === "DBserver") { %>
|
||||
<span><%= endpoints[i] %></span>
|
||||
<% } else { %>
|
||||
<a href="<%='http://' + endpoints[i].substr(6)%>"><%= endpoints[i] %></a>
|
||||
<% } %>
|
||||
</div>
|
||||
</div>
|
||||
<% } %>
|
||||
</div>
|
|
@ -1,26 +1,22 @@
|
|||
<div id="background">
|
||||
<ul class="thumbnails2">
|
||||
<div class="headerBar">
|
||||
<a class="arangoHeader">Cluster Management</a>
|
||||
</div>
|
||||
</ul>
|
||||
|
||||
<div class="thumbnails">
|
||||
<div>
|
||||
<legend class="gv_inner">Please select a cluster scenario:</legend>
|
||||
|
||||
<li class="bigtile" id="multiServerSymmetrical">
|
||||
<img src="img/multiMachineSym.png" class="scenarioImage" alt="">
|
||||
<h5 class="collectionName">Multi Machine Symmetrical</h5>
|
||||
</li>
|
||||
<li class="bigtile" id="multiServerAsymmetrical">
|
||||
<img src="img/multiMachineAsym.png" class="scenarioImage" alt="">
|
||||
<h5 class="collectionName">Multi Machine Asymmetrical</h5>
|
||||
</li>
|
||||
<li class="bigtile" id="singleServer">
|
||||
<img src="img/singleMachine.png" class="scenarioImage" alt="">
|
||||
<h5 class="collectionName">Single Machine</h5>
|
||||
</li>
|
||||
</div>
|
||||
<ul class="thumbnails2">
|
||||
<div class="headerBar">
|
||||
<a class="arangoHeader">Cluster Management</a>
|
||||
</div>
|
||||
</ul>
|
||||
|
||||
<div class="thumbnails">
|
||||
<legend class="gv_inner">Please select a cluster scenario:</legend>
|
||||
|
||||
<li class="bigtile" id="multiServerSymmetrical">
|
||||
<img src="img/multiMachineSym.png" class="scenarioImage" alt="">
|
||||
<h5 class="collectionName">Multi Machine Symmetrical</h5>
|
||||
</li>
|
||||
<li class="bigtile" id="multiServerAsymmetrical">
|
||||
<img src="img/multiMachineAsym.png" class="scenarioImage" alt="">
|
||||
<h5 class="collectionName">Multi Machine Asymmetrical</h5>
|
||||
</li>
|
||||
<li class="bigtile" id="singleServer">
|
||||
<img src="img/singleMachine.png" class="scenarioImage" alt="">
|
||||
<h5 class="collectionName">Single Machine</h5>
|
||||
</li>
|
||||
</div>
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
/*jslint indent: 2, nomen: true, maxlen: 100, sloppy: true, vars: true, white: true, plusplus: true, newcap: true */
|
||||
/*global window, $, Backbone, plannerTemplateEngine, alert */
|
||||
|
||||
(function() {
|
||||
"use strict";
|
||||
|
||||
window.DownloadView = Backbone.View.extend({
|
||||
el: "#content",
|
||||
template: plannerTemplateEngine.createTemplate("download.ejs"),
|
||||
|
||||
events: {
|
||||
"click #startDownload": "download"
|
||||
},
|
||||
|
||||
download: function() {
|
||||
window.open(this.content, "clusterConfiguration.json");
|
||||
},
|
||||
|
||||
render: function(content) {
|
||||
this.content = "data:application/octet-stream," + encodeURIComponent(JSON.stringify(content, 2));
|
||||
var toShow = _.findWhere(content.runInfo.runInfo, {isStartServers: true});
|
||||
$(this.el).html(this.template.render({
|
||||
endpoints: toShow.endpoints,
|
||||
roles: toShow.roles
|
||||
}));
|
||||
}
|
||||
});
|
||||
|
||||
}());
|
||||
|
|
@ -58,8 +58,10 @@
|
|||
|
||||
data.type = this.isSymmetric ? "symmetricalSetup" : "asymmetricalSetup";
|
||||
$.ajax("cluster/plan", {
|
||||
type: "POST",
|
||||
data: JSON.stringify(data)
|
||||
type: "POST",
|
||||
data: JSON.stringify(data)
|
||||
}).done(function(info) {
|
||||
window.App.showDownload(info);
|
||||
});
|
||||
},
|
||||
|
||||
|
|
|
@ -41,6 +41,8 @@
|
|||
numberDBServers: parseInt(d, 10),
|
||||
numberCoordinators: parseInt(c, 10)
|
||||
})
|
||||
}).done(function(info) {
|
||||
window.App.showDownload(info);
|
||||
});
|
||||
},
|
||||
|
||||
|
|
Loading…
Reference in New Issue