ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yus...@apache.org
Subject ambari git commit: AMBARI-8760. TEZ UI View. (Sreenath Somarajapuram via yusaku)
Date Mon, 05 Jan 2015 23:01:26 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk c9969233b -> 1767fcfa4


AMBARI-8760. TEZ UI View. (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/1767fcfa
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/1767fcfa
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/1767fcfa

Branch: refs/heads/trunk
Commit: 1767fcfa4e99c39dfe92f989749b828de143d918
Parents: c996923
Author: Yusaku Sako <yusaku@hortonworks.com>
Authored: Mon Jan 5 15:00:41 2015 -0800
Committer: Yusaku Sako <yusaku@hortonworks.com>
Committed: Mon Jan 5 15:01:20 2015 -0800

----------------------------------------------------------------------
 contrib/views/tez/pom.xml                       | 161 +++++++++++++++++++
 contrib/views/tez/readme.md                     |  90 +++++++++++
 .../apache/ambari/view/tez/ProxyServlet.java    |  71 ++++++++
 .../apache/ambari/view/tez/ViewController.java  |  36 +++++
 .../ambari/view/tez/ViewControllerImpl.java     |  66 ++++++++
 .../org/apache/ambari/view/tez/ViewStatus.java  |  44 +++++
 .../view/tez/rest/ViewStatusResource.java       |  46 ++++++
 .../tez/src/main/resources/WEB-INF/web.xml      |  37 +++++
 .../views/tez/src/main/resources/ui/index.html  |  50 ++++++
 .../resources/ui/scripts/init-ambari-view.js    | 120 ++++++++++++++
 contrib/views/tez/src/main/resources/view.xml   |  40 +++++
 11 files changed, 761 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/1767fcfa/contrib/views/tez/pom.xml
----------------------------------------------------------------------
diff --git a/contrib/views/tez/pom.xml b/contrib/views/tez/pom.xml
new file mode 100644
index 0000000..b62f4a1
--- /dev/null
+++ b/contrib/views/tez/pom.xml
@@ -0,0 +1,161 @@
+<!--
+   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.
+ -->
+ <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <parent>
+    <groupId>org.apache.ambari.views</groupId>
+    <artifactId>ambari-contrib-views</artifactId>
+    <version>0.1.0-SNAPSHOT</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache.ambari</groupId>
+  <artifactId>tez-ambari-view</artifactId>
+  <name>tez-ambari-view</name>
+  <version>0.6.0-SNAPSHOT</version>
+  <description>Tez Ambari View</description>
+  <repositories>
+    <repository>
+      <id>apache.snapshots</id>
+      <name>Apache Development Snapshot Repository</name>
+      <url>https://repository.apache.org/content/repositories/snapshots/</url>
+      <releases>
+        <enabled>false</enabled>
+      </releases>
+      <snapshots>
+        <enabled>true</enabled>
+      </snapshots>
+    </repository>
+  </repositories>
+  <build>
+
+    <plugins>
+      <plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>build-helper-maven-plugin</artifactId>
+        <version>1.8</version>
+        <executions>
+          <execution>
+            <id>parse-version</id>
+            <phase>validate</phase>
+            <goals>
+              <goal>parse-version</goal>
+            </goals>
+          </execution>
+          <execution>
+            <id>regex-property</id>
+            <goals>
+              <goal>regex-property</goal>
+            </goals>
+            <configuration>
+              <name>ambariVersion</name>
+              <value>${project.version}</value>
+              <regex>^([0-9]+)\.([0-9]+)\.([0-9]+)(\.|-).*</regex>
+              <replacement>$1.$2.$3</replacement>
+              <failIfNoMatch>false</failIfNoMatch>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+
+      <!-- Unpack the dependent war and add to classes directory -->
+      <plugin>
+       <groupId>org.apache.maven.plugins</groupId>
+       <artifactId>maven-dependency-plugin</artifactId>
+       <version>2.9</version>
+       <executions>
+         <execution>
+           <id>unpack</id>
+           <phase>process-resources</phase>
+           <goals>
+             <goal>unpack</goal>
+           </goals>
+           <configuration>
+             <artifactItems>
+               <artifactItem>
+                 <groupId>org.apache.tez</groupId>
+                 <artifactId>tez-ui</artifactId>
+                 <version>${version}</version>
+                 <type>war</type>
+                 <overWrite>false</overWrite>
+                 <outputDirectory>target/classes</outputDirectory>
+               </artifactItem>
+             </artifactItems>
+             <includes>fonts/**/*, img/**/*, scripts/**/*, styles/**/*</includes>
+           </configuration>
+         </execution>
+       </executions>
+      </plugin>
+    </plugins>
+
+    <resources>
+      <resource>
+        <directory>src/main/resources/ui</directory>
+        <filtering>false</filtering>
+        <includes>
+          <include>scripts/*</include>
+          <include>index.html</include>
+        </includes>
+      </resource>
+
+      <resource>
+        <directory>src/main/resources</directory>
+        <filtering>false</filtering>
+        <includes>
+          <include>WEB-INF/web.xml</include>
+          <include>META-INF/**/*</include>
+          <include>view.xml</include>
+        </includes>
+      </resource>
+    </resources>
+
+  </build>
+
+  <dependencies>
+
+    <dependency>
+      <groupId>org.apache.tez</groupId>
+      <artifactId>tez-ui</artifactId>
+      <version>${version}</version>
+      <type>war</type>
+    </dependency>
+
+    <dependency>
+      <groupId>com.sun.jersey</groupId>
+      <artifactId>jersey-server</artifactId>
+      <version>1.8</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.ambari</groupId>
+      <artifactId>ambari-views</artifactId>
+      <version>${ambari.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>javax.servlet</groupId>
+      <artifactId>servlet-api</artifactId>
+      <version>2.5</version>
+      <scope>provided</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>com.google.inject</groupId>
+      <artifactId>guice</artifactId>
+    </dependency>
+
+  </dependencies>
+</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/1767fcfa/contrib/views/tez/readme.md
----------------------------------------------------------------------
diff --git a/contrib/views/tez/readme.md b/contrib/views/tez/readme.md
new file mode 100644
index 0000000..68e3994
--- /dev/null
+++ b/contrib/views/tez/readme.md
@@ -0,0 +1,90 @@
+<!---
+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](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.
+-->
+
+TEZ View
+============
+
+Description
+-----
+This view provides a web interface for TEZ.
+
+Requirements
+-----
+
+- Ambari view 1.3.0
+- TEZ 0.6.0 or above
+
+Build
+-----
+
+The view can be built as a maven project.
+
+    mvn clean install
+
+The build will produce the view archive.
+
+    target/tez-ambari-view-0.6.0-SNAPSHOT.jar
+
+Configuration
+-----
+
+  For the UI to work as expected with all the required data, the following configurations
+must be set.
+
+In tez-site.xml
+  * tez.runtime.convert.user-payload.to.history-text
+      Should be enabled to get the configuration options. If enabled, the config options
are set
+    as userpayload per input/output.
+
+In yarn-site.xml
+  * yarn.timeline-service.http-cross-origin.enabled
+      Enable CORS in timeline.
+  * yarn.resourcemanager.system-metrics-publisher.enabled
+      Enable generic history service in timeline server
+  * yarn.timeline-service.enabled
+      Enabled the timeline server for logging details
+  * yarn.timeline-service.webapp.address
+      Value must be the IP:PORT on which timeline server is running
+
+In configs.js
+  * Visibility of table columns can be controlled using the column selector in the UI. Also
an optional set
+    of file system counters can be made visible as columns for most of the tables. For adding
more
+    counters refer configs.js.
+
+
+Deploying the View
+-----
+
+Use the [Ambari Vagrant](https://cwiki.apache.org/confluence/display/AMBARI/Quick+Start+Guide)
setup to create a cluster:
+
+Deploy the TEZ view into Ambari.
+
+    cp tez-ambari-view-0.6.0-SNAPSHOT.jar /var/lib/ambari-server/resources/views/
+    ambari-server restart
+
+From the Ambari Administration interface, create a TEZ view instance.
+
+|Property|Value|
+|---|---|
+| Details: Instance Name | TEZUI |
+| Details: Display Name | TEZ |
+| Details: Description | A web interface for TEZ |
+| Properties: yarn.ats.url | http://yarn.ats.address:8188 |
+| Properties: yarn.resourcemanager.url | http://yarn.resourcemanager.address:8088 |
+
+Login to Ambari as **"admin"** and browse to the view instance.
+
+    http://c6401.ambari.apache.org:8080/#/main/views/TEZ/0.6.0/TEZUI
+

http://git-wip-us.apache.org/repos/asf/ambari/blob/1767fcfa/contrib/views/tez/src/main/java/org/apache/ambari/view/tez/ProxyServlet.java
----------------------------------------------------------------------
diff --git a/contrib/views/tez/src/main/java/org/apache/ambari/view/tez/ProxyServlet.java
b/contrib/views/tez/src/main/java/org/apache/ambari/view/tez/ProxyServlet.java
new file mode 100644
index 0000000..0fdd47a
--- /dev/null
+++ b/contrib/views/tez/src/main/java/org/apache/ambari/view/tez/ProxyServlet.java
@@ -0,0 +1,71 @@
+/**
+ * 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 org.apache.ambari.view.HttpImpersonator;
+import org.apache.ambari.view.ImpersonatorSetting;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.net.URLDecoder;
+
+/**
+ * Simple servlet for proxying requests with doAs impersonation.
+ */
+public class ProxyServlet extends HttpServlet {
+
+  private ViewContext viewContext;
+  private HttpImpersonator impersonator;
+  private ImpersonatorSetting impersonatorSetting;
+
+  @Override
+  public void init(ServletConfig config) throws ServletException {
+    super.init(config);
+
+    ServletContext context = config.getServletContext();
+    viewContext = (ViewContext) context.getAttribute(ViewContext.CONTEXT_ATTRIBUTE);
+
+    this.impersonator = viewContext.getHttpImpersonator();
+    this.impersonatorSetting = viewContext.getImpersonatorSetting();
+  }
+
+  @Override
+  protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException
{
+    String urlToRead = URLDecoder.decode(request.getParameter("url"));
+
+    response.setContentType(request.getContentType());
+
+    // Getting the result is super simply by using the impersonator and the default values
in the factory.
+    String result = this.impersonator.requestURL(urlToRead, "GET", this.impersonatorSetting);
+    Boolean notFound = result == "" || result.indexOf("\"exception\":\"NotFoundException\"")
!= -1;
+
+    response.setStatus(notFound ? HttpServletResponse.SC_NOT_FOUND : HttpServletResponse.SC_OK);
+
+    PrintWriter writer = response.getWriter();
+    writer.print(result);
+  }
+}
+

http://git-wip-us.apache.org/repos/asf/ambari/blob/1767fcfa/contrib/views/tez/src/main/java/org/apache/ambari/view/tez/ViewController.java
----------------------------------------------------------------------
diff --git a/contrib/views/tez/src/main/java/org/apache/ambari/view/tez/ViewController.java
b/contrib/views/tez/src/main/java/org/apache/ambari/view/tez/ViewController.java
new file mode 100644
index 0000000..a72e9ce
--- /dev/null
+++ b/contrib/views/tez/src/main/java/org/apache/ambari/view/tez/ViewController.java
@@ -0,0 +1,36 @@
+/**
+ * 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 com.google.inject.ImplementedBy;
+
+/**
+ * Interface of controller to handle requests for the tez View.
+ */
+@ImplementedBy(ViewControllerImpl.class)
+public interface ViewController {
+
+  public static final String PARAM_YARN_ATS_URL = "yarn.ats.url";
+  public static final String PARAM_YARN_RESOURCEMANAGER_URL = "yarn.resourcemanager.url";
+
+  /**
+   * @return Get the properties that any user is allowed to see, even non-admin users.
+   */
+  public ViewStatus getViewStatus();
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/1767fcfa/contrib/views/tez/src/main/java/org/apache/ambari/view/tez/ViewControllerImpl.java
----------------------------------------------------------------------
diff --git a/contrib/views/tez/src/main/java/org/apache/ambari/view/tez/ViewControllerImpl.java
b/contrib/views/tez/src/main/java/org/apache/ambari/view/tez/ViewControllerImpl.java
new file mode 100644
index 0000000..5205740
--- /dev/null
+++ b/contrib/views/tez/src/main/java/org/apache/ambari/view/tez/ViewControllerImpl.java
@@ -0,0 +1,66 @@
+/**
+ * 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 java.lang.String;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.ambari.view.ViewContext;
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+
+/**
+ * Implementation of controller to handle requests for the tez View.
+ */
+@Singleton
+public class ViewControllerImpl implements ViewController {
+
+  @Inject
+  private ViewContext viewContext;
+
+  /**
+   * Because only an admin user is allowed to see the properties in
+   * api/v1/views/tez/versions/{version_number}/instances/{instance_name}/ ,
+   * we need a way for all users to see the basic properties of the tez View, primarily
+   * the YARN ATS URL and YARN Resource Manager URL
+   * @return Get the properties that any user is allowed to see, even non-admin users.
+   */
+  @Override
+  public ViewStatus getViewStatus() {
+    ViewStatus status = new ViewStatus();
+    Map<String, String> parameters = new HashMap<String, String>();
+    parameters.put(ViewController.PARAM_YARN_ATS_URL, getViewParameterValue(ViewController.PARAM_YARN_ATS_URL));
+    parameters.put(ViewController.PARAM_YARN_RESOURCEMANAGER_URL, getViewParameterValue(ViewController.PARAM_YARN_RESOURCEMANAGER_URL));
+    status.setParameters(parameters);
+    return status;
+  }
+
+  /**
+   * @param parameterName Parameter to get the value for
+   * @return Returns the value of the given parameter
+   */
+  private String getViewParameterValue(String parameterName) {
+    String value = viewContext.getProperties().get(parameterName);
+    if ("null".equals(value)) {
+      return null;
+    }
+    return value;
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/1767fcfa/contrib/views/tez/src/main/java/org/apache/ambari/view/tez/ViewStatus.java
----------------------------------------------------------------------
diff --git a/contrib/views/tez/src/main/java/org/apache/ambari/view/tez/ViewStatus.java b/contrib/views/tez/src/main/java/org/apache/ambari/view/tez/ViewStatus.java
new file mode 100644
index 0000000..8bf851b
--- /dev/null
+++ b/contrib/views/tez/src/main/java/org/apache/ambari/view/tez/ViewStatus.java
@@ -0,0 +1,44 @@
+/**
+ * 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 java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Class to represent the public-facing properties of the tez View that any user is allowed
to see.
+ */
+public class ViewStatus {
+
+  private Map<String, String> parameters = new HashMap<String, String>();
+
+  /**
+   * @return Get all of the public properties
+   */
+  public Map<String, String> getParameters() {
+    return parameters;
+  }
+
+  /**
+   * @param parameters Parameters to save
+   */
+  public void setParameters(Map<String, String> parameters) {
+    this.parameters = parameters;
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/1767fcfa/contrib/views/tez/src/main/java/org/apache/ambari/view/tez/rest/ViewStatusResource.java
----------------------------------------------------------------------
diff --git a/contrib/views/tez/src/main/java/org/apache/ambari/view/tez/rest/ViewStatusResource.java
b/contrib/views/tez/src/main/java/org/apache/ambari/view/tez/rest/ViewStatusResource.java
new file mode 100644
index 0000000..defbe4a
--- /dev/null
+++ b/contrib/views/tez/src/main/java/org/apache/ambari/view/tez/rest/ViewStatusResource.java
@@ -0,0 +1,46 @@
+/**
+ * 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.rest;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+import org.apache.ambari.view.tez.ViewController;
+import org.apache.ambari.view.tez.ViewStatus;
+
+import com.google.inject.Inject;
+
+/**
+ * Resource that exposes the status (mainly public properties) of the tez View.
+ */
+public class ViewStatusResource {
+
+  @Inject
+  ViewController controller;
+
+  /**
+   * @return Get the properties that any user is allowed to see, even non-admin users.
+   */
+  @GET
+  @Produces({ MediaType.APPLICATION_JSON })
+  public ViewStatus getViewStatus() {
+    return controller.getViewStatus();
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/1767fcfa/contrib/views/tez/src/main/resources/WEB-INF/web.xml
----------------------------------------------------------------------
diff --git a/contrib/views/tez/src/main/resources/WEB-INF/web.xml b/contrib/views/tez/src/main/resources/WEB-INF/web.xml
new file mode 100644
index 0000000..c620187
--- /dev/null
+++ b/contrib/views/tez/src/main/resources/WEB-INF/web.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+
+<!--
+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. Kerberos, LDAP, Custom. Binary/Htt
+-->
+
+<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
+         version="2.4">
+
+  <display-name>Proxy Application</display-name>
+  <description>
+    This is the proxy application.
+  </description>
+  <servlet>
+    <servlet-name>ProxyServlet</servlet-name>
+    <servlet-class>org.apache.ambari.view.tez.ProxyServlet</servlet-class>
+  </servlet>
+  <servlet-mapping>
+    <servlet-name>ProxyServlet</servlet-name>
+    <url-pattern>/proxy</url-pattern>
+  </servlet-mapping>
+</web-app>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/1767fcfa/contrib/views/tez/src/main/resources/ui/index.html
----------------------------------------------------------------------
diff --git a/contrib/views/tez/src/main/resources/ui/index.html b/contrib/views/tez/src/main/resources/ui/index.html
new file mode 100644
index 0000000..ed0230a
--- /dev/null
+++ b/contrib/views/tez/src/main/resources/ui/index.html
@@ -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.
+-->
+<!doctype html>
+<html>
+  <head>
+    <meta charset="utf-8">
+    <title>Tez UI</title>
+
+    <link rel="shortcut icon" href="img/tez-favicon.png" type="image/x-icon">
+
+    <link rel="stylesheet" href="styles/main.css">
+  </head>
+
+  <body>
+    <script src="scripts/components.js"></script>
+    <script src="scripts/templates.js"></script>
+    <script src="scripts/main.js"></script>
+    <script src="scripts/configs.js"></script>
+
+    <script src="scripts/init-ambari-view.js"></script>
+
+    <div class="error-bar" style="border: none;">
+      <div class="main-container">
+        <div class="message-container">
+          <span class="error-icon"></span>&nbsp;
+          <span class="message"></span>
+        </div><div class="close-container">
+          <div class="close">&#65516;</div>
+        </div>
+        <div class="details"></div>
+      </div>
+    </div>
+
+  </body>
+</html>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/1767fcfa/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
new file mode 100644
index 0000000..8c242b1
--- /dev/null
+++ b/contrib/views/tez/src/main/resources/ui/scripts/init-ambari-view.js
@@ -0,0 +1,120 @@
+/**
+ * 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.ambari = (function () {
+  /**
+   * Stores parameters from Ambari.
+   */
+  var ambariParameters = {},
+
+  /**
+   * Constructs URL for fetching Ambari view instance parameters.
+   * @return {String}
+   */
+  getURL = function () {
+    var urlParts = location.pathname.split('/');
+
+    return "/api/v1/views/%@/versions/%@/instances/%@/resources/status".fmt(
+      urlParts[2],
+      urlParts[3],
+      urlParts[4]
+    );
+  };
+
+  return {
+    /**
+     * Key for the property representing ATS url.
+     */
+    TIMELINE_URL: 'yarn.ats.url',
+    RM_URL: 'yarn.resourcemanager.url',
+
+    /**
+     * Returns parameter value.
+     * @param {String} name
+     * @return {String}
+     * @method getParam
+     */
+    getParam: function (name) {
+      Ember.assert('Parameter not found!', ambariParameters[name]);
+      return ambariParameters[name];
+    },
+
+    /**
+     * Get view instance properties provided by user.
+     * @returns {$.ajax}
+     * @method getInstanceParameters
+     */
+    getInstanceParameters: function () {
+      var hashArray = location.pathname.split('/'),
+      params = {
+        view: hashArray[2],
+        version: hashArray[3],
+        instanceName: hashArray[4],
+        clusterName: App.get('clusterName')
+      };
+
+      return $.ajax({
+        type: 'GET',
+        dataType: 'json',
+        async: true,
+        context: this,
+        url: getURL(),
+        success: this.getInstanceParametersSuccessCallback,
+        error: this.getInstanceParametersErrorCallback,
+      });
+    },
+
+    /**
+     * Success callback for getInstanceParameters-request.
+     * @param {object} data
+     * @method getInstanceParametersSuccessCallback
+     */
+    getInstanceParametersSuccessCallback: function (data) {
+      Ember.assert('Ambari instance parameter weren`t returned by the service!', data.parameters);
+      ambariParameters = data.parameters;
+    },
+
+    /**
+     * Error callback for getInstanceParameters-request.
+     * @method getInstanceParametersErrorCallback
+     */
+    getInstanceParametersErrorCallback: function (request, ajaxOptions, error) {
+      Ember.assert('Ambari instance parameter fetch failed: ' + error);
+    }
+  };
+
+})();
+
+App.deferReadiness();
+App.Helpers.ambari.getInstanceParameters().then(function () {
+  $.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)
+    }
+  });
+
+  App.advanceReadiness();
+});
+
+Ember.$.ajaxSetup({
+  beforeSend: function (jqXHR, settings) {
+    settings.url = location.pathname + 'proxy?url=' + encodeURIComponent(settings.url);
+  }
+});

http://git-wip-us.apache.org/repos/asf/ambari/blob/1767fcfa/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
new file mode 100644
index 0000000..94af8f1
--- /dev/null
+++ b/contrib/views/tez/src/main/resources/view.xml
@@ -0,0 +1,40 @@
+<!--
+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. Kerberos, LDAP, Custom. Binary/Htt
+-->
+<view>
+  <name>TEZ</name>
+  <label>TEZ View</label>
+  <version>0.6.0</version>
+  <parameter>
+    <name>yarn.ats.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>
+    <label>YARN ATS URL</label>
+    <placeholder>http://yarn.ats.address:8188</placeholder>
+    <required>true</required>
+  </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.address:8088</placeholder>
+    <required>true</required>
+  </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>
+</view>


Mime
View raw message