Commit 384d5dea authored by Aurel's avatar Aurel

use parallel option of replicate storage

parent fa8d91f5
......@@ -9,6 +9,7 @@ function ClearRoadAccountRegistration(login, password) {
this.jio = jIO.createJIO({
type: "replicate",
parallel_operation_amount: 100,
use_remote_post: false,
conflict_handling: 1,
check_local_modification: false,
......@@ -70,6 +71,7 @@ function ClearRoadAccountRegistrationReport(login, password, day_range) {
}
this.jio = jIO.createJIO({
type: "replicate",
parallel_operation_amount: 100,
use_remote_post: true,
conflict_handling: 1,
query: {
......@@ -121,6 +123,7 @@ function ClearRoadUsageData(login, password) {
this.jio = jIO.createJIO({
type: "replicate",
parallel_operation_amount: 100,
use_remote_post: false,
conflict_handling: 1,
check_local_modification: false,
......@@ -182,6 +185,7 @@ function ClearRoadUsageDataReport(login, password, day_range) {
}
this.jio = jIO.createJIO({
type: "replicate",
parallel_operation_amount: 100,
use_remote_post: true,
conflict_handling: 1,
query: {
......@@ -233,6 +237,7 @@ function ClearRoadAccountDirectory(login, password) {
this.jio = jIO.createJIO({
type: "replicate",
parallel_operation_amount: 100,
use_remote_post: true,
conflict_handling: 1,
query: {
......@@ -286,6 +291,7 @@ function ClearRoadAccountBalance(login, password, reference) {
}
this.jio = jIO.createJIO({
type: "replicate",
parallel_operation_amount: 100,
use_remote_post: true,
conflict_handling: 1,
query: {
......@@ -334,6 +340,7 @@ function ClearRoadEvent(login, password) {
this.jio = jIO.createJIO({
type: "replicate",
parallel_operation_amount: 100,
use_remote_post: false,
conflict_handling: 1,
check_local_modification: false,
......@@ -395,6 +402,7 @@ function ClearRoadEventReport(login, password, day_range) {
}
this.jio = jIO.createJIO({
type: "replicate",
parallel_operation_amount: 100,
use_remote_post: true,
conflict_handling: 1,
query: {
......@@ -452,6 +460,7 @@ function ClearRoadEventDirectory(login, password, day_range) {
}
this.jio = jIO.createJIO({
type: "replicate",
parallel_operation_amount: 100,
use_remote_post: true,
conflict_handling: 1,
query: {
......@@ -501,6 +510,7 @@ function ClearRoadBillingPeriodRegistration(login, password) {
this.jio = jIO.createJIO({
type: "replicate",
parallel_operation_amount: 100,
use_remote_post: false,
conflict_handling: 1,
check_local_modification: false,
......@@ -564,6 +574,7 @@ function ClearRoadBillingPeriodRegistrationReport(login, password, day_range) {
}
this.jio = jIO.createJIO({
type: "replicate",
parallel_operation_amount: 100,
use_remote_post: true,
conflict_handling: 1,
query: {
......@@ -614,6 +625,7 @@ function ClearRoadBillingPeriodDirectory(login, password) {
this.jio = jIO.createJIO({
type: "replicate",
parallel_operation_amount: 100,
use_remote_post: true,
conflict_handling: 1,
query: {
......@@ -669,6 +681,7 @@ function ClearRoadTransactionDirectory(login, password, account) {
}
this.jio = jIO.createJIO({
type: "replicate",
parallel_operation_amount: 100,
use_remote_post: true,
conflict_handling: 1,
query: {
......
......@@ -1902,6 +1902,11 @@ return new Parser;
};
}
/* Safari does not define DOMError */
if (window.DOMError === undefined) {
window.DOMError = {};
}
var util = {},
jIO;
......@@ -2481,6 +2486,12 @@ return new Parser;
});
this._use_remote_post = spec.use_remote_post || false;
// Number of request we allow browser execution for attachments
this._parallel_operation_attachment_amount =
spec.parallel_operation_attachment_amount || 1;
// Number of request we allow browser execution for documents
this._parallel_operation_amount =
spec.parallel_operation_amount || 1;
this._conflict_handling = spec.conflict_handling || 0;
// 0: no resolution (ie, throw an Error)
......@@ -2623,6 +2634,30 @@ return new Parser;
// Do not sync the signature document
skip_document_dict[context._signature_hash] = null;
function dispatchQueue(function_used, argument_list, number_queue) {
var result_promise_list = [],
i;
function pushAndExecute(queue) {
queue
.push(function () {
if (argument_list.length > 0) {
var argument_array = argument_list.shift();
argument_array[0] = queue;
function_used.apply(context, argument_array);
pushAndExecute(queue);
}
});
}
for (i = 0; i < number_queue; i += 1) {
result_promise_list.push(new RSVP.Queue());
pushAndExecute(result_promise_list[i]);
}
if (number_queue > 1) {
return RSVP.all(result_promise_list);
}
return result_promise_list[0];
}
function propagateAttachmentDeletion(skip_attachment_dict,
destination,
......@@ -3203,7 +3238,7 @@ return new Parser;
})
.push(function (result_list) {
var i,
sub_queue = new RSVP.Queue();
argument_list = [];
function getResult(j) {
return function (id) {
......@@ -3215,20 +3250,26 @@ return new Parser;
}
for (i = 0; i < result_list.length; i += 1) {
checkSignatureDifference(sub_queue, source, destination,
argument_list[i] = [undefined, source, destination,
id_list[i].parameter_list[0],
conflict_force, conflict_revert,
conflict_ignore,
document_status_list[i].is_creation,
document_status_list[i].is_modification,
getResult(i), options);
getResult(i), options];
}
return sub_queue;
return dispatchQueue(
checkSignatureDifference,
argument_list,
options.operation_amount
);
});
}
function pushStorage(source, destination, options) {
var queue = new RSVP.Queue();
var queue = new RSVP.Queue(),
argument_list = [],
argument_list_deletion = [];
if (!options.hasOwnProperty("use_post")) {
options.use_post = false;
}
......@@ -3265,6 +3306,7 @@ return new Parser;
signature_dict[result_list[1].data.rows[i].id] = i;
}
}
i = 0;
for (key in local_dict) {
if (local_dict.hasOwnProperty(key)) {
is_modification = signature_dict.hasOwnProperty(key)
......@@ -3282,29 +3324,50 @@ return new Parser;
is_modification: is_modification
});
} else {
checkSignatureDifference(queue, source, destination, key,
options.conflict_force,
options.conflict_revert,
options.conflict_ignore,
is_creation, is_modification,
source.get.bind(source),
options);
argument_list[i] = [undefined, source, destination,
key,
options.conflict_force,
options.conflict_revert,
options.conflict_ignore,
is_creation, is_modification,
source.get.bind(source),
options];
i += 1;
}
}
}
}
queue
.push(function () {
return dispatchQueue(
checkSignatureDifference,
argument_list,
options.operation_amount
);
});
if (options.check_deletion === true) {
i = 0;
for (key in signature_dict) {
if (signature_dict.hasOwnProperty(key)) {
if (!local_dict.hasOwnProperty(key)) {
checkLocalDeletion(queue, destination, key, source,
options.conflict_force,
options.conflict_revert,
options.conflict_ignore,
options);
argument_list_deletion[i] = [undefined,
destination, key,
source,
options.conflict_force,
options.conflict_revert,
options.conflict_ignore,
options];
i += 1;
}
}
}
queue.push(function () {
return dispatchQueue(
checkLocalDeletion,
argument_list_deletion,
options.operation_amount
);
});
}
if ((options.use_bulk_get === true) && (document_list.length !== 0)) {
checkBulkSignatureDifference(queue, source, destination,
......@@ -3317,6 +3380,12 @@ return new Parser;
});
}
function repairDocument(queue, id) {
queue.push(function () {
return repairDocumentAttachment(id);
});
}
return new RSVP.Queue()
.push(function () {
// Ensure that the document storage is usable
......@@ -3369,7 +3438,8 @@ return new Parser;
CONFLICT_CONTINUE),
check_modification: context._check_local_modification,
check_creation: context._check_local_creation,
check_deletion: context._check_local_deletion
check_deletion: context._check_local_deletion,
operation_amount: context._parallel_operation_amount
});
}
})
......@@ -3400,7 +3470,8 @@ return new Parser;
CONFLICT_CONTINUE),
check_modification: context._check_remote_modification,
check_creation: context._check_remote_creation,
check_deletion: context._check_remote_deletion
check_deletion: context._check_remote_deletion,
operation_amount: context._parallel_operation_amount
});
}
})
......@@ -3416,19 +3487,19 @@ return new Parser;
return context._signature_sub_storage.allDocs()
.push(function (result) {
var i,
repair_document_queue = new RSVP.Queue();
argument_list = [],
len = result.data.total_rows;
function repairDocument(id) {
repair_document_queue
.push(function () {
return repairDocumentAttachment(id);
});
}
for (i = 0; i < result.data.total_rows; i += 1) {
repairDocument(result.data.rows[i].id);
for (i = 0; i < len; i += 1) {
argument_list.push(
[undefined, result.data.rows[i].id]
);
}
return repair_document_queue;
return dispatchQueue(
repairDocument,
argument_list,
context._parallel_operation_attachment_amount
);
});
}
});
......
This source diff could not be displayed because it is too large. You can view the blob instead.
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