mirror of https://gitee.com/bigwinds/arangodb
Cluster Servers and Coordinators are now working async. It is now possible to contact a cluster even if some of the coordinators are down
This commit is contained in:
parent
9d85b25674
commit
06e9a949d5
|
@ -16,6 +16,27 @@
|
|||
this._retryCount = 0;
|
||||
},
|
||||
|
||||
checkRetries: function() {
|
||||
this.updateUrl();
|
||||
if (this._retryCount > 10) {
|
||||
window.App.clusterUnreachable();
|
||||
}
|
||||
},
|
||||
|
||||
successFullTry: function() {
|
||||
this._retryCount = 0;
|
||||
},
|
||||
|
||||
failureTry: function(retry, err) {
|
||||
if (err.status === 401) {
|
||||
window.App.requestAuth();
|
||||
} else {
|
||||
window.App.clusterPlan.rotateCoordinator();
|
||||
this._retryCount++;
|
||||
retry();
|
||||
}
|
||||
},
|
||||
|
||||
statusClass: function(s) {
|
||||
switch (s) {
|
||||
case "ok":
|
||||
|
@ -30,26 +51,15 @@
|
|||
return "danger";
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
getStatuses: function(cb, nextStep) {
|
||||
if (this._retryCount > 10) {
|
||||
console.log("Cluster unreachable");
|
||||
}
|
||||
this.checkRetries();
|
||||
var self = this;
|
||||
this.updateUrl();
|
||||
this.fetch({
|
||||
beforeSend: window.App.addAuth.bind(window.App),
|
||||
error: function() {
|
||||
self._retryCount++;
|
||||
console.log(self._retryCount);
|
||||
self.forEach(function(m) {
|
||||
cb(self.statusClass("critical"), m.get("address"));
|
||||
});
|
||||
window.App.clusterPlan.rotateCoordinator();
|
||||
self.getStatuses(cb, nextStep);
|
||||
}
|
||||
error: self.failureTry.bind(self, self.getStatuses.bind(self, cb, nextStep))
|
||||
}).done(function() {
|
||||
console.log(self._retryCount);
|
||||
self.successFullTry();
|
||||
self._retryCount = 0;
|
||||
self.forEach(function(m) {
|
||||
cb(self.statusClass(m.get("status")), m.get("address"));
|
||||
|
@ -59,14 +69,13 @@
|
|||
},
|
||||
|
||||
byAddress: function (res, callback) {
|
||||
this.checkRetries();
|
||||
var self = this;
|
||||
this.updateUrl();
|
||||
this.fetch({
|
||||
beforeSend: window.App.addAuth.bind(window.App),
|
||||
error: function() {
|
||||
console.log("incord2");
|
||||
}
|
||||
error: self.failureTry.bind(self, self.byAddress.bind(self, res, callback))
|
||||
}).done(function() {
|
||||
self.successFullTry();
|
||||
res = res || {};
|
||||
self.forEach(function(m) {
|
||||
var addr = m.get("address");
|
||||
|
@ -80,6 +89,8 @@
|
|||
},
|
||||
|
||||
getList: function() {
|
||||
throw "Do not use coordinator.getList";
|
||||
/*
|
||||
this.fetch({
|
||||
async: false,
|
||||
beforeSend: window.App.addAuth.bind(window.App)
|
||||
|
@ -87,9 +98,12 @@
|
|||
return this.map(function(m) {
|
||||
return m.forList();
|
||||
});
|
||||
*/
|
||||
},
|
||||
|
||||
getOverview: function() {
|
||||
throw "Do not use coordinator.getOverview";
|
||||
/*
|
||||
this.fetch({
|
||||
async: false,
|
||||
beforeSend: window.App.addAuth.bind(window.App)
|
||||
|
@ -123,6 +137,7 @@
|
|||
}
|
||||
});
|
||||
return res;
|
||||
*/
|
||||
}
|
||||
});
|
||||
}());
|
||||
|
|
|
@ -16,6 +16,28 @@
|
|||
|
||||
initialize: function() {
|
||||
window.App.registerForUpdate(this);
|
||||
this._retryCount = 0;
|
||||
},
|
||||
|
||||
checkRetries: function() {
|
||||
this.updateUrl();
|
||||
if (this._retryCount > 10) {
|
||||
window.App.clusterUnreachable();
|
||||
}
|
||||
},
|
||||
|
||||
successFullTry: function() {
|
||||
this._retryCount = 0;
|
||||
},
|
||||
|
||||
failureTry: function(retry, err) {
|
||||
if (err.status === 401) {
|
||||
window.App.requestAuth();
|
||||
} else {
|
||||
window.App.clusterPlan.rotateCoordinator();
|
||||
this._retryCount++;
|
||||
retry();
|
||||
}
|
||||
},
|
||||
|
||||
statusClass: function(s) {
|
||||
|
@ -34,45 +56,31 @@
|
|||
},
|
||||
|
||||
getStatuses: function(cb) {
|
||||
this.checkRetries();
|
||||
var self = this,
|
||||
completed = function() {
|
||||
self.successFullTry();
|
||||
self._retryCount = 0;
|
||||
self.forEach(function(m) {
|
||||
cb(self.statusClass(m.get("status")), m.get("address"));
|
||||
});
|
||||
};
|
||||
this.updateUrl();
|
||||
// This is the first function called in
|
||||
// Each update loop
|
||||
this.fetch({
|
||||
async: false,
|
||||
beforeSend: window.App.addAuth.bind(window.App),
|
||||
error: function(d) {
|
||||
if (d.status === 401) {
|
||||
window.App.requestAuth();
|
||||
} else {
|
||||
console.log("inDB");
|
||||
self.forEach(function(m) {
|
||||
cb(self.statusClass("critical"), m.get("address"));
|
||||
});
|
||||
}
|
||||
}
|
||||
error: self.failureTry.bind(self, self.getStatuses.bind(self, cb))
|
||||
}).done(completed);
|
||||
},
|
||||
|
||||
byAddress: function (res, callback) {
|
||||
this.checkRetries();
|
||||
var self = this;
|
||||
this.updateUrl();
|
||||
this.fetch({
|
||||
beforeSend: window.App.addAuth.bind(window.App),
|
||||
error: function(d) {
|
||||
if (d.status === 401) {
|
||||
window.App.requestAuth();
|
||||
} else {
|
||||
console.log(d);
|
||||
console.log("Hier isse kapuuuhhhttt inDB2");
|
||||
}
|
||||
}
|
||||
error: self.failureTry.bind(self, self.byAddress.bind(self, res, callback))
|
||||
}).done(function() {
|
||||
self.successFullTry();
|
||||
res = res || {};
|
||||
self.forEach(function(m) {
|
||||
var addr = m.get("address");
|
||||
|
@ -85,25 +93,30 @@
|
|||
});
|
||||
},
|
||||
|
||||
getList: function() {
|
||||
getList: function(callback) {
|
||||
throw "Do not use";
|
||||
var self = this;
|
||||
this.fetch({
|
||||
async: false,
|
||||
beforeSend: window.App.addAuth.bind(window.App)
|
||||
beforeSend: window.App.addAuth.bind(window.App),
|
||||
error: self.failureTry.bind(self, self.getList.bind(self, callback))
|
||||
}).done(function() {
|
||||
self.successFullTry();
|
||||
var res = [];
|
||||
_.each(self.where({role: "primary"}), function(m) {
|
||||
var e = {};
|
||||
e.primary = m.forList();
|
||||
if (m.get("secondary")) {
|
||||
e.secondary = self.get(m.get("secondary")).forList();
|
||||
}
|
||||
res.push(e);
|
||||
});
|
||||
callback(res);
|
||||
});
|
||||
var res = [],
|
||||
self = this;
|
||||
_.each(this.where({role: "primary"}), function(m) {
|
||||
var e = {};
|
||||
e.primary = m.forList();
|
||||
if (m.get("secondary")) {
|
||||
e.secondary = self.get(m.get("secondary")).forList();
|
||||
}
|
||||
res.push(e);
|
||||
});
|
||||
return res;
|
||||
},
|
||||
|
||||
getOverview: function() {
|
||||
throw "Do not use DbServer.getOverview";
|
||||
/*
|
||||
this.fetch({
|
||||
async: false,
|
||||
beforeSend: window.App.addAuth.bind(window.App)
|
||||
|
@ -146,6 +159,7 @@
|
|||
}
|
||||
});
|
||||
return res;
|
||||
*/
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -174,6 +174,10 @@ arangoDatabase, btoa, _*/
|
|||
serverToShow : this.serverToShow
|
||||
});
|
||||
this.dashboardView.render();
|
||||
},
|
||||
|
||||
clusterUnreachable: function() {
|
||||
alert("Your cluster seems to be unreachable. This is only temp msg");
|
||||
}
|
||||
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue