You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by at...@apache.org on 2009/02/04 00:56:56 UTC
svn commit: r740523 - in /hadoop/hive/trunk: ./
common/src/java/org/apache/hadoop/hive/conf/ conf/ hwi/ hwi/src/
hwi/src/java/ hwi/src/java/org/ hwi/src/java/org/apache/
hwi/src/java/org/apache/hadoop/ hwi/src/java/org/apache/hadoop/hive/
hwi/src/java/...
Author: athusoo
Date: Tue Feb 3 23:56:54 2009
New Revision: 740523
URL: http://svn.apache.org/viewvc?rev=740523&view=rev
Log:
HIVE-30. Hive Web User Interface. (Edward Capriolo via athusoo)
Added:
hadoop/hive/trunk/hwi/
hadoop/hive/trunk/hwi/build.xml
hadoop/hive/trunk/hwi/src/
hadoop/hive/trunk/hwi/src/java/
hadoop/hive/trunk/hwi/src/java/org/
hadoop/hive/trunk/hwi/src/java/org/apache/
hadoop/hive/trunk/hwi/src/java/org/apache/hadoop/
hadoop/hive/trunk/hwi/src/java/org/apache/hadoop/hive/
hadoop/hive/trunk/hwi/src/java/org/apache/hadoop/hive/hwi/
hadoop/hive/trunk/hwi/src/java/org/apache/hadoop/hive/hwi/HWIAuth.java
hadoop/hive/trunk/hwi/src/java/org/apache/hadoop/hive/hwi/HWIContextListener.java
hadoop/hive/trunk/hwi/src/java/org/apache/hadoop/hive/hwi/HWIException.java
hadoop/hive/trunk/hwi/src/java/org/apache/hadoop/hive/hwi/HWIServer.java
hadoop/hive/trunk/hwi/src/java/org/apache/hadoop/hive/hwi/HWISessionItem.java
hadoop/hive/trunk/hwi/src/java/org/apache/hadoop/hive/hwi/HWISessionManager.java
hadoop/hive/trunk/hwi/src/test/
hadoop/hive/trunk/hwi/src/test/org/
hadoop/hive/trunk/hwi/src/test/org/apache/
hadoop/hive/trunk/hwi/src/test/org/apache/hadoop/
hadoop/hive/trunk/hwi/src/test/org/apache/hadoop/hive/
hadoop/hive/trunk/hwi/src/test/org/apache/hadoop/hive/hwi/
hadoop/hive/trunk/hwi/src/test/org/apache/hadoop/hive/hwi/TestHWISessionManager.java
hadoop/hive/trunk/hwi/web/
hadoop/hive/trunk/hwi/web/WEB-INF/
hadoop/hive/trunk/hwi/web/WEB-INF/web.xml
hadoop/hive/trunk/hwi/web/admin_list_jobs.jsp
hadoop/hive/trunk/hwi/web/authorize.jsp
hadoop/hive/trunk/hwi/web/diagnostics.jsp
hadoop/hive/trunk/hwi/web/error_page.jsp
hadoop/hive/trunk/hwi/web/index.jsp
hadoop/hive/trunk/hwi/web/left_navigation.jsp
hadoop/hive/trunk/hwi/web/session_create.jsp
hadoop/hive/trunk/hwi/web/session_diagnostics.jsp
hadoop/hive/trunk/hwi/web/session_kill.jsp
hadoop/hive/trunk/hwi/web/session_list.jsp
hadoop/hive/trunk/hwi/web/session_manage.jsp
hadoop/hive/trunk/hwi/web/session_remove.jsp
hadoop/hive/trunk/hwi/web/set_processor.jsp
hadoop/hive/trunk/hwi/web/show_database.jsp
hadoop/hive/trunk/hwi/web/show_databases.jsp
hadoop/hive/trunk/hwi/web/show_table.jsp
hadoop/hive/trunk/hwi/web/view_file.jsp
Modified:
hadoop/hive/trunk/CHANGES.txt
hadoop/hive/trunk/build.xml
hadoop/hive/trunk/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java
hadoop/hive/trunk/conf/hive-default.xml
Modified: hadoop/hive/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/CHANGES.txt?rev=740523&r1=740522&r2=740523&view=diff
==============================================================================
--- hadoop/hive/trunk/CHANGES.txt (original)
+++ hadoop/hive/trunk/CHANGES.txt Tue Feb 3 23:56:54 2009
@@ -6,6 +6,8 @@
NEW FEATURES
+ HIVE-30. Hive Web User Interface. (Edward Capriolo via athusoo)
+
IMPROVEMENTS
OPTIMIZATIONS
Modified: hadoop/hive/trunk/build.xml
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/build.xml?rev=740523&r1=740522&r2=740523&view=diff
==============================================================================
--- hadoop/hive/trunk/build.xml (original)
+++ hadoop/hive/trunk/build.xml Tue Feb 3 23:56:54 2009
@@ -74,6 +74,9 @@
<subant target="compile">
<fileset dir="." includes="jdbc/build.xml"/>
</subant>
+ <subant target="compile">
+ <fileset dir="." includes="hwi/build.xml"/>
+ </subant>
</target>
<!-- ====================================================== -->
@@ -102,6 +105,9 @@
<subant target="deploy">
<fileset dir="." includes="jdbc/build.xml"/>
</subant>
+ <subant target="deploy">
+ <fileset dir="." includes="hwi/build.xml"/>
+ </subant>
</target>
<!-- ====================================================== -->
@@ -183,6 +189,7 @@
<fileset file="${build.dir.hive}/common/hive_common.jar"/>
<fileset file="${build.dir.hive}/ql/hive_exec.jar"/>
<fileset file="${build.dir.hive}/metastore/hive_metastore.jar"/>
+ <fileset file="${build.dir.hive}/hive_hwi.war"/>
</copy>
<copy todir="${target.example.dir}/files" preservelastmodified="true" flatten="true">
<fileset dir="${test.data.dir}/files" includes="*.*" excludes="**/.svn"/>
Modified: hadoop/hive/trunk/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java?rev=740523&r1=740522&r2=740523&view=diff
==============================================================================
--- hadoop/hive/trunk/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java (original)
+++ hadoop/hive/trunk/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java Tue Feb 3 23:56:54 2009
@@ -114,7 +114,13 @@
HIVEDEFAULTFILEFORMAT("hive.default.fileformat", "TextFile"),
//Location of Hive run time structured log file
- HIVEHISTORYFILELOC("hive.querylog.location", "/tmp/"+System.getProperty("user.name"));
+ HIVEHISTORYFILELOC("hive.querylog.location", "/tmp/"+System.getProperty("user.name")),
+
+ // HWI
+ HIVEHWILISTENHOST("hive.hwi.listen.host","0.0.0.0"),
+ HIVEHWILISTENPORT("hive.hwi.listen.port","9999"),
+ HIVEHWIWARFILE("hive.hwi.war.file",System.getenv("HIVE_HOME")+"/lib/hive_hwi.war");
+
public final String varname;
Modified: hadoop/hive/trunk/conf/hive-default.xml
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/conf/hive-default.xml?rev=740523&r1=740522&r2=740523&view=diff
==============================================================================
--- hadoop/hive/trunk/conf/hive-default.xml (original)
+++ hadoop/hive/trunk/conf/hive-default.xml Tue Feb 3 23:56:54 2009
@@ -100,5 +100,22 @@
<description> This controls whether intermediate files produced by hive between multiple map-reduce jobs are compressed. The compression codec and other options are determined from hadoop config variables mapred.output.compress* </description>
</property>
+<property>
+ <name>hive.hwi.listen.host</name>
+ <value>0.0.0.0</value>
+ <description>This is the host address the Hive Web Interface will listen on</description>
+</property>
+
+<property>
+ <name>hive.hwi.listen.port</name>
+ <value>9999</value>
+ <description>This is the port the Hive Web Interface will listen on</description>
+</property>
+
+<property>
+ <name>hive.hwi.war.file</name>
+ <value>${HIVE_HOME}/lib/hive.war</value>
+ <description>This is the WAR file with the jsp content for Hive Web Interface</description>
+</property>
</configuration>
Added: hadoop/hive/trunk/hwi/build.xml
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/hwi/build.xml?rev=740523&view=auto
==============================================================================
--- hadoop/hive/trunk/hwi/build.xml (added)
+++ hadoop/hive/trunk/hwi/build.xml Tue Feb 3 23:56:54 2009
@@ -0,0 +1,41 @@
+<project name="hwi" default="jar">
+
+ <property name="web.dir" location="${basedir}/web"/>
+ <property name="src.dir" value="${basedir}/src"/>
+
+ <import file="../build-common.xml"/>
+
+ <target name="hwi-init">
+ <mkdir dir="${build.dir}/classes"/>
+ <mkdir dir="${build.dir}/test/classes"/>
+ <mkdir dir="${build.dir}/test/src"/>
+ </target>
+
+ <target name="compile" depends="hwi-init">
+ <echo message="Compiling: ${name}"/>
+ <javac
+ encoding="${build.encoding}"
+ destdir="${build.classes}"
+ includes="**/*.java"
+ srcdir="${src.dir}"
+ debug="${javac.debug}"
+ deprecation="${javac.deprecation}">
+ <compilerarg line="${javac.args} ${javac.args.warnings}" />
+ <classpath refid="classpath-hwi"/>
+ </javac>
+ <jar jarfile="../build/hive_hwi.war" basedir="${basedir}/web"/>
+ </target>
+
+ <path id="classpath-hwi">
+ <pathelement location="${classpath}"/>
+ <fileset dir="${hadoop.root}/lib">
+ <include name="**/*.jar" />
+ <exclude name="**/excluded/" />
+ </fileset>
+ <fileset dir="../build">
+ <include name="**/*.jar" />
+ <exclude name="**/excluded/" />
+ </fileset>
+ </path>
+
+</project>
Added: hadoop/hive/trunk/hwi/src/java/org/apache/hadoop/hive/hwi/HWIAuth.java
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/hwi/src/java/org/apache/hadoop/hive/hwi/HWIAuth.java?rev=740523&view=auto
==============================================================================
--- hadoop/hive/trunk/hwi/src/java/org/apache/hadoop/hive/hwi/HWIAuth.java (added)
+++ hadoop/hive/trunk/hwi/src/java/org/apache/hadoop/hive/hwi/HWIAuth.java Tue Feb 3 23:56:54 2009
@@ -0,0 +1,76 @@
+package org.apache.hadoop.hive.hwi;
+/**
+ * Represents an authenticated user. This class is stored in the users session. It is also used
+ * as a key for the HiveSessionManager
+ */
+public class HWIAuth implements Comparable{
+ private String user;
+ private String[] groups;
+
+ public HWIAuth() {
+
+ }
+
+ public String getUser() {
+ return user;
+ }
+
+ public void setUser(String user) {
+ this.user = user;
+ }
+
+ public String[] getGroups() {
+ return groups;
+ }
+
+ public void setGroups(String[] groups) {
+ this.groups = groups;
+ }
+ /**
+ * HWIAuth is used in SortedSets(s) the compartTo method is required
+ * @return chained call to String.compareTo based on user property
+ */
+ public int compareTo(Object obj){
+ if (obj == null){
+ return -1;
+ }
+ if (! (obj instanceof HWIAuth)){
+ return -1;
+ }
+ HWIAuth o = (HWIAuth) obj;
+ return o.getUser().compareTo(this.user);
+ }
+
+ /** HWIAuth is used in Map(s) the hashCode method is required
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((user == null) ? 0 : user.hashCode());
+ return result;
+ }
+
+ /**
+ * HWIAuth is used in Map(s) the equals method is required
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (!(obj instanceof HWIAuth))
+ return false;
+ HWIAuth other = (HWIAuth) obj;
+ if (user == null) {
+ if (other.user != null)
+ return false;
+ } else if (!user.equals(other.user))
+ return false;
+ return true;
+ }
+
+}
\ No newline at end of file
Added: hadoop/hive/trunk/hwi/src/java/org/apache/hadoop/hive/hwi/HWIContextListener.java
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/hwi/src/java/org/apache/hadoop/hive/hwi/HWIContextListener.java?rev=740523&view=auto
==============================================================================
--- hadoop/hive/trunk/hwi/src/java/org/apache/hadoop/hive/hwi/HWIContextListener.java (added)
+++ hadoop/hive/trunk/hwi/src/java/org/apache/hadoop/hive/hwi/HWIContextListener.java Tue Feb 3 23:56:54 2009
@@ -0,0 +1,49 @@
+package org.apache.hadoop.hive.hwi;
+
+import javax.servlet.ServletContext;
+import javax.servlet.ServletContextEvent;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * After getting a contextInitialized event this component starts an
+ * instance of the HiveSessionManager.
+ *
+ */
+public class HWIContextListener implements javax.servlet.ServletContextListener {
+
+ protected static final Log l4j = LogFactory.getLog( HWIContextListener.class.getName() );
+ /**
+ * The Hive Web Interface manages multiple hive sessions. This event is used to
+ * start a Runnable, HiveSessionManager as a thread inside the servlet
+ * container.
+ * @param sce An event fired by the servlet context on startup
+ */
+ public void contextInitialized(ServletContextEvent sce){
+ ServletContext sc = sce.getServletContext();
+ HWISessionManager hs = new HWISessionManager();
+ l4j.debug("HWISessionManager created.");
+ Thread t = new Thread(hs);
+ t.start();
+ l4j.debug("HWISessionManager thread started.");
+ sc.setAttribute("hs", hs);
+ l4j.debug("HWISessionManager placed in application context.");
+ }
+ /**
+ * When the Hive Web Interface is closing we locate the Runnable
+ * HiveSessionManager and set it's internal goOn variable to false. This
+ * should allow the application to gracefully shutdown.
+ * @param sce An event fired by the servlet context on context shutdown
+ */
+ public void contextDestroyed(ServletContextEvent sce){
+ ServletContext sc = sce.getServletContext();
+ HWISessionManager hs = (HWISessionManager) sc.getAttribute("hs");
+ if (hs ==null){
+ l4j.error("HWISessionManager was not found in context");
+ } else {
+ l4j.error("HWISessionManager goOn set to false. Shutting down.");
+ hs.setGoOn(false);
+ }
+ }
+}
Added: hadoop/hive/trunk/hwi/src/java/org/apache/hadoop/hive/hwi/HWIException.java
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/hwi/src/java/org/apache/hadoop/hive/hwi/HWIException.java?rev=740523&view=auto
==============================================================================
--- hadoop/hive/trunk/hwi/src/java/org/apache/hadoop/hive/hwi/HWIException.java (added)
+++ hadoop/hive/trunk/hwi/src/java/org/apache/hadoop/hive/hwi/HWIException.java Tue Feb 3 23:56:54 2009
@@ -0,0 +1,26 @@
+package org.apache.hadoop.hive.hwi;
+
+public class HWIException extends Exception {
+
+ private static final long serialVersionUID = 1L;
+
+ public HWIException() {
+ super();
+ }
+
+ /** Specify an error String with the Exception */
+ public HWIException(String arg0) {
+ super(arg0);
+ }
+
+ /** Wrap an Exception in HWIException */
+ public HWIException(Throwable arg0) {
+ super(arg0);
+ }
+
+ /** Specify an error String and wrap an Exception in HWIException */
+ public HWIException(String arg0, Throwable arg1) {
+ super(arg0, arg1);
+ }
+
+}
Added: hadoop/hive/trunk/hwi/src/java/org/apache/hadoop/hive/hwi/HWIServer.java
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/hwi/src/java/org/apache/hadoop/hive/hwi/HWIServer.java?rev=740523&view=auto
==============================================================================
--- hadoop/hive/trunk/hwi/src/java/org/apache/hadoop/hive/hwi/HWIServer.java (added)
+++ hadoop/hive/trunk/hwi/src/java/org/apache/hadoop/hive/hwi/HWIServer.java Tue Feb 3 23:56:54 2009
@@ -0,0 +1,127 @@
+package org.apache.hadoop.hive.hwi;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.hive.conf.HiveConf;
+import org.mortbay.http.SocketListener;
+import org.mortbay.jetty.Server;
+import org.mortbay.jetty.servlet.WebApplicationContext;
+/**
+ * This is the entry point for HWI. A web server is invoked in the same manner as the hive CLI.
+ * Rather then opening a command line session a web server is started and a web application to work with
+ * hive is started.
+ */
+public class HWIServer {
+ protected static final Log l4j = LogFactory.getLog( HWIServer.class.getName() );
+
+ private org.mortbay.jetty.Server webServer;
+ private SocketListener listener;
+ private String [] args;
+
+ /**
+ *
+ * @param args These are the command line arguments. Usually -hiveconf.
+ * @throws java.io.IOException
+ */
+ public HWIServer(String [] args) throws IOException {
+ this.args = args;
+ }
+ /**
+ * This method initialized the internal Jetty Servlet Engine. It adds the hwi
+ * context path.
+ * @throws java.io.IOException Port already in use, bad bind etc.
+ */
+ public void start() throws IOException {
+
+ webServer = new org.mortbay.jetty.Server();
+ listener = new SocketListener();
+ HiveConf conf = new HiveConf(this.getClass());
+
+ String listen = null;
+ int port = -1;
+
+ listen = conf.getVar(HiveConf.ConfVars.HIVEHWILISTENHOST);
+ port = conf.getIntVar(HiveConf.ConfVars.HIVEHWILISTENPORT);
+
+ if (listen.equals("")){
+ l4j.warn("hive.hwi.listen.host was not specified defaulting to 0.0.0.0");
+ listen="0.0.0.0";
+ }
+ if (port ==-1){
+ l4j.warn("hive.hwi.listen.port was not specified defaulting to 9999");
+ port=9999;
+ }
+
+ listener.setPort(port);
+ listener.setHost(listen);
+
+ webServer.addListener(listener);
+
+ WebApplicationContext wac = new WebApplicationContext();
+ wac.setContextPath("/hwi");
+
+ String hwiWAR = conf.getVar(HiveConf.ConfVars.HIVEHWIWARFILE);
+ if (! new File (hwiWAR).exists() ){
+ l4j.fatal("HWI WAR file not found at "+ hwiWAR );
+ }
+
+ wac.setWAR(hwiWAR);
+
+ /*The command line args may be used by multiple components. Rather by setting
+ * these as a system property we avoid having to specifically pass them
+ */
+ StringBuffer sb = new StringBuffer();
+ for (int i=0;i<args.length;i++){
+ sb.append(args[i]+" ");
+ }
+ System.setProperty("hwi-args", sb.toString());
+
+ webServer.addContext(wac);
+ try {
+ while (true) {
+ try {
+ webServer.start();
+ webServer.join();
+ l4j.debug( " HWI Web Server is started.");
+ break;
+ } catch (org.mortbay.util.MultiException ex) {
+ throw ex;
+ }
+ }
+ } catch (IOException ie) {
+ throw ie;
+ } catch (Exception e) {
+ IOException ie = new IOException("Problem starting HWI server");
+ ie.initCause(e);
+ l4j.error("Parsing hwi.listen.port caused exception ", e);
+ throw ie;
+ }
+ }
+
+ /**
+ *
+ * @param args
+ * as of now no arguments are supported
+ * @throws java.lang.Exception
+ * Could be thrown if due to issues with Jetty or bad configuration options
+ *
+ */
+ public static void main(String[] args) throws Exception {
+ HWIServer hwi = new HWIServer(args);
+ l4j.info("HWI is starting up");
+ hwi.start();
+ }
+
+ /**
+ * Shut down the running HWI Server
+ * @throws InterruptedException Running Thread.stop() can and probably will throw this
+ */
+ public void stop() throws InterruptedException {
+ l4j.info("HWI is shutting down");
+ webServer.stop();
+ }
+
+}
Added: hadoop/hive/trunk/hwi/src/java/org/apache/hadoop/hive/hwi/HWISessionItem.java
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/hwi/src/java/org/apache/hadoop/hive/hwi/HWISessionItem.java?rev=740523&view=auto
==============================================================================
--- hadoop/hive/trunk/hwi/src/java/org/apache/hadoop/hive/hwi/HWISessionItem.java (added)
+++ hadoop/hive/trunk/hwi/src/java/org/apache/hadoop/hive/hwi/HWISessionItem.java Tue Feb 3 23:56:54 2009
@@ -0,0 +1,400 @@
+package org.apache.hadoop.hive.hwi;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.util.Collection;
+import java.util.Vector;
+
+import org.apache.hadoop.hive.cli.CliSessionState;
+import org.apache.hadoop.hive.cli.OptionsProcessor;
+import org.apache.hadoop.hive.cli.SetProcessor;
+import org.apache.hadoop.hive.conf.HiveConf;
+import org.apache.hadoop.hive.ql.Driver;
+import org.apache.hadoop.hive.ql.exec.ExecDriver;
+import org.apache.hadoop.hive.ql.session.SessionState;
+import org.apache.hadoop.conf.*;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+/**
+ * HWISessionItem can be viewed as a wrapper for a Hive shell. With it the user has a
+ * session on the web server rather then in a console window.
+ *
+ */
+public class HWISessionItem implements Runnable, Comparable<HWISessionItem> {
+
+ protected static final Log l4j = LogFactory.getLog( HWISessionItem.class.getName() );
+ /**
+ * Represents the state a session item can be in.
+ *
+ */
+ public enum WebSessionItemStatus{
+ NEW,QUERY_SET,QUERY_RUNNING,QUERY_COMPLETE,DESTROY,KILL_QUERY
+ };
+
+ private String sessionName;
+ private HWISessionItem.WebSessionItemStatus status;
+
+
+ private CliSessionState ss;
+ private SetProcessor sp;
+ private Driver qp;
+
+ private String resultFile;
+ private String errorFile;
+
+ private String query;
+ private int queryRet;
+
+ HiveConf conf;
+ Thread runnable;
+ /**
+ * Creates an instance of WebSessionItem, sets status
+ * to NEW.
+ */
+ protected HWISessionItem(){
+ l4j.debug("HWISessionItem created");
+ status=WebSessionItemStatus.NEW;
+ queryRet=-40;
+ }
+
+ /**
+ * This is the initialization process that is carried out for each
+ * SessionItem this is a section of the code taken from the CLIDriver
+ */
+ protected void itemInit() {
+ l4j.debug("HWISessionItem itemInit start "+this.getSessionName() );
+ OptionsProcessor oproc = new OptionsProcessor();
+
+ if (System.getProperty("hwi-args")!=null){
+ String [] parts = System.getProperty("hwi-args").split("\\s+");
+
+ if (!oproc.process_stage1(parts)) {
+ }
+ }
+
+ SessionState.initHiveLog4j();
+ conf=new HiveConf(SessionState.class);
+ ss = new CliSessionState(conf);
+ SessionState.start(ss);
+
+ sp = new SetProcessor();
+ qp = new Driver();
+ l4j.debug("HWISessionItem itemInit Complete "+this.getSessionName() );
+ }
+
+ /**
+ * Set processor queries block for only a short amount of time the
+ * client can issue these directly.
+ * @param query This is a query in the form of SET THIS=THAT
+ * @return chained call to setProcessor.run(String)
+ */
+ public int runSetProcessorQuery(String query){
+ return sp.run(query);
+ }
+
+ /**
+ * The client does not start the thread themselves. They set their status to
+ * QUERY_SET.
+ *
+ */
+ public void clientStart() throws HWIException {
+ if (ss == null) {
+ throw new HWIException("SessionState is null.");
+ }
+
+ if (query == null) {
+ throw new HWIException("No Query was specified.");
+ }
+
+ if (this.status == WebSessionItemStatus.QUERY_RUNNING) {
+ throw new HWIException("Query already running");
+ }
+ this.status = WebSessionItemStatus.QUERY_SET;
+ l4j.debug(this.getSessionName()+" Query is set to start");
+ }
+
+ public void clientKill() throws HWIException {
+ if (this.status != WebSessionItemStatus.QUERY_RUNNING){
+ throw new HWIException("Can not kill that which is not running.");
+ }
+ this.status=WebSessionItemStatus.KILL_QUERY;
+ l4j.debug(this.getSessionName()+" Query is set to KILL_QUERY");
+ }
+ /**
+ * This method returns A KILL command a non silent clisession would return
+ * when invoking a HQL query from the CLI.
+ * @return a string URL showing the job in the job tracker
+ */
+ public Collection<String> getKillCommand(){
+ return ExecDriver.runningJobKillURIs.values();
+ //Kill Command = /opt/hadoop/hadoop-0.19.0/bin/../bin/hadoop job -Dmapred.job.tracker=hadoop1.jointhegrid.local:54311 -kill job_200812231617_0001
+ //StringBuffer sb = new StringBuffer();
+ //sb.append( conf.getVar(HiveConf.ConfVars.HADOOPBIN));
+ //sb.append( " job ");
+ //sb.append( " -Dmapred.job.tracker= ");
+ //sb.append( conf.getVar(HiveConf.ConfVars.HADOOPJT));
+ //sb.append( " -kill ");
+ //sb.append( conf.getVar(HiveConf.ConfVars.HADOOPJOBNAME));
+ //return sb.toString();
+ }
+ /**
+ * This method returns the URL a non silent clisession would return
+ * when invoking a HQL query from the CLI.
+ * @return a string URL showing the job in the job tracker
+ */
+ public Vector<String> getJobTrackerURI(){
+ //is this my job?
+ Vector<String> results = new Vector<String>();
+ for (String id: ExecDriver.runningJobKillURIs.keySet() ){
+
+ StringBuffer sb = new StringBuffer();
+ sb.append("http://");
+ //sb.append( this.conf.getVar( HiveConf.ConfVars.HADOOPJT ) );
+ sb.append( conf.get("mapred.job.tracker.http.address") );
+ sb.append("/jobdetails.jsp?jobid=");
+ sb.append(id);
+ results.add( sb.toString() );
+
+ }
+ return results;
+ //http://hadoop1.jointhegrid.local:50030/jobdetails.jsp?jobid=
+ }
+
+ /** This method clears the private member variables. */
+ public void clientRenew() throws HWIException {
+ if (this.status == WebSessionItemStatus.QUERY_RUNNING) {
+ throw new HWIException("Query already running");
+ }
+
+ this.query = null;
+ this.resultFile = null;
+ this.errorFile = null;
+ this.status = WebSessionItemStatus.NEW;
+ l4j.debug(this.getSessionName()+" Query is renewed to start");
+ }
+
+ /**
+ * This is a chained call to SessionState.setIsSilent(). Use this
+ * if you do not want the result file to have information status
+ */
+ public void setSSIsSilent(boolean silent) throws HWIException{
+ if (ss == null)
+ throw new HWIException("Session State is null");
+ this.ss.setIsSilent(silent);
+ }
+
+ /**
+ * This is a chained call to SessionState.getIsSilent()
+ */
+ public boolean getSSIsSilent() throws HWIException {
+ if (ss == null)
+ throw new HWIException("Session State is null");
+ return ss.getIsSilent();
+ }
+
+ /**
+ * This is a callback style function used by the HiveSessionManager. The
+ * HiveSessionManager notices this and changes the state to QUERY_RUNNING
+ * then starts a thread.
+ */
+ protected void startIt() {
+ this.status = WebSessionItemStatus.QUERY_RUNNING;
+ l4j.debug(this.getSessionName()+" Runnable is starting");
+ runnable = new Thread(this);
+ runnable.start();
+ l4j.debug(this.getSessionName()+" Runnable has started");
+ }
+ /**
+ * This is a callback style function used by the HiveSessionManager. The
+ * HiveSessionManager notices this and attempts to stop the query.
+ */
+ protected void killIt(){
+ l4j.debug(this.getSessionName()+" Attempting kill.");
+ if ( this.runnable != null){
+ try {
+ this.runnable.join(1000);
+ l4j.debug(this.getSessionName()+" Thread join complete");
+ } catch (InterruptedException e) {
+ l4j.error(this.getSessionName()+" killing session caused exception ",e );
+ }
+ }
+ }
+ /**
+ * Helper function to get configuration variables
+ *
+ * @param wanted a ConfVar
+ * @return
+ */
+ public String getHiveConfVar(HiveConf.ConfVars wanted) throws HWIException {
+ String result = null;
+ try {
+ result = this.ss.getConf().getVar(wanted);
+ } catch (Exception ex) {
+ throw new HWIException(ex);
+ }
+ return result;
+ }
+
+
+ @Override
+ /**
+ * The run method will be called by HiveSessionManager. This method
+ * reads the results from query processor completely when the query is done.
+ * when completed this is set to HWISessionItemStatus.QUERY_COMPLETE.
+ */
+ public void run() {
+ l4j.debug(this.getSessionName()+" state is now QUERY_COMPLETE.");
+ FileOutputStream fos = null;
+
+ if (this.getResultFile() != null) {
+ try {
+ fos = new FileOutputStream(new File(this.resultFile));
+ ss.out = new PrintStream(fos, true, "UTF-8");
+ } catch (java.io.FileNotFoundException fex) {
+ l4j.error(this.getSessionName()+" opening resultfile "+this.resultFile, fex);
+ } catch (java.io.UnsupportedEncodingException uex) {
+ l4j.error(this.getSessionName()+" opening resultfile "+this.resultFile, uex);
+ }
+ } else {
+ l4j.debug(this.getSessionName()+" Output file was not specified");
+ }
+
+ queryRet = qp.run(this.query);
+ Vector<String> res = new Vector<String>();
+ while (qp.getResults(res)) {
+ for (String row : res) {
+ if (ss.out != null){
+ ss.out.println(row);
+ }
+ }
+ res.clear();
+ }
+ try {
+ if (fos!= null){
+ fos.close();
+ }
+ } catch (IOException ex) {
+ l4j.error(this.getSessionName()+" closing result file "+this.getResultFile()+" caused exception." ,ex );
+ }
+ this.status = WebSessionItemStatus.QUERY_COMPLETE;
+ l4j.debug(this.getSessionName()+" state is now QUERY_COMPLETE.");
+
+ }
+
+ public int compareTo(HWISessionItem other) {
+ if (other == null)
+ return -1;
+ return this.getSessionName().compareTo(other.getSessionName());
+ }
+
+ /**
+ * Uses the sessionName property to compare to sessions
+ * @return true if sessionNames are equal false otherwise
+ */
+ public boolean equals(Object other){
+ if (other == null)
+ return false;
+ if (! (other instanceof HWISessionItem))
+ return false;
+ HWISessionItem o = (HWISessionItem) other;
+ if (this.getSessionName().equals(o.getSessionName()) ){
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ protected void setQp(Driver qp) {
+ this.qp = qp;
+ }
+
+ /**
+ * The query executed by Hive
+ * @return The query that this is executing or will be executed
+ */
+ public String getQuery() {
+ return query;
+ }
+ /**
+ * Use this function to set the query that Hive will run.
+ * @param query A query in Hive Query Language
+ */
+ public void setQuery(String query) {
+ this.query = query;
+ }
+ /**
+ * Used to determine the status of a query, possibly why it failed
+ * @return The result from Hive queryProcessor
+ */
+ public int getQueryRet() {
+ return queryRet;
+ }
+
+ protected void setQueryRet(int queryRet) {
+ this.queryRet = queryRet;
+ }
+
+ public String getResultFile() {
+ return resultFile;
+ }
+
+ public void setResultFile(String resultFile) {
+ this.resultFile = resultFile;
+ }
+ /**
+ * The session name is an identifier to recognize the session
+ * @return the sessions name
+ */
+ public String getSessionName() {
+ return sessionName;
+ }
+
+ protected void setSessionName(String sessionName) {
+ this.sessionName = sessionName;
+ }
+
+ protected SetProcessor getSp() {
+ return sp;
+ }
+
+ protected void setSp(SetProcessor sp) {
+ this.sp = sp;
+ }
+
+ protected CliSessionState getSs() {
+ return ss;
+ }
+
+ protected void setSs(CliSessionState ss) {
+ this.ss = ss;
+ }
+ /**
+ * Used to represent to the user and other components what state the HWISessionItem
+ * is in. Certain commands can only be run when the application is in certain states.
+ * @return the current status of the session
+ */
+ public WebSessionItemStatus getStatus() {
+ return status;
+ }
+
+ /**
+ * Currently unused
+ * @return a String with the full path to the error file.
+ */
+ public String getErrorFile() {
+ return errorFile;
+ }
+
+ /**
+ * Currently unused
+ * @param errorFile
+ * the full path to the file for results.
+ */
+ public void setErrorFile(String errorFile) {
+ this.errorFile = errorFile;
+ }
+
+}
Added: hadoop/hive/trunk/hwi/src/java/org/apache/hadoop/hive/hwi/HWISessionManager.java
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/hwi/src/java/org/apache/hadoop/hive/hwi/HWISessionManager.java?rev=740523&view=auto
==============================================================================
--- hadoop/hive/trunk/hwi/src/java/org/apache/hadoop/hive/hwi/HWISessionManager.java (added)
+++ hadoop/hive/trunk/hwi/src/java/org/apache/hadoop/hive/hwi/HWISessionManager.java Tue Feb 3 23:56:54 2009
@@ -0,0 +1,193 @@
+package org.apache.hadoop.hive.hwi;
+
+import java.util.*;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.hive.conf.HiveConf;
+
+/**
+ * HiveSessionManager is a Runnable started inside a web application context.
+ * It's basic function is to hold a collection of SessionItem(s). It also works
+ * as a facade, as jsp clients can not create a Hive Session directly. Hive
+ * Sessions are long lived, unlike a traditional Query and Block system clients
+ * set up the query to be started with an instance of this class.
+ *
+ */
+public class HWISessionManager implements Runnable {
+
+ protected static final Log l4j = LogFactory.getLog( HWISessionManager.class.getName() );
+
+ private boolean goOn;
+ private TreeMap<HWIAuth,Set<HWISessionItem>> items;
+
+ protected HWISessionManager() {
+ goOn = true;
+ items = new TreeMap<HWIAuth,Set<HWISessionItem>>();
+ }
+
+ /**
+ * This method scans the SessionItem collection. If a SessionItem is in the
+ * QUERY_SET state that signals that its thread should be started. If the
+ * SessionItem is in the DESTROY state it should be cleaned up and
+ * removed from the collection. Currently we are using a sleep. A
+ * wait/notify could be implemented. Queries will run for a long time, a one
+ * second wait on start will not be noticed.
+ *
+ */
+ public void run() {
+ l4j.debug("Entered run() thread has started");
+ while (goOn) {
+ l4j.debug("locking items");
+ synchronized (items) {
+
+ for (HWIAuth a: items.keySet() ){
+ for (HWISessionItem i : items.get(a)) {
+ if (i.getStatus() == HWISessionItem.WebSessionItemStatus.QUERY_SET) {
+ l4j.debug("Starting item: "+i.getSessionName());
+ i.startIt();
+ }
+ if (i.getStatus() == HWISessionItem.WebSessionItemStatus.DESTROY) {
+ items.get(a).remove(i);
+ }
+ if (i.getStatus() == HWISessionItem.WebSessionItemStatus.KILL_QUERY){
+ l4j.debug("Killing item: "+i.getSessionName());
+ i.killIt();
+ l4j.debug("Killed item: "+i.getSessionName());
+ items.get(a).remove(i);
+ }
+ }
+ }
+
+ } // end sync
+ try {
+ Thread.sleep(100);
+ } catch (InterruptedException ex) {
+ l4j.error("Could not sleep ", ex);
+ }
+ } // end while
+ l4j.debug("goOn is false. Loop has ended.");
+ // Cleanup used here to stop all threads
+ synchronized (items) {
+ for (HWIAuth a: items.keySet() ){
+ for (HWISessionItem i : items.get(a)) {
+ try {
+ if (i.getStatus()==HWISessionItem.WebSessionItemStatus.QUERY_RUNNING){
+ l4j.debug(i.getSessionName() +"Joining ");
+ i.runnable.join(1000);
+ l4j.debug(i.getSessionName() +"Joined ");
+ }
+ } catch (InterruptedException ex) {
+ l4j.error(i.getSessionName() +"while joining ",ex);
+ }
+ }
+ }
+ }
+ } // end run
+
+ protected boolean isGoOn() {
+ return goOn;
+ }
+
+ protected void setGoOn(boolean goOn) {
+ this.goOn = goOn;
+ }
+
+ protected TreeMap<HWIAuth,Set<HWISessionItem>> getItems() {
+ return items;
+ }
+
+ protected void setItems(TreeMap <HWIAuth,Set<HWISessionItem>> items) {
+ this.items = items;
+ }
+
+ // client methods called from JSP
+ /**
+ * Rather then return the actual items we return a list copies. This
+ * enforces our HWISessionManager by preventing the ability of the
+ * client(jsp) to create SessionItems.
+ *
+ * @return A set of SessionItems this framework manages
+ */
+ public Vector<HWISessionItem> findAllSessionItems() {
+ Vector<HWISessionItem> otherItems = new Vector<HWISessionItem>();
+ for (HWIAuth a:items.keySet()){
+ otherItems.addAll(items.get(a));
+ }
+ return otherItems;
+ }
+ /**
+ * Here we handle creating the SessionItem, we do this for the JSP client
+ * because we need to set parameters the client is not aware of. One such
+ * parameter is the command line arguments the server was started with.
+ * @param sessionname Represents the session name
+ * @param sessionpass the session password, can be ""
+ * @return a new SessionItem or null if a session with that name already exists
+ */
+ public HWISessionItem createSession( HWIAuth a, String sessionName ){
+
+ l4j.debug("Creating session: "+sessionName);
+
+ HWISessionItem si=null;
+
+ synchronized ( this.items) {
+ if ( findSessionItemByName(a,sessionName) == null){
+ l4j.debug("Initializing session: "+sessionName+" already exists for "+a.getUser());
+ si = new HWISessionItem();
+ si.setSessionName(sessionName);
+ si.itemInit();
+ si.runSetProcessorQuery("hadoop.job.ugi="+a.getUser()+","+a.getGroups()[0]);
+ si.runSetProcessorQuery("user.name="+a.getUser() );
+ if (! items.containsKey(a)){
+ l4j.debug("SessionList is empty " +a.getUser());
+ TreeSet<HWISessionItem> list= new TreeSet<HWISessionItem>();
+ list.add(si);
+ items.put(a,list );
+ l4j.debug("Item added "+si.getSessionName()+" for user " +a.getUser());
+ } else{
+ items.get(a).add(si);
+ l4j.debug("Item added "+si.getSessionName()+" for user " +a.getUser());
+ }
+
+ } else {
+ l4j.debug("Creating session: "+sessionName+" already exists " +a.getUser());
+ }
+ }
+ return si;
+ }
+
+ /**
+ * Helper method useful when you know the session name you wish to reference.
+ * @param sessionname
+ * @return A SessionItem matching the sessionname or null if it does not exists
+ */
+ public HWISessionItem findSessionItemByName(HWIAuth auth,String sessionname){
+ Collection<HWISessionItem> sessForUser= this.items.get(auth);
+ if (sessForUser==null){
+ return null;
+ }
+ for (HWISessionItem si : sessForUser ){
+ if (si.getSessionName().equals(sessionname)){
+ return si;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Used to list all users that have at least one session
+ * @return keySet of items all users that have any sessions
+ */
+ public Set <HWIAuth> findAllUsersWithSessions() {
+ return items.keySet();
+ }
+ /**
+ * Used to list all the sessions of a user
+ * @param auth the user being enquired about
+ * @return all the sessions of that user
+ */
+ public Set<HWISessionItem> findAllSessionsForUser(HWIAuth auth) {
+ return this.items.get(auth);
+ }
+
+}
\ No newline at end of file
Added: hadoop/hive/trunk/hwi/src/test/org/apache/hadoop/hive/hwi/TestHWISessionManager.java
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/hwi/src/test/org/apache/hadoop/hive/hwi/TestHWISessionManager.java?rev=740523&view=auto
==============================================================================
--- hadoop/hive/trunk/hwi/src/test/org/apache/hadoop/hive/hwi/TestHWISessionManager.java (added)
+++ hadoop/hive/trunk/hwi/src/test/org/apache/hadoop/hive/hwi/TestHWISessionManager.java Tue Feb 3 23:56:54 2009
@@ -0,0 +1,99 @@
+package org.apache.hadoop.hive.hwi;
+import junit.framework.TestCase;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.util.StringUtils;
+import org.apache.hadoop.hive.conf.HiveConf;
+import org.apache.hadoop.hive.hwi.HWIAuth;
+import org.apache.hadoop.hive.hwi.HWISessionItem;
+import org.apache.hadoop.hive.hwi.HWISessionManager;
+
+public class TestHWISessionManager extends TestCase {
+
+ private static String tableName="test_hwi_table";
+
+ private HiveConf conf;
+ private Path dataFilePath;
+ private HWISessionManager hsm;
+
+ public TestHWISessionManager(String name){
+ super(name);
+ conf = new HiveConf(TestHWISessionManager.class);
+ String dataFileDir = conf.get("test.data.files").replace('\\', '/').replace("c:", "");
+ dataFilePath = new Path(dataFileDir, "kv1.txt");
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ hsm = new HWISessionManager();
+ Thread t = new Thread(hsm);
+ t.start();
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ hsm.setGoOn(false);
+ }
+
+ public final void testHiveDriver() throws Exception {
+ //create a user
+ HWIAuth user1= new HWIAuth();
+ user1.setUser("hadoop");
+ user1.setGroups(new String[]{ "hadoop"});
+
+ //create two sessions for user
+ HWISessionItem user1_item1 = hsm.createSession(user1, "session1");
+ HWISessionItem user1_item2 = hsm.createSession(user1, "session2");
+
+ //create second user
+ HWIAuth user2= new HWIAuth();
+ user2.setUser("user2");
+ user2.setGroups(new String[]{ "user2"});
+
+ //create one session for this user
+ HWISessionItem user2_item1 =hsm.createSession(user2, "session1");
+
+ assertEquals( hsm.findAllSessionsForUser(user1).size(),2 );
+ assertEquals( hsm.findAllSessionsForUser(user2).size(),1 );
+ assertEquals( hsm.findAllSessionItems().size(),3);
+
+ HWISessionItem searchItem =hsm.findSessionItemByName(user1, "session1");
+ assertEquals( searchItem, user1_item1);
+
+ searchItem.setQuery("create table " + tableName + " (key int, value string)");
+ searchItem.clientStart();
+
+ //wait for the session manager to make the table it is non blocking api
+ while (searchItem.getStatus() != HWISessionItem.WebSessionItemStatus.QUERY_COMPLETE){
+ Thread.sleep(1);
+ }
+ assertEquals(searchItem.getQueryRet(),0 );
+
+ //start two queries simultaniously
+ user1_item2.setQuery("select distinct(test_hwi_table.key) from "+tableName);
+ user2_item1.setQuery("select distinct(test_hwi_table.key) from "+tableName);
+
+ user1_item2.clientStart();
+ user2_item1.clientStart();
+
+
+ while (user1_item2.getStatus() != HWISessionItem.WebSessionItemStatus.QUERY_COMPLETE ){
+ Thread.sleep(1);
+ }
+ while (user2_item1.getStatus() != HWISessionItem.WebSessionItemStatus.QUERY_COMPLETE ) {
+ Thread.sleep(1);
+ }
+
+ assertEquals(user1_item2.getQueryRet(),0);
+ assertEquals(user2_item1.getQueryRet(),0);
+
+ HWISessionItem cleanup = hsm.createSession(user1, "cleanup");
+ cleanup.setQuery("drop table " + tableName);
+ cleanup.clientStart();
+
+ while (cleanup.getStatus() != HWISessionItem.WebSessionItemStatus.QUERY_COMPLETE ){
+ Thread.sleep(1);
+ }
+
+ assertEquals(cleanup.getQueryRet(),0);
+ }
+}
Added: hadoop/hive/trunk/hwi/web/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/hwi/web/WEB-INF/web.xml?rev=740523&view=auto
==============================================================================
--- hadoop/hive/trunk/hwi/web/WEB-INF/web.xml (added)
+++ hadoop/hive/trunk/hwi/web/WEB-INF/web.xml Tue Feb 3 23:56:54 2009
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+ <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
+
+ <listener>
+ <description>Used to manage Hive Sessions</description>
+ <listener-class>org.apache.hadoop.hive.hwi.HWIContextListener</listener-class>
+ </listener>
+
+ <session-config>
+ <session-timeout>
+ 30
+ </session-timeout>
+ </session-config>
+ <welcome-file-list>
+ <welcome-file>index.jsp</welcome-file>
+ </welcome-file-list>
+</web-app>
Added: hadoop/hive/trunk/hwi/web/admin_list_jobs.jsp
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/hwi/web/admin_list_jobs.jsp?rev=740523&view=auto
==============================================================================
--- hadoop/hive/trunk/hwi/web/admin_list_jobs.jsp (added)
+++ hadoop/hive/trunk/hwi/web/admin_list_jobs.jsp Tue Feb 3 23:56:54 2009
@@ -0,0 +1,34 @@
+<%@page errorPage="error_page.jsp" %>
+<%@ page import="org.apache.hadoop.hive.hwi.*,org.apache.hadoop.hive.ql.exec.ExecDriver" %>
+<% HWIAuth auth = (HWIAuth) session.getAttribute("auth"); %>
+<% if (auth==null) { %>
+ <jsp:forward page="/authorize.jsp" />
+<% } %>
+<html>
+ <head>
+ <title>Hive Web Interface</title>
+ </head>
+ <body>
+ <table>
+ <tr>
+ <td valign="top" valign="top" width="100">
+ <jsp:include page="/left_navigation.jsp"/></td>
+ <td valign="top">
+ <h2>Hive Web Interface</h2>
+ <p>List Hive JobTracker Jobs</p>
+ <table border="1">
+ <tr>
+ <td>Job ID</td>
+ <td>Kill URL</td>
+ </tr>
+ <% for (String id: ExecDriver.runningJobKillURIs.keySet() ){ %>
+ <tr>
+ <td><%=id%></td>
+ <td><%=ExecDriver.runningJobKillURIs.get(id)%></td>
+ </tr>
+ <% } %>
+ </td>
+ </tr>
+ </table>
+ </body>
+</html>
Added: hadoop/hive/trunk/hwi/web/authorize.jsp
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/hwi/web/authorize.jsp?rev=740523&view=auto
==============================================================================
--- hadoop/hive/trunk/hwi/web/authorize.jsp (added)
+++ hadoop/hive/trunk/hwi/web/authorize.jsp Tue Feb 3 23:56:54 2009
@@ -0,0 +1,60 @@
+<%@ page import="org.apache.hadoop.hive.hwi.*" %>
+<%@page errorPage="error_page.jsp" %>
+<%
+ HWIAuth auth = (HWIAuth) session.getAttribute("auth");
+ if ( auth == null ){
+ auth = new HWIAuth();
+ auth.setUser("");
+ auth.setGroups( new String [] { "" });
+ session.setAttribute("auth", auth);
+ }
+%>
+<%
+ String user = request.getParameter("user");
+ String groups = request.getParameter("groups");
+ if (user != null){
+ auth.setUser(user);
+ auth.setGroups( groups.split("\\s+") );
+ session.setAttribute("auth", auth);
+ }
+%>
+<html>
+ <head>
+ <title>Authorize</title>
+ </head>
+ <body>
+ <table>
+ <tr>
+ <td valign="top" width="100">
+ <jsp:include page="/left_navigation.jsp"/></td>
+ <td valign="top">
+ <h2>Change User Info</h2>
+
+ <% if (request.getParameter("user")!=null){ %>
+ <font color="red"><b>Authorization is complete.</b></font>
+ <% } %>
+ <form action="authorize.jsp">
+ <table border="1">
+ <tr>
+ <td>User</td>
+ <td><input type="text" name="user" value="<%=auth.getUser()%>"></td>
+ </tr>
+ <tr>
+ <td>Groups</td>
+ <td><input type="text" name="groups" value="<%
+ for (String group:auth.getGroups() ){
+ out.print(group);
+ }
+ %>"></td>
+ </tr>
+ <tr>
+ <td colSpan="2"><input type="submit"></td>
+ </tr>
+ </table>
+ </form>
+
+ </td>
+ </tr>
+ </table>
+ </body>
+</html>
\ No newline at end of file
Added: hadoop/hive/trunk/hwi/web/diagnostics.jsp
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/hwi/web/diagnostics.jsp?rev=740523&view=auto
==============================================================================
--- hadoop/hive/trunk/hwi/web/diagnostics.jsp (added)
+++ hadoop/hive/trunk/hwi/web/diagnostics.jsp Tue Feb 3 23:56:54 2009
@@ -0,0 +1,55 @@
+<%@page contentType="text/html" pageEncoding="UTF-8"%>
+<%@page errorPage="error_page.jsp" %>
+<%@page import="java.util.*" %>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+"http://www.w3.org/TR/html4/loose.dtd">
+
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title>Diagnostics</title>
+ </head>
+ <body>
+ <table>
+ <tr>
+ <td valign="top" width="100"><jsp:include page="/left_navigation.jsp"/></td>
+ <td valign="top">
+
+ <h2>System.getProperties()</h2>
+ <table border="1">
+ <tr>
+ <td>Name</td>
+ <td>Value</td>
+ </tr>
+ <%
+ Properties p = System.getProperties();
+ for (Object o : p.keySet()) {%>
+ <tr>
+ <td><%=o%></td>
+ <td><%=p.getProperty(((String) o))%></td>
+ </tr>
+ <% }%>
+ </table>
+
+ <h2>System.getenv()</h2>
+ <table border="1">
+ <tr>
+ <td>Name</td>
+ <td>Value</td>
+ </tr>
+ <%
+ Map<String,String> env = System.getenv();
+ for (String key : env.keySet() ) {%>
+ <tr>
+ <td><%=key%></td>
+ <td><%=env.get(key)%></td>
+ </tr>
+ <% }%>
+ </table>
+
+
+ </td>
+ </tr>
+ </table>
+ </body>
+</html>
\ No newline at end of file
Added: hadoop/hive/trunk/hwi/web/error_page.jsp
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/hwi/web/error_page.jsp?rev=740523&view=auto
==============================================================================
--- hadoop/hive/trunk/hwi/web/error_page.jsp (added)
+++ hadoop/hive/trunk/hwi/web/error_page.jsp Tue Feb 3 23:56:54 2009
@@ -0,0 +1,28 @@
+<%@ page import="org.apache.hadoop.hive.hwi.*" %>
+<%@page isErrorPage="true" %>
+<html>
+ <head>
+ <title>Hive Web Interface</title>
+ </head>
+ <body>
+ <table>
+ <tr>
+ <td valign="top" valign="top" width="100">
+ <jsp:include page="/left_navigation.jsp"/></td>
+ <td valign="top">
+ <h2>Hive Web Interface</h2>
+ <p>
+ <%= exception.getClass().getName() %>
+ <br>
+ <%=exception.getMessage() %>
+ <br>
+ <% for (StackTraceElement e: exception.getStackTrace() ) { %>
+ File: <%= e.getFileName() %> Line:<%= e.getLineNumber() %> method: <%= e.getMethodName() %>
+ class: <%=e.getClassName() %> <br>
+ <% } %>
+ </p>
+ </td>
+ </tr>
+ </table>
+ </body>
+</html>
Added: hadoop/hive/trunk/hwi/web/index.jsp
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/hwi/web/index.jsp?rev=740523&view=auto
==============================================================================
--- hadoop/hive/trunk/hwi/web/index.jsp (added)
+++ hadoop/hive/trunk/hwi/web/index.jsp Tue Feb 3 23:56:54 2009
@@ -0,0 +1,26 @@
+<%@page errorPage="error_page.jsp" %>
+<%@ page import="org.apache.hadoop.hive.hwi.*" %>
+<% HWIAuth auth = (HWIAuth) session.getAttribute("auth"); %>
+<% if (auth==null) { %>
+ <jsp:forward page="/authorize.jsp" />
+<% } %>
+<html>
+ <head>
+ <title>Hive Web Interface</title>
+ </head>
+ <body>
+ <table>
+ <tr>
+ <td valign="top" valign="top" width="100">
+ <jsp:include page="/left_navigation.jsp"/></td>
+ <td valign="top">
+ <h2>Hive Web Interface</h2>
+ <p>The Hive Web Interface (HWI) offers an alternative to the command line interface (CLI). Once authenticated
+ a user can start HWIWebSessions. A HWIWebSession is roughly equal to the hive shell from the console window.
+ Users have access to the SetProcessor and QueryProcessor. After initiating a query the state is kept on the
+ web server. They can return later to view the status of the query and view any results it produced. </p>
+ </td>
+ </tr>
+ </table>
+ </body>
+</html>
Added: hadoop/hive/trunk/hwi/web/left_navigation.jsp
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/hwi/web/left_navigation.jsp?rev=740523&view=auto
==============================================================================
--- hadoop/hive/trunk/hwi/web/left_navigation.jsp (added)
+++ hadoop/hive/trunk/hwi/web/left_navigation.jsp Tue Feb 3 23:56:54 2009
@@ -0,0 +1,9 @@
+<h2>User</h2>
+<a href="authorize.jsp">Authorize</a><br>
+<a href="show_databases.jsp">Browse Schema</a><br>
+<a href="session_create.jsp">Create Session</a><br>
+<a href="diagnostics.jsp">Diagnostics</a><br>
+<a href="session_list.jsp">List Sessions</a><br>
+<br>
+<h2>Administration</h2>
+<a href="admin_list_jobs.jsp">List Running Jobs</a><br>
\ No newline at end of file
Added: hadoop/hive/trunk/hwi/web/session_create.jsp
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/hwi/web/session_create.jsp?rev=740523&view=auto
==============================================================================
--- hadoop/hive/trunk/hwi/web/session_create.jsp (added)
+++ hadoop/hive/trunk/hwi/web/session_create.jsp Tue Feb 3 23:56:54 2009
@@ -0,0 +1,60 @@
+<%@ page import="org.apache.hadoop.hive.hwi.*" %>
+<%@ page errorPage="error_page.jsp" %>
+<% HWIAuth auth = (HWIAuth) session.getAttribute("auth"); %>
+<% if (auth==null) { %>
+ <jsp:forward page="/authorize.jsp" />
+<% } %>
+
+<% HWISessionManager hs = (HWISessionManager) application.getAttribute("hs"); %>
+
+<% String sessionName=request.getParameter("sessionName"); %>
+<% String message = null; %>
+
+<%
+ if (sessionName != null){
+ if (sessionName.equals("")){
+ message="This is not a valid session name";
+ } else {
+ HWISessionItem item= hs.findSessionItemByName(auth, sessionName);
+ if (item!=null){
+ message="This name is already in use";
+ } else {
+ hs.createSession(auth,sessionName);
+ RequestDispatcher rd = application.getRequestDispatcher("/session_manage.jsp");
+ rd.forward(request,response);
+ }
+ }
+ }
+
+ if (sessionName == null){
+ sessionName="";
+ }
+%>
+
+<html>
+ <head>
+ <title>Hive Web Interface-Create a Hive Session</title>
+ </head>
+ <body>
+ <table>
+ <tr>
+ <td valign="top" valign="top" width="100">
+ <jsp:include page="/left_navigation.jsp"/></td>
+ <td valign="top">
+ <h2>Create a Hive Session</h2>
+ <form action="session_create.jsp">
+ <table border="1">
+ <tr>
+ <td>Session Name</td>
+ <td><input type="text" name="sessionName" value="<%=sessionName%>" ></td>
+ </tr>
+ <tr>
+ <td colSpan="2"><input type="submit"></td>
+ </tr>
+ </table>
+ </form>
+ </td>
+ </tr>
+ </table>
+ </body>
+</html>
\ No newline at end of file
Added: hadoop/hive/trunk/hwi/web/session_diagnostics.jsp
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/hwi/web/session_diagnostics.jsp?rev=740523&view=auto
==============================================================================
--- hadoop/hive/trunk/hwi/web/session_diagnostics.jsp (added)
+++ hadoop/hive/trunk/hwi/web/session_diagnostics.jsp Tue Feb 3 23:56:54 2009
@@ -0,0 +1,51 @@
+<%@page contentType="text/html" pageEncoding="UTF-8" %>
+<%@page errorPage="error_page.jsp" %>
+<%@page import="org.apache.hadoop.hive.hwi.*" %>
+<%@page import="org.apache.hadoop.hive.conf.*" %>
+<%@page import="java.util.*" %>
+
+<% HWISessionManager hs = (HWISessionManager) application.getAttribute("hs"); %>
+<% if (hs == null) { %>
+ <jsp:forward page="error.jsp">
+ <jsp:param name="message" value="Hive Session Manager Not Found" />
+ </jsp:forward>
+<% } %>
+
+<% HWIAuth auth = (HWIAuth) session.getAttribute("auth"); %>
+<% if (auth==null) { %>
+ <jsp:forward page="/authorize.jsp" />
+<% } %>
+<% String sessionName = request.getParameter("sessionName"); %>
+<% HWISessionItem si = hs.findSessionItemByName(auth,sessionName); %>
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title>Session Diagnostics</title>
+ </head>
+ <body>
+ <table>
+ <tr>
+ <td valign="top"><jsp:include page="left_navigation.jsp"/></td>
+ <td valign="top">
+ <h2>Session Diagnostics</h2>
+
+ <% if (si!=null) { %>
+ <table border="1">
+ <tr>
+ <td>Var Name</td>
+ <td>Var Value</td>
+ </tr>
+ <% for (HiveConf.ConfVars var : HiveConf.ConfVars.values() ){ %>
+ <tr>
+ <td><%=var.name()%></td>
+ <td><%=si.getHiveConfVar(var)%></td>
+ </tr>
+ <% } %>
+ </table>
+ <% } %>
+
+ </td>
+ </tr>
+ </table>
+ </body>
+</html>
Added: hadoop/hive/trunk/hwi/web/session_kill.jsp
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/hwi/web/session_kill.jsp?rev=740523&view=auto
==============================================================================
--- hadoop/hive/trunk/hwi/web/session_kill.jsp (added)
+++ hadoop/hive/trunk/hwi/web/session_kill.jsp Tue Feb 3 23:56:54 2009
@@ -0,0 +1,39 @@
+<%@ page import="org.apache.hadoop.hive.hwi.*" %>
+<%@ page errorPage="error_page.jsp" %>
+<% HWIAuth auth = (HWIAuth) session.getAttribute("auth"); %>
+<% if (auth==null) { %>
+ <jsp:forward page="/authorize.jsp" />
+<% } %>
+<% HWISessionManager hs = (HWISessionManager) application.getAttribute("hs"); %>
+<% String sessionName=request.getParameter("sessionName"); %>
+<% String message=null; %>
+<%
+ if (request.getParameter("confirm")!=null){
+ HWISessionItem i = hs.findSessionItemByName(auth,sessionName);
+ i.clientKill();
+ message="Query will be killed";
+ }
+%>
+<html>
+ <head>
+ <title>Hive Web Interface</title>
+ </head>
+ <body>
+ <table>
+ <tr>
+ <td valign="top" valign="top" width="100">
+ <jsp:include page="/left_navigation.jsp"/></td>
+ <td valign="top">
+ <h2>Hive Web Interface</h2>
+ <% if (message!=null){ %><font color="red"><%=message%></font><% } %>
+ <br>
+ <form action="session_kill.jsp">
+ <input type="hidden" name="sessionName" value="<%=sessionName%>">
+ Are you sure you want to kill this session?
+ <input type="submit" name="confirm" value="yes">
+ </form>
+ </td>
+ </tr>
+ </table>
+ </body>
+</html>
Added: hadoop/hive/trunk/hwi/web/session_list.jsp
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/hwi/web/session_list.jsp?rev=740523&view=auto
==============================================================================
--- hadoop/hive/trunk/hwi/web/session_list.jsp (added)
+++ hadoop/hive/trunk/hwi/web/session_list.jsp Tue Feb 3 23:56:54 2009
@@ -0,0 +1,48 @@
+<%@ page import="org.apache.hadoop.hive.hwi.*" %>
+<%@page errorPage="error_page.jsp" %>
+<% HWISessionManager hs = (HWISessionManager) application.getAttribute("hs"); %>
+<% if (hs == null) { %>
+ <jsp:forward page="error.jsp">
+ <jsp:param name="message" value="Hive Session Manager Not Found" />
+ </jsp:forward>
+<% } %>
+
+<% HWIAuth auth = (HWIAuth) session.getAttribute("auth"); %>
+<% if (auth==null) { %>
+ <jsp:forward page="/authorize.jsp" />
+<% } %>
+
+<html>
+ <head>
+ <title>Session List</title>
+ </head>
+ <body>
+ <table>
+ <tr>
+ <td valign="top" valign="top" width="100">
+ <jsp:include page="left_navigation.jsp"/></td>
+ <td valign="top">
+ <h2>Session List</h2>
+
+ <table border="1">
+ <tr>
+ <td>Name</td>
+ <td>Status</td>
+ <td>Action</td>
+ </tr>
+ <% if ( hs.findAllSessionsForUser(auth)!=null){ %>
+ <% for (HWISessionItem item: hs.findAllSessionsForUser(auth) ){ %>
+ <tr>
+ <td><%=item.getSessionName()%></td>
+ <td><%=item.getStatus()%></td>
+ <td><a href="/hwi/session_manage.jsp?sessionName=<%=item.getSessionName()%>">Manager</a></td>
+ </tr>
+ <% } %>
+ <% } %>
+ </table>
+ </td>
+ </tr>
+ </table>
+ </body>
+</html>
+
Added: hadoop/hive/trunk/hwi/web/session_manage.jsp
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/hwi/web/session_manage.jsp?rev=740523&view=auto
==============================================================================
--- hadoop/hive/trunk/hwi/web/session_manage.jsp (added)
+++ hadoop/hive/trunk/hwi/web/session_manage.jsp Tue Feb 3 23:56:54 2009
@@ -0,0 +1,150 @@
+<%@page import="org.apache.hadoop.hive.hwi.*" %>
+<%@page errorPage="error_page.jsp" %>
+<% HWISessionManager hs = (HWISessionManager) application.getAttribute("hs");; %>
+
+<% HWIAuth auth = (HWIAuth) session.getAttribute("auth"); %>
+<% if (auth==null) { %>
+ <jsp:forward page="/authorize.jsp" />
+<% } %>
+<% String sessionName=request.getParameter("sessionName"); %>
+<% HWISessionItem sess = hs.findSessionItemByName(auth,sessionName); %>
+<% String message=null; %>
+<%
+ String errorFile=request.getParameter("errorFile");
+ String resultFile=request.getParameter("resultFile");
+ String query = request.getParameter("query");
+ String silent = request.getParameter("silent");
+ String start = request.getParameter("start");
+%>
+<%
+ if (request.getParameter("start")!=null ){
+ if ( sess.getStatus()!=HWISessionItem.WebSessionItemStatus.QUERY_RUNNING){
+ sess.setErrorFile(errorFile);
+ sess.setResultFile(resultFile);
+ sess.setQuery(query);
+
+ if (query.length()==0){
+ message="You did not specify a query";
+ start="NO";
+ }
+
+ if (silent.equalsIgnoreCase("YES") )
+ sess.setSSIsSilent(true);
+ else
+ sess.setSSIsSilent(false);
+
+ message="Changes accepted.";
+ if (start.equalsIgnoreCase("YES") ){
+ sess.clientStart();
+ message="Session is set to start.";
+ }
+ }
+ }
+%>
+
+<html>
+ <head>
+ <title>Manage Session <%=sessionName%></title>
+ </head>
+ <body>
+ <table>
+ <tr>
+ <td valign="top" valign="top" width="100">
+ <jsp:include page="/left_navigation.jsp"/>
+ </td>
+ <td valign="top">
+ <h2>Manage Session <%=sessionName%></h2>
+
+ <% if (message != null) { %> <font color="red"><%=message %></font> <% } %>
+ <br>
+ <% if (sess.getStatus()==HWISessionItem.WebSessionItemStatus.QUERY_RUNNING) { %>
+ <font color="RED">Session is in QUERY_RUNNING state. Changes are not possible!</font>
+ <% } %>
+ <br>
+
+ <% if (sess.getStatus()==HWISessionItem.WebSessionItemStatus.QUERY_RUNNING){ %>
+ <%--
+ View JobTracker: <a href="<%= sess.getJobTrackerURI() %>">View Job</a><br>
+ Kill Command: <%= sess.getKillCommand() %>
+ Session Kill: <a href="/hwi/session_kill.jsp?sessionName=<%=sessionName%>"><%=sessionName%></a><br>
+ --%>
+ <% } %>
+
+
+ Session Diagnostics: <a href="/hwi/session_diagnostics.jsp?sessionName=<%=sessionName%>"><%=sessionName%></a><br>
+ Set Processor: <a href="/hwi/set_processor.jsp?sessionName=<%=sessionName%>"><%=sessionName%></a><br>
+ Session Remove: <a href="/hwi/session_remove.jsp?sessionName=<%=sessionName%>"><%=sessionName%></a><br>
+ <br>
+
+ <form action="session_manage.jsp">
+ <input type="hidden" name="sessionName" value="<%=sessionName %>">
+ <table>
+ <tr>
+ <td>Result File</td>
+ <td>
+ <input type="text" name="resultFile" value="<%
+ if (sess.getResultFile()==null) { out.print(""); } else { out.print(sess.getResultFile()); }
+ %>"><br>
+ <% if (sess.getResultFile()!=null) { %>
+ <a href="/hwi/view_file.jsp?sessionName=<%=sessionName%>">View File</a>
+ <% } %>
+ </td>
+ </tr>
+
+ <tr>
+ <td>Error File</td>
+ <td>
+ <input type="text" name="errorFile" value="<%
+ if (sess.getErrorFile()==null) { out.print(""); } else { out.print(sess.getErrorFile()); }
+ %>"></td>
+ </tr>
+
+ <tr>
+ <td>Query</td>
+ <td><textarea name="query" rows="8" cols="30"><%
+ if (sess.getQuery()==null) { out.print(""); } else { out.print(sess.getQuery()); }
+ %></textarea></td>
+ </tr>
+
+ <tr>
+ <td>Silent Mode ?</td>
+ <td><select name="silent">
+ <option value="YES"
+ <% if (sess.getSSIsSilent()==true) { out.print("SELECTED=\"TRUE\""); } %>
+ >YES</option>
+ <option value="NO"
+ <% if (sess.getSSIsSilent()==false) { out.print("SELECTED=\"TRUE\""); } %>
+ >NO</option>
+ </select>
+ </td>
+ </tr>
+
+ <tr>
+ <td>Start Query?</td>
+ <td><select name="start">
+ <option value="NO" SELECTED="TRUE">NO</option>
+ <option value="YES" >YES</option>
+ </select>
+ </td>
+ </tr>
+
+ <tr>
+ <td>Query Return Code</td>
+ <td><%=sess.getQueryRet() %></td>
+ </tr>
+ <tr>
+ <td colSpan="2">
+ <% if (sess.getStatus()==HWISessionItem.WebSessionItemStatus.QUERY_RUNNING) { %>
+ <font color="RED">Session is in QUERY_RUNNING state. Changes are not possible!</font>
+ <% } else { %>
+ <input type="submit">
+ <% } %>
+ </td>
+ </tr>
+ </table>
+ </form>
+ </td>
+ </tr>
+ </table>
+ </body>
+</html>
\ No newline at end of file
Added: hadoop/hive/trunk/hwi/web/session_remove.jsp
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/hwi/web/session_remove.jsp?rev=740523&view=auto
==============================================================================
--- hadoop/hive/trunk/hwi/web/session_remove.jsp (added)
+++ hadoop/hive/trunk/hwi/web/session_remove.jsp Tue Feb 3 23:56:54 2009
@@ -0,0 +1,44 @@
+<%@ page import="org.apache.hadoop.hive.hwi.*" %>
+<%@ page errorPage="error_page.jsp" %>
+<% HWIAuth auth = (HWIAuth) session.getAttribute("auth"); %>
+<% if (auth==null) { %>
+ <jsp:forward page="/authorize.jsp" />
+<% } %>
+<% HWISessionManager hs = (HWISessionManager) application.getAttribute("hs"); %>
+<% String sessionName=request.getParameter("sessionName"); %>
+<% String message=null; %>
+<%
+ if (request.getParameter("confirm")!=null){
+ HWISessionItem i = hs.findSessionItemByName(auth,sessionName);
+ if (i.getStatus() == HWISessionItem.WebSessionItemStatus.QUERY_COMPLETE ||
+ i.getStatus() == HWISessionItem.WebSessionItemStatus.NEW){
+ hs.findAllSessionsForUser(auth).remove(i);
+ message="Session removed";
+ } else {
+ message="Session could not be removed";
+ }
+ }
+%>
+<html>
+ <head>
+ <title>Hive Web Interface</title>
+ </head>
+ <body>
+ <table>
+ <tr>
+ <td valign="top" valign="top" width="100">
+ <jsp:include page="/left_navigation.jsp"/></td>
+ <td valign="top">
+ <h2>Hive Web Interface</h2>
+ <% if (message!=null){ %><font color="red"><%=message%></font><% } %>
+ <br>
+ <form action="session_remove.jsp">
+ <input type="hidden" name="sessionName" value="<%=sessionName%>">
+ Are you sure you want to remove this session?
+ <input type="submit" name="confirm" value="yes">
+ </form>
+ </td>
+ </tr>
+ </table>
+ </body>
+</html>
Added: hadoop/hive/trunk/hwi/web/set_processor.jsp
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/hwi/web/set_processor.jsp?rev=740523&view=auto
==============================================================================
--- hadoop/hive/trunk/hwi/web/set_processor.jsp (added)
+++ hadoop/hive/trunk/hwi/web/set_processor.jsp Tue Feb 3 23:56:54 2009
@@ -0,0 +1,57 @@
+<%@page contentType="text/html" pageEncoding="UTF-8" %>
+<%@page errorPage="error_page.jsp" %>
+<%@page import="org.apache.hadoop.hive.hwi.*" %>
+<%@page import="org.apache.hadoop.hive.conf.*" %>
+<%@page import="java.util.*" %>
+<% HWISessionManager hs = (HWISessionManager) application.getAttribute("hs"); %>
+
+<% HWIAuth auth = (HWIAuth) session.getAttribute("auth"); %>
+<% if (auth==null) { %>
+ <jsp:forward page="/authorize.jsp" />
+<% } %>
+
+
+<% String sessionName = request.getParameter("sessionName"); %>
+<% HWISessionItem sess = hs.findSessionItemByName(auth,sessionName); %>
+
+<%
+String setquery= request.getParameter("setquery");
+String setaction= request.getParameter("setaction");
+String message = null;
+if (setaction != null){
+ int ret = sess.runSetProcessorQuery(setquery);
+ message =" Action taken "+ret;
+}
+%>
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title>HWI Set Processor</title>
+ </head>
+ <body>
+ <% if (message !=null){ %>
+ <font color="red"><b><%=message%></b></font>
+ <% } %>
+ <table>
+ <tr>
+ <td valign="top" width="100"><jsp:include page="/left_navigation.jsp"/></td>
+ <td valign="top">
+ <form action="set_processor.jsp">
+ <table border="1">
+ <tr>
+ <td>Set Query</td>
+ <td><input type="text" name="setquery"></td>
+ </tr>
+ <tr>
+ <td colspan="2">
+ <input type="hidden" name="sessionName" value="<%=sessionName%>">
+ <input type="submit" name="setaction" value="setaction"></td>
+ </tr>
+ </table>
+ </form>
+
+ </td>
+ </tr>
+ </table>
+ </body>
+</html>
\ No newline at end of file
Added: hadoop/hive/trunk/hwi/web/show_database.jsp
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/hwi/web/show_database.jsp?rev=740523&view=auto
==============================================================================
--- hadoop/hive/trunk/hwi/web/show_database.jsp (added)
+++ hadoop/hive/trunk/hwi/web/show_database.jsp Tue Feb 3 23:56:54 2009
@@ -0,0 +1,45 @@
+<% String db = request.getParameter("db"); %>
+<%@page errorPage="error_page.jsp" %>
+<jsp:include page="/include/session_credentials.jsp" />
+<%@page import="org.apache.hadoop.hive.metastore.*,
+org.apache.hadoop.hive.metastore.api.*,
+org.apache.hadoop.hive.conf.HiveConf,
+org.apache.hadoop.hive.ql.session.SessionState,
+java.util.*,
+org.apache.hadoop.hive.ql.*,
+org.apache.hadoop.hive.cli.*" %>
+<%@page contentType="text/html" pageEncoding="UTF-8"%>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+ "http://www.w3.org/TR/html4/loose.dtd">
+<%
+ HiveConf hiveConf = new HiveConf(SessionState.class);
+ HiveMetaStoreClient client = new HiveMetaStoreClient(hiveConf);
+ Database db2 = client.getDatabase("default");
+ List<String> tables = client.getTables(".*");
+ client.close();
+%>
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title>HWI Hive Web Interface</title>
+ </head>
+ <body>
+ <table>
+ <tr>
+ <td valign="top"><jsp:include page="/left_navigation.jsp"/></td>
+ <td valign="top">
+ <h2><%= db%> Table List </h2>
+ Name: <%= db2.getName()%><br>
+ Description: <%= db2.getDescription()%><br>
+
+ <table border="1">
+ <% for (String table : tables){ %>
+ <tr><td><a href="/hwi/show_table.jsp?db=<%=db%>&table=<%=table%>"><%=table%></a></td></tr>
+ <% } %>
+ </table>
+
+ </td>
+ </tr>
+ </table>
+ </body>
+</html>
\ No newline at end of file
Added: hadoop/hive/trunk/hwi/web/show_databases.jsp
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/hwi/web/show_databases.jsp?rev=740523&view=auto
==============================================================================
--- hadoop/hive/trunk/hwi/web/show_databases.jsp (added)
+++ hadoop/hive/trunk/hwi/web/show_databases.jsp Tue Feb 3 23:56:54 2009
@@ -0,0 +1,39 @@
+<%@page import="org.apache.hadoop.hive.metastore.*,
+org.apache.hadoop.hive.metastore.api.*,
+org.apache.hadoop.hive.conf.HiveConf,
+org.apache.hadoop.hive.ql.session.SessionState,
+java.util.*,
+org.apache.hadoop.hive.ql.*,
+org.apache.hadoop.hive.cli.*" %>
+<%@page errorPage="error_page.jsp" %>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+"http://www.w3.org/TR/html4/loose.dtd">
+<%
+ HiveConf hiveConf = new HiveConf(SessionState.class);
+ HiveMetaStoreClient client = new HiveMetaStoreClient(hiveConf);
+ List <String> dbs = client.getDatabases();
+ client.close();
+%>
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title>HWI Hive Web Interface-Schema Browser</title>
+ </head>
+ <body>
+ <table>
+ <tr>
+ <td valign="top"><jsp:include page="/left_navigation.jsp"/></td>
+ <td valign="top">
+
+ <h2>Database List</h2>
+ <table border="1">
+ <% for (String db : dbs) { %>
+ <tr><td><a href="/hwi/show_database.jsp?db=<%=db%>"><%=db%></a>
+ </td></tr>
+ <% } %>
+ </table>
+ </td>
+ </tr>
+ </table>
+ </body>
+</html>
Added: hadoop/hive/trunk/hwi/web/show_table.jsp
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/hwi/web/show_table.jsp?rev=740523&view=auto
==============================================================================
--- hadoop/hive/trunk/hwi/web/show_table.jsp (added)
+++ hadoop/hive/trunk/hwi/web/show_table.jsp Tue Feb 3 23:56:54 2009
@@ -0,0 +1,132 @@
+<%@page contentType="text/html" pageEncoding="UTF-8"%>
+<%@page errorPage="error_page.jsp" %>
+<%@page import="java.util.*" %>
+<jsp:include page="/include/session_credentials.jsp" />
+<%@page import="org.apache.hadoop.hive.metastore.*,
+org.apache.hadoop.hive.metastore.api.*,
+org.apache.hadoop.hive.conf.HiveConf,
+org.apache.hadoop.hive.ql.session.SessionState,
+java.util.*,
+org.apache.hadoop.hive.ql.*,
+org.apache.hadoop.hive.cli.*" %>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+"http://www.w3.org/TR/html4/loose.dtd">
+<%
+ String db= request.getParameter("db");
+ String table= request.getParameter("table");
+
+ HiveConf hiveConf = new HiveConf(SessionState.class);
+ HiveMetaStoreClient client = new HiveMetaStoreClient(hiveConf);
+ org.apache.hadoop.hive.metastore.api.Table t = client.getTable(db, table);
+ StorageDescriptor sd = t.getSd();
+ List<String> bcols = sd.getBucketCols();
+ List<FieldSchema> fsc = sd.getCols();
+ List<Order> ord = sd.getSortCols();
+ Partition p = null;//How do we get this info?
+%>
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title>HWI Hive Web Interface-Schema Browser</title>
+ </head>
+ <body>
+ <table>
+ <tr>
+ <td valign="top"><jsp:include page="/left_navigation.jsp"/></td>
+ <td valign="top">
+
+ <h2><%=table%></h2>
+ ColsSize: <%= sd.getColsSize()%> <br>
+ Input Format: <%= sd.getInputFormat() %><br>
+ Output Format: <%= sd.getOutputFormat() %><br>
+ Is Compressed?: <%= sd.isCompressed() %><br>
+ Location: <%= sd.getLocation() %> <br>
+ Number Of Buckets: <%= sd.getNumBuckets() %><br>
+
+ <h2>Field Schema</h2>
+ <table border="1">
+ <tr>
+ <td>Name</td>
+ <td>Type</td>
+ <td>Comment</td>
+ </tr>
+ <% for (FieldSchema fs: fsc ) {%>
+ <tr>
+ <td><%=fs.getName() %></td>
+ <td><%=fs.getType() %></td>
+ <td><%=fs.getComment() %></td>
+ </tr>
+ <% } %>
+ </table>
+
+ <table border="1">
+ <tr><td>Bucket Columns</td></tr>
+ <% for (String col: bcols ) {%>
+ <tr><td><%=col%></td></tr>
+ <% } %>
+ </table>
+
+ <h2>Sort Columns</h2>
+ <table border="1">
+ <tr>
+ <td>Column</td>
+ <td>Order</td>
+ </tr>
+ <% for (Order o: ord ) {%>
+ <tr>
+ <td><%= o.getCol() %></td>
+ <td><%= o.getOrder() %></td>
+ </tr>
+ <% } %>
+ </table>
+ <h2>Parameters</h2>
+ <table border="1">
+ <tr>
+ <td>Name</td>
+ <td>Value</td>
+ </tr>
+ <% for ( String key: sd.getParameters().keySet() ){ %>
+ <tr>
+ <td><%=key%></td>
+ <td><%=sd.getParameters().get(key)%></td>
+ </tr>
+ <% } %>
+ </table>
+
+ <h2>SerDe Info</h2>
+ <% SerDeInfo si = sd.getSerdeInfo(); %>
+ Name:<%= si.getName() %><br>
+ Lib: <%= si.getSerializationLib() %><br>
+ <table border="1">
+ <tr>
+ <td>Name</td>
+ <td>value</td>
+ </tr>
+ <% for (String key: si.getParameters().keySet() ) { %>
+ <tr>
+ <td><%= key %></td>
+ <td><%= si.getParameters().get(key) %></td>
+ </tr>
+ <% } %>
+ </table>
+
+ <h2>Partition Information</h2>
+ <table border="1">
+ <tr>
+ <td>Name</td>
+ <td>Type</td>
+ <td>Comment</td>
+ </tr>
+ <% for (FieldSchema fieldSchema: t.getPartitionKeys() ){ %>
+ <tr>
+ <td><%= fieldSchema.getName() %></td>
+ <td><%= fieldSchema.getType() %></td>
+ <td><%= fieldSchema.getComment() %></td>
+ </tr>
+ <% } %>
+ </td>
+ </tr>
+ </table>
+ </body>
+</html>
+<% client.close(); %>
\ No newline at end of file
Added: hadoop/hive/trunk/hwi/web/view_file.jsp
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/hwi/web/view_file.jsp?rev=740523&view=auto
==============================================================================
--- hadoop/hive/trunk/hwi/web/view_file.jsp (added)
+++ hadoop/hive/trunk/hwi/web/view_file.jsp Tue Feb 3 23:56:54 2009
@@ -0,0 +1,55 @@
+<%@page errorPage="error_page.jsp" %>
+<%@ page import="org.apache.hadoop.hive.hwi.*,java.io.*" %>
+<% HWIAuth auth = (HWIAuth) session.getAttribute("auth"); %>
+<% HWISessionManager hs = (HWISessionManager) application.getAttribute("hs"); %>
+<% if (auth==null) { %>
+ <jsp:forward page="/authorize.jsp" />
+<% } %>
+<% String sessionName=request.getParameter("sessionName"); %>
+<% HWISessionItem sess = hs.findSessionItemByName(auth,sessionName); %>
+<% int start=0;
+ if (request.getParameter("start")!=null){
+ start = Integer.parseInt( request.getParameter("start") );
+ }
+%>
+<% int bsize=1024;
+ if (request.getParameter("bsize")!=null){
+ bsize = Integer.parseInt( request.getParameter("bsize") );
+ }
+%>
+
+<html>
+ <head>
+ <title>Hive Web Interface</title>
+ </head>
+ <body>
+ <table>
+ <tr>
+ <td valign="top" valign="top" width="100">
+ <jsp:include page="/left_navigation.jsp"/></td>
+ <td valign="top">
+ <h2>Hive Web Interface</h2>
+ <p><%=sess.getResultFile() %></p>
+ <textarea rows="8" cols="40"><%
+ File f = new File( sess.getResultFile() );
+ BufferedReader br = new BufferedReader( new FileReader(f) );
+ br.skip(start*bsize);
+
+ char [] c = new char [bsize] ;
+ int cread=-1;
+
+ if( ( cread=br.read(c)) != -1 ){
+ out.println( c );
+ }
+ br.close();
+ %></textarea>
+ <br>
+ <% long numberOfBlocks = f.length()/ (long)bsize;%>
+ This file contains <%=numberOfBlocks%> of <%=bsize%> blocks.
+
+ <a href="/hwi/view_file.jsp?sessionName=<%=sessionName%>&start=<%=(start+1) %>&bsize=<%=bsize %>">Next Block</a>
+ </td>
+ </tr>
+ </table>
+ </body>
+</html>