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

java.lang.Object
  extended by org.apache.hadoop.hive.ql.session.SessionState

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.AuthorizationMode
           
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).
 PrintStream err
           
 InputStream in
          Streams to read/write from.
 PrintStream info
           
 PrintStream out
           
 
Constructor Summary
SessionState(HiveConf conf)
           
SessionState(HiveConf conf, String userName)
           
 
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)
           
 void applyAuthorizationPolicy()
          If authorization mode is v2, then pass it through authorizer so that it can apply any security configuration changes.
static boolean canDownloadResource(String value)
          Returns true if it is from any external File Systems except local
 void close()
           
 void delete_resource(SessionState.ResourceType t)
           
 boolean delete_resource(SessionState.ResourceType t, String value)
           
static void detachSession()
           
 String downloadResource(String value, boolean convertToUnix)
           
static SessionState.ResourceType find_resource_type(String s)
           
static SessionState get()
          get the current session.
 HiveAuthenticationProvider getAuthenticator()
           
 SessionState.AuthorizationMode getAuthorizationMode()
           
 HiveAuthorizationProvider getAuthorizer()
           
 HiveAuthorizer getAuthorizerV2()
           
 String getCmd()
           
 String getCommandType()
           
 HiveConf getConf()
           
static SessionState.LogHelper getConsole()
          initialize or retrieve console object for SessionState.
 CreateTableAutomaticGrant getCreateTableGrants()
           
 String getCurrentDatabase()
           
 HiveHistory getHiveHistory()
          get hiveHitsory object which does structured logging.
 HiveOperation getHiveOperation()
           
 Map<String,String> getHiveVariables()
           
 boolean getIsSilent()
           
 boolean getIsVerbose()
           
 String getLastCommand()
           
 List<MapRedStats> getLastMapRedStatsList()
           
 LineageState getLineageState()
          Get the lineage state stored in this session.
 Map<String,List<String>> getLocalMapRedErrors()
           
 Map<String,String> getOverriddenConfigurations()
           
 PerfLogger getPerfLogger(boolean resetPerfLogger)
           
 String getQueryId()
           
 String getSessionId()
           
 Map<String,List<List<String>>> getStackTraces()
           
 TezSessionState getTezSession()
           
 File getTmpOutputFile()
           
static String getUserFromAuthenticator()
           
 String getUserName()
           
 boolean hasAddedResource()
           
 boolean isAuthorizationModeV2()
           
 boolean isHiveServerQuery()
           
 Set<String> list_resource(SessionState.ResourceType t, List<String> filter)
           
static boolean registerJar(String newJar)
           
 void setAddedResource(boolean addedResouce)
           
 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 setCurrentDatabase(String currentDatabase)
           
static void setCurrentSessionState(SessionState startSs)
          Sets the given session state in the thread local var for sessions.
 void setHiveVariables(Map<String,String> hiveVariables)
           
 void setIsHiveServerQuery(boolean isHiveServerQuery)
           
 void setIsSilent(boolean isSilent)
           
 void setIsVerbose(boolean isVerbose)
           
 void setLastCommand(String lastCommand)
           
 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 setTezSession(TezSessionState session)
           
 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
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

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).

Constructor Detail

SessionState

public SessionState(HiveConf conf)

SessionState

public SessionState(HiveConf conf,
                    String userName)
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()

isHiveServerQuery

public boolean isHiveServerQuery()

setIsSilent

public void setIsSilent(boolean isSilent)

getIsVerbose

public boolean getIsVerbose()

setIsVerbose

public void setIsVerbose(boolean isVerbose)

setIsHiveServerQuery

public void setIsHiveServerQuery(boolean isHiveServerQuery)

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.


setCurrentSessionState

public static void setCurrentSessionState(SessionState startSs)
Sets the given session state in the thread local var for sessions.


detachSession

public static void detachSession()

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

getLastCommand

public String getLastCommand()

setLastCommand

public void setLastCommand(String lastCommand)

getConsole

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


validateFile

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

getUserFromAuthenticator

public static String getUserFromAuthenticator()
Returns:
username from current SessionState authenticator. username will be null if there is no current SessionState object or authenticator is null.

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


downloadResource

public String downloadResource(String value,
                               boolean convertToUnix)

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)

getAuthorizerV2

public HiveAuthorizer getAuthorizerV2()

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)

getCurrentDatabase

public String getCurrentDatabase()

setCurrentDatabase

public void setCurrentDatabase(String currentDatabase)

close

public void close()
           throws IOException
Throws:
IOException

getAuthorizationMode

public SessionState.AuthorizationMode getAuthorizationMode()

isAuthorizationModeV2

public boolean isAuthorizationModeV2()

getPerfLogger

public PerfLogger getPerfLogger(boolean resetPerfLogger)
Parameters:
resetPerfLogger -
Returns:
Tries to return an instance of the class whose name is configured in hive.exec.perf.logger, but if it can't it just returns an instance of the base PerfLogger class

getTezSession

public TezSessionState getTezSession()

setTezSession

public void setTezSession(TezSessionState session)

getUserName

public String getUserName()

applyAuthorizationPolicy

public void applyAuthorizationPolicy()
                              throws HiveException
If authorization mode is v2, then pass it through authorizer so that it can apply any security configuration changes.

Parameters:
hiveConf -
Throws:
HiveException

hasAddedResource

public boolean hasAddedResource()

setAddedResource

public void setAddedResource(boolean addedResouce)


Copyright © 2014 The Apache Software Foundation. All rights reserved.