Commit 9144223c authored by Alain Takoudjou's avatar Alain Takoudjou

slapos_monitoring: improve data sync, add retry sync of failed urls

parent 71182a2a
......@@ -139,6 +139,7 @@
date = '';
for (j = 0; j < document_list[i].length; j += 1) {
if (document_list[i][j] === undefined) {
status = 'ERROR';
continue;
}
hosting_dict.amount += 1;
......@@ -173,7 +174,7 @@
hosting_dict.status = 'ERROR';
hosting_dict.title = gadget.props.opml_dict[
gadget.props.opml_key_list[i]].title;
hosting_dict.date = 'Not available';
hosting_dict.date = 'Not Synchronized';
// Redirect to configurator to sync data
hosting_dict.href = '#page=settings_configurator&tab=manage';
} else {
......
......@@ -160,6 +160,9 @@
.innerHTML = gadget.props.hosting.title; // + '<span class="label label-{{status}}">{{status}}</span>';
for (i = 0; i < document_list.length; i += 1) {
if (!document_list[i]) {
continue;
}
instance_list.push(
getInstanceDict(document_list[i])
);
......
......@@ -166,7 +166,7 @@
});
}
function clearDeletedMonitorUrl(opml_title) {
function clearDeletedMonitorUrl(opml_url, opml_title) {
var jio_options = {
type: "query",
sub_storage: {
......@@ -177,7 +177,7 @@
}
}
},
jio_storage = jIO.createJIO(jio_options);
jio_storage = createOPMLReplicatedJio(opml_url);
return jio_storage.allDocs({include_docs: true})
.push(function (document_list) {
var i,
......@@ -307,8 +307,8 @@
.declareMethod('getMonitorUrlList', function (query, opml_title) {
return getMonitorUrlList(query, opml_title);
})
.declareMethod('clearDeletedMonitorUrl', function (opml_title) {
return clearDeletedMonitorUrl(opml_title);
.declareMethod('clearDeletedMonitorUrl', function (opml_url, opml_title) {
return clearDeletedMonitorUrl(opml_url, opml_title);
})
.declareMethod('allDocs', function () {
var storage = this.state_parameter_dict.jio_storage;
......
......@@ -212,7 +212,7 @@
}
}
};
gadget.property_dict.jio_gadget.createJio(jio_options, false);
gadget.property_dict.jio_gadget.createJio(jio_options);
return gadget.property_dict.jio_gadget.get(title+'.history')
.push(undefined, function (error) {
console.log(error);
......
......@@ -569,7 +569,9 @@
gadget.props.login_gadget.clearSettingFromParentUrl(url_description_dict[key_list[i]].href)
);
delete_promise_list.push(
gadget.props.jio_gadget.clearDeletedMonitorUrl(url_description_dict[key_list[i]].title)
gadget.props.jio_gadget.clearDeletedMonitorUrl(
url_description_dict[key_list[i]].href,
url_description_dict[key_list[i]].title)
);
delete url_description_dict[key_list[i]];
}
......
......@@ -43,6 +43,10 @@
gadget.props.jio_gadget.createJio(storage_dict, true, query);
return gadget.props.jio_gadget.repair()
.push(undefined, function (error) {
gadget.props.error_list.push({
storage_dict: storage_dict,
query: query
});
console.log(error);
});
}
......@@ -143,6 +147,7 @@
var i,
promise_list = [];
monitor_storage_list = getMonitoringStorageList(url_list);
gadget.props.error_list = [];
for (i = 0; i < monitor_storage_list.length; i += 1) {
promise_list.push(syncStorage(
gadget,
......@@ -152,20 +157,58 @@
console.log("Sync monitoring data...");
return RSVP.all(promise_list);
})
.push(function () {
// Check if there was errors and retry them if possible
var error_size = gadget.props.error_list.length,
error_list = gadget.props.error_list.slice(0),
promise_list = [],
i;
if (error_size > 0) {
// Reset list of errors
gadget.props.error_list = [];
$(".notifyjs-wrapper").remove();
promise_list.push($.notify(
"Retry Previous Failure(s)...",
{
position:"bottom right",
autoHide: false,
className: "info"
}
));
for (i = 0; i < error_size; i += 1) {
promise_list.push(syncStorage(
gadget,
error_list[i].storage_dict,
error_list[i].query
));
}
}
return RSVP.all(promise_list);
})
.push(function () {
last_sync_time = new Date().getTime();
sync_lock = false;
return gadget.setSetting('latest_sync_time', last_sync_time);
})
.push(function () {
var time = 3000,
classname = "info",
error_amount = gadget.props.error_list.length,
message = "Synchronisation finished.";
if ( error_amount > 0) {
classname = "warning";
time = 5000;
message = "Synchronisation finished with " + error_amount + "error(s). \n" +
"You can retry with manual sync.";
}
$(".notifyjs-wrapper").remove();
return $.notify(
"Synchronisation finished.",
message,
{
position:"bottom right",
autoHide: true,
className: "info",
autoHideDelay: 3000
className: classname,
autoHideDelay: time
}
);
})
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment