1
0
Fork 0

Merge branch 'sharding' of https://github.com/triAGENS/ArangoDB into sharding

This commit is contained in:
Jan Steemann 2014-01-22 08:38:09 +01:00
commit e81e057510
9 changed files with 98 additions and 57 deletions

View File

@ -70,6 +70,25 @@
res.json(resList);
});
controller.get("/Coordinators", function(req, res) {
var resList = [],
list = coords.getList(),
noBeat = beats.noBeat();
_.each(list, function(url, k) {
var v = {};
v.name = k;
v.url = url;
resList.push(v);
if (_.contains(noBeat, k)) {
v.status = "critical";
return;
}
v.status = "ok";
});
res.json(resList);
});
controller.get("/Databases", function(req, res) {
var list = dbs.getList();
res.json(_.map(list, function(d) {

View File

@ -1,5 +1,5 @@
/*jslint indent: 2, nomen: true, maxlen: 100, white: true, plusplus: true */
/*global window, Backbone */
/*global window, Backbone, console */
(function() {
"use strict";
window.ClusterCoordinators = Backbone.Collection.extend({
@ -8,32 +8,47 @@
url: "/_admin/aardvark/cluster/Coordinators",
getList: function() {
return [
{
name: "Charly",
url: "tcp://192.168.0.1:1337",
status: "ok"
},
{
name: "Carlos",
url: "tcp://192.168.0.2:1337",
status: "critical"
},
{
name: "Chantalle",
url: "tcp://192.168.0.5:1337",
status: "ok"
}
];
this.fetch({
async: false
});
return this.map(function(m) {
return m.forList();
});
},
getOverview: function() {
// Fake data
return {
plan: 3,
having: 2,
status: "critical"
this.fetch({
async: false
});
var res = {
plan: 0,
having: 0,
status: "ok"
},
updateStatus = function(to) {
if (res.status === "critical") {
return;
}
res.status = to;
};
this.each(function(m) {
res.plan++;
switch (m.get("status")) {
case "ok":
res.having++;
break;
case "warning":
res.having++;
updateStatus("warning");
break;
case "critical":
updateStatus("critical");
break;
default:
console.debug("Undefined server state occured. This is still in development");
}
});
return res;
}
});

View File

@ -6,11 +6,10 @@
window.ClusterCollection = Backbone.Model.extend({
defaults: {
"name": "",
"id": "",
"status": "ok"
},
idAttribute: "id",
idAttribute: "name",
forList: function() {
return {

View File

@ -4,15 +4,23 @@
"use strict";
window.ClusterCoordinator = Backbone.Model.extend({
defaults: {
"name": "",
"url": ""
"url": "",
"status": "ok"
},
idAttribute: "name",
url: function() {
return "/_admin/aardvark/cluster/Coordinators";
url: "/_admin/aardvark/cluster/Coordinators",
forList: function() {
return {
name: this.get("name"),
status: this.get("status"),
url: this.get("url")
};
}
});

View File

@ -223,12 +223,21 @@ module.exports = function(karma) {
// 'test/specs/graphViewer/specNodeReducer/modularityJoinerSpec.js',
// 'test/specs/graphViewer/specWindowObjects/workerWrapperSpec.js',
'test/specs/graphViewer/specContextMenu/contextMenuSpec.js',
// Arango
'test/specs/arango/arangoSpec.js',
// Models
'test/specs/models/currentDatabaseSpec.js',
'test/specs/models/graphSpec.js',
// Collections
'test/specs/collections/clusterServersSpec.js',
'test/specs/collections/clusterDatabasesSpec.js',
'test/specs/collections/clusterCollectionsSpec.js',
'test/specs/collections/clusterShardsSpec.js',
// Views
'test/specs/views/editListEntryViewSpec.js',
'test/specs/views/collectionViewSpec.js',

View File

@ -6,9 +6,11 @@
"use strict";
describe("Cluster Collection View", function() {
var view, div, shardsView, shardCol;
var view, div, shardsView, shardCol, server, db;
beforeEach(function() {
server = "pavel";
db = "_system";
div = document.createElement("div");
div.id = "clusterCollections";
document.body.appendChild(div);
@ -81,7 +83,7 @@
view = new window.ClusterCollectionView({
collection: collCol
});
view.render();
view.render(db, server);
});
it("should not unrender the server view", function() {
@ -117,27 +119,18 @@
});
it("should be able to navigate to Documents", function() {
info = {
name: "Documents"
};
$("#Documents").click();
expect(shardsView.render).toHaveBeenCalledWith(info);
expect(shardsView.render).toHaveBeenCalledWith(db, "Documents", server);
});
it("should be able to navigate to Edges", function() {
info = {
name: "Edges"
};
$("#Edges").click();
expect(shardsView.render).toHaveBeenCalledWith(info);
expect(shardsView.render).toHaveBeenCalledWith(db, "Edges", server);
});
it("should be able to navigate to People", function() {
info = {
name: "People"
};
$("#People").click();
expect(shardsView.render).toHaveBeenCalledWith(info);
expect(shardsView.render).toHaveBeenCalledWith(db, "People", server);
});
});

View File

@ -6,9 +6,10 @@
"use strict";
describe("Cluster Database View", function() {
var view, div, colView, colCol;
var view, div, colView, colCol, server;
beforeEach(function() {
server = "pavel";
div = document.createElement("div");
div.id = "clusterDatabases";
document.body.appendChild(div);
@ -83,7 +84,7 @@
view = new window.ClusterDatabaseView({
collection: dbCol
});
view.render();
view.render(server);
});
it("should not render the Server view", function() {
@ -116,19 +117,19 @@
it("should be able to navigate to _system", function() {
db = "_system";
$("#" + db).click();
expect(colView.render).toHaveBeenCalledWith(db);
expect(colView.render).toHaveBeenCalledWith(db, server);
});
it("should be able to navigate to myDatabase", function() {
db = "myDatabase";
$("#" + db).click();
expect(colView.render).toHaveBeenCalledWith(db);
expect(colView.render).toHaveBeenCalledWith(db, server);
});
it("should be able to navigate to otherDatabase", function() {
db = "otherDatabase";
$("#" + db).click();
expect(colView.render).toHaveBeenCalledWith(db);
expect(colView.render).toHaveBeenCalledWith(db, server);
});
});

View File

@ -57,11 +57,8 @@
dbView.render.reset();
view.render.reset();
var name = o.primary.name;
info = {
name: name
};
$(getTile(name)).click();
expect(dbView.render).toHaveBeenCalledWith(info);
expect(dbView.render).toHaveBeenCalledWith(name);
expect(view.render).toHaveBeenCalledWith(true);
});
});

View File

@ -22,27 +22,27 @@
describe("rendering", function() {
var s1, s2, s3, shards, shardCol,
checkButtonContent = function(col, cls) {
var btn = document.getElementById(col.name);
checkButtonContent = function(sh, cls) {
var btn = document.getElementById(sh.id);
expect(btn).toBeOfClass("btn");
expect(btn).toBeOfClass("btn-server");
expect(btn).toBeOfClass("shard");
expect(btn).toBeOfClass("btn-" + cls);
expect($(btn).text()).toEqual(col.name);
expect($(btn).text()).toEqual(sh.id);
};
beforeEach(function() {
s1 = {
name: "Shard 1",
id: "Shard 1",
status: "ok"
};
s2 = {
name: "Shard 2",
id: "Shard 2",
status: "warning"
};
s3 = {
name: "Shard 3",
id: "Shard 3",
status: "critical"
};
shards = [