org.apache.hadoop.hive.hwi
Class HWISessionManager

java.lang.Object
  extended by org.apache.hadoop.hive.hwi.HWISessionManager
All Implemented Interfaces:
Runnable

public class HWISessionManager
extends Object
implements Runnable

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.


Field Summary
protected static org.apache.commons.logging.Log l4j
           
 
Constructor Summary
protected HWISessionManager()
           
 
Method Summary
 HWISessionItem createSession(HWIAuth a, String sessionName)
          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.
 ArrayList<HWISessionItem> findAllSessionItems()
          Rather then return the actual items we return a list copies.
 Set<HWISessionItem> findAllSessionsForUser(HWIAuth auth)
          Used to list all the sessions of a user.
 Set<HWIAuth> findAllUsersWithSessions()
          Used to list all users that have at least one session.
 HWISessionItem findSessionItemByName(HWIAuth auth, String sessionname)
          Helper method useful when you know the session name you wish to reference.
protected  TreeMap<HWIAuth,Set<HWISessionItem>> getItems()
           
protected  boolean isGoOn()
           
 void run()
          This method scans the SessionItem collection.
protected  void setGoOn(boolean goOn)
           
protected  void setItems(TreeMap<HWIAuth,Set<HWISessionItem>> items)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

l4j

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

HWISessionManager

protected HWISessionManager()
Method Detail

run

public void run()
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.

Specified by:
run in interface Runnable

isGoOn

protected boolean isGoOn()

setGoOn

protected void setGoOn(boolean goOn)

getItems

protected TreeMap<HWIAuth,Set<HWISessionItem>> getItems()

setItems

protected void setItems(TreeMap<HWIAuth,Set<HWISessionItem>> items)

findAllSessionItems

public ArrayList<HWISessionItem> findAllSessionItems()
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.

Returns:
A set of SessionItems this framework manages

createSession

public HWISessionItem createSession(HWIAuth a,
                                    String sessionName)
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.

Parameters:
a - Authenticated user
sessionName - Represents the session name
Returns:
a new SessionItem or null if a session with that name already exists

findSessionItemByName

public HWISessionItem findSessionItemByName(HWIAuth auth,
                                            String sessionname)
Helper method useful when you know the session name you wish to reference.

Parameters:
sessionname -
Returns:
A SessionItem matching the sessionname or null if it does not exists

findAllUsersWithSessions

public Set<HWIAuth> findAllUsersWithSessions()
Used to list all users that have at least one session.

Returns:
keySet of items all users that have any sessions

findAllSessionsForUser

public Set<HWISessionItem> findAllSessionsForUser(HWIAuth auth)
Used to list all the sessions of a user.

Parameters:
auth - the user being enquired about
Returns:
all the sessions of that user


Copyright © 2013 The Apache Software Foundation