org.apache.lens.server.query
Class QueryExecutionServiceImpl

java.lang.Object
  extended by org.apache.hive.service.AbstractService
      extended by org.apache.hive.service.CompositeService
          extended by org.apache.lens.server.LensService
              extended by org.apache.lens.server.query.QueryExecutionServiceImpl
All Implemented Interfaces:
Externalizable, Serializable, org.apache.hive.service.Service, QueryExecutionService

public class QueryExecutionServiceImpl
extends LensService
implements QueryExecutionService

The Class QueryExecutionServiceImpl.

See Also:
Serialized Form

Nested Class Summary
static class QueryExecutionServiceImpl.QueryStatusLogger
          The Class QueryStatusLogger.
 
Nested classes/interfaces inherited from class org.apache.hive.service.CompositeService
org.apache.hive.service.CompositeService.CompositeServiceShutdownHook
 
Nested classes/interfaces inherited from interface org.apache.hive.service.Service
org.apache.hive.service.Service.STATE
 
Field Summary
static org.apache.commons.logging.Log LOG
          The Constant LOG.
static String NAME
          The Constant NAME.
static String PREPARED_QUERIES_COUNTER
          The Constant PREPARED_QUERIES_COUNTER.
static String PREPARED_QUERY_PURGER_COUNTER
          The Constant PREPARED_QUERY_PURGER_COUNTER.
static String QUERY_PURGER_COUNTER
          The Constant QUERY_PURGER_COUNTER.
static String QUERY_SUBMITTER_COUNTER
          The Constant QUERY_SUBMITTER_COUNTER.
protected  Thread querySubmitter
          The query submitter.
static String STATUS_UPDATE_COUNTER
          The Constant STATUS_UPDATE_COUNTER.
 
Fields inherited from class org.apache.lens.server.LensService
sessionMap, stopped
 
Constructor Summary
QueryExecutionServiceImpl(org.apache.hive.service.cli.CLIService cliService)
          Instantiates a new query execution service impl.
 
Method Summary
 void addResource(org.apache.lens.api.LensSessionHandle sessionHandle, String type, String path)
          Adds the resource.
 boolean cancelQuery(org.apache.lens.api.LensSessionHandle sessionHandle, org.apache.lens.api.query.QueryHandle queryHandle)
           
 void closeDriverSessions(org.apache.lens.api.LensSessionHandle sessionHandle)
          Allow drivers to release resources acquired for a session if any.
 void closeResultSet(org.apache.lens.api.LensSessionHandle sessionHandle, org.apache.lens.api.query.QueryHandle queryHandle)
           
 void closeSession(org.apache.lens.api.LensSessionHandle sessionHandle)
          Close session.
protected  QueryContext createContext(PreparedQueryContext pctx, String userName, org.apache.lens.api.LensConf conf, org.apache.hadoop.conf.Configuration qconf)
          Creates the context.
protected  QueryContext createContext(String query, String userName, org.apache.lens.api.LensConf conf, org.apache.hadoop.conf.Configuration qconf)
          Creates the context.
 void deleteResource(org.apache.lens.api.LensSessionHandle sessionHandle, String type, String path)
          Delete resource.
 boolean destroyPrepared(org.apache.lens.api.LensSessionHandle sessionHandle, org.apache.lens.api.query.QueryPrepareHandle prepared)
           
 org.apache.lens.api.query.QueryHandleWithResultSet execute(org.apache.lens.api.LensSessionHandle sessionHandle, String query, long timeoutMillis, org.apache.lens.api.LensConf conf, String queryName)
           
 org.apache.lens.api.query.QueryHandle executeAsync(org.apache.lens.api.LensSessionHandle sessionHandle, String query, org.apache.lens.api.LensConf conf, String queryName)
           
 org.apache.lens.api.query.QueryHandleWithResultSet executePrepare(org.apache.lens.api.LensSessionHandle sessionHandle, org.apache.lens.api.query.QueryPrepareHandle prepareHandle, long timeoutMillis, org.apache.lens.api.LensConf conf, String queryName)
           
 org.apache.lens.api.query.QueryHandle executePrepareAsync(org.apache.lens.api.LensSessionHandle sessionHandle, org.apache.lens.api.query.QueryPrepareHandle prepareHandle, org.apache.lens.api.LensConf conf, String queryName)
           
 org.apache.lens.api.query.QueryPlan explain(org.apache.lens.api.LensSessionHandle sessionHandle, String query, org.apache.lens.api.LensConf lensConf)
           
 org.apache.lens.api.query.QueryPlan explainAndPrepare(org.apache.lens.api.LensSessionHandle sessionHandle, String query, org.apache.lens.api.LensConf lensConf, String queryName)
           
 org.apache.lens.api.query.QueryResult fetchResultSet(org.apache.lens.api.LensSessionHandle sessionHandle, org.apache.lens.api.query.QueryHandle queryHandle, long startIndex, int fetchSize)
           
 List<org.apache.lens.api.query.QueryPrepareHandle> getAllPreparedQueries(org.apache.lens.api.LensSessionHandle sessionHandle, String user, String queryName, long fromDate, long toDate)
           
 List<org.apache.lens.api.query.QueryHandle> getAllQueries(org.apache.lens.api.LensSessionHandle sessionHandle, String state, String userName, String queryName, long fromDate, long toDate)
           
protected  LensEventService getEventService()
           
 long getFinishedQueriesCount()
           
 javax.ws.rs.core.Response getHttpResultSet(org.apache.lens.api.LensSessionHandle sessionHandle, org.apache.lens.api.query.QueryHandle queryHandle)
           
 org.apache.lens.api.query.LensPreparedQuery getPreparedQuery(org.apache.lens.api.LensSessionHandle sessionHandle, org.apache.lens.api.query.QueryPrepareHandle prepareHandle)
           
 org.apache.lens.api.query.LensQuery getQuery(org.apache.lens.api.LensSessionHandle sessionHandle, org.apache.lens.api.query.QueryHandle queryHandle)
           
 long getQueuedQueriesCount()
           
 org.apache.lens.api.query.QueryResultSetMetadata getResultSetMetadata(org.apache.lens.api.LensSessionHandle sessionHandle, org.apache.lens.api.query.QueryHandle queryHandle)
           
 long getRunningQueriesCount()
           
protected  void handleDriverSessionStart(DriverEvent event)
          Handle driver session start.
 void init(org.apache.hadoop.hive.conf.HiveConf hiveConf)
           
 void pauseQuerySubmitter()
          Pause query submitter.
 org.apache.lens.api.query.QueryPrepareHandle prepare(org.apache.lens.api.LensSessionHandle sessionHandle, String query, org.apache.lens.api.LensConf lensConf, String queryName)
           
 void prepareStopping()
          Prepare stopping.
 void readExternal(ObjectInput in)
           
 void start()
           
 void stop()
           
 boolean updateQueryConf(org.apache.lens.api.LensSessionHandle sessionHandle, org.apache.lens.api.query.QueryHandle queryHandle, org.apache.lens.api.LensConf newconf)
           
 boolean updateQueryConf(org.apache.lens.api.LensSessionHandle sessionHandle, org.apache.lens.api.query.QueryPrepareHandle prepareHandle, org.apache.lens.api.LensConf newconf)
           
 void writeExternal(ObjectOutput out)
           
 
Methods inherited from class org.apache.lens.server.LensService
acquire, acquire, getCliService, getHiveSessionHandle, getLensConf, getLensConf, getServerDomain, getSession, getSessionHandle, getSessionManager, openSession, release, release, restoreSession
 
Methods inherited from class org.apache.hive.service.CompositeService
addService, getServices, removeService
 
Methods inherited from class org.apache.hive.service.AbstractService
getHiveConf, getName, getServiceState, getStartTime, register, unregister
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

public static final org.apache.commons.logging.Log LOG
The Constant LOG.


PREPARED_QUERIES_COUNTER

public static final String PREPARED_QUERIES_COUNTER
The Constant PREPARED_QUERIES_COUNTER.

See Also:
Constant Field Values

QUERY_SUBMITTER_COUNTER

public static final String QUERY_SUBMITTER_COUNTER
The Constant QUERY_SUBMITTER_COUNTER.

See Also:
Constant Field Values

STATUS_UPDATE_COUNTER

public static final String STATUS_UPDATE_COUNTER
The Constant STATUS_UPDATE_COUNTER.

See Also:
Constant Field Values

QUERY_PURGER_COUNTER

public static final String QUERY_PURGER_COUNTER
The Constant QUERY_PURGER_COUNTER.

See Also:
Constant Field Values

PREPARED_QUERY_PURGER_COUNTER

public static final String PREPARED_QUERY_PURGER_COUNTER
The Constant PREPARED_QUERY_PURGER_COUNTER.

See Also:
Constant Field Values

NAME

public static final String NAME
The Constant NAME.

See Also:
Constant Field Values

querySubmitter

protected final Thread querySubmitter
The query submitter.

Constructor Detail

QueryExecutionServiceImpl

public QueryExecutionServiceImpl(org.apache.hive.service.cli.CLIService cliService)
                          throws org.apache.lens.api.LensException
Instantiates a new query execution service impl.

Parameters:
cliService - the cli service
Throws:
org.apache.lens.api.LensException - the lens exception
Method Detail

getEventService

protected LensEventService getEventService()

pauseQuerySubmitter

public void pauseQuerySubmitter()
Pause query submitter.


init

public void init(org.apache.hadoop.hive.conf.HiveConf hiveConf)
Specified by:
init in interface org.apache.hive.service.Service
Overrides:
init in class org.apache.hive.service.CompositeService

prepareStopping

public void prepareStopping()
Description copied from class: LensService
Prepare stopping.

Overrides:
prepareStopping in class LensService

stop

public void stop()
Specified by:
stop in interface org.apache.hive.service.Service
Overrides:
stop in class org.apache.hive.service.CompositeService

start

public void start()
Specified by:
start in interface org.apache.hive.service.Service
Overrides:
start in class org.apache.hive.service.CompositeService

prepare

public org.apache.lens.api.query.QueryPrepareHandle prepare(org.apache.lens.api.LensSessionHandle sessionHandle,
                                                            String query,
                                                            org.apache.lens.api.LensConf lensConf,
                                                            String queryName)
                                                     throws org.apache.lens.api.LensException
Specified by:
prepare in interface QueryExecutionService
Throws:
org.apache.lens.api.LensException

explainAndPrepare

public org.apache.lens.api.query.QueryPlan explainAndPrepare(org.apache.lens.api.LensSessionHandle sessionHandle,
                                                             String query,
                                                             org.apache.lens.api.LensConf lensConf,
                                                             String queryName)
                                                      throws org.apache.lens.api.LensException
Specified by:
explainAndPrepare in interface QueryExecutionService
Throws:
org.apache.lens.api.LensException

executePrepareAsync

public org.apache.lens.api.query.QueryHandle executePrepareAsync(org.apache.lens.api.LensSessionHandle sessionHandle,
                                                                 org.apache.lens.api.query.QueryPrepareHandle prepareHandle,
                                                                 org.apache.lens.api.LensConf conf,
                                                                 String queryName)
                                                          throws org.apache.lens.api.LensException
Specified by:
executePrepareAsync in interface QueryExecutionService
Throws:
org.apache.lens.api.LensException

executePrepare

public org.apache.lens.api.query.QueryHandleWithResultSet executePrepare(org.apache.lens.api.LensSessionHandle sessionHandle,
                                                                         org.apache.lens.api.query.QueryPrepareHandle prepareHandle,
                                                                         long timeoutMillis,
                                                                         org.apache.lens.api.LensConf conf,
                                                                         String queryName)
                                                                  throws org.apache.lens.api.LensException
Specified by:
executePrepare in interface QueryExecutionService
Throws:
org.apache.lens.api.LensException

executeAsync

public org.apache.lens.api.query.QueryHandle executeAsync(org.apache.lens.api.LensSessionHandle sessionHandle,
                                                          String query,
                                                          org.apache.lens.api.LensConf conf,
                                                          String queryName)
                                                   throws org.apache.lens.api.LensException
Specified by:
executeAsync in interface QueryExecutionService
Throws:
org.apache.lens.api.LensException

createContext

protected QueryContext createContext(String query,
                                     String userName,
                                     org.apache.lens.api.LensConf conf,
                                     org.apache.hadoop.conf.Configuration qconf)
                              throws org.apache.lens.api.LensException
Creates the context.

Parameters:
query - the query
userName - the user name
conf - the conf
qconf - the qconf
Returns:
the query context
Throws:
org.apache.lens.api.LensException - the lens exception

createContext

protected QueryContext createContext(PreparedQueryContext pctx,
                                     String userName,
                                     org.apache.lens.api.LensConf conf,
                                     org.apache.hadoop.conf.Configuration qconf)
                              throws org.apache.lens.api.LensException
Creates the context.

Parameters:
pctx - the pctx
userName - the user name
conf - the conf
qconf - the qconf
Returns:
the query context
Throws:
org.apache.lens.api.LensException - the lens exception

updateQueryConf

public boolean updateQueryConf(org.apache.lens.api.LensSessionHandle sessionHandle,
                               org.apache.lens.api.query.QueryHandle queryHandle,
                               org.apache.lens.api.LensConf newconf)
                        throws org.apache.lens.api.LensException
Specified by:
updateQueryConf in interface QueryExecutionService
Throws:
org.apache.lens.api.LensException

updateQueryConf

public boolean updateQueryConf(org.apache.lens.api.LensSessionHandle sessionHandle,
                               org.apache.lens.api.query.QueryPrepareHandle prepareHandle,
                               org.apache.lens.api.LensConf newconf)
                        throws org.apache.lens.api.LensException
Specified by:
updateQueryConf in interface QueryExecutionService
Throws:
org.apache.lens.api.LensException

getQuery

public org.apache.lens.api.query.LensQuery getQuery(org.apache.lens.api.LensSessionHandle sessionHandle,
                                                    org.apache.lens.api.query.QueryHandle queryHandle)
                                             throws org.apache.lens.api.LensException
Specified by:
getQuery in interface QueryExecutionService
Throws:
org.apache.lens.api.LensException

getPreparedQuery

public org.apache.lens.api.query.LensPreparedQuery getPreparedQuery(org.apache.lens.api.LensSessionHandle sessionHandle,
                                                                    org.apache.lens.api.query.QueryPrepareHandle prepareHandle)
                                                             throws org.apache.lens.api.LensException
Specified by:
getPreparedQuery in interface QueryExecutionService
Throws:
org.apache.lens.api.LensException

execute

public org.apache.lens.api.query.QueryHandleWithResultSet execute(org.apache.lens.api.LensSessionHandle sessionHandle,
                                                                  String query,
                                                                  long timeoutMillis,
                                                                  org.apache.lens.api.LensConf conf,
                                                                  String queryName)
                                                           throws org.apache.lens.api.LensException
Specified by:
execute in interface QueryExecutionService
Throws:
org.apache.lens.api.LensException

getResultSetMetadata

public org.apache.lens.api.query.QueryResultSetMetadata getResultSetMetadata(org.apache.lens.api.LensSessionHandle sessionHandle,
                                                                             org.apache.lens.api.query.QueryHandle queryHandle)
                                                                      throws org.apache.lens.api.LensException
Specified by:
getResultSetMetadata in interface QueryExecutionService
Throws:
org.apache.lens.api.LensException

fetchResultSet

public org.apache.lens.api.query.QueryResult fetchResultSet(org.apache.lens.api.LensSessionHandle sessionHandle,
                                                            org.apache.lens.api.query.QueryHandle queryHandle,
                                                            long startIndex,
                                                            int fetchSize)
                                                     throws org.apache.lens.api.LensException
Specified by:
fetchResultSet in interface QueryExecutionService
Throws:
org.apache.lens.api.LensException

closeResultSet

public void closeResultSet(org.apache.lens.api.LensSessionHandle sessionHandle,
                           org.apache.lens.api.query.QueryHandle queryHandle)
                    throws org.apache.lens.api.LensException
Specified by:
closeResultSet in interface QueryExecutionService
Throws:
org.apache.lens.api.LensException

cancelQuery

public boolean cancelQuery(org.apache.lens.api.LensSessionHandle sessionHandle,
                           org.apache.lens.api.query.QueryHandle queryHandle)
                    throws org.apache.lens.api.LensException
Specified by:
cancelQuery in interface QueryExecutionService
Throws:
org.apache.lens.api.LensException

getAllQueries

public List<org.apache.lens.api.query.QueryHandle> getAllQueries(org.apache.lens.api.LensSessionHandle sessionHandle,
                                                                 String state,
                                                                 String userName,
                                                                 String queryName,
                                                                 long fromDate,
                                                                 long toDate)
                                                          throws org.apache.lens.api.LensException
Specified by:
getAllQueries in interface QueryExecutionService
Throws:
org.apache.lens.api.LensException

getAllPreparedQueries

public List<org.apache.lens.api.query.QueryPrepareHandle> getAllPreparedQueries(org.apache.lens.api.LensSessionHandle sessionHandle,
                                                                                String user,
                                                                                String queryName,
                                                                                long fromDate,
                                                                                long toDate)
                                                                         throws org.apache.lens.api.LensException
Specified by:
getAllPreparedQueries in interface QueryExecutionService
Throws:
org.apache.lens.api.LensException

destroyPrepared

public boolean destroyPrepared(org.apache.lens.api.LensSessionHandle sessionHandle,
                               org.apache.lens.api.query.QueryPrepareHandle prepared)
                        throws org.apache.lens.api.LensException
Specified by:
destroyPrepared in interface QueryExecutionService
Throws:
org.apache.lens.api.LensException

explain

public org.apache.lens.api.query.QueryPlan explain(org.apache.lens.api.LensSessionHandle sessionHandle,
                                                   String query,
                                                   org.apache.lens.api.LensConf lensConf)
                                            throws org.apache.lens.api.LensException
Specified by:
explain in interface QueryExecutionService
Throws:
org.apache.lens.api.LensException

addResource

public void addResource(org.apache.lens.api.LensSessionHandle sessionHandle,
                        String type,
                        String path)
                 throws org.apache.lens.api.LensException
Description copied from class: LensService
Adds the resource.

Overrides:
addResource in class LensService
Parameters:
sessionHandle - the session handle
type - the type
path - the path
Throws:
org.apache.lens.api.LensException - the lens exception

deleteResource

public void deleteResource(org.apache.lens.api.LensSessionHandle sessionHandle,
                           String type,
                           String path)
                    throws org.apache.lens.api.LensException
Description copied from class: LensService
Delete resource.

Overrides:
deleteResource in class LensService
Parameters:
sessionHandle - the session handle
type - the type
path - the path
Throws:
org.apache.lens.api.LensException - the lens exception

readExternal

public void readExternal(ObjectInput in)
                  throws IOException,
                         ClassNotFoundException
Specified by:
readExternal in interface Externalizable
Overrides:
readExternal in class LensService
Throws:
IOException
ClassNotFoundException

writeExternal

public void writeExternal(ObjectOutput out)
                   throws IOException
Specified by:
writeExternal in interface Externalizable
Overrides:
writeExternal in class LensService
Throws:
IOException

getHttpResultSet

public javax.ws.rs.core.Response getHttpResultSet(org.apache.lens.api.LensSessionHandle sessionHandle,
                                                  org.apache.lens.api.query.QueryHandle queryHandle)
                                           throws org.apache.lens.api.LensException
Specified by:
getHttpResultSet in interface QueryExecutionService
Throws:
org.apache.lens.api.LensException

closeDriverSessions

public void closeDriverSessions(org.apache.lens.api.LensSessionHandle sessionHandle)
Allow drivers to release resources acquired for a session if any.

Parameters:
sessionHandle - the session handle

closeSession

public void closeSession(org.apache.lens.api.LensSessionHandle sessionHandle)
                  throws org.apache.lens.api.LensException
Description copied from class: LensService
Close session.

Overrides:
closeSession in class LensService
Parameters:
sessionHandle - the session handle
Throws:
org.apache.lens.api.LensException - the lens exception

getQueuedQueriesCount

public long getQueuedQueriesCount()
Specified by:
getQueuedQueriesCount in interface QueryExecutionService

getRunningQueriesCount

public long getRunningQueriesCount()
Specified by:
getRunningQueriesCount in interface QueryExecutionService

getFinishedQueriesCount

public long getFinishedQueriesCount()
Specified by:
getFinishedQueriesCount in interface QueryExecutionService

handleDriverSessionStart

protected void handleDriverSessionStart(DriverEvent event)
Handle driver session start.

Parameters:
event - the event


Copyright © 2014–2015 Apache Software Foundation. All rights reserved.