You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by pa...@apache.org on 2016/04/07 15:34:48 UTC
ambari git commit: AMBARI-15755. Hive view should have some checks
before starting similar to pig view (pallavkul)
Repository: ambari
Updated Branches:
refs/heads/trunk de09ef87c -> 9ca341d4d
AMBARI-15755. Hive view should have some checks before starting similar to pig view (pallavkul)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/9ca341d4
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/9ca341d4
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/9ca341d4
Branch: refs/heads/trunk
Commit: 9ca341d4dabe07b2097b3e89a977d6935fc8da24
Parents: de09ef8
Author: Pallav Kulshreshtha <pa...@gmail.com>
Authored: Thu Apr 7 19:03:48 2016 +0530
Committer: Pallav Kulshreshtha <pa...@gmail.com>
Committed: Thu Apr 7 19:03:48 2016 +0530
----------------------------------------------------------------------
.../apache/ambari/view/hive/HelpService.java | 47 ++++++++
.../jobs/atsJobs/ATSRequestsDelegateImpl.java | 8 ++
.../ui/hive-web/app/controllers/splash.js | 118 +++++++++++++++++++
.../main/resources/ui/hive-web/app/router.js | 2 +
.../ui/hive-web/app/routes/application.js | 5 +
.../resources/ui/hive-web/app/routes/splash.js | 59 ++++++++++
.../ui/hive-web/app/templates/splash.hbs | 91 ++++++++++++++
7 files changed, 330 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/9ca341d4/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/HelpService.java
----------------------------------------------------------------------
diff --git a/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/HelpService.java b/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/HelpService.java
index d581d9a..05b55d2 100644
--- a/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/HelpService.java
+++ b/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/HelpService.java
@@ -20,11 +20,17 @@ package org.apache.ambari.view.hive;
import org.apache.ambari.view.ViewContext;
import org.apache.ambari.view.ViewResourceHandler;
+import org.apache.ambari.view.hive.resources.files.FileService;
+import org.apache.ambari.view.hive.resources.jobs.atsJobs.ATSParserFactory;
+import org.apache.ambari.view.hive.resources.jobs.atsJobs.ATSRequestsDelegate;
+import org.apache.ambari.view.hive.resources.jobs.atsJobs.ATSRequestsDelegateImpl;
+import org.json.simple.JSONObject;
import javax.inject.Inject;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
+import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
@@ -56,6 +62,47 @@ public class HelpService extends BaseService {
return Response.ok("0.0.1-SNAPSHOT").build();
}
+ // ================================================================================
+ // Smoke tests
+ // ================================================================================
+
+ /**
+ * HDFS Status
+ * @return status
+ */
+ @GET
+ @Path("/hdfsStatus")
+ @Produces(MediaType.APPLICATION_JSON)
+ public Response hdfsStatus(){
+ FileService.hdfsSmokeTest(context);
+ return getOKResponse();
+ }
+
+ /**
+ * ATS Status
+ * @return status
+ */
+ @GET
+ @Path("/atsStatus")
+ @Produces(MediaType.APPLICATION_JSON)
+ public Response atsStatus() {
+ try {
+ ATSRequestsDelegateImpl atsimpl = new ATSRequestsDelegateImpl(context, ATSParserFactory.getATSUrl(context));
+ atsimpl.checkATSStatus();
+ return getOKResponse();
+ }catch (Exception e){
+ throw new WebApplicationException(e);
+ }
+ }
+
+ private Response getOKResponse() {
+ JSONObject response = new JSONObject();
+ response.put("message", "OK");
+ response.put("trace", null);
+ response.put("status", "200");
+ return Response.ok().entity(response).type(MediaType.APPLICATION_JSON).build();
+ }
+
/**
* Version
* @return version
http://git-wip-us.apache.org/repos/asf/ambari/blob/9ca341d4/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/resources/jobs/atsJobs/ATSRequestsDelegateImpl.java
----------------------------------------------------------------------
diff --git a/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/resources/jobs/atsJobs/ATSRequestsDelegateImpl.java b/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/resources/jobs/atsJobs/ATSRequestsDelegateImpl.java
index 041ab01..471645d 100644
--- a/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/resources/jobs/atsJobs/ATSRequestsDelegateImpl.java
+++ b/contrib/views/hive/src/main/java/org/apache/ambari/view/hive/resources/jobs/atsJobs/ATSRequestsDelegateImpl.java
@@ -107,6 +107,14 @@ public class ATSRequestsDelegateImpl implements ATSRequestsDelegate {
return atsUrl + "/ws/v1/timeline/TEZ_DAG_ID?primaryFilter=callerId:" + entity;
}
+ public boolean checkATSStatus() throws IOException {
+ String url = atsUrl + "/ws/v1/timeline/";
+ InputStream responseInputStream = context.getURLStreamProvider().readAsCurrent(url, "GET",
+ (String)null, new HashMap<String, String>());
+ IOUtils.toString(responseInputStream);
+ return true;
+ }
+
@Override
public JSONObject tezVerticesListForDAG(String dagId) {
String response = readFromWithDefault(tezVerticesListForDAGUrl(dagId), "{ \"entities\" : [ ] }");
http://git-wip-us.apache.org/repos/asf/ambari/blob/9ca341d4/contrib/views/hive/src/main/resources/ui/hive-web/app/controllers/splash.js
----------------------------------------------------------------------
diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/app/controllers/splash.js b/contrib/views/hive/src/main/resources/ui/hive-web/app/controllers/splash.js
new file mode 100644
index 0000000..eec1f17
--- /dev/null
+++ b/contrib/views/hive/src/main/resources/ui/hive-web/app/controllers/splash.js
@@ -0,0 +1,118 @@
+/**
+ * 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.
+ */
+
+import Ember from 'ember';
+import constants from 'hive/utils/constants';
+
+export default Ember.Controller.extend({
+
+ databaseService: Ember.inject.service(constants.namingConventions.database),
+ isExpanded: false,
+ errors: "",
+ stackTrace: "",
+ startTests: function() {
+
+ var model = this.get('model');
+ var url = this.container.lookup('adapter:application').buildURL() + '/resources/hive/'
+ var self = this;
+
+ var processResponse = function(name, data) {
+
+ if(data.databases){
+ data = Ember.Object.create( {trace: null, message: "OK", status: "200"});
+ } else {
+ data = data;
+ }
+
+ model.set(name + 'Test', data.status == 200);
+
+ if (data.status != 200) {
+ var checkFailedMessage = "Service '" + name + "' check failed";
+ var errors = self.get("errors");
+ errors += checkFailedMessage;
+ errors += (data.message)?(': <i>' + data.message + '</i><br>'):'<br>';
+ self.set("errors", errors);
+ }
+
+ if (data.trace != null) {
+ var stackTrace = self.get("stackTrace");
+ stackTrace += checkFailedMessage + ':\n' + data.trace;
+ self.set("stackTrace", stackTrace);
+ }
+
+ model.set(name + 'TestDone', true);
+
+ var percent = model.get('percent');
+ model.set('percent', percent + 33.33);
+ };
+
+ var promises = ['hdfs', 'hiveserver', 'ats'].map(function(name) {
+
+ var finalurl = ((name == 'hiveserver') ? self.get('databaseService.baseUrl') : (url + name + 'Status')) || '' ;
+
+ return Ember.$.getJSON( finalurl )
+ .then(
+ function(data) {
+ processResponse(name, data);
+ },
+ function(reason) {
+ processResponse(name, reason.responseJSON);
+ }
+ );
+ });
+
+ return Ember.RSVP.all(promises);
+ },
+
+ progressBarStyle: function() {
+ return 'width: ' + this.get("model").get("percent") + '%;';
+ }.property("model.percent"),
+
+ modelhdfsTestDone: function() {
+ return this.get('model.hdfsTestDone');
+ }.property('model.hdfsTestDone' ),
+
+ modelhiveserverTestDone: function() {
+ return this.get('model.hiveserverTestDone');
+ }.property('model.hiveserverTestDone' ),
+
+ modelatsTestDone: function() {
+ return this.get('model.atsTestDone');
+ }.property('model.atsTestDone' ),
+
+ modelhdfsTest: function() {
+ return this.get('model.hdfsTest');
+ }.property('model.hdfsTest' ),
+
+ modelhiveserverTest: function() {
+ return this.get('model.hiveserverTest');
+ }.property('model.hiveserverTest' ),
+
+ modelatsTest: function() {
+ return this.get('model.atsTest');
+ }.property('model.atsTest' ),
+
+ actions: {
+ toggleStackTrace:function () {
+ var value = this.get('isExpanded');
+ this.set('isExpanded', !value);
+ }
+ }
+});
+
+
http://git-wip-us.apache.org/repos/asf/ambari/blob/9ca341d4/contrib/views/hive/src/main/resources/ui/hive-web/app/router.js
----------------------------------------------------------------------
diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/app/router.js b/contrib/views/hive/src/main/resources/ui/hive-web/app/router.js
index 56e87d9..382f1eb 100644
--- a/contrib/views/hive/src/main/resources/ui/hive-web/app/router.js
+++ b/contrib/views/hive/src/main/resources/ui/hive-web/app/router.js
@@ -43,6 +43,8 @@ Router.map(function () {
});
this.route('loading');
+ this.route('splash');
+
});
export default Router;
http://git-wip-us.apache.org/repos/asf/ambari/blob/9ca341d4/contrib/views/hive/src/main/resources/ui/hive-web/app/routes/application.js
----------------------------------------------------------------------
diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/app/routes/application.js b/contrib/views/hive/src/main/resources/ui/hive-web/app/routes/application.js
index 916b7b3..096ce30 100644
--- a/contrib/views/hive/src/main/resources/ui/hive-web/app/routes/application.js
+++ b/contrib/views/hive/src/main/resources/ui/hive-web/app/routes/application.js
@@ -20,6 +20,11 @@ import Ember from 'ember';
import constants from 'hive/utils/constants';
export default Ember.Route.extend({
+
+ beforeModel: function () {
+ this.transitionTo('splash');
+ },
+
notifyService: Ember.inject.service(constants.namingConventions.notify),
setupController: function (controller, model) {
http://git-wip-us.apache.org/repos/asf/ambari/blob/9ca341d4/contrib/views/hive/src/main/resources/ui/hive-web/app/routes/splash.js
----------------------------------------------------------------------
diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/app/routes/splash.js b/contrib/views/hive/src/main/resources/ui/hive-web/app/routes/splash.js
new file mode 100644
index 0000000..1ff155c
--- /dev/null
+++ b/contrib/views/hive/src/main/resources/ui/hive-web/app/routes/splash.js
@@ -0,0 +1,59 @@
+/**
+ * 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.
+ */
+
+import Ember from 'ember';
+
+export default Ember.Route.extend({
+
+ model: function() {
+ return Ember.Object.create({
+ hdfsTest: null,
+ hdfsTestDone: null,
+ hiveserverTest: null,
+ hiveserverTestDone: null,
+ atsTest: null,
+ atsTestDone: null,
+ percent: 0
+ });
+ },
+
+ setupController: function(controller, model) {
+
+ if (!model) {
+ return;
+ }
+
+ controller.set('model', model);
+ var self = this;
+ controller.startTests().then(function() {
+
+ if (model.get("hiveserverTest") && model.get("hdfsTest") && model.get("atsTest")) {
+ Ember.run.later(this, function() {
+ self.send('transition');
+ }, 5000);
+ }
+ });
+ },
+
+ actions: {
+ transition: function() {
+ this.transitionTo('index');
+ }
+ }
+
+});
http://git-wip-us.apache.org/repos/asf/ambari/blob/9ca341d4/contrib/views/hive/src/main/resources/ui/hive-web/app/templates/splash.hbs
----------------------------------------------------------------------
diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/app/templates/splash.hbs b/contrib/views/hive/src/main/resources/ui/hive-web/app/templates/splash.hbs
new file mode 100644
index 0000000..3e81a9c
--- /dev/null
+++ b/contrib/views/hive/src/main/resources/ui/hive-web/app/templates/splash.hbs
@@ -0,0 +1,91 @@
+{{!
+* 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.
+}}
+
+<div class="spinner"></div>
+<div class="container-fluid">
+ <h1>Welcome to the Hive View</h1>
+ <h2>Please wait...</h2>
+ <div class="progress progress-striped active">
+ <div class="progress-bar" role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" {{bind-attr style="progressBarStyle"}}>
+ </div>
+ </div>
+ <table class="table">
+ <tbody>
+ <tr>
+ <td>
+ {{#if modelhdfsTestDone}}
+ {{#if modelhdfsTest}}
+ <i class="fa fa-check"></i>
+ {{else}}
+ <i class="fa fa-remove"></i>
+ {{/if}}
+ {{else}}
+ <i class="fa fa-arrow-right"></i>
+ {{/if}}
+ </td>
+ <td>hdfs service test</td>
+ </tr>
+ <tr>
+ <td>
+ {{#if modelhiveserverTestDone}}
+ {{#if modelhiveserverTest}}
+ <i class="fa fa-check"></i>
+ {{else}}
+ <i class="fa fa-remove"></i>
+ {{/if}}
+ {{else}}
+ <i class="fa fa-arrow-right"></i>
+ {{/if}}
+ </td>
+ <td>hiveserver service test</td>
+ </tr>
+ <tr>
+ <td>
+ {{#if modelatsTestDone}}
+ {{#if modelatsTest}}
+ <i class="fa fa-check"></i>
+ {{else}}
+ <i class="fa fa-remove"></i>
+ {{/if}}
+ {{else}}
+ <i class="fa fa-arrow-right"></i>
+ {{/if}}
+ </td>
+ <td>ats service test</td>
+ </tr>
+ </tbody>
+ </table>
+ {{#if errors}}
+ <h3>Issues detected</h3>
+ <p>{{{errors}}}</p>
+ {{/if}}
+ {{#if stackTrace}}
+ <a href="#" {{action "toggleStackTrace" post}}>
+ {{#if isExpanded}}
+ <i class="fa fa-minus"></i> Collapse Stack Trace
+ {{else}}
+ <<i class="fa fa-plus"></i> Expand Stack Trace
+ {{/if}}
+ </a>
+ {{#if isExpanded}}
+ <pre class="prettyprint">
+ {{stackTrace}}
+ </pre>
+ {{/if}}
+ {{/if}}
+</div>