Skip to content

Commit

Permalink
Merge pull request #128 from s3u/master
Browse files Browse the repository at this point in the history
Ignore error while merging/projecting partial failures in case of scatter-gather
  • Loading branch information
shimonchayim committed Dec 6, 2011
2 parents c7fd5e0 + 89d179b commit 39ce88a
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 4 deletions.
11 changes: 8 additions & 3 deletions modules/engine/lib/engine/http.request.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ exports.exec = function(args) {
}(uri));
});
async.parallel(tasks, function(err, results) {
if(err) {
// In the case of scatter-gather, ignore errors and process the rest.
if(err && resourceUri.length === 1) {
return cb(err, results);
}
else {
Expand Down Expand Up @@ -175,7 +176,7 @@ exports.exec = function(args) {
ret.body = undefined;
}
}
return cb(err, ret);
return cb(undefined, ret);
}
else {
return cb(err, results);
Expand Down Expand Up @@ -633,7 +634,11 @@ function ip() {
return os.hostname();
}

function mergeArray(arr, prop, merge) {
function mergeArray(uarr, prop, merge) {
// Remove undefineds.
var arr = _.filter(uarr, function(ele) {
return ele;
});
var merged;
if(merge === 'block') {
merged = [];
Expand Down
2 changes: 1 addition & 1 deletion modules/engine/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"author": "ql.io",
"name": "ql.io-engine",
"version": "0.3.2",
"version": "0.3.3",
"repository": {
"type": "git",
"url": "https://github.com/ql-io/ql.io"
Expand Down
68 changes: 68 additions & 0 deletions modules/engine/test/exec-scatter-partial-failure.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* Copyright 2011 eBay Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

"use strict";

var _ = require('underscore'),
Engine = require('../lib/engine'),
sys = require('sys'),
fs = require('fs'),
http = require('http'),
util = require('util'),
EventEmitter = require('events').EventEmitter(),
logger = require('winston');

var engine = new Engine({
tables: __dirname + '/tables',
config: __dirname + '/config/dev.json',
'connection': 'close'
});

module.exports = {
'partial failure': function (test) {
var server = http.createServer(function (req, res) {
if(req.url === '/ok') {
res.writeHead(200, {
'Content-Type': 'application/json'
});
res.end('{"state":"ok"}');
}
else if(req.url === '/fail') {
res.writeHead(500, {
'Content-Type': 'application/json'
});
res.end('{"state":"fail"}');
}
});
server.listen(3000, function () {
// Do the test here.
var engine = new Engine({
connection: 'close'
});
var q = fs.readFileSync(__dirname + '/mock/scatter-partial-failure.ql', 'UTF-8');
engine.exec(q, function (err, list) {
if(err) {
test.fail('got error: ' + err.stack || err);
}
else {
test.ok(true);
}
test.done();
server.close();
});
});
}
};
7 changes: 7 additions & 0 deletions modules/engine/test/mock/scatter-partial-failure.ql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

create table state
on select get from "http://localhost:3000/{^mode}";

list = ["ok", "fail"];

return select * from state where mode in ("{list}");

0 comments on commit 39ce88a

Please sign in to comment.