use of org.teiid.core.TeiidRuntimeException in project teiid by teiid.
the class DQPCore method start.
public void start(DQPConfiguration theConfig) {
this.config = theConfig;
this.authorizationValidator = config.getAuthorizationValidator();
this.chunkSize = config.getLobChunkSizeInKB() * 1024;
this.processWorkerPool = config.getTeiidExecutor();
// we don't want cancellations waiting on normal processing, so they get a small dedicated pool
// TODO: overflow to the worker pool
// $NON-NLS-1$
timeoutExecutor = ExecutorUtils.newFixedThreadPool(3, "Server Side Timeout");
this.cancellationTimer = new EnhancedTimer(timeoutExecutor, timeoutExecutor);
this.maxActivePlans = config.getMaxActivePlans();
if (this.maxActivePlans > config.getMaxThreads()) {
LogManager.logWarning(LogConstants.CTX_DQP, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30006, this.maxActivePlans, config.getMaxThreads()));
this.maxActivePlans = config.getMaxThreads();
}
// for now options are scoped to the engine - vdb scoping is a todo
options = new Options();
options.setAssumeMatchingCollation(false);
options.setProperties(config.getProperties());
// $NON-NLS-1$
PropertiesUtils.setBeanProperties(options, options.getProperties(), "org.teiid", true);
this.bufferManager.setOptions(options);
// hack to set the max active plans
this.bufferManager.setMaxActivePlans(this.maxActivePlans);
try {
this.bufferManager.initialize();
} catch (TeiidComponentException e) {
throw new TeiidRuntimeException(QueryPlugin.Event.TEIID30496, e);
}
this.userRequestSourceConcurrency = config.getUserRequestSourceConcurrency();
if (this.userRequestSourceConcurrency < 1) {
this.userRequestSourceConcurrency = Math.min(config.getMaxThreads(), 2 * config.getMaxThreads() / this.maxActivePlans);
}
DataTierManagerImpl processorDataManager = new DataTierManagerImpl(this, this.bufferManager, this.config.isDetectingChangeEvents());
processorDataManager.setEventDistributor(eventDistributor);
dataTierMgr = new TempTableDataManager(processorDataManager, this.bufferManager, this.rsCache);
dataTierMgr.setExecutor(new TempTableDataManager.RequestExecutor() {
@Override
public void execute(String command, List<?> parameters) {
final String sessionId = DQPWorkContext.getWorkContext().getSessionId();
RequestMessage request = new RequestMessage(command);
request.setParameterValues(parameters);
request.setStatementType(StatementType.PREPARED);
ResultsFuture<ResultsMessage> result;
try {
result = executeRequest(0, request);
} catch (TeiidProcessingException e) {
throw new TeiidRuntimeException(e);
}
result.addCompletionListener(new ResultsFuture.CompletionListener<ResultsMessage>() {
@Override
public void onCompletion(ResultsFuture<ResultsMessage> future) {
terminateSession(sessionId);
}
});
}
@Override
public boolean isShutdown() {
return shutdown;
}
});
dataTierMgr.setEventDistributor(eventDistributor);
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
LogManager.logDetail(LogConstants.CTX_DQP, "DQPCore started maxThreads", this.config.getMaxThreads(), "maxActivePlans", this.maxActivePlans, "source concurrency", this.userRequestSourceConcurrency);
}
use of org.teiid.core.TeiidRuntimeException in project teiid by teiid.
the class BufferManagerImpl method setState.
@Override
public void setState(String state_id, InputStream istream) {
TupleBuffer buffer = this.getTupleBuffer(state_id);
if (buffer == null) {
try {
ObjectInputStream in = new ObjectInputStream(istream);
setTupleBufferState(state_id, in);
} catch (IOException e) {
throw new TeiidRuntimeException(QueryPlugin.Event.TEIID30056, e);
} catch (ClassNotFoundException e) {
throw new TeiidRuntimeException(QueryPlugin.Event.TEIID30057, e);
} catch (TeiidComponentException e) {
throw new TeiidRuntimeException(QueryPlugin.Event.TEIID30058, e);
}
}
}
use of org.teiid.core.TeiidRuntimeException in project teiid by teiid.
the class BufferManagerImpl method getState.
@Override
public void getState(String state_id, OutputStream ostream) {
TupleBuffer buffer = this.getTupleBuffer(state_id);
if (buffer != null) {
try {
ObjectOutputStream out = new ObjectOutputStream(ostream);
getTupleBufferState(out, buffer);
out.flush();
} catch (TeiidComponentException e) {
throw new TeiidRuntimeException(QueryPlugin.Event.TEIID30054, e);
} catch (IOException e) {
throw new TeiidRuntimeException(QueryPlugin.Event.TEIID30055, e);
}
}
}
use of org.teiid.core.TeiidRuntimeException in project teiid by teiid.
the class TestOlapTranslator method testCannedProcedure.
@Test
public void testCannedProcedure() throws Exception {
String ddl = "create foreign procedure proc(arg integer, arg1 date) returns table (x string) options (\"teiid_rel:native-query\" '$2 $1 something')";
String query = "exec proc(2, {d'1970-01-01'})";
TransformationMetadata tm = RealMetadataFactory.fromDDL(ddl, "x", "phy");
CommandBuilder commandBuilder = new CommandBuilder(tm);
Command obj = commandBuilder.getCommand(query);
OlapExecutionFactory oef = new OlapExecutionFactory();
Connection mock = Mockito.mock(java.sql.Connection.class);
OlapWrapper mock2 = Mockito.mock(OlapWrapper.class);
OlapConnection mock3 = Mockito.mock(OlapConnection.class);
OlapStatement mock4 = Mockito.mock(OlapStatement.class);
Mockito.stub(mock4.executeOlapQuery(Mockito.anyString())).toThrow(new TeiidRuntimeException());
Mockito.stub(mock3.createStatement()).toReturn(mock4);
Mockito.stub(mock2.unwrap(OlapConnection.class)).toReturn(mock3);
Mockito.stub(mock.unwrap(OlapWrapper.class)).toReturn(mock2);
ProcedureExecution pe = oef.createProcedureExecution((Call) obj, Mockito.mock(ExecutionContext.class), new RuntimeMetadataImpl(tm), mock);
try {
pe.execute();
fail();
} catch (TeiidRuntimeException e) {
Mockito.verify(mock4).executeOlapQuery("'1970-01-01' 2 something");
}
}
use of org.teiid.core.TeiidRuntimeException in project teiid by teiid.
the class SetQuery method getTypedProjectedSymbols.
public static List<Expression> getTypedProjectedSymbols(List<? extends Expression> acutal, List<Class<?>> projectedTypes, QueryMetadataInterface metadata) {
List<Expression> newProject = new ArrayList<Expression>();
for (int i = 0; i < acutal.size(); i++) {
Expression originalSymbol = acutal.get(i);
Expression symbol = originalSymbol;
Class<?> type = projectedTypes.get(i);
if (symbol.getType() != type) {
symbol = SymbolMap.getExpression(originalSymbol);
try {
symbol = ResolverUtil.convertExpression(symbol, DataTypeManager.getDataTypeName(type), metadata);
} catch (QueryResolverException err) {
throw new TeiidRuntimeException(QueryPlugin.Event.TEIID30447, err);
}
if (originalSymbol instanceof Symbol) {
symbol = new AliasSymbol(Symbol.getShortName(originalSymbol), symbol);
}
}
newProject.add(symbol);
}
return newProject;
}
Aggregations