Updated Branches: refs/heads/master a6f0685d4 -> 937f19edc
OOZIE-1661 Stream logs in oozie UI (puru via rohini) Project: http://git-wip-us.apache.org/repos/asf/oozie/repo Commit: http://git-wip-us.apache.org/repos/asf/oozie/commit/937f19ed Tree: http://git-wip-us.apache.org/repos/asf/oozie/tree/937f19ed Diff: http://git-wip-us.apache.org/repos/asf/oozie/diff/937f19ed Branch: refs/heads/master Commit: 937f19edcee3f12a270da92759edc07d358ef1aa Parents: a6f0685 Author: Rohini Palaniswamy <[email protected]> Authored: Thu Jan 9 11:56:58 2014 -0800 Committer: Rohini Palaniswamy <[email protected]> Committed: Thu Jan 9 11:56:58 2014 -0800 ---------------------------------------------------------------------- release-log.txt | 1 + webapp/src/main/webapp/oozie-console.js | 176 +++++++++++++++------------ 2 files changed, 96 insertions(+), 81 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/oozie/blob/937f19ed/release-log.txt ---------------------------------------------------------------------- diff --git a/release-log.txt b/release-log.txt index 2b2a819..01a9d66 100644 --- a/release-log.txt +++ b/release-log.txt @@ -1,5 +1,6 @@ -- Oozie 4.1.0 release (trunk - unreleased) +OOZIE-1661 Stream logs in oozie UI (puru via rohini) OOZIE-1610 UnitTests fail on Windows because of wrong paths (omaliuvanchuk via rohini) OOZIE-1660 DB connection misconfig causes all or most unit tests to fail (rkanter) OOZIE-1641 Oozie should mask the signature secret in the configuration output (rkanter) http://git-wip-us.apache.org/repos/asf/oozie/blob/937f19ed/webapp/src/main/webapp/oozie-console.js ---------------------------------------------------------------------- diff --git a/webapp/src/main/webapp/oozie-console.js b/webapp/src/main/webapp/oozie-console.js index 986d10e..e2822ad 100644 --- a/webapp/src/main/webapp/oozie-console.js +++ b/webapp/src/main/webapp/oozie-console.js @@ -30,7 +30,70 @@ $(document).ready(function() { } }); -//so it works from remote browsers, "http://localhost:8080"; +function getLogs(url, textArea, shouldParseResponse, errorMsg) { + textArea.getEl().dom.value = ''; + + if (!errorMsg) { + errorMsg = "Fatal Error. Can't load logs."; + } + if (!window.XMLHttpRequest) { + Ext.Ajax.request({ + url : url, + timeout : 300000, + success : function(response, request) { + if (shouldParseResponse) { + processAndDisplayLog(response.responseText, textArea); + } else { + textArea.getEl().dom.value = response.responseText; + } + }, + + failure : function() { + textArea.getEl().dom.value = errorMsg; + } + }); + + } else { + var xhr = new XMLHttpRequest(); + xhr.previous_text_length = 0; + + xhr.onerror = function() { + textArea.getEl().dom.value = errorMsg; + }; + xhr.onreadystatechange = function() { + try { + if (xhr.readyState > 2 && xhr.status == 200) { + var new_response = xhr.responseText + .substring(xhr.previous_text_length); + textArea.getEl().dom.value += new_response; + xhr.previous_text_length = xhr.responseText.length; + + } + if (xhr.status != 200 && xhr.status != 0) { + textArea.getEl().dom.value = "Error :\n" + xhr.responseText; + } + } catch (e) { + } + }; + xhr.open("GET", url, true); + xhr.send(); + } +} + +function processAndDisplayLog(response, textArea) { + var responseLength = response.length; + var twentyFiveMB = 25 * 1024 * 1024; + if (responseLength > twentyFiveMB) { + response = response.substring(responseLength - twentyFiveMB, + responseLength); + response = response.substring(response.indexOf("\n") + 1, + responseLength); + textArea.getEl().dom.value = response; + } else { + textArea.getEl().dom.value = response; + } +} + var oozie_host = ""; var flattenedObject; @@ -284,13 +347,8 @@ function jobDetailsPopup(response, request) { }); } function fetchLogs(workflowId) { - Ext.Ajax.request({ - url: getOozieBase() + 'job/' + workflowId + "?show=log", - success: function(response, request) { - jobLogArea.setRawValue(response.responseText); - } + getLogs(getOozieBase() + 'job/' + workflowId + "?show=log", jobLogArea, false, null); - }); } var jobDetails = eval("(" + response.responseText + ")"); var workflowId = jobDetails["id"]; @@ -765,15 +823,16 @@ function coordJobDetailsPopup(response, request) { var jobLogArea = new Ext.form.TextArea({ fieldLabel: 'Logs', editable: false, - id: 'jobLogAreaId', + id: 'jobLogAreaId', name: 'logs', width: 1035, height: 400, autoScroll: true, - emptyText: "Loading..." + emptyText: "Enter the list of actions in the format similar to 1,3-4,7-40 to get logs for specific coordinator actions. " + + "To get the log for the coordinator job, leave the actions field empty." }); var getLogButton = new Ext.Button({ - text: 'Retrieve coord action logs', + text: 'Get logs', handler: function() { fetchLogs(coordJobId, actionsTextBox.getValue()); } @@ -781,8 +840,14 @@ function coordJobDetailsPopup(response, request) { var actionsTextBox = new Ext.form.TextField({ fieldLabel: 'ActionsList', name: 'ActionsList', - value: 'Enter the action list here' + width: 150, + value: '' }); + + var actionsText = new Ext.form.Label({ + text : 'Enter action list : ' + }); + function fetchDefinition(coordJobId) { Ext.Ajax.request({ url: getOozieBase() + 'job/' + coordJobId + "?show=definition", @@ -792,45 +857,17 @@ function coordJobDetailsPopup(response, request) { }); } function fetchLogs(coordJobId, actionsList) { - if(actionsList=='') { - Ext.Ajax.request({ - url: getOozieBase() + 'job/' + coordJobId + "?show=log", - success: function(response, request) { - processAndDisplayLog(response.responseText); - } - }); - } - else { - Ext.Ajax.request({ - url: getOozieBase() + 'job/' + coordJobId + "?show=log&type=action&scope="+actionsList, - timeout: 300000, - success: function(response, request) { - processAndDisplayLog(response.responseText); - }, - failure: function() { - Ext.MessageBox.show({ - title: 'Format Error', - msg: 'Action List format is wrong. Format should be similar to 1,3-4,7-40', - buttons: Ext.MessageBox.OK, - icon: Ext.MessageBox.ERROR - }); - } - }); - } - } - function processAndDisplayLog(response) - { - var responseLength = response.length; - var twentyFiveMB = 25*1024*1024; - if(responseLength > twentyFiveMB) { - response = response.substring(responseLength-twentyFiveMB,responseLength); - response = response.substring(response.indexOf("\n")+1,responseLength); - jobLogArea.setRawValue(response); - } - else { - jobLogArea.setRawValue(response); - } + if (actionsList == '') { + getLogs(getOozieBase() + 'job/' + coordJobId + "?show=log", + jobLogArea, true, null); + } else { + getLogs(getOozieBase() + 'job/' + coordJobId + + "?show=log&type=action&scope=" + actionsList, jobLogArea, + true, + 'Action List format is wrong. Format should be similar to 1,3-4,7-40'); + } } + var jobDetails = eval("(" + response.responseText + ")"); var coordJobId = jobDetails["coordJobId"]; var appName = jobDetails["coordJobName"]; @@ -1159,20 +1196,9 @@ function coordJobDetailsPopup(response, request) { }) },{ title: 'Coord Job Log', - items: [jobLogArea, actionsTextBox, getLogButton], - tbar: [ { - text: " ", - icon: 'ext-2.2/resources/images/default/grid/refresh.gif', - handler: function() { - var actionsText = actionsTextBox.getValue(); - if (actionsText == 'Enter the action list here' || actionsText == '') { - fetchLogs(coordJobId, ''); - } - else { - fetchLogs(coordJobId, actionsText); - } - } - }] + items: jobLogArea, + tbar: [ + actionsText,actionsTextBox, getLogButton] }] }); @@ -1181,11 +1207,6 @@ function coordJobDetailsPopup(response, request) { coord_jobs_grid.setVisible(true); return; } - if (selectedTab.title == 'Coord Job Log') { - fetchLogs(coordJobId, ''); - //actionsTextBox.position - actionsTextBox.setValue('Enter the action list here'); - } else if (selectedTab.title == 'Coord Job Definition') { fetchDefinition(coordJobId); } @@ -1212,6 +1233,7 @@ function bundleJobDetailsPopup(response, request) { height: 400, autoScroll: true, emptyText: "Loading..." + }); var jobDetails = eval("(" + response.responseText + ")"); var bundleJobId = jobDetails["bundleJobId"]; @@ -1394,17 +1416,17 @@ function bundleJobDetailsPopup(response, request) { autoScroll: true, value: jobDetails["conf"] }) - },{ + },{ title: 'Bundle Job Log', - items: jobLogArea, + items: jobLogArea, tbar: [ { text: " ", icon: 'ext-2.2/resources/images/default/grid/refresh.gif', handler: function() { - fetchLogs(bundleJobId); + getLogs(getOozieBase() + 'job/' + bundleJobId + "?show=log", jobLogArea, false, null); } }] - }] + }] }); jobDetailsTab.addListener("tabchange", function(panel, selectedTab) { @@ -1413,7 +1435,7 @@ function bundleJobDetailsPopup(response, request) { return; } else if (selectedTab.title == 'Bundle Job Log') { - fetchLogs(bundleJobId); + getLogs(getOozieBase() + 'job/' + bundleJobId + "?show=log", jobLogArea, false, null); } else if (selectedTab.title == 'Bundle Job Definition') { fetchDefinition(bundleJobId); @@ -1430,15 +1452,7 @@ function bundleJobDetailsPopup(response, request) { }); } - function fetchLogs(bundleJobId) { - Ext.Ajax.request({ - url: getOozieBase() + 'job/' + bundleJobId + "?show=log", - success: function(response, request) { - jobLogArea.setRawValue(response.responseText); - } - }); - } var win = new Ext.Window({ title: 'Job (Name: ' + bundleJobName + '/bundleJobId: ' + bundleJobId + ')',
