Created
January 31, 2013 23:35
-
-
Save gdanko/4687737 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function status_fn_oor_state(jobId) { | |
var status_fn_oor_state_cfg = { | |
method: 'GET', | |
on: { | |
success: function(id, o) { | |
var jsonString = o.responseText; | |
rec = Y.JSON.parse(jsonString); | |
rec.data = rec.result.output; | |
rec.result.output = undefined; | |
if(rec.result.status !== 'completed' && rec.result.status !== 'completed_with_map_errors' | |
&&rec.result.status !== 'completed_with_fetch_errors' && rec.result.status !== 'errored' | |
&&rec.result.status !== 'error_worker_crashed' && rec.result.status !== 'error_reduce_failed') { | |
var timer = function() { status_fn_oor_state(jobId); }; | |
setTimeout(timer, 2000); | |
return; | |
} | |
oorStateOk = 1; | |
oorStateRec = rec; | |
}, | |
failure: function(id, o) { | |
Y.helpers.buildDialog('Error', 'Failed to fetch Gru data. Function: status_fn_oor_state.'); | |
} | |
} | |
}; | |
Y.io('/gru/job/status?jobId=' + jobId + '&debug=0', status_fn_oor_state_cfg); | |
} | |
function status_fn_igor_state(jobId) { | |
var status_fn_igor_state_cfg = { | |
method: 'GET', | |
on: { | |
success: function(id, o) { | |
var jsonString = o.responseText; | |
rec = Y.JSON.parse(jsonString); | |
rec.data = rec.result.output; | |
rec.result.output = undefined; | |
if(rec.result.status !== 'completed' && rec.result.status !== 'completed_with_map_errors' | |
&&rec.result.status !== 'completed_with_fetch_errors' && rec.result.status !== 'errored' | |
&&rec.result.status !== 'error_worker_crashed' && rec.result.status !== 'error_reduce_failed') { | |
var timer = function() { status_fn_igor_state(jobId); }; | |
setTimeout(timer, 2000); | |
return; | |
} | |
igorStateOk = 1; | |
igorStateRec = rec; | |
}, | |
failure: function(id, o) { | |
Y.helpers.buildDialog('Error', 'Failed to fetch Gru data. Function: status_fn_oor_state.'); | |
} | |
} | |
}; | |
Y.io('/gru/job/status?jobId=' + jobId + '&debug=0', status_fn_igor_state_cfg); | |
window.setInterval(oorDataTable, 2000); | |
function oorDataTable() { | |
if (oorStateOk == 1 && igorStateOk == 1) { | |
console.log('ok'); | |
window.clearInterval(); | |
} else { | |
console.log('retry'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment