Search in sources :

Example 31 with TeiidRuntimeException

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);
}
Also used : Options(org.teiid.query.util.Options) EnhancedTimer(org.teiid.jdbc.EnhancedTimer) TempTableDataManager(org.teiid.query.tempdata.TempTableDataManager) TeiidRuntimeException(org.teiid.core.TeiidRuntimeException) TeiidProcessingException(org.teiid.core.TeiidProcessingException) ResultsFuture(org.teiid.client.util.ResultsFuture) AtomicRequestMessage(org.teiid.dqp.message.AtomicRequestMessage) RequestMessage(org.teiid.client.RequestMessage) TeiidComponentException(org.teiid.core.TeiidComponentException)

Example 32 with TeiidRuntimeException

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);
        }
    }
}
Also used : TeiidComponentException(org.teiid.core.TeiidComponentException) IOException(java.io.IOException) TeiidRuntimeException(org.teiid.core.TeiidRuntimeException) ObjectInputStream(java.io.ObjectInputStream)

Example 33 with TeiidRuntimeException

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);
        }
    }
}
Also used : TeiidComponentException(org.teiid.core.TeiidComponentException) TeiidRuntimeException(org.teiid.core.TeiidRuntimeException) IOException(java.io.IOException) ObjectOutputStream(java.io.ObjectOutputStream)

Example 34 with TeiidRuntimeException

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");
    }
}
Also used : TransformationMetadata(org.teiid.query.metadata.TransformationMetadata) OlapConnection(org.olap4j.OlapConnection) Connection(java.sql.Connection) OlapConnection(org.olap4j.OlapConnection) TeiidRuntimeException(org.teiid.core.TeiidRuntimeException) OlapStatement(org.olap4j.OlapStatement) ExecutionContext(org.teiid.translator.ExecutionContext) Command(org.teiid.language.Command) OlapWrapper(org.olap4j.OlapWrapper) ProcedureExecution(org.teiid.translator.ProcedureExecution) RuntimeMetadataImpl(org.teiid.dqp.internal.datamgr.RuntimeMetadataImpl) CommandBuilder(org.teiid.cdk.CommandBuilder) Test(org.junit.Test)

Example 35 with TeiidRuntimeException

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;
}
Also used : AliasSymbol(org.teiid.query.sql.symbol.AliasSymbol) Expression(org.teiid.query.sql.symbol.Expression) AliasSymbol(org.teiid.query.sql.symbol.AliasSymbol) Symbol(org.teiid.query.sql.symbol.Symbol) ArrayList(java.util.ArrayList) TeiidRuntimeException(org.teiid.core.TeiidRuntimeException) QueryResolverException(org.teiid.api.exception.query.QueryResolverException)

Aggregations

TeiidRuntimeException (org.teiid.core.TeiidRuntimeException)103 IOException (java.io.IOException)27 TeiidComponentException (org.teiid.core.TeiidComponentException)22 TeiidException (org.teiid.core.TeiidException)22 ArrayList (java.util.ArrayList)20 TeiidProcessingException (org.teiid.core.TeiidProcessingException)17 SQLException (java.sql.SQLException)11 ObjectInputStream (java.io.ObjectInputStream)9 HashMap (java.util.HashMap)9 InputStream (java.io.InputStream)7 Map (java.util.Map)7 Test (org.junit.Test)7 QueryMetadataException (org.teiid.api.exception.query.QueryMetadataException)7 ObjectOutputStream (java.io.ObjectOutputStream)6 List (java.util.List)6 QueryResolverException (org.teiid.api.exception.query.QueryResolverException)6 XMLStreamException (javax.xml.stream.XMLStreamException)5 QueryPlannerException (org.teiid.api.exception.query.QueryPlannerException)5 JsonObject (com.couchbase.client.java.document.json.JsonObject)4 ByteArrayInputStream (java.io.ByteArrayInputStream)4