Repository: ambari Updated Branches: refs/heads/trunk 21442eb8f -> 7aecacbf7
AMBARI-11042. Tez UI View: Support Auto Create and Cluster Association. (Sreenath Somarajapuram via yusaku) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/7aecacbf Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/7aecacbf Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/7aecacbf Branch: refs/heads/trunk Commit: 7aecacbf74e063c2039cfbfa3f973447ef8aa4bf Parents: 21442eb Author: Yusaku Sako <yus...@hortonworks.com> Authored: Mon May 11 17:15:53 2015 -0700 Committer: Yusaku Sako <yus...@hortonworks.com> Committed: Mon May 11 18:08:15 2015 -0700 ---------------------------------------------------------------------- .../ambari/view/tez/ConfigurationService.java | 50 ++++++++++++++ .../apache/ambari/view/tez/PropertyService.java | 68 ++++++++++++++++++++ .../apache/ambari/view/tez/SettingService.java | 47 ++++++++++++++ .../resources/ui/scripts/init-ambari-view.js | 10 ++- contrib/views/tez/src/main/resources/view.xml | 40 ++++++++++-- 5 files changed, 207 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/7aecacbf/contrib/views/tez/src/main/java/org/apache/ambari/view/tez/ConfigurationService.java ---------------------------------------------------------------------- diff --git a/contrib/views/tez/src/main/java/org/apache/ambari/view/tez/ConfigurationService.java b/contrib/views/tez/src/main/java/org/apache/ambari/view/tez/ConfigurationService.java new file mode 100644 index 0000000..9f3c18d --- /dev/null +++ b/contrib/views/tez/src/main/java/org/apache/ambari/view/tez/ConfigurationService.java @@ -0,0 +1,50 @@ +/** + * 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. + */ +package org.apache.ambari.view.tez; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.HttpHeaders; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.UriInfo; + +/** + * The tez configuration service. + */ +public class ConfigurationService extends PropertyService { + + /** + * Handles: GET /. + * + * @param headers http headers + * @param ui uri info + * + * @return value JSON representation + */ + @GET + @Path("/") + @Produces({"text/plain", "application/json"}) + public Response getValue(@Context HttpHeaders headers, @Context UriInfo ui) { + return Response.ok(getResponse( + ViewController.PARAM_YARN_ATS_URL, + ViewController.PARAM_YARN_RESOURCEMANAGER_URL) + ).build(); + } +} // end PropertyService http://git-wip-us.apache.org/repos/asf/ambari/blob/7aecacbf/contrib/views/tez/src/main/java/org/apache/ambari/view/tez/PropertyService.java ---------------------------------------------------------------------- diff --git a/contrib/views/tez/src/main/java/org/apache/ambari/view/tez/PropertyService.java b/contrib/views/tez/src/main/java/org/apache/ambari/view/tez/PropertyService.java new file mode 100644 index 0000000..04803d9 --- /dev/null +++ b/contrib/views/tez/src/main/java/org/apache/ambari/view/tez/PropertyService.java @@ -0,0 +1,68 @@ +/** + * 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. + */ +package org.apache.ambari.view.tez; + +import org.apache.ambari.view.ViewContext; + +import javax.inject.Inject; +import java.util.Map; + +/** + * The base property service. + */ +public abstract class PropertyService { + + /** + * The view context. + */ + @Inject + protected ViewContext context; + + protected String getResponse(String ... propertyNames) { + + Map<String, String> properties = context.getProperties(); + + StringBuffer buffer = new StringBuffer(); + int count = 0; + + buffer.append("["); + for (String propertyName : propertyNames) { + if (count++ > 0) { + buffer.append(",\n"); + } + buffer.append(getPropertyResponse(properties, propertyName)); + } + buffer.append("]"); + + return buffer.toString(); + } + + private String getPropertyResponse(Map<String, String> properties, String key) { + StringBuffer buffer = new StringBuffer(); + + String value = properties.get(key); + + buffer.append("{\""); + buffer.append(key); + buffer.append("\" : \""); + buffer.append(value); + buffer.append("\"}"); + + return buffer.toString(); + } +} // end PropertyService http://git-wip-us.apache.org/repos/asf/ambari/blob/7aecacbf/contrib/views/tez/src/main/java/org/apache/ambari/view/tez/SettingService.java ---------------------------------------------------------------------- diff --git a/contrib/views/tez/src/main/java/org/apache/ambari/view/tez/SettingService.java b/contrib/views/tez/src/main/java/org/apache/ambari/view/tez/SettingService.java new file mode 100644 index 0000000..a675de6 --- /dev/null +++ b/contrib/views/tez/src/main/java/org/apache/ambari/view/tez/SettingService.java @@ -0,0 +1,47 @@ +/** + * 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. + */ +package org.apache.ambari.view.tez; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.HttpHeaders; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.UriInfo; + +/** + * The setting service. + */ +public class SettingService extends PropertyService { + + /** + * Handles: GET /. + * + * @param headers http headers + * @param ui uri info + * + * @return value JSON representation + */ + @GET + @Path("/") + @Produces({"text/plain", "application/json"}) + public Response getValue(@Context HttpHeaders headers, @Context UriInfo ui) { + return Response.ok(getResponse()).build(); + } +} // end PropertyService http://git-wip-us.apache.org/repos/asf/ambari/blob/7aecacbf/contrib/views/tez/src/main/resources/ui/scripts/init-ambari-view.js ---------------------------------------------------------------------- diff --git a/contrib/views/tez/src/main/resources/ui/scripts/init-ambari-view.js b/contrib/views/tez/src/main/resources/ui/scripts/init-ambari-view.js index 6f44211..12e0da6 100644 --- a/contrib/views/tez/src/main/resources/ui/scripts/init-ambari-view.js +++ b/contrib/views/tez/src/main/resources/ui/scripts/init-ambari-view.js @@ -194,11 +194,17 @@ function allowFullScreen() { function loadParams() { App.Helpers.ambari.getInstanceParameters().then(function () { + var timelineBaseUrl = App.Helpers.ambari.getParam(App.Helpers.ambari.TIMELINE_URL), + RMWebUrl = App.Helpers.ambari.getParam(App.Helpers.ambari.RM_URL); $.extend(true, App.Configs, { envDefaults: { isStandalone: false, - timelineBaseUrl: App.Helpers.ambari.getParam(App.Helpers.ambari.TIMELINE_URL), - RMWebUrl: App.Helpers.ambari.getParam(App.Helpers.ambari.RM_URL) + timelineBaseUrl: timelineBaseUrl.match('://') ? + timelineBaseUrl : + '%@//%@'.fmt(location.protocol, timelineBaseUrl), + RMWebUrl: RMWebUrl.match('://') ? + RMWebUrl : + '%@//%@'.fmt(location.protocol, RMWebUrl) } }); http://git-wip-us.apache.org/repos/asf/ambari/blob/7aecacbf/contrib/views/tez/src/main/resources/view.xml ---------------------------------------------------------------------- diff --git a/contrib/views/tez/src/main/resources/view.xml b/contrib/views/tez/src/main/resources/view.xml index 33a1c40..6106818 100644 --- a/contrib/views/tez/src/main/resources/view.xml +++ b/contrib/views/tez/src/main/resources/view.xml @@ -16,25 +16,53 @@ limitations under the License. Kerberos, LDAP, Custom. Binary/Htt --> <view> <name>TEZ</name> - <label>TEZ View</label> + <label>Tez View</label> <version>${tez.view.version}</version> + <description>Ambari view for Apache Tez</description> + <parameter> <name>yarn.timeline-server.url</name> - <description>The URL to the YARN Application Timeline Server, used to provide TEZ information. Typically this is the yarn.timeline-service.webapp.address property in the yarn-site.xml configuration. Url must be accessible from Ambari server.</description> + <description>The URL to the YARN Application Timeline Server, used to provide Tez information. Typically this is the yarn.timeline-service.webapp.address property in the yarn-site.xml configuration. Url must be accessible from Ambari server.</description> <label>YARN Timeline Server URL</label> - <placeholder>http://yarn.timeline-service.hostname:8188</placeholder> - <required>true</required> + <placeholder>yarn.timeline-service.hostname:8188</placeholder> + <default-value>localhost:8188</default-value> + <cluster-config>yarn-site/yarn.timeline-service.webapp.address</cluster-config> </parameter> <parameter> <name>yarn.resourcemanager.url</name> <description>The URL to the YARN ResourceManager, used to provide YARN Application data. Typically this is the yarn.resourcemanager.webapp.address property in the yarn-site.xml configuration. Url must be accessible from Ambari server.</description> <label>YARN ResourceManager URL</label> - <placeholder>http://yarn.resourcemanager.hostname:8088</placeholder> - <required>true</required> + <placeholder>yarn.resourcemanager.hostname:8088</placeholder> + <default-value>localhost:8088</default-value> + <cluster-config>yarn-site/yarn.resourcemanager.webapp.address</cluster-config> </parameter> + <!-- The status resource exists to show the subset of properties that any user is allowed to see, not just an admin user. --> <resource> <name>status</name> <service-class>org.apache.ambari.view.tez.rest.ViewStatusResource</service-class> </resource> + <resource> + <name>configurations</name> + <service-class>org.apache.ambari.view.tez.ConfigurationService</service-class> + </resource> + <resource> + <name>settings</name> + <service-class>org.apache.ambari.view.tez.SettingService</service-class> + </resource> + + <auto-instance> + <name>TEZ_CLUSTER_INSTANCE</name> + <label>Tez View: Cluster Instance</label> + <description>This view instance is auto created when the Tez service is added to a cluster.</description> + <stack-id>HDP-2.*</stack-id> + <services> + <service>TEZ</service> + </services> + </auto-instance> + <instance> + <name>TEZ_DEPLOYMENT_INSTANCE</name> + <label>Tez View: Deployment Instance</label> + <description>This view instance is created when the Tez view is deployed. The instance must be associated with a cluster to have valid cluster configuration values.</description> + </instance> </view>