org.apache.hadoop.hive.ql.session
Class SessionState

java.lang.Object
  extended by org.apache.hadoop.hive.ql.session.SessionState
Direct Known Subclasses:
CliSessionState

public class SessionState
extends Object

SessionState encapsulates common data associated with a session. Also provides support for a thread static session object that can be accessed from any point in the code to interact with the user and to retrieve configuration information


Nested Class Summary
static class SessionState.LogHelper
          This class provides helper routines to emit informational and error messages to the user and log4j files while obeying the current session's verbosity levels.
static interface SessionState.ResourceHook
          ResourceHook.
static class SessionState.ResourceType
          ResourceType.
 
Field Summary
 PrintStream childErr
          Error output from any child process(es).
 PrintStream childOut
          Standard output from any child process(es).
protected  HiveConf conf
          current configuration.
 PrintStream err
           
protected  HiveHistory hiveHist
           
 InputStream in
          Streams to read/write from.
 PrintStream info
           
protected  boolean isSilent
          silent mode.
protected  boolean isVerbose
          verbose mode
 PrintStream out
           
protected  File tmpOutputFile
          Temporary file name used to store results of non-Hive commands (e.g., set, dfs) and HiveServer.fetch*() function will read results from this file
 
Constructor Summary
SessionState()
           
SessionState(HiveConf conf)
           
 
Method Summary
 void add_builtin_resource(SessionState.ResourceType t, String value)
           
 String add_resource(SessionState.ResourceType t, String value)
           
 String add_resource(SessionState.ResourceType t, String value, boolean convertToUnix)
           
 void addLocalMapRedErrors(String id, List<String> localMapRedErrors)
           
static boolean canDownloadResource(String value)
          Returns true if it is from any external File Systems except local
 void delete_resource(SessionState.ResourceType t)
           
 boolean delete_resource(SessionState.ResourceType t, String value)
           
static SessionState.ResourceType find_resource_type(String s)
           
static SessionState get()
          get the current session.
 HiveAuthenticationProvider getAuthenticator()
           
 HiveAuthorizationProvider getAuthorizer()
           
 String getCmd()
           
 String getCommandType()
           
 HiveConf getConf()
           
static SessionState.LogHelper getConsole()
          initialize or retrieve console object for SessionState.
 CreateTableAutomaticGrant getCreateTableGrants()
           
 HiveHistory getHiveHistory()
          get hiveHitsory object which does structured logging.
 HiveOperation getHiveOperation()
           
 Map<String,String> getHiveVariables()
           
 boolean getIsSilent()
           
 boolean getIsVerbose()
           
 List<MapRedStats> getLastMapRedStatsList()
           
 LineageState getLineageState()
          Get the lineage state stored in this session.
 Map<String,List<String>> getLocalMapRedErrors()
           
 Map<String,String> getOverriddenConfigurations()
           
 String getQueryId()
           
 String getSessionId()
           
 Map<String,List<List<String>>> getStackTraces()
           
 File getTmpOutputFile()
           
 Set<String> list_resource(SessionState.ResourceType t, List<String> filter)
           
static boolean registerJar(String newJar)
           
 void setAuthenticator(HiveAuthenticationProvider authenticator)
           
 void setAuthorizer(HiveAuthorizationProvider authorizer)
           
 void setCmd(String cmdString)
           
 void setCommandType(HiveOperation commandType)
           
 void setConf(HiveConf conf)
           
 void setCreateTableGrants(CreateTableAutomaticGrant createTableGrants)
           
 void setHiveVariables(Map<String,String> hiveVariables)
           
 void setIsSilent(boolean isSilent)
           
 void setIsVerbose(boolean isVerbose)
           
 void setLastMapRedStatsList(List<MapRedStats> lastMapRedStatsList)
           
 void setLocalMapRedErrors(Map<String,List<String>> localMapRedErrors)
           
 void setOverriddenConfigurations(Map<String,String> overriddenConfigurations)
           
 void setStackTraces(Map<String,List<List<String>>> stackTraces)
           
 void setTmpOutputFile(File f)
           
static SessionState start(HiveConf conf)
          start a new session and set it to current session.
static SessionState start(SessionState startSs)
          set current session to existing session object if a thread is running multiple sessions - it must call this method with the new session object when switching from one session to another.
static boolean unregisterJar(String jarsToUnregister)
           
static String validateFile(Set<String> curFiles, String newFile)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

conf

protected HiveConf conf
current configuration.


isSilent

protected boolean isSilent
silent mode.


isVerbose

protected boolean isVerbose
verbose mode


hiveHist

protected HiveHistory hiveHist

in

public InputStream in
Streams to read/write from.


out

public PrintStream out

info

public PrintStream info

err

public PrintStream err

childOut

public PrintStream childOut
Standard output from any child process(es).


childErr

public PrintStream childErr
Error output from any child process(es).


tmpOutputFile

protected File tmpOutputFile
Temporary file name used to store results of non-Hive commands (e.g., set, dfs) and HiveServer.fetch*() function will read results from this file

Constructor Detail

SessionState

public SessionState()

SessionState

public SessionState(HiveConf conf)
Method Detail

getLineageState

public LineageState getLineageState()
Get the lineage state stored in this session.

Returns:
LineageState

getConf

public HiveConf getConf()

setConf

public void setConf(HiveConf conf)

getTmpOutputFile

public File getTmpOutputFile()

setTmpOutputFile

public void setTmpOutputFile(File f)

getIsSilent

public boolean getIsSilent()

setIsSilent

public void setIsSilent(boolean isSilent)

getIsVerbose

public boolean getIsVerbose()

setIsVerbose

public void setIsVerbose(boolean isVerbose)

setCmd

public void setCmd(String cmdString)

getCmd

public String getCmd()

getQueryId

public String getQueryId()

getHiveVariables

public Map<String,String> getHiveVariables()

setHiveVariables

public void setHiveVariables(Map<String,String> hiveVariables)

getSessionId

public String getSessionId()

start

public static SessionState start(HiveConf conf)
start a new session and set it to current session.


start

public static SessionState start(SessionState startSs)
set current session to existing session object if a thread is running multiple sessions - it must call this method with the new session object when switching from one session to another.

Throws:
HiveException

get

public static SessionState get()
get the current session.


getHiveHistory

public HiveHistory getHiveHistory()
get hiveHitsory object which does structured logging.

Returns:
The hive history object

getConsole

public static SessionState.LogHelper getConsole()
initialize or retrieve console object for SessionState.


validateFile

public static String validateFile(Set<String> curFiles,
                                  String newFile)

registerJar

public static boolean registerJar(String newJar)

unregisterJar

public static boolean unregisterJar(String jarsToUnregister)

find_resource_type

public static SessionState.ResourceType find_resource_type(String s)

add_resource

public String add_resource(SessionState.ResourceType t,
                           String value)

add_resource

public String add_resource(SessionState.ResourceType t,
                           String value,
                           boolean convertToUnix)

add_builtin_resource

public void add_builtin_resource(SessionState.ResourceType t,
                                 String value)

canDownloadResource

public static boolean canDownloadResource(String value)
Returns true if it is from any external File Systems except local


delete_resource

public boolean delete_resource(SessionState.ResourceType t,
                               String value)

list_resource

public Set<String> list_resource(SessionState.ResourceType t,
                                 List<String> filter)

delete_resource

public void delete_resource(SessionState.ResourceType t)

getCommandType

public String getCommandType()

getHiveOperation

public HiveOperation getHiveOperation()

setCommandType

public void setCommandType(HiveOperation commandType)

getAuthorizer

public HiveAuthorizationProvider getAuthorizer()

setAuthorizer

public void setAuthorizer(HiveAuthorizationProvider authorizer)

getAuthenticator

public HiveAuthenticationProvider getAuthenticator()

setAuthenticator

public void setAuthenticator(HiveAuthenticationProvider authenticator)

getCreateTableGrants

public CreateTableAutomaticGrant getCreateTableGrants()

setCreateTableGrants

public void setCreateTableGrants(CreateTableAutomaticGrant createTableGrants)

getLastMapRedStatsList

public List<MapRedStats> getLastMapRedStatsList()

setLastMapRedStatsList

public void setLastMapRedStatsList(List<MapRedStats> lastMapRedStatsList)

setStackTraces

public void setStackTraces(Map<String,List<List<String>>> stackTraces)

getStackTraces

public Map<String,List<List<String>>> getStackTraces()

getOverriddenConfigurations

public Map<String,String> getOverriddenConfigurations()

setOverriddenConfigurations

public void setOverriddenConfigurations(Map<String,String> overriddenConfigurations)

getLocalMapRedErrors

public Map<String,List<String>> getLocalMapRedErrors()

addLocalMapRedErrors

public void addLocalMapRedErrors(String id,
                                 List<String> localMapRedErrors)

setLocalMapRedErrors

public void setLocalMapRedErrors(Map<String,List<String>> localMapRedErrors)


Copyright © 2013 The Apache Software Foundation