Package org.teiid.dqp.internal.process
Class RequestWorkItem
- java.lang.Object
-
- org.teiid.dqp.internal.process.AbstractWorkItem
-
- org.teiid.dqp.internal.process.RequestWorkItem
-
- All Implemented Interfaces:
Runnable
,ThreadReuseExecutor.PrioritizedRunnable
public class RequestWorkItem extends AbstractWorkItem implements ThreadReuseExecutor.PrioritizedRunnable
Compiles results and other information for the client. There is quite a bit of logic surrounding forming batches to prevent buffer growth, send multiple batches at a time, partial batches, etc. There is also special handling for the update count case, which needs to read the entire result before sending it back to the client.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
RequestWorkItem.MoreWorkTask
-
Field Summary
Fields Modifier and Type Field Description protected DQPCore
dqpCore
static String
REQUEST_KEY
protected boolean
useCallingThread
-
Fields inherited from interface org.teiid.dqp.internal.process.ThreadReuseExecutor.PrioritizedRunnable
NO_WAIT_PRIORITY
-
-
Constructor Summary
Constructors Constructor Description RequestWorkItem(DQPCore dqpCore, RequestMessage requestMsg, Request request, ResultsReceiver<ResultsMessage> receiver, RequestID requestID, DQPWorkContext workContext)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addConnectorRequest(AtomicRequestID atomicRequestId, DataTierTupleSource connInfo)
<T> FutureWork<T>
addRequestWork(Callable<T> callable)
protected void
close()
Client close is currently implemented as asynch.void
closeAtomicRequest(AtomicRequestID atomicRequestId)
ResultsMessage
createResultsMessage(List<? extends List<?>> batch, List<? extends Expression> columnSymbols)
void
doMoreWork()
Special call from request threads to allow resumption of processing by the calling thread.long
getCreationTime()
DQPCore
getDqpCore()
DQPWorkContext
getDqpWorkContext()
int
getPriority()
The execution priority - higher is lowerlong
getProcessingTimestamp()
QueryProcessor
getProcessor()
PlanNode
getQueryPlan()
RequestID
getRequestID()
SessionAwareCache<CachedResults>
getRsCache()
io.opentracing.Span
getTracingSpan()
boolean
isCloseRequested()
protected boolean
isDoneProcessing()
protected void
process()
void
processLobChunkRequest(String id, int streamRequestId, ResultsReceiver<LobChunk> chunckReceiver)
protected void
processMore()
protected void
processNew()
void
removeLobStream(int streamRequestId)
boolean
requestCancel(String reason)
void
requestClose()
void
requestMore(int batchFirst, int batchLast, ResultsReceiver<ResultsMessage> receiver)
protected void
resumeProcessing()
void
run()
Future<Void>
scheduleWork(long delay)
protected boolean
sendResultsIfNeeded(TupleBatch batch)
Send results if they have been requested.void
setCancelTask(EnhancedTimer.Task cancelTask)
void
setTracingSpan(io.opentracing.Span span)
String
toString()
-
Methods inherited from class org.teiid.dqp.internal.process.AbstractWorkItem
isProcessing, moreWork, moreWork, pauseProcessing
-
-
-
-
Field Detail
-
REQUEST_KEY
public static final String REQUEST_KEY
- See Also:
- Constant Field Values
-
dqpCore
protected final DQPCore dqpCore
-
useCallingThread
protected boolean useCallingThread
-
-
Constructor Detail
-
RequestWorkItem
public RequestWorkItem(DQPCore dqpCore, RequestMessage requestMsg, Request request, ResultsReceiver<ResultsMessage> receiver, RequestID requestID, DQPWorkContext workContext)
-
-
Method Detail
-
isDoneProcessing
protected boolean isDoneProcessing()
- Specified by:
isDoneProcessing
in classAbstractWorkItem
-
run
public void run()
- Specified by:
run
in interfaceRunnable
- Overrides:
run
in classAbstractWorkItem
-
resumeProcessing
protected void resumeProcessing()
- Specified by:
resumeProcessing
in classAbstractWorkItem
-
doMoreWork
public void doMoreWork()
Special call from request threads to allow resumption of processing by the calling thread.
-
process
protected void process()
- Specified by:
process
in classAbstractWorkItem
-
processMore
protected void processMore() throws BlockedException, TeiidException
- Throws:
BlockedException
TeiidException
-
close
protected void close()
Client close is currently implemented as asynch. Any errors that occur will not make it to the client, instead we just log them here.
-
processNew
protected void processNew() throws TeiidProcessingException, TeiidComponentException
-
getRsCache
public SessionAwareCache<CachedResults> getRsCache()
-
sendResultsIfNeeded
protected boolean sendResultsIfNeeded(TupleBatch batch) throws TeiidComponentException, TeiidProcessingException
Send results if they have been requested. This should only be called from the processing thread.- Returns:
- true if the batch should be buffered
- Throws:
TeiidComponentException
TeiidProcessingException
-
createResultsMessage
public ResultsMessage createResultsMessage(List<? extends List<?>> batch, List<? extends Expression> columnSymbols)
-
getQueryPlan
public PlanNode getQueryPlan()
-
processLobChunkRequest
public void processLobChunkRequest(String id, int streamRequestId, ResultsReceiver<LobChunk> chunckReceiver)
-
removeLobStream
public void removeLobStream(int streamRequestId)
-
requestCancel
public boolean requestCancel(String reason) throws TeiidComponentException
- Throws:
TeiidComponentException
-
requestClose
public void requestClose() throws TeiidComponentException
- Throws:
TeiidComponentException
-
isCloseRequested
public boolean isCloseRequested()
-
requestMore
public void requestMore(int batchFirst, int batchLast, ResultsReceiver<ResultsMessage> receiver)
-
closeAtomicRequest
public void closeAtomicRequest(AtomicRequestID atomicRequestId)
-
addConnectorRequest
public void addConnectorRequest(AtomicRequestID atomicRequestId, DataTierTupleSource connInfo)
-
toString
public String toString()
- Specified by:
toString
in classAbstractWorkItem
-
getDqpWorkContext
public DQPWorkContext getDqpWorkContext()
- Specified by:
getDqpWorkContext
in interfaceThreadReuseExecutor.PrioritizedRunnable
-
getProcessingTimestamp
public long getProcessingTimestamp()
-
getPriority
public int getPriority()
Description copied from interface:ThreadReuseExecutor.PrioritizedRunnable
The execution priority - higher is lower- Specified by:
getPriority
in interfaceThreadReuseExecutor.PrioritizedRunnable
-
getCreationTime
public long getCreationTime()
- Specified by:
getCreationTime
in interfaceThreadReuseExecutor.PrioritizedRunnable
-
addRequestWork
public <T> FutureWork<T> addRequestWork(Callable<T> callable)
-
setCancelTask
public void setCancelTask(EnhancedTimer.Task cancelTask)
-
getProcessor
public QueryProcessor getProcessor()
-
getRequestID
public RequestID getRequestID()
-
setTracingSpan
public void setTracingSpan(io.opentracing.Span span)
-
getTracingSpan
public io.opentracing.Span getTracingSpan()
-
getDqpCore
public DQPCore getDqpCore()
-
-