You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by sr...@apache.org on 2014/01/25 02:59:51 UTC
git commit: AMBARI-4421. Jobs: create a model for Hive and Tez query
JSON data. (srimanth)
Updated Branches:
refs/heads/trunk f31c604e4 -> f14dae7ef
AMBARI-4421. Jobs: create a model for Hive and Tez query JSON data. (srimanth)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/f14dae7e
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/f14dae7e
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/f14dae7e
Branch: refs/heads/trunk
Commit: f14dae7ef02ef2df47dd3da4798c22fd4d58c21b
Parents: f31c604
Author: Srimanth Gunturi <sg...@hortonworks.com>
Authored: Fri Jan 24 16:49:59 2014 -0800
Committer: Srimanth Gunturi <sg...@hortonworks.com>
Committed: Fri Jan 24 17:59:38 2014 -0800
----------------------------------------------------------------------
ambari-web/app/models.js | 3 +
ambari-web/app/models/jobs/hive_job.js | 27 ++++++
ambari-web/app/models/jobs/job.js | 53 +++++++++++
ambari-web/app/models/jobs/tez_dag.js | 138 ++++++++++++++++++++++++++++
ambari-web/app/utils/date.js | 21 +++++
5 files changed, 242 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/f14dae7e/ambari-web/app/models.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models.js b/ambari-web/app/models.js
index 00029ca..9706a79 100644
--- a/ambari-web/app/models.js
+++ b/ambari-web/app/models.js
@@ -49,3 +49,6 @@ require('models/dataset_job');
require('classes/run_class');
require('classes/job_class');
require('models/config_group');
+require('models/jobs/tez_dag');
+require('models/jobs/job');
+require('models/jobs/hive_job');
http://git-wip-us.apache.org/repos/asf/ambari/blob/f14dae7e/ambari-web/app/models/jobs/hive_job.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/jobs/hive_job.js b/ambari-web/app/models/jobs/hive_job.js
new file mode 100644
index 0000000..ab66fbf
--- /dev/null
+++ b/ambari-web/app/models/jobs/hive_job.js
@@ -0,0 +1,27 @@
+/**
+ * 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.
+ */
+
+var App = require('app');
+
+App.HiveJob = App.AbstractJob.extend({
+ jobType : App.JobType.HIVE,
+ queryText : DS.attr('string'),
+ stages : DS.hasMany('string'),
+ tezDag : DS.belongsTo('App.TezDag')
+});
+
+App.HiveJob.FIXTURES = [];
http://git-wip-us.apache.org/repos/asf/ambari/blob/f14dae7e/ambari-web/app/models/jobs/job.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/jobs/job.js b/ambari-web/app/models/jobs/job.js
new file mode 100644
index 0000000..a4f858d
--- /dev/null
+++ b/ambari-web/app/models/jobs/job.js
@@ -0,0 +1,53 @@
+/**
+ * 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.
+ */
+
+var App = require('app');
+var dateUtils = require('utils/date');
+
+/**
+ * Base class of all Jobs.
+ *
+ * This class is meant to be extended and not instantiated directly.
+ */
+App.AbstractJob = DS.Model.extend({
+ id : DS.attr('string'),
+ name : DS.attr('string'),
+ user : DS.attr('string'),
+ startTime : DS.attr('number'),
+ endTime : DS.attr('number'),
+
+ /**
+ * Provides the duration of this job. If the job has not started, duration
+ * will be given as 0. If the job has not ended, duration will be till now.
+ *
+ * @return {Number} Duration in milliseconds.
+ */
+ duration : function() {
+ return dateUtils.duration(this.get('startTime'), this.get('endTime'))
+ }.property('startTime', 'endTime'),
+
+ /**
+ * Type of this job. Should be one of constants defined in App.JobType
+ */
+ jobType : DS.attr('string')
+});
+
+App.JobType = {
+ HIVE : "hive"
+};
+
+App.AbstractJob.FIXTURES = [];
http://git-wip-us.apache.org/repos/asf/ambari/blob/f14dae7e/ambari-web/app/models/jobs/tez_dag.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/jobs/tez_dag.js b/ambari-web/app/models/jobs/tez_dag.js
new file mode 100644
index 0000000..d0c05c3
--- /dev/null
+++ b/ambari-web/app/models/jobs/tez_dag.js
@@ -0,0 +1,138 @@
+/**
+ * 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.
+ */
+
+var App = require('app');
+var dateUtils = require('utils/date');
+
+App.TezDag = DS.Model.extend({
+ id : DS.attr('string'),
+ name : DS.attr('string'),
+ stage : DS.attr('string'),
+ vertices : DS.hasMany('App.TezDagVertex'),
+ edges: DS.hasMany('App.TezDagEdge')
+});
+
+App.TezDagEdge = DS.Model.extend({
+ id : DS.attr('string'),
+ fromVertex : DS.belongsTo('App.TezDagVertex'),
+ toVertex : DS.belongsTo('App.TezDagVertex'),
+ /**
+ * Type of this edge connecting vertices. Should be one of constants defined
+ * in 'App.TezDagVertexType'.
+ */
+ edgeType : DS.attr('string')
+});
+
+App.TezDagVertex = DS.Model.extend({
+ id : DS.attr('string'),
+ name : DS.attr('string'),
+
+ /**
+ * State of this vertex. Should be one of constants defined in
+ * App.TezDagVertexState.
+ */
+ state : DS.attr('string'),
+
+ /**
+ * @return {Boolean} Whether this vertex is a Map or Reduce operation.
+ */
+ isMap : DS.attr('boolean'),
+
+ /**
+ * A vertex can have multiple incoming edges.
+ */
+ incomingEdges: DS.hasMany('App.TezDagEdge'),
+
+ /**
+ * This vertex can have multiple outgoing edges.
+ */
+ outgoingEdges: DS.hasMany('App.TezDagEdge'),
+
+ startTime : DS.attr('number'),
+ endTime : DS.attr('number'),
+
+ /**
+ * Provides the duration of this job. If the job has not started, duration
+ * will be given as 0. If the job has not ended, duration will be till now.
+ *
+ * @return {Number} Duration in milliseconds.
+ */
+ duration : function() {
+ return dateUtils.duration(this.get('startTime'), this.get('endTime'))
+ }.property('startTime', 'endTime'),
+
+ /**
+ * Each Tez vertex can perform arbitrary application specific computations
+ * inside. The application can provide a list of operations it has provided in
+ * this vertex.
+ */
+ operations : DS.hasMany('string'),
+
+ /**
+ * Provides additional information about the 'operations' performed in this
+ * vertex. This is shown directly to the user.
+ */
+ operationPlan : DS.attr('string'),
+
+ /**
+ * Number of tasks in this vertex
+ */
+ tasksCount : DS.attr('number'),
+
+ /**
+ * Local filesystem usage metrics for this vertex
+ */
+ fileReadBytes : DS.attr('number'),
+ fileWriteBytes : DS.attr('number'),
+ fileReadOps : DS.attr('number'),
+ fileWriteOps : DS.attr('number'),
+
+ /**
+ * HDFS usage metrics for this vertex
+ */
+ hdfsReadBytes : DS.attr('number'),
+ hdfsWriteBytes : DS.attr('number'),
+ hdfsReadOps : DS.attr('number'),
+ hdfsWriteOps : DS.attr('number'),
+
+ /**
+ * Record metrics for this vertex
+ */
+ recordReadCount : DS.attr('number'),
+ recordWriteCount : DS.attr('number')
+});
+
+App.TezDagVertexState = {
+ NEW : "NEW",
+ INITIALIZING : "INITIALIZING",
+ INITED : "INITED",
+ RUNNING : "RUNNING",
+ SUCCEEDED : "SUCCEEDED",
+ FAILED : "FAILED",
+ KILLED : "KILLED",
+ ERROR : "ERROR",
+ TERMINATING : "TERMINATING"
+};
+
+App.TezDagVertexType = {
+ SCATTER_GATHER : "SCATTER_GATHER",
+ BROADCAST : "BROADCAST"
+};
+
+App.TezDag.FIXTURES = [];
+App.TezDagEdge.FIXTURES = [];
+App.TezDagVertex.FIXTURES = [];
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/f14dae7e/ambari-web/app/utils/date.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/date.js b/ambari-web/app/utils/date.js
index 0aa94a0..6800e9c 100644
--- a/ambari-web/app/utils/date.js
+++ b/ambari-web/app/utils/date.js
@@ -93,5 +93,26 @@ module.exports = {
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
+ */
+ duration : function(startTime, endTime) {
+ var duration = 0;
+ if (startTime && startTime > 0) {
+ if (!endTime || endTime < 1) {
+ endTime = new Date().getTime();
+ }
+ duration = endTime - startTime;
+ }
+ return duration;
}
};