org.apache.hadoop.hive.hwi
Class HWISessionItem

java.lang.Object
  extended by org.apache.hadoop.hive.hwi.HWISessionItem
All Implemented Interfaces:
Comparable<HWISessionItem>, Runnable

public class HWISessionItem
extends Object
implements Runnable, Comparable<HWISessionItem>

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.


Nested Class Summary
static class HWISessionItem.WebSessionItemStatus
          Represents the state a session item can be in.
 
Field Summary
protected static org.apache.commons.logging.Log l4j
           
 
Constructor Summary
protected HWISessionItem()
          Creates an instance of WebSessionItem, sets status to NEW.
 
Method Summary
 void clientKill()
           
 void clientRenew()
          This method clears the private member variables.
 void clientStart()
          HWISessionItem is a Runnable instance.
 int compareTo(HWISessionItem other)
           
 boolean equals(Object other)
          Uses the sessionName property to compare to sessions
 HWIAuth getAuth()
           
 String getErrorFile()
          Currently unused
 HiveHistoryViewer getHistoryViewer()
           
 String getHiveConfVar(HiveConf.ConfVars wanted)
          Helper function to get configuration variables
 String getQuery()
          The query executed by Hive
 int getQueryRet()
          Used to determine the status of a query, possibly why it failed
 String getResultFile()
           
 String getSessionName()
          The session name is an identifier to recognize the session
protected  SetProcessor getSp()
           
protected  CliSessionState getSs()
           
 boolean getSSIsSilent()
          This is a chained call to SessionState.getIsSilent()
 HWISessionItem.WebSessionItemStatus getStatus()
          Used to represent to the user and other components what state the HWISessionItem is in.
protected  void itemInit()
          This is the initialization process that is carried out for each SessionItem.
protected  void killIt()
          This is a callback style function used by the HiveSessionManager.
 void run()
           
 void runQuery()
          This method calls the qp.run() method, writes the output to the result file, when finished the status will be QUERY_COMPLETE.
 int runSetProcessorQuery(String query)
          Set processor queries block for only a short amount of time.
protected  void setAuth(HWIAuth auth)
           
 void setErrorFile(String errorFile)
          Currently unused
protected  void setQp(Driver qp)
           
 void setQuery(String query)
          Use this function to set the query that Hive will run.
protected  void setQueryRet(int queryRet)
           
 void setResultFile(String resultFile)
           
protected  void setSessionName(String sessionName)
           
protected  void setSp(SetProcessor sp)
           
protected  void setSs(CliSessionState ss)
           
 void setSSIsSilent(boolean silent)
          This is a chained call to SessionState.setIsSilent().
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

l4j

protected static final org.apache.commons.logging.Log l4j
Constructor Detail

HWISessionItem

protected HWISessionItem()
Creates an instance of WebSessionItem, sets status to NEW.

Method Detail

itemInit

protected void itemInit()
This is the initialization process that is carried out for each SessionItem. The goal is to emulate the startup of CLIDriver.


runSetProcessorQuery

public int runSetProcessorQuery(String query)
Set processor queries block for only a short amount of time. The client can issue these directly.

Parameters:
query - This is a query in the form of SET THIS=THAT
Returns:
chained call to setProcessor.run(String)

clientStart

public void clientStart()
                 throws HWIException
HWISessionItem is a Runnable instance. Calling this method will change the status to QUERY_SET and notify(). The run method detects this and then continues processing.

Throws:
HWIException

clientKill

public void clientKill()
                throws HWIException
Throws:
HWIException

clientRenew

public void clientRenew()
                 throws HWIException
This method clears the private member variables.

Throws:
HWIException

setSSIsSilent

public void setSSIsSilent(boolean silent)
                   throws HWIException
This is a chained call to SessionState.setIsSilent(). Use this if you do not want the result file to have information status

Throws:
HWIException

getSSIsSilent

public boolean getSSIsSilent()
                      throws HWIException
This is a chained call to SessionState.getIsSilent()

Throws:
HWIException

killIt

protected void killIt()
This is a callback style function used by the HiveSessionManager. The HiveSessionManager notices this and attempts to stop the query.


getHiveConfVar

public String getHiveConfVar(HiveConf.ConfVars wanted)
                      throws HWIException
Helper function to get configuration variables

Parameters:
wanted - a ConfVar
Returns:
Value of the configuration variable.
Throws:
HWIException

run

public void run()
Specified by:
run in interface Runnable

runQuery

public void runQuery()
This method calls the qp.run() method, writes the output to the result file, when finished the status will be QUERY_COMPLETE.


compareTo

public int compareTo(HWISessionItem other)
Specified by:
compareTo in interface Comparable<HWISessionItem>

getHistoryViewer

public HiveHistoryViewer getHistoryViewer()
                                   throws HWIException
Returns:
the HiveHistoryViewer for the session
Throws:
HWIException

equals

public boolean equals(Object other)
Uses the sessionName property to compare to sessions

Overrides:
equals in class Object
Returns:
true if sessionNames are equal false otherwise

setQp

protected void setQp(Driver qp)

getQuery

public String getQuery()
The query executed by Hive

Returns:
The query that this is executing or will be executed

setQuery

public void setQuery(String query)
Use this function to set the query that Hive will run.

Parameters:
query - A query in Hive Query Language

getQueryRet

public int getQueryRet()
Used to determine the status of a query, possibly why it failed

Returns:
The result from Hive queryProcessor

setQueryRet

protected void setQueryRet(int queryRet)

getResultFile

public String getResultFile()

setResultFile

public void setResultFile(String resultFile)

getSessionName

public String getSessionName()
The session name is an identifier to recognize the session

Returns:
the session's name

setSessionName

protected void setSessionName(String sessionName)

getSp

protected SetProcessor getSp()

setSp

protected void setSp(SetProcessor sp)

getSs

protected CliSessionState getSs()

setSs

protected void setSs(CliSessionState ss)

getStatus

public HWISessionItem.WebSessionItemStatus getStatus()
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.

Returns:
the current status of the session

getErrorFile

public String getErrorFile()
Currently unused

Returns:
a String with the full path to the error file.

setErrorFile

public void setErrorFile(String errorFile)
Currently unused

Parameters:
errorFile - the full path to the file for results.

getAuth

public HWIAuth getAuth()
Returns:
the auth

setAuth

protected void setAuth(HWIAuth auth)
Parameters:
auth - the auth to set


Copyright © 2009 The Apache Software Foundation