http://git-wip-us.apache.org/repos/asf/tez/blob/13132ec7/tez-ui/src/main/webapp/app/scripts/controllers/vertex_task_attempts_controller.js ---------------------------------------------------------------------- diff --git a/tez-ui/src/main/webapp/app/scripts/controllers/vertex_task_attempts_controller.js b/tez-ui/src/main/webapp/app/scripts/controllers/vertex_task_attempts_controller.js deleted file mode 100644 index 750bd92..0000000 --- a/tez-ui/src/main/webapp/app/scripts/controllers/vertex_task_attempts_controller.js +++ /dev/null @@ -1,238 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - */ - -App.VertexTaskAttemptsController = App.TablePageController.extend(App.AutoCounterColumnMixin, { - - controllerName: 'VertexTaskAttemptsController', - needs: "vertex", - - entityType: 'vertexTaskAttempt', - baseEntityType: 'taskAttempt', - filterEntityType: 'vertex', - filterEntityId: Ember.computed.alias('controllers.vertex.id'), - - cacheDomain: Ember.computed.alias('controllers.vertex.dagID'), - - pollingType: 'attemptInfo', - - pollsterControl: function () { - if(this.get('dag.status') == 'RUNNING' && - this.get('dag.amWebServiceVersion') != '1' && - !this.get('loading') && - this.get('isActive') && - this.get('pollingEnabled') && - this.get('rowsDisplayed.length') > 0) { - this.get('pollster').start(); - } - else { - this.get('pollster').stop(); - } - }.observes('dag.status', 'dag.amWebServiceVersion', 'rowsDisplayed', 'loading', 'isActive', 'pollingEnabled'), - - pollsterOptionsObserver: function () { - this.set('pollster.options', { - appID: this.get('dag.applicationId'), - dagID: this.get('dag.idx'), - counters: this.get('countersDisplayed'), - attemptID: this.get('rowsDisplayed').map(function (row) { - var attemptIndex = App.Helpers.misc.getIndexFromId(row.get('id')), - taskIndex = App.Helpers.misc.getIndexFromId(row.get('taskID')), - vertexIndex = App.Helpers.misc.getIndexFromId(row.get('vertexID')); - return '%@_%@_%@'.fmt(vertexIndex, taskIndex, attemptIndex); - }).join(',') - }); - }.observes('dag.applicationId', 'dag.idx', 'rowsDisplayed'), - - countersDisplayed: function () { - return App.Helpers.misc.getCounterQueryParam(this.get('columns')); - }.property('columns'), - - beforeLoad: function () { - var controller = this.get('controllers.vertex'), - model = controller.get('model'); - return model.reload().then(function () { - return controller.loadAdditional(model); - }); - }, - - afterLoading: function () { - var data = this.get('data'), - isUnsuccessfulVertex = App.Helpers.misc.isStatusInUnsuccessful( - that.get('controllers.vertex.status') - ); - - data.forEach(function (attempt) { - var attemptStatus = App.Helpers.misc - .getFixedupDisplayStatus(attempt.get('status')); - if (attemptStatus == 'RUNNING' && isUnsuccessfulVertex) { - attemptStatus = 'KILLED' - } - if (attemptStatus != attempt.get('status')) { - attempt.set('status', attemptStatus); - } - }); - - return this._super(); - }, - - defaultColumnConfigs: function() { - var that = this; - return [ - { - id: 'taskId', - headerCellName: 'Task Index', - templateName: 'components/basic-table/linked-cell', - contentPath: 'taskID', - getCellContent: function (row) { - var taskId = row.get('taskID'), - idPrefix = 'task_%@_'.fmt(row.get('dagID').substr(4)); - return { - linkTo: 'task', - entityId: taskId, - displayText: taskId.indexOf(idPrefix) == 0 ? taskId.substr(idPrefix.length) : taskId - }; - }, - getSearchValue: function (row) { - var id = row.get('taskID'), - idPrefix = 'task_%@_'.fmt(row.get('dagID').substr(4)); - return id.indexOf(idPrefix) == 0 ? id.substr(idPrefix.length) : id; - } - }, - { - id: 'attemptNo', - headerCellName: 'Attempt No', - templateName: 'components/basic-table/linked-cell', - contentPath: 'id', - getCellContent: function(row) { - var attemptID = row.get('id') || ''; - return { - linkTo: 'taskAttempt', - displayText: attemptID.split(/[_]+/).pop(), - entityId: attemptID - }; - }, - getSearchValue: function (row) { - var attemptID = row.get('id') || ''; - return attemptID.split(/[_]+/).pop(); - }, - getSortValue: function (row) { - var attemptID = row.get('id') || ''; - return attemptID.split(/[_]+/).pop(); - } - }, - { - id: 'status', - headerCellName: 'Status', - templateName: 'components/basic-table/status-cell', - contentPath: 'status', - observePath: true, - onSort: this.onInProgressColumnSort.bind(this), - getCellContent: function(row) { - var status = App.Helpers.misc.getFixedupDisplayStatus(row.get('status')); - return { - status: status, - statusIcon: App.Helpers.misc.getStatusClassForEntity(status) - }; - } - }, - { - id: 'progress', - headerCellName: 'Progress', - contentPath: 'progress', - observePath: true, - onSort: this.onInProgressColumnSort.bind(this), - templateName: 'components/basic-table/progress-cell' - }, - { - id: 'startTime', - headerCellName: 'Start Time', - contentPath: 'startTime', - getCellContent: function(row) { - return App.Helpers.date.dateFormat(row.get('startTime')); - }, - getSearchValue: function(row) { - return App.Helpers.date.dateFormat(row.get('startTime')); - } - }, - { - id: 'endTime', - headerCellName: 'End Time', - contentPath: 'endTime', - getCellContent: function(row) { - return App.Helpers.date.dateFormat(row.get('endTime')); - }, - getSearchValue: function(row) { - return App.Helpers.date.dateFormat(row.get('endTime')); - }, - }, - { - id: 'duration', - headerCellName: 'Duration', - contentPath: 'duration', - getCellContent: function(row) { - return App.Helpers.date.timingFormat(row.get('duration'), 1); - }, - getSearchValue: function(row) { - return App.Helpers.date.timingFormat(row.get('duration'), 1); - }, - }, - { - id: 'containerId', - headerCellName: 'Container', - contentPath: 'containerId' - }, - { - id: 'nodeId', - headerCellName: 'Node', - contentPath: 'nodeId' - }, - { - id: 'actions', - headerCellName: 'Actions', - templateName: 'components/basic-table/linked-cell', - searchAndSortable: false, - contentPath: 'id', - getCellContent: function(row) { - var attemptID = row.get('id') || ''; - return { - linkTo: 'taskAttempt.counters', - displayText: 'counters', - entityId: attemptID - }; - } - }, - { - id: 'logs', - headerCellName: 'Logs', - templateName: 'components/basic-table/logs-cell', - searchAndSortable: false, - getCellContent: function(row) { - var cellContent = App.Helpers.misc.constructLogLinks( - row, - that.get('controllers.vertex.yarnAppState'), - that.get('controllers.vertex.tezApp.user') - ); - - cellContent.notAvailable = cellContent.viewUrl || cellContent.downloadUrl; - return cellContent; - } - } - ]; - }.property('controllers.vertex.yarnAppState', 'controllers.vertex.tezApp.user'), - -});
http://git-wip-us.apache.org/repos/asf/tez/blob/13132ec7/tez-ui/src/main/webapp/app/scripts/controllers/vertex_tasks_controller.js ---------------------------------------------------------------------- diff --git a/tez-ui/src/main/webapp/app/scripts/controllers/vertex_tasks_controller.js b/tez-ui/src/main/webapp/app/scripts/controllers/vertex_tasks_controller.js deleted file mode 100644 index bb7e292..0000000 --- a/tez-ui/src/main/webapp/app/scripts/controllers/vertex_tasks_controller.js +++ /dev/null @@ -1,207 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - */ - -App.VertexTasksController = App.TablePageController.extend(App.AutoCounterColumnMixin, { - - controllerName: 'VertexTasksController', - needs: "vertex", - - entityType: 'vertexTask', - baseEntityType: 'task', - filterEntityType: 'vertex', - filterEntityId: Ember.computed.alias('controllers.vertex.id'), - - cacheDomain: Ember.computed.alias('controllers.vertex.dagID'), - - pollingType: 'taskInfo', - - pollsterControl: function () { - if(this.get('dag.status') == 'RUNNING' && - this.get('dag.amWebServiceVersion') != '1' && - !this.get('loading') && this.get('isActive') && - this.get('pollingEnabled') && - this.get('rowsDisplayed.length') > 0) { - this.get('pollster').start(); - } - else { - this.get('pollster').stop(); - } - }.observes('dag.status', 'dag.amWebServiceVersion', 'rowsDisplayed', 'loading', 'isActive', 'pollingEnabled'), - - pollsterOptionsObserver: function () { - this.set('pollster.options', { - appID: this.get('dag.applicationId'), - dagID: this.get('dag.idx'), - counters: this.get('countersDisplayed'), - taskID: this.get('rowsDisplayed').map(function (row) { - var taskIndex = App.Helpers.misc.getIndexFromId(row.get('id')), - vertexIndex = App.Helpers.misc.getIndexFromId(row.get('vertexID')); - return '%@_%@'.fmt(vertexIndex, taskIndex); - }).join(',') - }); - }.observes('dag.applicationId', 'dag.idx', 'rowsDisplayed'), - - countersDisplayed: function () { - return App.Helpers.misc.getCounterQueryParam(this.get('columns')); - }.property('columns'), - - beforeLoad: function () { - var controller = this.get('controllers.vertex'), - model = controller.get('model'); - return model.reload().then(function () { - return controller.loadAdditional(model); - }); - }, - - afterLoad: function () { - var data = this.get('data'), - isUnsuccessfulVertex = App.Helpers.misc.isStatusInUnsuccessful( - this.get('controllers.vertex.status') - ); - - data.forEach(function (task) { - var taskStatus = App.Helpers.misc.getFixedupDisplayStatus(task.get('status')); - - if (taskStatus == 'RUNNING' && isUnsuccessfulVertex) { - taskStatus = 'KILLED' - } - if (taskStatus != task.get('status')) { - task.set('status', taskStatus); - } - }); - - return this._super(); - }, - - defaultColumnConfigs: function() { - var that = this; - - function getLogContent(attempt) { - var cellContent = App.Helpers.misc.constructLogLinks( - attempt, - that.get('controllers.vertex.yarnAppState'), - that.get('controllers.vertex.tezApp.user') - ); - - cellContent.notAvailable = cellContent.viewUrl || cellContent.downloadUrl; - return cellContent; - } - - return [ - { - id: 'id', - headerCellName: 'Task Index', - templateName: 'components/basic-table/linked-cell', - contentPath: 'id', - getCellContent: function (row) { - var id = row.get('id'), - idPrefix = 'task_%@_'.fmt(row.get('dagID').substr(4)); - return { - linkTo: 'task', - entityId: id, - displayText: id.indexOf(idPrefix) == 0 ? id.substr(idPrefix.length) : id - }; - }, - getSearchValue: function (row) { - var id = row.get('id'), - idPrefix = 'task_%@_'.fmt(row.get('dagID').substr(4)); - return id.indexOf(idPrefix) == 0 ? id.substr(idPrefix.length) : id; - } - }, - { - id: 'status', - headerCellName: 'Status', - templateName: 'components/basic-table/status-cell', - contentPath: 'status', - observePath: true, - onSort: this.onInProgressColumnSort.bind(this), - getCellContent: function(row) { - var status = row.get('status'); - return { - status: status, - statusIcon: App.Helpers.misc.getStatusClassForEntity(status, - row.get('hasFailedTaskAttempts')) - }; - } - }, - { - id: 'progress', - headerCellName: 'Progress', - contentPath: 'progress', - observePath: true, - onSort: this.onInProgressColumnSort.bind(this), - templateName: 'components/basic-table/progress-cell' - }, - { - id: 'startTime', - headerCellName: 'Start Time', - contentPath: 'startTime', - getCellContent: function(row) { - return App.Helpers.date.dateFormat(row.get('startTime')); - }, - getSearchValue: function(row) { - return App.Helpers.date.dateFormat(row.get('startTime')); - } - }, - { - id: 'endTime', - headerCellName: 'End Time', - contentPath: 'endTime', - getCellContent: function(row) { - return App.Helpers.date.dateFormat(row.get('endTime')); - }, - getSearchValue: function(row) { - return App.Helpers.date.dateFormat(row.get('endTime')); - }, - }, - { - id: 'duration', - headerCellName: 'Duration', - contentPath: 'duration', - getCellContent: function(row) { - return App.Helpers.date.timingFormat(row.get('duration'), 1); - }, - getSearchValue: function(row) { - return App.Helpers.date.timingFormat(row.get('duration'), 1); - }, - }, - { - id: 'actions', - headerCellName: 'Actions', - templateName: 'components/basic-table/task-actions-cell', - contentPath: 'id', - searchAndSortable: false - }, - { - id: 'logs', - headerCellName: 'Logs', - templateName: 'components/basic-table/logs-cell', - searchAndSortable: false, - getCellContent: function(row) { - var taskAttemptId = row.get('successfulAttemptId') || row.get('attempts.lastObject'), - store = that.get('store'); - - if (taskAttemptId) { - return store.find('taskAttempt', taskAttemptId).then(getLogContent); - } - } - } - ]; - }.property('controllers.vertex.yarnAppState', 'controllers.vertex.tezApp.user') - -}); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tez/blob/13132ec7/tez-ui/src/main/webapp/app/scripts/default-configs.js ---------------------------------------------------------------------- diff --git a/tez-ui/src/main/webapp/app/scripts/default-configs.js b/tez-ui/src/main/webapp/app/scripts/default-configs.js deleted file mode 100644 index dbdf707..0000000 --- a/tez-ui/src/main/webapp/app/scripts/default-configs.js +++ /dev/null @@ -1,326 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - */ - -function constructDefaultUrl(location, port) { - var protocol, - hostname; - if (App.env.isStandalone && location.protocol != 'file:') { - protocol = location.protocol; - hostname = location.hostname; - } else { - protocol = 'http:'; - hostname = 'localhost'; - } - return '%@//%@:%@'.fmt(protocol, hostname, port); -} - -var getDefaultTimelineUrl = function() { - return constructDefaultUrl(window.location, 8188); -}; - -var getDefaultRMWebUrl = function() { - return constructDefaultUrl(window.location, 8088); -}; - -$.extend(true, App.Configs, { - envDefaults: { - version: "0.7.0", - - timelineBaseUrl: getDefaultTimelineUrl(), - RMWebUrl: getDefaultRMWebUrl() - }, - - restNamespace: { - timeline: 'ws/v1/timeline', - applicationHistory: 'ws/v1/applicationhistory', - aminfo: 'proxy/__app_id__/ws/v1/tez', - aminfoV2: 'proxy/__app_id__/ws/v2/tez', - cluster: 'ws/v1/cluster' - }, - - otherNamespace: { - cluster: 'cluster', - }, - - tables: { - entity: { - dag: [ - // DAG Counters - { - counterName :"NUM_FAILED_TASKS", - counterGroupName :"org.apache.tez.common.counters.DAGCounter", - }, - { - counterName :"NUM_KILLED_TASKS", - counterGroupName :"org.apache.tez.common.counters.DAGCounter", - }, - { - counterName :"NUM_SUCCEEDED_TASKS", - counterGroupName :"org.apache.tez.common.counters.DAGCounter", - }, - { - counterName :"TOTAL_LAUNCHED_TASKS", - counterGroupName :"org.apache.tez.common.counters.DAGCounter", - }, - { - counterName :"OTHER_LOCAL_TASKS", - counterGroupName :"org.apache.tez.common.counters.DAGCounter", - }, - { - counterName :"DATA_LOCAL_TASKS", - counterGroupName :"org.apache.tez.common.counters.DAGCounter", - }, - { - counterName :"RACK_LOCAL_TASKS", - counterGroupName :"org.apache.tez.common.counters.DAGCounter", - }, - { - counterName :"SLOTS_MILLIS_TASKS", - counterGroupName :"org.apache.tez.common.counters.DAGCounter", - }, - { - counterName :"FALLOW_SLOTS_MILLIS_TASKS", - counterGroupName :"org.apache.tez.common.counters.DAGCounter", - }, - { - counterName :"TOTAL_LAUNCHED_UBERTASKS", - counterGroupName :"org.apache.tez.common.counters.DAGCounter", - }, - { - counterName :"NUM_UBER_SUBTASKS", - counterGroupName :"org.apache.tez.common.counters.DAGCounter", - }, - { - counterName :"NUM_FAILED_UBERTASKS", - counterGroupName :"org.apache.tez.common.counters.DAGCounter", - }, - - { - counterName: "REDUCE_OUTPUT_RECORDS", - counterGroupName: "REDUCE_OUTPUT_RECORDS", - }, - { - counterName: "REDUCE_SKIPPED_GROUPS", - counterGroupName: "REDUCE_SKIPPED_GROUPS", - }, - { - counterName: "REDUCE_SKIPPED_RECORDS", - counterGroupName: "REDUCE_SKIPPED_RECORDS", - }, - { - counterName: "COMBINE_OUTPUT_RECORDS", - counterGroupName: "COMBINE_OUTPUT_RECORDS", - }, - { - counterName: "SKIPPED_RECORDS", - counterGroupName: "SKIPPED_RECORDS", - }, - { - counterName: "INPUT_GROUPS", - counterGroupName: "INPUT_GROUPS", - } - ] - } - }, - - defaultCounters: [ - // File System Counters - { - counterName: 'FILE_BYTES_READ', - counterGroupName: 'org.apache.tez.common.counters.FileSystemCounter', - }, - { - counterName: 'FILE_BYTES_WRITTEN', - counterGroupName: 'org.apache.tez.common.counters.FileSystemCounter', - }, - { - counterName: 'FILE_READ_OPS', - counterGroupName: 'org.apache.tez.common.counters.FileSystemCounter', - }, - { - counterName: 'FILE_LARGE_READ_OPS', - counterGroupName: 'org.apache.tez.common.counters.FileSystemCounter', - }, - { - counterName: 'FILE_WRITE_OPS', - counterGroupName: 'org.apache.tez.common.counters.FileSystemCounter', - }, - { - counterName: 'HDFS_BYTES_READ', - counterGroupName: 'org.apache.tez.common.counters.FileSystemCounter', - }, - { - counterName: 'HDFS_BYTES_WRITTEN', - counterGroupName: 'org.apache.tez.common.counters.FileSystemCounter', - }, - { - counterName: 'HDFS_READ_OPS', - counterGroupName: 'org.apache.tez.common.counters.FileSystemCounter', - }, - { - counterName: 'HDFS_LARGE_READ_OPS', - counterGroupName: 'org.apache.tez.common.counters.FileSystemCounter', - }, - { - counterName: 'HDFS_WRITE_OPS', - counterGroupName: 'org.apache.tez.common.counters.FileSystemCounter', - }, - - // Task Counters - { - counterName: "NUM_SPECULATIONS", - counterGroupName: "org.apache.tez.common.counters.TaskCounter", - }, - { - counterName: "REDUCE_INPUT_GROUPS", - counterGroupName: "org.apache.tez.common.counters.TaskCounter", - }, - { - counterName: "REDUCE_INPUT_RECORDS", - counterGroupName: "org.apache.tez.common.counters.TaskCounter", - }, - { - counterName: "SPLIT_RAW_BYTES", - counterGroupName: "org.apache.tez.common.counters.TaskCounter", - }, - { - counterName: "COMBINE_INPUT_RECORDS", - counterGroupName: "org.apache.tez.common.counters.TaskCounter", - }, - { - counterName: "SPILLED_RECORDS", - counterGroupName: "org.apache.tez.common.counters.TaskCounter", - }, - { - counterName: "NUM_SHUFFLED_INPUTS", - counterGroupName: "org.apache.tez.common.counters.TaskCounter", - }, - { - counterName: "NUM_SKIPPED_INPUTS", - counterGroupName: "org.apache.tez.common.counters.TaskCounter", - }, - { - counterName: "NUM_FAILED_SHUFFLE_INPUTS", - counterGroupName: "org.apache.tez.common.counters.TaskCounter", - }, - { - counterName: "MERGED_MAP_OUTPUTS", - counterGroupName: "org.apache.tez.common.counters.TaskCounter", - }, - { - counterName: "GC_TIME_MILLIS", - counterGroupName: "org.apache.tez.common.counters.TaskCounter", - }, - { - counterName: "CPU_MILLISECONDS", - counterGroupName: "org.apache.tez.common.counters.TaskCounter", - }, - { - counterName: "PHYSICAL_MEMORY_BYTES", - counterGroupName: "org.apache.tez.common.counters.TaskCounter", - }, - { - counterName: "VIRTUAL_MEMORY_BYTES", - counterGroupName: "org.apache.tez.common.counters.TaskCounter", - }, - { - counterName: "COMMITTED_HEAP_BYTES", - counterGroupName: "org.apache.tez.common.counters.TaskCounter", - }, - { - counterName: "INPUT_RECORDS_PROCESSED", - counterGroupName: "org.apache.tez.common.counters.TaskCounter", - }, - { - counterName: "OUTPUT_RECORDS", - counterGroupName: "org.apache.tez.common.counters.TaskCounter", - }, - { - counterName: "OUTPUT_LARGE_RECORDS", - counterGroupName: "org.apache.tez.common.counters.TaskCounter", - }, - { - counterName: "OUTPUT_BYTES", - counterGroupName: "org.apache.tez.common.counters.TaskCounter", - }, - { - counterName: "OUTPUT_BYTES_WITH_OVERHEAD", - counterGroupName: "org.apache.tez.common.counters.TaskCounter", - }, - { - counterName: "OUTPUT_BYTES_PHYSICAL", - counterGroupName: "org.apache.tez.common.counters.TaskCounter", - }, - { - counterName: "ADDITIONAL_SPILLS_BYTES_WRITTEN", - counterGroupName: "org.apache.tez.common.counters.TaskCounter", - }, - { - counterName: "ADDITIONAL_SPILLS_BYTES_READ", - counterGroupName: "org.apache.tez.common.counters.TaskCounter", - }, - { - counterName: "ADDITIONAL_SPILL_COUNT", - counterGroupName: "org.apache.tez.common.counters.TaskCounter", - }, - { - counterName: "SHUFFLE_BYTES", - counterGroupName: "org.apache.tez.common.counters.TaskCounter", - }, - { - counterName: "SHUFFLE_BYTES_DECOMPRESSED", - counterGroupName: "org.apache.tez.common.counters.TaskCounter", - }, - { - counterName: "SHUFFLE_BYTES_TO_MEM", - counterGroupName: "org.apache.tez.common.counters.TaskCounter", - }, - { - counterName: "SHUFFLE_BYTES_TO_DISK", - counterGroupName: "org.apache.tez.common.counters.TaskCounter", - }, - { - counterName: "SHUFFLE_BYTES_DISK_DIRECT", - counterGroupName: "org.apache.tez.common.counters.TaskCounter", - }, - { - counterName: "NUM_MEM_TO_DISK_MERGES", - counterGroupName: "org.apache.tez.common.counters.TaskCounter", - }, - { - counterName: "NUM_DISK_TO_DISK_MERGES", - counterGroupName: "org.apache.tez.common.counters.TaskCounter", - }, - { - counterName: "SHUFFLE_PHASE_TIME", - counterGroupName: "org.apache.tez.common.counters.TaskCounter", - }, - { - counterName: "MERGE_PHASE_TIME", - counterGroupName: "org.apache.tez.common.counters.TaskCounter", - }, - { - counterName: "FIRST_EVENT_RECEIVED", - counterGroupName: "org.apache.tez.common.counters.TaskCounter", - }, - { - counterName: "LAST_EVENT_RECEIVED", - counterGroupName: "org.apache.tez.common.counters.TaskCounter", - }, - ] -}); http://git-wip-us.apache.org/repos/asf/tez/blob/13132ec7/tez-ui/src/main/webapp/app/scripts/helpers/date.js ---------------------------------------------------------------------- diff --git a/tez-ui/src/main/webapp/app/scripts/helpers/date.js b/tez-ui/src/main/webapp/app/scripts/helpers/date.js deleted file mode 100644 index b9c9683..0000000 --- a/tez-ui/src/main/webapp/app/scripts/helpers/date.js +++ /dev/null @@ -1,224 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - */ - -App.Helpers.date = { - - /** - * List of monthes short names - * @type {string[]} - */ - dateMonths: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], - - /** - * List of days short names - * @type {string[]} - */ - dateDays: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], - - /** - * Add leading zero - * - * @param {string} time - * @returns {string} - * @method dateFormatZeroFirst - */ - dateFormatZeroFirst: function (time) { - if (time < 10) return '0' + time; - return "" + time; - }, - - /** - * Convert timestamp to date-string 'DAY_OF_THE_WEEK, MONTH DAY, YEAR HOURS:MINUTES' - * - * @param {number} timestamp - * @param {bool} showSeconds should seconds be added to result string. true by default. - * @param {bool} showMilliseconds should miliseconds be added to result string (if <code>showSeconds</code> is false, milliseconds wouldn't be added) - * @return {*} date - * @method dateFormat - */ - dateFormat: function (timestamp, showSeconds, showMilliseconds) { - if (!App.Helpers.number.isValidInt(timestamp) || timestamp == 0) { - return ""; - } - if(showSeconds == undefined) showSeconds = true; - var format = 'DD MMM YYYY HH:mm'; - if (showSeconds) { - format += ':ss'; - if (showMilliseconds) { - format += ':SSS'; - } - } - var zone = moment.tz.zone(App.get('env.timezone')); - if (zone == null) { - return moment.utc(timestamp).local().format(format); - } - return moment.tz(timestamp, zone.name).format(format); - }, - - /** - * Convert timestamp to date-string 'DAY_OF_THE_WEEK MONTH DAY YEAR' - * - * @param {string} timestamp - * @return {string} - * @method dateFormatShort - */ - dateFormatShort: function (timestamp) { - if (!App.Helpers.number.isValidInt(timestamp)) { - return timestamp; - } - var format = 'ddd MMM DD YYYY'; - var date = moment((new Date(timestamp)).toISOString().replace('Z', '')).format(format); - var today = moment((new Date()).toISOString().replace('Z', '')).format(format); - if (date === today) { - return 'Today ' + (new Date(timestamp)).toLocaleTimeString(); - } - return date; - }, - - /** - * Convert starTimestamp to 'DAY_OF_THE_WEEK, MONTH DAY, YEAR HOURS:MINUTES', except for the case: year equals 1969 - * - * @param {string} startTimestamp - * @return {string} startTimeSummary - * @method startTime - */ - startTime: function (startTimestamp) { - if (!App.Helpers.number.isValidInt(startTimestamp)) { - return ''; - } - var startDate = new Date(startTimestamp); - var months = this.dateMonths; - var days = this.dateDays; - // generate start time - if (startDate.getFullYear() == 1969 || startTimestamp < 1) { - return 'Not started'; - } - var startTimeSummary = ''; - if (new Date(startTimestamp).setHours(0, 0, 0, 0) == new Date().setHours(0, 0, 0, 0)) { //today - startTimeSummary = 'Today ' + this.dateFormatZeroFirst(startDate.getHours()) + ':' + this.dateFormatZeroFirst(startDate.getMinutes()); - } else { - startTimeSummary = days[startDate.getDay()] + ' ' + months[startDate.getMonth()] + ' ' + - this.dateFormatZeroFirst(startDate.getDate()) + ' ' + startDate.getFullYear() + ' ' - + this.dateFormatZeroFirst(startDate.getHours()) + ':' + this.dateFormatZeroFirst(startDate.getMinutes()); - } - return startTimeSummary; - }, - - /** - * Provides the duration between the given start and end timestamp. If start time - * not valid, duration will be ''. If end time is not valid, duration will - * be till now, showing 'Lasted for xxx secs'. - * - * @param {string} startTimestamp - * @param {string} endTimestamp - * @return {string} durationSummary - * @method durationSummary - */ - durationSummary: function (startTimestamp, endTimestamp) { - // generate duration - var durationSummary = ''; - var startDate = new Date(startTimestamp); - var endDate = new Date(endTimestamp); - if (startDate.getFullYear() == 1969 || startTimestamp < 1) { - // not started - return Em.I18n.t('common.na'); - } - if (endDate.getFullYear() != 1969 && endTimestamp > 0) { - return '' + this.timingFormat(endTimestamp - startTimestamp, 1); //lasted for xx secs - } else { - // still running, duration till now - var t = new Date().getTime(), - time = (t - startTimestamp) < 0 ? 0 : (t - startTimestamp); - durationSummary = '' + this.timingFormat(time, 1); - } - return durationSummary; - }, - - /** - * Convert time in mseconds to - * 30 ms = 30 ms - * 300 ms = 300 ms - * 999 ms = 999 ms - * 1000 ms = 1.00 secs - * 3000 ms = 3.00 secs - * 35000 ms = 35.00 secs - * 350000 ms = 350.00 secs - * 999999 ms = 999.99 secs - * 1000000 ms = 16.66 mins - * 3500000 secs = 58.33 mins - * - * @param {number} time - * @param {bool} zeroValid for the case to show 0 when time is 0, not null - * @return {string|null} formatted date - * @method timingFormat - */ - timingFormat: function (time, /* optional */ zeroValid) { - var intTime = parseInt(time); - if (zeroValid && intTime <= 0) { - return 0 + ' secs'; - } - if (!intTime) { - return null; - } - var timeStr = intTime.toString(); - var lengthOfNumber = timeStr.length; - var oneMinMs = 60000; - var oneHourMs = 3600000; - var oneDayMs = 86400000; - - if (lengthOfNumber < 4) { - time = Math.floor(time); - return time + ' ms'; - } else if (lengthOfNumber < 7) { - time = (time / 1000).toFixed(2); - time = Math.floor(time); - return time + ' secs'; - } else if (time < oneHourMs) { - time = (time / oneMinMs).toFixed(2); - return time + ' mins'; - } else if (time < oneDayMs) { - time = (time / oneHourMs).toFixed(2); - return time + ' hours'; - } else { - time = (time / oneDayMs).toFixed(2); - return time + ' days'; - } - }, - - /** - * Provides the duration between the given start and end time. If start time - * is not given, duration will be 0. If end time is not given, duration will - * be till now. - * - * @param {Number} startTime Start time from epoch - * @param {Number} endTime End time from epoch - * @return {Number} duration - * @method duration - */ - duration: function (startTime, endTime) { - if (!startTime || !endTime) return undefined; - var duration = 0; - if (startTime && startTime > 0) { - if (!endTime || endTime < 1) { - endTime = new Date().getTime(); - } - duration = endTime - startTime; - } - return duration; - } -}; http://git-wip-us.apache.org/repos/asf/tez/blob/13132ec7/tez-ui/src/main/webapp/app/scripts/helpers/dialogs.js ---------------------------------------------------------------------- diff --git a/tez-ui/src/main/webapp/app/scripts/helpers/dialogs.js b/tez-ui/src/main/webapp/app/scripts/helpers/dialogs.js deleted file mode 100644 index d4cdfae..0000000 --- a/tez-ui/src/main/webapp/app/scripts/helpers/dialogs.js +++ /dev/null @@ -1,109 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - */ - -App.Helpers.Dialogs = Em.Namespace.create({ - - /** - * Shows an alert box with a title and body - * @param title {String} The alert window title - * @param message {String} The alert message - * @param controller {Controller} Active ember controller - */ - alert: function (title, message, controller) { - Bootstrap.ModalManager.open( - 'alertModal', - title, - Ember.View.extend({ - template: Em.Handlebars.compile( - '<p id="modalMessage">%@</p>'.fmt(message) - ) - }), [ - Ember.Object.create({title: 'OK', dismiss: 'modal'}) - ], controller); - }, - - /* - * Displays a dialog with a multiselector based on the provided data. - * - Helper looks for id & displayText in listItems. - * @param listItems Array of all items - * @param selectedItems - * @param keyHash Defines the key that helper must use to get value from item. - * @return Returns a promoise that would be fulfilled when Ok is pressed - */ - displayMultiSelect: function (title, listItems, selectedItems, keyHash) { - /* - * Looks in an object for properties. - */ - function getProperty(object, propertyName) { - var propertyName = (keyHash && keyHash[propertyName]) || propertyName; - return object[propertyName] || (object.get && object.get(propertyName)); - } - - var container = $( "<div/>" ), - listHTML = "<input type='hidden' autofocus='autofocus'/>"; - - listItems.forEach(function (item) { - var id = getProperty(item, 'id'), - displayText = getProperty(item, 'displayText'); - - listHTML += '<li class="no-wrap"><input id=%@ type="checkbox" %@ /> %@</li>'.fmt( - id, - selectedItems[id] ? 'checked' : '', - displayText - ); - }); - - container.append('<ol class="selectable"> %@ </ol>'.fmt(listHTML)); - - return new Em.RSVP.Promise(function (resolve, reject) { - var dialogOptions = { - modal: true, - title: title, - width: 350, - height: 500, - resizable: false, - open: function() { - $(this).closest(".ui-dialog") - .find(".ui-dialog-titlebar-close") - .append('<span\ - class="ui-button-icon-primary ui-icon ui-icon-closethick align-close-button">\ - </span>'); - }, - buttons: { - Ok: function() { - var visibleColumnIds = {}; - - container.find('input:checked').each(function(index, checkbox){ - visibleColumnIds[checkbox.id] = true; - }); - resolve(visibleColumnIds); - - $( this ).dialog("close"); - container.remove(); - } - } - }; - - if($('#dialog-container').length) { - dialogOptions.appendTo = '#dialog-container'; - } - - container.dialog(dialogOptions); - }); - } -}); http://git-wip-us.apache.org/repos/asf/tez/blob/13132ec7/tez-ui/src/main/webapp/app/scripts/helpers/em-data.js ---------------------------------------------------------------------- diff --git a/tez-ui/src/main/webapp/app/scripts/helpers/em-data.js b/tez-ui/src/main/webapp/app/scripts/helpers/em-data.js deleted file mode 100644 index 8ad3eb2..0000000 --- a/tez-ui/src/main/webapp/app/scripts/helpers/em-data.js +++ /dev/null @@ -1,59 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - */ - -App.Helpers.emData = { - /** - * Merge data from an array of records to another - * @param target {Array} Target record array - * @param source {Array} Source record array - * @param mergeProps {Array} Array of strings of property names to be merged - * @return true if merge was success, else false - */ - mergeRecords: function (target, source, mergeProps) { - - if(source && target && mergeProps) { - target.forEach(function (row) { - var info = source.findBy('id', row.get('id')), - merge = !!info; - - if(info && info.get('counters')) { - row.set('counterGroups', - App.Helpers.misc.mergeCounterInfo( - row.get('counterGroups'), - info.get('counters') - ).slice(0) - ); - row.didLoad();// To update the record time stamp - } - - if(merge && row.get('progress') && info.get('progress')) { - if(row.get('progress') >= info.get('progress')) { - merge = false; - } - } - - if(merge) { - row.setProperties(info.getProperties.apply(info, mergeProps)); - row.didLoad();// To update the record time stamp - } - }); - return true; - } - return false; - } -}; http://git-wip-us.apache.org/repos/asf/tez/blob/13132ec7/tez-ui/src/main/webapp/app/scripts/helpers/entity-array-pollster.js ---------------------------------------------------------------------- diff --git a/tez-ui/src/main/webapp/app/scripts/helpers/entity-array-pollster.js b/tez-ui/src/main/webapp/app/scripts/helpers/entity-array-pollster.js deleted file mode 100644 index ca81d19..0000000 --- a/tez-ui/src/main/webapp/app/scripts/helpers/entity-array-pollster.js +++ /dev/null @@ -1,99 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - */ - -App.Helpers.EntityArrayPollster = App.Helpers.Pollster.extend({ - entityType: null, // Entity type to be polled - store: null, - mergeProperties: [], - options: null, - - isRunning: false, - isWaiting: false, - - polledRecords: null, - targetRecords: [], - - _ready: function () { - return this.get('entityType') && - this.get('store') && - this.get('options') && - this.get('targetRecords.length'); - }.property('entityType', 'store', 'options', 'targetRecords.length'), - - start: function(runImmediate, interval) { - if(!this.get('isRunning')) { - this.set('isRunning', true); - this._super(runImmediate == undefined ? true : runImmediate, interval); - } - }, - - stop: function() { - if(this.get('isRunning')) { - this._super(); - this.set('isRunning', false); - } - }, - - onPoll: function(){ - if(!this.get('isWaiting') && this.get('_ready')) { - this.set('isWaiting', true); - - return this.store.findQuery(this.get('entityType'), { - metadata: this.get('options') - }).then(this._callIfRunning(this, 'onResponse')). - catch(this._callIfRunning(this, 'onFailure')). - finally(this._final.bind(this)); - } - }, - - _preRequisitesObserver: function () { - if(this.get('isRunning')) { - this.onPoll(); - } - }.observes('options', 'targetRecords'), - - _callIfRunning: function (that, funName) { - return function (data) { - var fun = that.get(funName); - if(fun && that.get('isRunning')) { - fun.call(that, data); - } - }; - }, - - onResponse: function (data) { - this.set('polledRecords', data); - this.mergeToTarget(); - }, - - onFailure: function (err) { - // Implement based on requirement - }, - - _final: function () { - this.set('isWaiting', false); - }, - - mergeToTarget: function () { - App.Helpers.emData.mergeRecords( - this.get('targetRecords'), - this.get('polledRecords'), - this.get('mergeProperties') || [] - ); - }.observes('targetRecords').on('init') -}); http://git-wip-us.apache.org/repos/asf/tez/blob/13132ec7/tez-ui/src/main/webapp/app/scripts/helpers/error-bar.js ---------------------------------------------------------------------- diff --git a/tez-ui/src/main/webapp/app/scripts/helpers/error-bar.js b/tez-ui/src/main/webapp/app/scripts/helpers/error-bar.js deleted file mode 100644 index 42df27f..0000000 --- a/tez-ui/src/main/webapp/app/scripts/helpers/error-bar.js +++ /dev/null @@ -1,97 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - */ - - -/* - * A singleton class to control the error bar. - */ -App.Helpers.ErrorBar = (function () { - var _instance; // Singleton instance of the class - - var ErrorBar = Em.Object.extend({ - init: function () { - var errorBar = $('.error-bar'); - errorBar.find('.close').click(function () { - if(_instance) { - _instance.hide(); - } - }); - }, - /* - * Displays an error message in the error bar. - * @param message String Error message - * @param details String HTML to be displayed as details. - */ - show: function (message, details) { - var errorBar = $('.error-bar'), - messageElement, - lineEndIndex; - - errorBar.find('.expander').unbind('click'); - errorBar.find('.details').removeClass('visible'); - - if(typeof message == 'string') { - lineEndIndex = message.indexOf('\n'); - - if(lineEndIndex == -1) { - lineEndIndex = message.indexOf('<br'); - } - - if(lineEndIndex != -1) { - details = details ? "<br />" + details : ""; - details = message.substr(lineEndIndex) + details; - message = message.substr(0, lineEndIndex); - } - } - - if(details) { - messageElement = $('<a class="expander" href="#">' + message + '</a>'); - messageElement.click(function (event) { - errorBar.find('.details').toggleClass('visible'); - event.preventDefault(); - }); - - errorBar.find('.details').html(details.replace(/\n/g, "<br />")); - } - else { - messageElement = $('<span>' + message + '</span>'); - } - - errorBar.find('.message').empty().append(messageElement); - errorBar.addClass('visible'); - }, - - /* - * Hides if the error bar is visible. - */ - hide: function () { - var errorBar = $('.error-bar').first(); - - errorBar.find('.expander').unbind('click'); - errorBar.find('.details').removeClass('visible'); - - errorBar.removeClass('visible'); - } - }); - - ErrorBar.getInstance = function(){ - return _instance || (_instance = ErrorBar.create()); - }; - return ErrorBar; -})(); - http://git-wip-us.apache.org/repos/asf/tez/blob/13132ec7/tez-ui/src/main/webapp/app/scripts/helpers/fullscreen.js ---------------------------------------------------------------------- diff --git a/tez-ui/src/main/webapp/app/scripts/helpers/fullscreen.js b/tez-ui/src/main/webapp/app/scripts/helpers/fullscreen.js deleted file mode 100644 index f0e31e5..0000000 --- a/tez-ui/src/main/webapp/app/scripts/helpers/fullscreen.js +++ /dev/null @@ -1,55 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - */ - -App.Helpers.fullscreen = (function(){ - function inFullscreenMode() { - return document.fullscreenElement || - document.mozFullScreenElement || - document.webkitFullscreenElement || - document.msFullscreenElement; - } - - return { - inFullscreenMode: inFullscreenMode, - toggle: function (element) { - if (inFullscreenMode()) { - if (document.exitFullscreen) { - document.exitFullscreen(); - } else if (document.msExitFullscreen) { - document.msExitFullscreen(); - } else if (document.mozCancelFullScreen) { - document.mozCancelFullScreen(); - } else if (document.webkitExitFullscreen) { - document.webkitExitFullscreen(); - } - } else { - if (element.requestFullscreen) { - element.requestFullscreen(); - } else if (element.msRequestFullscreen) { - element.msRequestFullscreen(); - } else if (element.mozRequestFullScreen) { - element.mozRequestFullScreen(); - } else if (element.webkitRequestFullscreen) { - element.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT); - } - } - - return inFullscreenMode(); - } - }; -})(); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tez/blob/13132ec7/tez-ui/src/main/webapp/app/scripts/helpers/handlebarHelpers.js ---------------------------------------------------------------------- diff --git a/tez-ui/src/main/webapp/app/scripts/helpers/handlebarHelpers.js b/tez-ui/src/main/webapp/app/scripts/helpers/handlebarHelpers.js deleted file mode 100644 index 5cbdef5..0000000 --- a/tez-ui/src/main/webapp/app/scripts/helpers/handlebarHelpers.js +++ /dev/null @@ -1,88 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - */ - -/** - * formats the given unix timestamp. returns Not Available if its not a number. - * - * @param {number} unixtimestamp - * @returns {string} - * @method formatUnixTimestamp - */ -Em.Handlebars.helper('formatUnixTimestamp', function(timestamp) { - if (!App.Helpers.number.isValidInt(timestamp)) return 'Not Available'; - if (timestamp > 0) { - return App.Helpers.date.dateFormat(timestamp); - } - return ''; -}); - -/** - * Format value with US style thousands separator - * @param {string/number} value to be formatted - * @returns {string} Formatted string - */ -Em.Handlebars.helper('formatNumThousands', function (value) { - return App.Helpers.number.formatNumThousands(value); -}); - -/* - * formats the duration. - * - * @param {duration} duration in milliseconds - * @return {Number} - * @method formatDuration - */ -Em.Handlebars.helper('formatDuration', function(startTime, endTime) { - if (!endTime || !startTime) { - return 'Not Available'; - } - - // unixtimestamp is in seconds. javascript expects milliseconds. - if (endTime < startTime) { - endTime = new Date().getTime(); - } - - return App.Helpers.date.durationSummary(startTime, endTime); -}); - -Em.Handlebars.helper('formatTimeMillis', function(duration) { - return App.Helpers.date.timingFormat(duration, true); -}); - -function replaceAll(str, str1, str2, ignore) -{ - return str.replace(new RegExp(str1.replace(/([\/\,\!\\\^\$\{\}\[\]\(\)\.\*\+\?\|\<\>\-\&])/g,"\\$&"),(ignore?"gi":"g")),(typeof(str2)=="string")?str2.replace(/\$/g,"$$$$"):str2); -} - -//TODO: needs better indendation. -Em.Handlebars.helper('formatDiagnostics', function(diagnostics) { - var x = replaceAll(diagnostics, '[', '<div class="log-indent"><i> </i>'); - x = replaceAll(x, '],', '</div>'); - x = replaceAll(x, ']', '</div>'); - x = replaceAll(x, '\n', '<br />'); - x = replaceAll(x, '\t', '<span class="log-indent" /></span>'); - return new Handlebars.SafeString(x); -}); - -/** - * Returns first-item class if called from inside a loop/each. - * @param view Will be _view in hbs - */ -Em.Handlebars.helper('firstItemCSS', function(view) { - return view && view.contentIndex == 0 ? 'first-item' : ''; -}); http://git-wip-us.apache.org/repos/asf/tez/blob/13132ec7/tez-ui/src/main/webapp/app/scripts/helpers/io.js ---------------------------------------------------------------------- diff --git a/tez-ui/src/main/webapp/app/scripts/helpers/io.js b/tez-ui/src/main/webapp/app/scripts/helpers/io.js deleted file mode 100644 index 1a1be6e..0000000 --- a/tez-ui/src/main/webapp/app/scripts/helpers/io.js +++ /dev/null @@ -1,269 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with this - * work for additional information regarding copyright ownership. The ASF - * licenses this file to you 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. - */ - -zip.workerScriptsPath = "scripts/zip.js/"; - -App.Helpers.io = { - /* Allow queuing of downloads and then get a callback once all the downloads are done. - * sample usage. - * var downloader = App.Helpers.io.fileDownloader(); - * downloader.queueItem({ - * url: 'http://....', - * onItemFetched: function(data, context) {...}, - * context: {}, // context object gets passed back to the callback - * }); - * downloader.queueItem({...}); //queue in other items - * downloader.finish(); // once all items are queued. items can be queued from - * // callbacks too. in that case the finish should be called - * // once all items are queued. - * downloader.then(successCallback).catch(failurecallback).finally(callback) - */ - fileDownloader: function(options) { - var itemList = [], - opts = options || {}, - numParallel = opts.numParallel || 5, - hasMoreInputs = true, - inProgress = 0, - hasFailed = false, - pendingRequests = {}, - pendingRequestID = 0, - failureReason = 'Unknown', - deferredPromise = Em.RSVP.defer(); - - function checkForCompletion() { - if (hasFailed) { - if (inProgress == 0) { - deferredPromise.reject("Unknown Error"); - } - return; - } - - if (hasMoreInputs || itemList.length > 0 || inProgress > 0) { - return; - } - - deferredPromise.resolve(); - } - - function getRequestId() { - return "req_" + pendingRequestID++; - } - - function abortPendingRequests() { - $.each(pendingRequests, function(idx, val) { - try { - val.abort("abort"); - } catch(e) {} - }); - } - - function markFailed(reason) { - if (!hasFailed) { - hasFailed = true; - failureReason = reason; - abortPendingRequests(); - } - } - - function processNext() { - if (inProgress >= numParallel) { - Em.Logger.debug("delaying download as %@ of %@ is in progress".fmt(inProgress, numParallel)); - return; - } - - if (itemList.length < 1) { - Em.Logger.debug("no items to download"); - checkForCompletion(); - return; - } - - inProgress++; - Em.Logger.debug("starting download %@".fmt(inProgress)); - var item = itemList.shift(); - - var xhr = $.ajax({ - crossOrigin: true, - url: item.url, - dataType: 'json', - xhrFields: { - withCredentials: true - }, - }); - var reqID = getRequestId(); - pendingRequests[reqID] = xhr; - - xhr.done(function(data, statusText, xhr) { - delete pendingRequests[reqID]; - - if ($.isFunction(item.onItemFetched)) { - try { - item.onItemFetched(data, item.context); - } catch (e) { - markFailed(e || 'failed to process data'); - inProgress--; - checkForCompletion(); - return; - } - } - - inProgress--; - processNext(); - }).fail(function(xhr, statusText, errorObject) { - delete pendingRequests[reqID]; - markFailed(statusText); - inProgress--; - checkForCompletion(); - }); - } - - return DS.PromiseObject.create({ - promise: deferredPromise.promise, - - queueItems: function(options) { - options.forEach(this.queueItem); - }, - - queueItem: function(option) { - itemList.push(option); - processNext(); - }, - - finish: function() { - hasMoreInputs = false; - checkForCompletion(); - }, - - cancel: function() { - markFailed("User cancelled"); - checkForCompletion(); - } - }); - }, - - - /* - * allows to zip files and download that. - * usage: - * zipHelper = App.Helpers.io.zipHelper({ - * onProgress: function(filename, current, total) { ...}, - * onAdd: function(filename) {...} - * }); - * zipHelper.addFile({name: filenameinsidezip, data: data); - * // add all files - * once all files are added call the close - * zipHelper.close(); // or .abort to abort zip - * zipHelper.then(function(zippedBlob) { - * saveAs(filename, zippedBlob); - * }).catch(failureCallback); - */ - zipHelper: function(options) { - var opts = options || {}, - zipFileEntry, - zipWriter, - completion = Em.RSVP.defer(), - fileList = [], - completed = 0, - currentIdx = -1, - numFiles = 0, - hasMoreInputs = true, - inProgress = false, - hasFailed = false; - - zip.createWriter(new zip.BlobWriter("application/zip"), function(writer) { - zipWriter = writer; - checkForCompletion(); - nextFile(); - }); - - function checkForCompletion() { - if (hasFailed) { - if (zipWriter) { - Em.Logger.debug("aborting zipping. closing file."); - zipWriter.close(completion.reject); - zipWriter = null; - } - } else { - if (!hasMoreInputs && numFiles == completed) { - Em.Logger.debug("completed zipping. closing file."); - zipWriter.close(completion.resolve); - } - } - } - - function onProgress(current, total) { - if ($.isFunction(opts.onProgress)) { - opts.onProgress(fileList[currentIdx].name, current, total); - } - } - - function onAdd(filename) { - if ($.isFunction(opts.onAdd)) { - opts.onAdd(filename); - } - } - - function nextFile() { - if (hasFailed || completed == numFiles || inProgress) { - return; - } - - currentIdx++; - var file = fileList[currentIdx]; - inProgress = true; - onAdd(file.name); - zipWriter.add(file.name, new zip.TextReader(file.data), function() { - completed++; - inProgress = false; - if (currentIdx < numFiles - 1) { - nextFile(); - } - checkForCompletion(); - }, onProgress); - } - - return DS.PromiseObject.create({ - addFiles: function(files) { - files.forEach(this.addFile); - }, - - addFile: function(file) { - if (hasFailed) { - Em.Logger.debug("Skipping add of file %@ as zip has been aborted".fmt(file.name)); - return; - } - numFiles++; - fileList.push(file); - if (zipWriter) { - Em.Logger.debug("addinng file from addFile: " + file.name); - nextFile(); - } - }, - - close: function() { - hasMoreInputs = false; - checkForCompletion(); - }, - - promise: completion.promise, - - abort: function() { - hasFailed = true; - this.close(); - } - }); - } -}; http://git-wip-us.apache.org/repos/asf/tez/blob/13132ec7/tez-ui/src/main/webapp/app/scripts/helpers/misc.js ---------------------------------------------------------------------- diff --git a/tez-ui/src/main/webapp/app/scripts/helpers/misc.js b/tez-ui/src/main/webapp/app/scripts/helpers/misc.js deleted file mode 100644 index 6f091ee..0000000 --- a/tez-ui/src/main/webapp/app/scripts/helpers/misc.js +++ /dev/null @@ -1,824 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with this - * work for additional information regarding copyright ownership. The ASF - * licenses this file to you 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. - */ - -App.Helpers.misc = { - getStatusClassForEntity: function(status, hasFailedTasks) { - if(!status) return ''; - - switch(status) { - case 'FAILED': - return 'failed'; - case 'KILLED': - return 'killed'; - case 'RUNNING': - return 'running'; - case 'ERROR': - return 'error'; - case 'SUCCEEDED': - if (!!hasFailedTasks) { - return 'warning'; - } - /* - TODO: TEZ-2113 - var counterGroups = dag.get('counterGroups'); - var numFailedTasks = this.getCounterValueForDag(counterGroups, - dag.get('id'), 'org.apache.tez.common.counters.DAGCounter', - 'NUM_FAILED_TASKS' - ); - - if (numFailedTasks > 0) { - return 'warning'; - }*/ - - return 'success'; - case 'UNDEFINED': - return 'unknown'; - case 'SCHEDULED': - return 'schedule'; - default: - return 'submitted'; - } - }, - - getRealStatus: function(entityState, yarnAppState, yarnAppFinalState) { - if (entityState != 'RUNNING' || (yarnAppState != 'FINISHED' && yarnAppState != 'KILLED' && yarnAppState != 'FAILED')) { - return entityState; - } - - if (yarnAppState == 'KILLED' || yarnAppState == 'FAILED') { - return yarnAppState; - } - - return yarnAppFinalState; - }, - - getCounterValueForDag: function(counterGroups, dagID, counterGroupName, counterName) { - if (!counterGroups) { - return 0; - } - - var cgName = dagID + '/' + counterGroupName; - var cg = counterGroups.findBy('id', cgName); - if (!cg) { - return 0; - } - var counters = cg.get('counters'); - if (!counters) { - return 0; - } - - var counter = counters.findBy('id', cgName + '/' + counterName); - if (!counter) return 0; - - return counter.get('value'); - }, - - isValidDagStatus: function(status) { - return $.inArray(status, ['SUBMITTED', 'INITING', 'RUNNING', 'SUCCEEDED', - 'KILLED', 'FAILED', 'ERROR']) != -1; - }, - - isFinalDagStatus: function(status) { - return $.inArray(status, ['SUCCEEDED', 'KILLED', 'FAILED', 'ERROR']) != -1; - }, - - isValidTaskStatus: function(status) { - return $.inArray(status, ['RUNNING', 'SUCCEEDED', 'FAILED', 'KILLED']) != -1; - }, - - isStatusInUnsuccessful: function(status) { - return $.inArray(status, ['FAILED', 'KILLED', 'UNDEFINED']) != -1; - }, - - /** - * To trim a complete class path with namespace to the class name. - */ - getClassName: function (classPath) { - return classPath.substr(classPath.lastIndexOf('.') + 1); - }, - - /** - * Return a normalized group name for a counter name - * @param groupName {String} - * @return Normlaized name - */ - getCounterGroupDisplayName: function (groupName) { - var displayName = App.Helpers.misc.getClassName(groupName), // Remove path - ioParts, - toText; - - function removeCounterFromEnd(text) { - if(text.substr(-7) == 'Counter') { - text = text.substr(0, text.length - 7); - } - return text; - } - - displayName = removeCounterFromEnd(displayName); - - // Reformat per-io counters - switch(App.Helpers.misc.checkIOCounterGroup(displayName)) { - case 'in': - ioParts = displayName.split('_INPUT_'); - toText = 'to %@ Input'.fmt(ioParts[1]); - break; - case 'out': - ioParts = displayName.split('_OUTPUT_'); - toText = 'to %@ Output'.fmt(ioParts[1]); - break; - } - if(ioParts) { - ioParts = ioParts[0].split('_'); - if(ioParts.length > 1) { - displayName = '%@ - %@ %@'.fmt( - removeCounterFromEnd(ioParts.shift()), - ioParts.join('_'), - toText - ); - } - } - - return displayName; - }, - - /* - * Normalizes counter style configurations - * @param counterConfigs Array - * @return Normalized configurations - */ - normalizeCounterConfigs: function (counterConfigs, controller) { - return counterConfigs.map(function (configuration) { - var groupName = configuration.counterGroupName || configuration.groupId, - counterName = configuration.counterName || configuration.counterId; - - configuration.headerCellName = '%@ - %@'.fmt( - App.Helpers.misc.getCounterGroupDisplayName(groupName), - counterName - ); - configuration.id = '%@/%@'.fmt(groupName, counterName), - - configuration.observePath = true; - configuration.contentPath = 'counterGroups'; - configuration.counterGroupName = groupName; - configuration.counterName = counterName; - - if(controller) { - configuration.onSort = controller.onInProgressColumnSort.bind(controller); - } - - configuration.getSortValue = App.Helpers.misc.getCounterCellContent; - configuration.getCellContent = - configuration.getSearchValue = App.Helpers.misc.getCounterCellContentFormatted; - return configuration; - }); - }, - - getCounterQueryParam: function (columns) { - var counterHash = {}, - counters = []; - - columns.forEach(function (column) { - var groupName = column.get('counterGroupName'), - counterName = column.get('counterName'); - if(column.get('contentPath') == 'counterGroups') { - counterHash[groupName] = counterHash[groupName] || []; - counterHash[groupName].push(counterName); - } - }); - for(var groupName in counterHash) { - counters.push('%@/%@'.fmt(groupName, counterHash[groupName].join(','))); - } - - return counters.join(';'); - }, - - /* - * Merges counter information from AM counter object into ATS counters array - */ - mergeCounterInfo: function (targetATSCounters, sourceAMCounters) { - var atsCounters, atsCounter, - counters; - - targetATSCounters = targetATSCounters || []; - - try{ - for(var counterGroupName in sourceAMCounters) { - counters = sourceAMCounters[counterGroupName], - atsCounters = targetATSCounters.findBy('counterGroupName', counterGroupName); - if(!atsCounters) { - atsCounters = []; - targetATSCounters.pushObject({ - counterGroupName: counterGroupName, - counterGroupDisplayName: counterGroupName, - counters: atsCounters - }); - } - else { - atsCounters = atsCounters.counters; - } - for(var counterName in counters) { - atsCounter = atsCounters.findBy('counterName', counterName); - if(atsCounter) { - Em.set(atsCounter, 'counterValue', counters[counterName]); - } - else { - atsCounters.pushObject({ - "counterName": counterName, - "counterDisplayName": counterName, - "counterValue": counters[counterName] - }); - } - } - } - } - catch(e){ - Em.Logger.info("Counter merge failed", e); - } - - return targetATSCounters; - }, - - /* - * Creates column definitions form configuration object array - * @param columnConfigs Array - * @return columnDefinitions Array - */ - createColumnsFromConfigs: function (columnConfigs) { - return columnConfigs.map(function (columnConfig) { - if(columnConfig.getCellContentHelper) { - columnConfig.getCellContent = App.Helpers.get(columnConfig.getCellContentHelper); - } - columnConfig.minWidth = columnConfig.minWidth || 135; - - return columnConfig.filterID ? - App.ExTable.ColumnDefinition.createWithMixins(App.ExTable.FilterColumnMixin, columnConfig) : - App.ExTable.ColumnDefinition.create(columnConfig); - }); - }, - - createColumnDescription: function (columnConfigs) { - return columnConfigs.map(function (column) { - return App.BasicTableComponent.ColumnDefinition.create(column); - }); - }, - - /* - * Returns a counter value from for a row - * @param row - * @return value - */ - getCounterCellContent: function (row) { - var contentPath = this.id.split('/'), - value = null; - - try{ - value = row.get('counterGroups'). - findBy('counterGroupName', contentPath[0]) - ['counters']. - findBy('counterName', contentPath[1]) - ['counterValue']; - }catch(e){} - - return value; - }, - - /* - * Returns a counter value from for a row - * @param row - * @return value - */ - getCounterCellContentFormatted: function (row) { - if(row.get(this.get('contentPath')) == undefined) { - return { - isPending: true - }; - } - var value = App.Helpers.misc.getCounterCellContent.call(this, row); - return App.Helpers.number.formatNumThousands(value); - }, - - /* - * returns a formatted message, the real cause is unknown and the error object details - * depends on the error cause. the function tries to handle ajax error or a native errors - */ - formatError: function(error, defaultErrorMessage) { - var msg; - // for cross domain requests, the error is not set if no access control headers were found. - // this could be either because there was a n/w error or the cors headers being not set. - if (error.status === 0 && error.statusText === 'error') { - msg = defaultErrorMessage || error.message; - } else { - msg = error.statusText || error.message; - } - msg = msg || 'Unknown error'; - if (!!error.responseText) { - msg += error.responseText; - } - - if(error.requestOptions) { - msg = '%@<br/>Could not retrieve expected data from %@ @ %@'.fmt( - msg, - error.requestOptions.targetServer, - error.requestOptions.url - ) - } - - return { - errCode: error.status || 'Unknown', - msg: msg, - details: error.stack - }; - }, - - /** - * Normalize path - * @param path {String} - * @return normalized path {String} - */ - normalizePath: function (path) { - if(path && path.charAt(path.length - 1) == '/') { - path = path.slice(0, -1); - } - return path; - }, - - // Tez originally shows the status for task and task attempt only on - // completion. this causes confusion to the user as the status would not be - // displayed. so if status is not set return the status as 'RUNNING'. We do - // not diffentiate between running and scheduled. - getFixedupDisplayStatus: function(originalStatus) { - // if status is not set show it as running, since originally the task did - // not have a status set on scheduled/running. - // with the new version we set the status of task as scheduled and that of - // task attempt as running - if (!originalStatus || originalStatus == 'SCHEDULED') { - originalStatus = 'RUNNING'; - } - return originalStatus; - }, - - /** - * Merge content of obj2 into obj2, array elements will be concated. - * @param obj1 {Object} - * @param obj2 {Object} - */ - merge: function objectMerge(obj1, obj2) { - $.each(obj2, function (key, val) { - if(Array.isArray(obj1[key]) && Array.isArray(val)) { - $.merge(obj1[key], val); - } - else if($.isPlainObject(obj1[key]) && $.isPlainObject(val)) { - objectMerge(obj1[key], val); - } - else { - obj1[key] = val; - } - }); - }, - - getTaskIndex: function(dagID, taskID) { - var idPrefix = 'task_%@_'.fmt(dagID.substr(4)); - return taskID.indexOf(idPrefix) == 0 ? taskID.substr(idPrefix.length) : id; - }, - - getVertexIdFromName: function(idToNameMap, vertexName) { - idToNameMap = idToNameMap || {}; - var vertexId = undefined; - $.each(idToNameMap, function(id, name) { - if (name === vertexName) { - vertexId = id; - return false; - } - }); - return vertexId; - }, - - /* Gets the application id from dagid - * @param dagId {String} - * @return application id for the dagid {String} - */ - getAppIdFromDagId: function(dagId) { - var dagIdRegex = /^dag_(\d+)_(\d+)_\d+$/, - appId = undefined; - if (dagIdRegex.test(dagId)) { - appId = dagId.replace(dagIdRegex, 'application_$1_$2'); - } - return appId; - }, - - /* Gets the application id from vertex id - * @param vertexId {String} - * @return application id for the vertexId {String} - */ - getAppIdFromVertexId: function(vertexId) { - var vertexIdRegex = /^vertex_(\d+)_(\d+)_\d+_\d+$/ - appId = undefined; - if (vertexIdRegex.test(vertexId)) { - appId = vertexId.replace(vertexIdRegex, 'application_$1_$2'); - } - return appId; - }, - - /* Gets the dag index from the dag id - * @param dagId {String} - * @return dag index for the given dagId {String} - */ - getDagIndexFromDagId: function(dagId) { - return dagId.split('_').splice(-1).pop(); - }, - - /* - * Return index for the given id - * @param id {string} - * @return index {Number} - */ - getIndexFromId: function (id) { - return parseInt(id.split('_').splice(-1).pop()); - }, - - /** - * Remove the specific record from store - * @param store {DS.Store} - * @param type {String} - * @param id {String} - */ - //TODO: TEZ-2876 Extend store to have a loadRecord function that skips the cache - removeRecord: function (store, type, id) { - var record = store.getById(type, id); - if(record) { - store.unloadRecord(record); - } - }, - - downloadDAG: function(dagID, options) { - var opts = options || {}, - batchSize = opts.batchSize || 1000, - baseurl = '%@/%@'.fmt(App.env.timelineBaseUrl, App.Configs.restNamespace.timeline), - itemsToDownload = [ - { - url: getUrl('TEZ_APPLICATION', 'tez_' + this.getAppIdFromDagId(dagID)), - context: { name: 'application', type: 'TEZ_APPLICATION' }, - onItemFetched: processSingleItem - }, - { - url: getUrl('TEZ_DAG_ID', dagID), - context: { name: 'dag', type: 'TEZ_DAG_ID' }, - onItemFetched: processSingleItem - }, - { - url: getUrl('TEZ_VERTEX_ID', dagID), - context: { name: 'vertices', type: 'TEZ_VERTEX_ID', part: 0 }, - onItemFetched: processMultipleItems - }, - { - url: getUrl('TEZ_TASK_ID', dagID), - context: { name: 'tasks', type: 'TEZ_TASK_ID', part: 0 }, - onItemFetched: processMultipleItems - }, - { - url: getUrl('TEZ_TASK_ATTEMPT_ID', dagID), - context: { name: 'task_attempts', type: 'TEZ_TASK_ATTEMPT_ID', part: 0 }, - onItemFetched: processMultipleItems - } - ], - numItemTypesToDownload = itemsToDownload.length, - downloader = App.Helpers.io.fileDownloader(), - zipHelper = App.Helpers.io.zipHelper({ - onProgress: function(filename, current, total) { - Em.Logger.debug('%@: %@ of %@'.fmt(filename, current, total)); - }, - onAdd: function(filename) { - Em.Logger.debug('adding %@ to Zip'.fmt(filename)); - } - }); - - function getUrl(type, dagID, fromID) { - var url; - if (type == 'TEZ_DAG_ID' || type == 'TEZ_APPLICATION') { - url = '%@/%@/%@'.fmt(baseurl, type, dagID); - } else { - url = '%@/%@?primaryFilter=TEZ_DAG_ID:%@&limit=%@'.fmt(baseurl, type, dagID, batchSize + 1); - if (!!fromID) { - url = '%@&fromId=%@'.fmt(url, fromID); - } - } - return url; - } - - function checkIfAllDownloaded() { - numItemTypesToDownload--; - if (numItemTypesToDownload == 0) { - downloader.finish(); - } - } - - function processSingleItem(data, context) { - var obj = {}; - obj[context.name] = data; - - zipHelper.addFile({name: '%@.json'.fmt(context.name), data: JSON.stringify(obj, null, 2)}); - checkIfAllDownloaded(); - } - - function processMultipleItems(data, context) { - var obj = {}; - var nextBatchStart = undefined; - - if (!$.isArray(data.entities)) { - throw "invalid data"; - } - - // need to handle no more entries , zero entries - if (data.entities.length > batchSize) { - nextBatchStart = data.entities.pop().entity; - } - obj[context.name] = data.entities; - - zipHelper.addFile({name: '%@_part_%@.json'.fmt(context.name, context.part), data: JSON.stringify(obj, null, 2)}); - - if (!!nextBatchStart) { - context.part++; - downloader.queueItem({ - url: getUrl(context.type, dagID, nextBatchStart), - context: context, - onItemFetched: processMultipleItems - }); - } else { - checkIfAllDownloaded(); - } - } - - downloader.queueItems(itemsToDownload); - - downloader.then(function() { - Em.Logger.info('Finished download'); - zipHelper.close(); - }).catch(function(e) { - Em.Logger.error('Failed to download: ' + e); - zipHelper.abort(); - }); - - var that = this; - zipHelper.then(function(zippedBlob) { - saveAs(zippedBlob, '%@.zip'.fmt(dagID)); - if ($.isFunction(opts.onSuccess)) { - opts.onSuccess(); - } - }).catch(function() { - Em.Logger.error('zip Failed'); - if ($.isFunction(opts.onFailure)) { - opts.onFailure(); - } - }); - - return { - cancel: function() { - downloader.cancel(); - } - } - }, - - /** - * Returns in/out/empty string based counter group type - * @param counterGroupName {String} - * @return in/out/empty string - */ - checkIOCounterGroup: function (counterGroupName) { - if(counterGroupName == undefined){ - debugger; - } - var relationPart = counterGroupName.substr(counterGroupName.indexOf('_') + 1); - if(relationPart.match('_INPUT_')) { - return 'in'; - } - else if(relationPart.match('_OUTPUT_')) { - return 'out'; - } - return ''; - }, - - /** - * Return unique values form array based on a property - * @param array {Array} - * @param property {String} - * @return uniqueArray {Array} - */ - getUniqueByProperty: function (array, property) { - var propHash = {}, - uniqueArray = []; - - array.forEach(function (item) { - if(item && !propHash[item[property]]) { - uniqueArray.push(item); - propHash[item[property]] = true; - } - }); - - return uniqueArray; - }, - - /* - * Extends the path and adds new query params into an url - * @param url {String} Url to modify - * @param path {String} Path to be added - * @param queryParams {Object} Params to be added - * @return modified path - */ - modifyUrl: function (url, path, queryParams, protocol) { - var urlParts = url.split('?'), - params = {}; - - if(queryParams) { - if(urlParts[1]) { - params = urlParts[1].split('&').reduce(function (obj, param) { - var paramParts; - if(param.trim()) { - paramParts = param.split('='); - obj[paramParts[0]] = paramParts[1]; - } - return obj; - }, {}); - } - - params = $.extend(params, queryParams); - - queryParams = []; - $.map(params, function (val, key) { - queryParams.push(key + "=" + val); - }); - - urlParts[1] = queryParams.join('&'); - } - - urlParts[0] += path || ''; - - url = urlParts[1] ? '%@?%@'.fmt(urlParts[0], urlParts[1]) : urlParts[0]; - - if(url.indexOf("://") === -1 && protocol) { - url = "%@://%@".fmt(protocol, url); - } - - return url; - }, - - constructLogLinks: function (attempt, yarnAppState, amUser) { - var path, - link, - logLinks = {}, - params = amUser ? { - "user.name": amUser - } : {}, - RMWebUrl = App.env.RMWebUrl || "", - currentProtocol = location.protocol, - protocol = App.env.yarnProtocol || - RMWebUrl.substr(0, RMWebUrl.indexOf("://")) || - currentProtocol.substr(0, currentProtocol.length - 1); - - if(attempt) { - link = attempt.get('inProgressLog'); - if(link) { - if(!link.match("/syslog_")) { - path = "/syslog_" + attempt.get('id'); - } - logLinks.viewUrl = App.Helpers.misc.modifyUrl(link, path, params, protocol); - } - - link = attempt.get('completedLog'); - if (link && yarnAppState === 'FINISHED' || yarnAppState === 'KILLED' || yarnAppState === 'FAILED') { - params["start"] = "0"; - - if(!link.match("/syslog_")) { - path = "/syslog_" + attempt.get('id'); - } - - logLinks.downloadUrl = App.Helpers.misc.modifyUrl(link, path, params); - } - } - - return logLinks; - }, - - timelinePathForType: (function () { - var typeToPathMap = { - dag: 'TEZ_DAG_ID', - - vertex: 'TEZ_VERTEX_ID', - dagVertex: 'TEZ_VERTEX_ID', - - task: 'TEZ_TASK_ID', - dagTask: 'TEZ_TASK_ID', - vertexTask: 'TEZ_TASK_ID', - - taskAttempt: 'TEZ_TASK_ATTEMPT_ID', - dagTaskAttempt: 'TEZ_TASK_ATTEMPT_ID', - vertexTaskAttempt: 'TEZ_TASK_ATTEMPT_ID', - taskTaskAttempt: 'TEZ_TASK_ATTEMPT_ID', - - hiveQuery: 'HIVE_QUERY_ID', - - tezApp: 'TEZ_APPLICATION' - }; - return function (type) { - return typeToPathMap[type]; - }; - })(), - - getTimelineFilterForType: (function () { - var typeToPathMap = { - dag: 'TEZ_DAG_ID', - - vertex: 'TEZ_VERTEX_ID', - dagVertex: 'TEZ_VERTEX_ID', - - task: 'TEZ_TASK_ID', - dagTask: 'TEZ_TASK_ID', - vertexTask: 'TEZ_TASK_ID', - - taskAttempt: 'TEZ_TASK_ATTEMPT_ID', - dagTaskAttempt: 'TEZ_TASK_ATTEMPT_ID', - vertexTaskAttempt: 'TEZ_TASK_ATTEMPT_ID', - taskTaskAttempt: 'TEZ_TASK_ATTEMPT_ID', - - hiveQuery: 'HIVE_QUERY_ID', - - tezApp: 'applicationId' - }; - return function (type) { - return typeToPathMap[type]; - }; - })(), - - dagStatusUIOptions: [ - { label: 'All', id: null }, - { label: 'Submitted', id: 'SUBMITTED' }, - { label: 'Running', id: 'RUNNING' }, - { label: 'Succeeded', id: 'SUCCEEDED' }, - { label: 'Failed', id: 'FAILED' }, - { label: 'Error', id: 'ERROR' }, - ], - - vertexStatusUIOptions: [ - { label: 'All', id: null }, - { label: 'Running', id: 'RUNNING' }, - { label: 'Succeeded', id: 'SUCCEEDED' }, - { label: 'Failed', id: 'FAILED' }, - { label: 'Killed', id: 'KILLED' }, - { label: 'Error', id: 'ERROR' }, - ], - - taskStatusUIOptions: [ - { label: 'All', id: null }, - { label: 'Running', id: 'SCHEDULED' }, - { label: 'Succeeded', id: 'SUCCEEDED' }, - { label: 'Failed', id: 'FAILED' }, - { label: 'Killed', id: 'KILLED' }, - ], - - taskAttemptStatusUIOptions: [ - { label: 'All', id: null }, - { label: 'Running', id: 'RUNNING' }, - { label: 'Succeeded', id: 'SUCCEEDED' }, - { label: 'Failed', id: 'FAILED' }, - { label: 'Killed', id: 'KILLED' }, - ], - - defaultQueryParamsConfig: { - refreshModel: true, - replace: true - }, - - /** - * Load app details form RM if available, else load from ATS if AHS is enabled - * @param store {Store} - * @param appId {String} - * @param useCache {Boolean} - */ - loadApp: function (store, appId, useCache) { - if(!useCache) { - App.Helpers.misc.removeRecord(store, 'appDetail', appId); - App.Helpers.misc.removeRecord(store, 'clusterApp', appId); - } - - return store.find('clusterApp', appId).catch(function () { - return store.find('appDetail', appId); - }).catch(function (error) { - error.message = "Couldn't get details of application %@. RM is not reachable, and history service is not enabled.".fmt(appId); - throw error; - }); - } - -}
