use of org.teiid.common.buffer.BlockedException in project teiid by teiid.
the class TestDataTierManager method testPartialResults.
@Test
public void testPartialResults() throws Exception {
DataTierTupleSource info = helpSetup(1);
connectorManager.throwExceptionOnExecute = true;
for (int i = 0; i < 10; i++) {
try {
assertNull(info.nextTuple());
SourceWarning warning = (SourceWarning) context.getAndClearWarnings().get(0);
assertTrue(warning.isPartialResultsError());
return;
} catch (BlockedException e) {
Thread.sleep(50);
}
}
fail();
}
use of org.teiid.common.buffer.BlockedException in project teiid by teiid.
the class ComplexDocumentFilter method matches.
@Override
public boolean matches(Map<String, Object> parentProperties, Map<String, Object> childProperties) throws TranslatorException {
try {
List<Object> tuple = new ArrayList<>();
int i = 0;
for (Column column : parentTable.getMetadataObject().getColumns()) {
tuple.add(i++, parentProperties.get(MarshallerBuilder.getDocumentAttributeName(column, false, metadata)));
}
for (Column column : childTable.getMetadataObject().getColumns()) {
tuple.add(i++, childProperties.get(MarshallerBuilder.getDocumentAttributeName(column, true, metadata)));
}
org.teiid.query.util.CommandContext cc = new org.teiid.query.util.CommandContext();
final Evaluator evaluator = new Evaluator(elementMap, null, cc);
return evaluator.evaluate(criteria, tuple);
} catch (ExpressionEvaluationException e) {
throw new TranslatorException(e);
} catch (BlockedException e) {
throw new TranslatorException(e);
} catch (TeiidComponentException e) {
throw new TranslatorException(e);
}
}
use of org.teiid.common.buffer.BlockedException in project teiid by teiid.
the class SortUtility method onePassSort.
public List<TupleBuffer> onePassSort(boolean lowLatency) throws TeiidComponentException, TeiidProcessingException {
boolean success = false;
try {
if (this.phase == INITIAL_SORT) {
initialSort(true, lowLatency, -1);
if (!isDoneReading()) {
this.phase = INITIAL_SORT;
}
}
for (TupleBuffer tb : activeTupleBuffers) {
tb.close();
// it is up to the caller to set the flag now
tb.setForwardOnly(false);
}
success = true;
return activeTupleBuffers;
} catch (BlockedException e) {
success = true;
throw e;
} finally {
if (!success) {
remove();
}
}
}
use of org.teiid.common.buffer.BlockedException in project teiid by teiid.
the class AccessNode method nextBatchDirect.
public TupleBatch nextBatchDirect() throws BlockedException, TeiidComponentException, TeiidProcessingException {
if (!open) {
// -- blocked during actual open
openInternal();
open = true;
}
if (multiSource && connectorBindingExpression == null) {
return this.getChildren()[0].nextBatch();
}
while (shouldExecute && (!tupleSources.isEmpty() || hasNextCommand())) {
if (tupleSources.isEmpty() && processCommandsIndividually()) {
registerNext();
}
// drain the tuple source(s)
for (int i = 0; i < this.tupleSources.size(); i++) {
TupleSource tupleSource = tupleSources.get(i);
try {
List<?> tuple = null;
while ((tuple = tupleSource.nextTuple()) != null) {
returnedRows = true;
if (this.projection != null && this.projection.length > 0) {
List<Object> newTuple = new ArrayList<Object>(this.projection.length);
for (Object object : this.projection) {
if (object instanceof Integer) {
newTuple.add(tuple.get((Integer) object));
} else {
newTuple.add(((Constant) object).getValue());
}
}
tuple = newTuple;
}
addBatchRow(tuple);
if (isBatchFull()) {
return pullBatch();
}
}
// end of source
tupleSource.closeSource();
tupleSources.remove(i--);
if (reserved > 0) {
reserved -= schemaSize;
getBufferManager().releaseBuffers(schemaSize);
}
if (!processCommandsIndividually()) {
registerNext();
}
continue;
} catch (BlockedException e) {
if (processCommandsIndividually()) {
if (hasPendingRows()) {
return pullBatch();
}
throw e;
}
continue;
}
}
if (processCommandsIndividually()) {
if (hasPendingRows()) {
return pullBatch();
}
continue;
}
if (!this.tupleSources.isEmpty()) {
if (hasPendingRows()) {
return pullBatch();
}
// $NON-NLS-1$
throw BlockedException.block(getContext().getRequestId(), "Blocking on source request(s).");
}
}
if (isUpdate && !returnedRows) {
List<Integer> tuple = new ArrayList<Integer>(1);
tuple.add(Integer.valueOf(0));
// Add tuple to current batch
addBatchRow(tuple);
}
terminateBatches();
return pullBatch();
}
use of org.teiid.common.buffer.BlockedException in project teiid by teiid.
the class AccessNode method openInternal.
private void openInternal() throws TeiidComponentException, TeiidProcessingException {
// TODO: support a partitioning concept with multi-source and full dependent join pushdown
if (subPlans != null) {
if (this.evaluatedPlans == null) {
this.evaluatedPlans = new HashMap<GroupSymbol, SubqueryState>();
for (Map.Entry<GroupSymbol, RelationalPlan> entry : subPlans.entrySet()) {
SubqueryState state = new SubqueryState();
RelationalPlan value = entry.getValue();
value.reset();
state.processor = new QueryProcessor(value, getContext().clone(), getBufferManager(), getDataManager());
state.collector = state.processor.createBatchCollector();
this.evaluatedPlans.put(entry.getKey(), state);
}
}
BlockedException be = null;
for (SubqueryState state : evaluatedPlans.values()) {
try {
state.collector.collectTuples();
} catch (BlockedException e) {
be = e;
}
}
if (be != null) {
throw be;
}
}
/*
* Check to see if we need a multi-source expansion. If the connectorBindingExpression != null, then
* the logic below will handle that case
*/
if (multiSource && connectorBindingExpression == null) {
synchronized (this) {
// the description can be obtained asynchly, so we need to synchronize
VDBMetaData vdb = getContext().getVdb();
ModelMetaData model = vdb.getModel(getModelName());
List<String> sources = model.getSourceNames();
// make sure that we have the right nodes
if (this.getChildCount() != 0 && (this.sourceNames == null || !this.sourceNames.equals(sources))) {
this.childCount--;
this.getChildren()[0] = null;
}
if (this.getChildCount() == 0) {
sourceNames = sources;
RelationalNode node = multiSourceModify(this, connectorBindingExpression, getContext().getMetadata(), sourceNames);
RelationalPlan.connectExternal(node, getContext(), getDataManager(), getBufferManager());
this.addChild(node);
}
}
this.getChildren()[0].open();
return;
}
// Copy command and resolve references if necessary
if (processingCommand == null) {
processingCommand = command;
isUpdate = RelationalNodeUtil.isUpdate(command);
}
boolean needProcessing = true;
if (this.connectorBindingExpression != null && connectorBindingId == null) {
this.connectorBindingId = (String) getEvaluator(Collections.emptyMap()).evaluate(this.connectorBindingExpression, null);
VDBMetaData vdb = getContext().getVdb();
ModelMetaData model = vdb.getModel(getModelName());
List<String> sources = model.getSourceNames();
String replacement = this.connectorBindingId;
if (!sources.contains(this.connectorBindingId)) {
shouldExecute = false;
if (command instanceof StoredProcedure) {
StoredProcedure sp = (StoredProcedure) command;
if (sp.returnParameters() && sp.getProjectedSymbols().size() > sp.getResultSetColumns().size()) {
throw new TeiidProcessingException(QueryPlugin.Event.TEIID30561, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30561, command));
}
}
return;
}
if (!(command instanceof StoredProcedure || command instanceof Insert)) {
processingCommand = (Command) command.clone();
MultiSourceElementReplacementVisitor.visit(replacement, getContext().getMetadata(), processingCommand);
}
}
do {
Command atomicCommand = nextCommand();
if (shouldEvaluate) {
needProcessing = prepareNextCommand(atomicCommand);
nextCommand = null;
} else {
needProcessing = RelationalNodeUtil.shouldExecute(atomicCommand, true);
}
if (needProcessing) {
registerRequest(atomicCommand);
}
// We use an upper limit here to the currency because these commands have potentially large in-memory value sets
} while (!processCommandsIndividually() && hasNextCommand() && this.tupleSources.size() < Math.max(Math.min(MAX_CONCURRENT, this.getContext().getUserRequestSourceConcurrency()), this.getContext().getUserRequestSourceConcurrency() / 2));
}
Aggregations