Commit 65a8b9d0 authored by Boris Kocherov's avatar Boris Kocherov Committed by Romain Courteaud

[erp5_only_office] use url array in cube functions for failover mirrors

parent 7d6a07d7
...@@ -83,8 +83,15 @@ function (window, RSVP, Xmla, console) { ...@@ -83,8 +83,15 @@ function (window, RSVP, Xmla, console) {
}); });
} }
function xmla_request_retry(func, prop) { function xmla_request_retry(func, settings) {
return xmla_request(func, prop) var queue,
urls = settings.urls,
i;
function make_request(url) {
return function (error) {
settings.prop.url = url;
return xmla_request(func, settings.prop)
.push(undefined, function (response) { .push(undefined, function (response) {
// fix mondrian Internal and Sql errors // fix mondrian Internal and Sql errors
if (response) { if (response) {
...@@ -92,11 +99,19 @@ function (window, RSVP, Xmla, console) { ...@@ -92,11 +99,19 @@ function (window, RSVP, Xmla, console) {
case "SOAP-ENV:Server.00HSBE02": case "SOAP-ENV:Server.00HSBE02":
case "SOAP-ENV:00UE001.Internal Error": case "SOAP-ENV:00UE001.Internal Error":
// rarely server error, so try again // rarely server error, so try again
return xmla_request(func, prop); return xmla_request(func, settings.prop);
} }
} }
throw response; throw response;
}); });
};
}
queue = make_request(urls[0])();
for (i = 1; i < settings.urls.length; i += 1) {
queue.push(undefined, make_request(urls[i]));
}
return queue;
} }
function discover_hierarchies(connection) { function discover_hierarchies(connection) {
...@@ -109,7 +124,7 @@ function (window, RSVP, Xmla, console) { ...@@ -109,7 +124,7 @@ function (window, RSVP, Xmla, console) {
// 'HIERARCHY_UNIQUE_NAME': hierarchy_name, // 'HIERARCHY_UNIQUE_NAME': hierarchy_name,
'CUBE_NAME': settings["cube"] 'CUBE_NAME': settings["cube"]
}; };
return xmla_request_retry("discoverMDHierarchies", prop); return xmla_request_retry("discoverMDHierarchies", settings);
}) })
.push(function (response) { .push(function (response) {
var hierarchies = {}, var hierarchies = {},
...@@ -168,9 +183,12 @@ function (window, RSVP, Xmla, console) { ...@@ -168,9 +183,12 @@ function (window, RSVP, Xmla, console) {
throw "connection not exist"; throw "connection not exist";
} }
c = value[connection]; c = value[connection];
if (!c.hasOwnProperty('properties')) {
c.properties = {};
}
return { return {
urls: c.urls,
prop: { prop: {
url: c.url,
properties: { properties: {
DataSourceInfo: c.properties.DataSourceInfo, DataSourceInfo: c.properties.DataSourceInfo,
Catalog: c.properties.Catalog Catalog: c.properties.Catalog
...@@ -332,7 +350,7 @@ function (window, RSVP, Xmla, console) { ...@@ -332,7 +350,7 @@ function (window, RSVP, Xmla, console) {
} }
prop.statement = "SELECT " + mdx.join("*") + prop.statement = "SELECT " + mdx.join("*") +
" ON 0 FROM [" + settings["cube"] + "]"; " ON 0 FROM [" + settings["cube"] + "]";
return xmla_request_retry("execute", prop); return xmla_request_retry("execute", settings);
}) })
.push(function (dataset) { .push(function (dataset) {
var cellset = dataset.getCellset(), var cellset = dataset.getCellset(),
...@@ -420,7 +438,7 @@ function (window, RSVP, Xmla, console) { ...@@ -420,7 +438,7 @@ function (window, RSVP, Xmla, console) {
if (cached_member) { if (cached_member) {
return [cached_member]; return [cached_member];
} else { } else {
return xmla_request_retry("discoverMDMembers", prop) return xmla_request_retry("discoverMDMembers", settings)
.push(function (r) { .push(function (r) {
var ret = [], var ret = [],
uname, uname,
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
"title": "XMLA connection", "title": "XMLA connection",
"type": "object", "type": "object",
"properties": { "properties": {
"url": { "urls": {
"uniqueItems": true, "uniqueItems": true,
"items": { "items": {
"format": "uri", "format": "uri",
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
} }
}, },
"required": [ "required": [
"url" "urls"
], ],
"additionalProperties": false "additionalProperties": false
} }
\ No newline at end of file
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