Package org.teiid.query.util
Class CommandContext
- java.lang.Object
-
- org.teiid.query.util.CommandContext
-
- All Implemented Interfaces:
Cloneable
,CommandContext
public class CommandContext extends Object implements Cloneable, CommandContext
Defines the context that a command is processing in. For example, this defines who is processing the command and why. Also, this class (or subclasses) provide a means to pass context-specific information between users of the query processor framework.
-
-
Constructor Summary
Constructors Constructor Description CommandContext()
CommandContext(Object processorID, String connectionID, String userName, String vdbName, Object vdbVersion)
Construct a new context.CommandContext(String connectionID, String userName, Serializable commandPayload, String vdbName, Object vdbVersion, boolean collectNodeStatistics)
Construct a new context.
-
Method Summary
-
-
-
Constructor Detail
-
CommandContext
public CommandContext(String connectionID, String userName, Serializable commandPayload, String vdbName, Object vdbVersion, boolean collectNodeStatistics)
Construct a new context.
-
CommandContext
public CommandContext(Object processorID, String connectionID, String userName, String vdbName, Object vdbVersion)
Construct a new context.
-
CommandContext
public CommandContext()
-
-
Method Detail
-
getDeterminismLevel
public FunctionMethod.Determinism getDeterminismLevel()
-
resetDeterminismLevel
public FunctionMethod.Determinism resetDeterminismLevel(boolean detach)
-
resetDeterminismLevel
public FunctionMethod.Determinism resetDeterminismLevel()
-
setDeterminismLevel
public void setDeterminismLevel(FunctionMethod.Determinism level)
-
getWorkItem
public RequestWorkItem getWorkItem()
- Returns:
-
setWorkItem
public void setWorkItem(RequestWorkItem object)
- Parameters:
object
-
-
clone
public CommandContext clone()
-
setNewVDBState
public void setNewVDBState(DQPWorkContext newWorkContext)
-
getConnectionId
public String getConnectionId()
- Specified by:
getConnectionId
in interfaceCommandContext
-
getConnectionID
public String getConnectionID()
- Specified by:
getConnectionID
in interfaceCommandContext
-
getUserName
public String getUserName()
- Specified by:
getUserName
in interfaceCommandContext
-
getVdbName
public String getVdbName()
- Specified by:
getVdbName
in interfaceCommandContext
-
getVdbVersion
public String getVdbVersion()
- Specified by:
getVdbVersion
in interfaceCommandContext
-
setConnectionID
public void setConnectionID(String connectionID)
Sets the connectionID.- Parameters:
connectionID
- The connectionID to set
-
setUserName
public void setUserName(String userName)
Sets the userName.- Parameters:
userName
- The userName to set
-
setVdbName
public void setVdbName(String vdbName)
Sets the vdbName.- Parameters:
vdbName
- The vdbName to set
-
setVdbVersion
public void setVdbVersion(Object vdbVersion)
Sets the vdbVersion.- Parameters:
vdbVersion
- The vdbVersion to set
-
getCommandPayload
public Serializable getCommandPayload()
- Specified by:
getCommandPayload
in interfaceCommandContext
-
setCommandPayload
public void setCommandPayload(Serializable commandPayload)
-
setCollectNodeStatistics
public void setCollectNodeStatistics(boolean collectNodeStatistics)
- Parameters:
collectNodeStatistics
- The collectNodeStatistics to set.- Since:
- 4.2
-
getCollectNodeStatistics
public boolean getCollectNodeStatistics()
-
getProcessorBatchSize
public int getProcessorBatchSize()
- Specified by:
getProcessorBatchSize
in interfaceCommandContext
-
getProcessorBatchSize
public int getProcessorBatchSize(List<Expression> schema)
-
setProcessorBatchSize
public void setProcessorBatchSize(int processorBatchSize)
-
getNextRand
public double getNextRand()
- Specified by:
getNextRand
in interfaceCommandContext
-
getNextRand
public double getNextRand(long seed)
- Specified by:
getNextRand
in interfaceCommandContext
-
pushCall
public void pushCall(String value) throws QueryProcessingException
- Throws:
QueryProcessingException
-
getCallStackDepth
public int getCallStackDepth()
-
popCall
public void popCall()
-
setAuthoriziationValidator
public void setAuthoriziationValidator(AuthorizationValidator authorizationValidator)
-
getTempTableStore
public TempTableStore getTempTableStore()
-
setTempTableStore
public void setTempTableStore(TempTableStore tempTableStore)
-
getSessionTempTableStore
public TempTableStore getSessionTempTableStore()
-
setSessionTempTableStore
public void setSessionTempTableStore(TempTableStore tempTableStore)
-
getServerTimeZone
public TimeZone getServerTimeZone()
- Specified by:
getServerTimeZone
in interfaceCommandContext
-
getQueryProcessorFactory
public QueryProcessor.ProcessorFactory getQueryProcessorFactory()
-
setQueryProcessorFactory
public void setQueryProcessorFactory(QueryProcessor.ProcessorFactory queryProcessorFactory)
-
getVariableContext
public VariableContext getVariableContext()
-
setVariableContext
public void setVariableContext(VariableContext variableContext)
-
pushVariableContext
public void pushVariableContext(VariableContext toPush)
-
getFromContext
public Object getFromContext(Expression expression) throws TeiidComponentException
- Throws:
TeiidComponentException
-
getTimeSliceEnd
public long getTimeSliceEnd()
-
getTimeoutEnd
public long getTimeoutEnd()
-
setTimeSliceEnd
public void setTimeSliceEnd(long timeSliceEnd)
-
setTimeoutEnd
public void setTimeoutEnd(long timeoutEnd)
-
setMetadata
public void setMetadata(QueryMetadataInterface metadata)
-
getMetadata
public QueryMetadataInterface getMetadata()
-
getBufferManager
public BufferManager getBufferManager()
-
setBufferManager
public void setBufferManager(BufferManager bm)
-
getGlobalTableStore
public GlobalTableStore getGlobalTableStore()
-
setGlobalTableStore
public void setGlobalTableStore(GlobalTableStore tempTableStore)
-
isNonBlocking
public boolean isNonBlocking()
-
setNonBlocking
public void setNonBlocking(boolean nonBlocking)
-
setPreparedPlanCache
public void setPreparedPlanCache(SessionAwareCache<PreparedPlan> cache)
-
getPlan
public PreparedPlan getPlan(String key)
-
putPlan
public void putPlan(String key, PreparedPlan plan, FunctionMethod.Determinism determinismLevel)
-
isResultSetCacheEnabled
public boolean isResultSetCacheEnabled()
-
setResultSetCacheEnabled
public void setResultSetCacheEnabled(boolean resultSetCacheEnabled)
-
getUserRequestSourceConcurrency
public int getUserRequestSourceConcurrency()
-
setUserRequestSourceConcurrency
public void setUserRequestSourceConcurrency(int userRequestSourceConcurrency)
-
getSubject
public Subject getSubject()
- Specified by:
getSubject
in interfaceCommandContext
-
setSubject
public void setSubject(Subject subject)
-
accessedPlanningObject
public void accessedPlanningObject(Object id)
-
accessedDataObject
public void accessedDataObject(Object id)
-
getSession
public SessionMetadata getSession()
- Specified by:
getSession
in interfaceCommandContext
-
setSession
public void setSession(SessionMetadata session)
-
getRequestId
public String getRequestId()
- Specified by:
getRequestId
in interfaceCommandContext
-
setRequestId
public void setRequestId(RequestID requestId)
-
setDQPWorkContext
public void setDQPWorkContext(DQPWorkContext workContext)
-
getAllowedDataPolicies
public Map<String,DataPolicy> getAllowedDataPolicies()
- Specified by:
getAllowedDataPolicies
in interfaceCommandContext
-
getVdb
public VDBMetaData getVdb()
- Specified by:
getVdb
in interfaceCommandContext
-
getDQPWorkContext
public DQPWorkContext getDQPWorkContext()
-
getTransactionContext
public TransactionContext getTransactionContext()
-
setTransactionContext
public void setTransactionContext(TransactionContext transactionContext)
-
getTransactionServer
public TransactionService getTransactionServer()
-
setTransactionService
public void setTransactionService(TransactionService transactionService)
-
getExecutor
public Executor getExecutor()
-
submit
public <V> Future<V> submit(Callable<V> callable)
Submit work that will notify the request work item of more work when complete- Parameters:
callable
-- Returns:
-
setExecutor
public void setExecutor(Executor e)
-
getReusableExecution
public ReusableExecution<?> getReusableExecution(Object key)
-
putReusableExecution
public void putReusableExecution(Object key, ReusableExecution<?> execution)
-
close
public void close()
-
addListener
public void addListener(CommandListener listener)
- Specified by:
addListener
in interfaceCommandContext
-
removeListener
public void removeListener(CommandListener listener)
- Specified by:
removeListener
in interfaceCommandContext
-
getDecimalFormat
public static DecimalFormat getDecimalFormat(CommandContext context, String format)
-
getDateFormat
public static SimpleDateFormat getDateFormat(CommandContext context, String format)
-
getPattern
public static Pattern getPattern(CommandContext context, String regex, int flags)
Compile a regular expression into aPattern
and cache it in theCommandContext
for future use.- Parameters:
context
-regex
- Regular expression.flags
- Bitmask flags likePattern.CASE_INSENSITIVE
.- Returns:
- Compiled regex.
-
incrementReuseCount
public void incrementReuseCount()
-
getReuseCount
public long getReuseCount()
- Specified by:
getReuseCount
in interfaceCommandContext
-
isContinuous
public boolean isContinuous()
- Specified by:
isContinuous
in interfaceCommandContext
-
setContinuous
public void setContinuous()
-
getVDBClassLoader
public ClassLoader getVDBClassLoader()
- Specified by:
getVDBClassLoader
in interfaceCommandContext
-
setVDBClassLoader
public void setVDBClassLoader(ClassLoader classLoader)
-
getAndClearWarnings
public List<Exception> getAndClearWarnings()
Get all warnings found while processing this plan. These warnings may be detected throughout the plan lifetime, which means new ones may arrive at any time. This method returns all current warnings and clears the current warnings list. The warnings are in order they were detected.- Returns:
- Current list of warnings, never null
-
addWarning
public void addWarning(Exception warning)
- Specified by:
addWarning
in interfaceCommandContext
-
getTupleSourceCache
public TupleSourceCache getTupleSourceCache()
-
setTupleSourceCache
public void setTupleSourceCache(TupleSourceCache tupleSourceCache)
-
getOptions
public Options getOptions()
-
setOptions
public void setOptions(Options options)
-
isReturnAutoGeneratedKeys
public boolean isReturnAutoGeneratedKeys()
- Specified by:
isReturnAutoGeneratedKeys
in interfaceCommandContext
-
setReturnAutoGeneratedKeys
public void setReturnAutoGeneratedKeys(List<ElementSymbol> variables)
-
getReturnAutoGeneratedKeys
public List<ElementSymbol> getReturnAutoGeneratedKeys()
-
returnGeneratedKeys
public GeneratedKeysImpl returnGeneratedKeys(String[] columnNames, Class<?>[] columnDataTypes)
- Specified by:
returnGeneratedKeys
in interfaceCommandContext
-
getGeneratedKeys
public GeneratedKeysImpl getGeneratedKeys()
- Specified by:
getGeneratedKeys
in interfaceCommandContext
-
getThreadLocalContext
public static CommandContext getThreadLocalContext()
-
pushThreadLocalContext
public static void pushThreadLocalContext(CommandContext context)
-
popThreadLocalContext
public static void popThreadLocalContext()
-
addAndGetReservedBuffers
public long addAndGetReservedBuffers(int i)
-
setSessionVariable
public Object setSessionVariable(String key, Object value)
- Specified by:
setSessionVariable
in interfaceCommandContext
-
getSessionVariable
public Object getSessionVariable(String key)
- Specified by:
getSessionVariable
in interfaceCommandContext
-
getAuthorizationValidator
public AuthorizationValidator getAuthorizationValidator()
-
getCodeLookup
public TupleSource getCodeLookup(String matTableName, Object keyValue)
-
putCodeLookup
public void putCodeLookup(String matTableName, Object keyValue, TupleSource ts)
-
getConnection
public TeiidConnection getConnection() throws TeiidSQLException
- Specified by:
getConnection
in interfaceCommandContext
- Throws:
TeiidSQLException
-
getSpatialRefSys
public Clob getSpatialRefSys()
Used by the system table logic- Returns:
-
addCreatedLob
public void addCreatedLob(FileStoreInputStreamFactory isf)
-
disableAutoCleanLobs
public void disableAutoCleanLobs()
-
requestCancelled
public void requestCancelled()
-
isCancelled
public boolean isCancelled()
Check if this context or the parent has been cancelled. If the parent has been, then we'll propagate.- Returns:
-
clearGeneratedKeys
public void clearGeneratedKeys()
-
isAccessible
public Boolean isAccessible(AbstractMetadataRecord record)
-
setAccessible
public void setAccessible(AbstractMetadataRecord record, Boolean result)
-
getBatchUpdateException
public Throwable getBatchUpdateException()
-
setBatchUpdateException
public void setBatchUpdateException(Throwable t)
-
isParallel
public boolean isParallel()
-
setParallel
public boolean setParallel(boolean value)
-
currentDate
public Date currentDate()
-
currentTime
public Time currentTime()
-
currentTimestamp
public Timestamp currentTimestamp()
-
setCurrentTimestamp
public void setCurrentTimestamp(long currentTimeMillis)
-
isAtomicBlock
public boolean isAtomicBlock()
Used by transaction detection logic when starting an atomic block transaction- Returns:
-
setAtomicBlock
public void setAtomicBlock(boolean atomicBlock)
-
addAccessed
public void addAccessed(TempMetadataID id)
Used by the planner to track only what is accessed by the plan
-
setAccessed
public void setAccessed(Collection<TempMetadataID> accessed)
-
isReadOnly
public boolean isReadOnly()
-
setReadOnly
public void setReadOnly(boolean b)
-
-