Search in sources :

Example 1 with EnhancedTimer

use of org.teiid.jdbc.EnhancedTimer 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)

Aggregations

RequestMessage (org.teiid.client.RequestMessage)1 ResultsFuture (org.teiid.client.util.ResultsFuture)1 TeiidComponentException (org.teiid.core.TeiidComponentException)1 TeiidProcessingException (org.teiid.core.TeiidProcessingException)1 TeiidRuntimeException (org.teiid.core.TeiidRuntimeException)1 AtomicRequestMessage (org.teiid.dqp.message.AtomicRequestMessage)1 EnhancedTimer (org.teiid.jdbc.EnhancedTimer)1 TempTableDataManager (org.teiid.query.tempdata.TempTableDataManager)1 Options (org.teiid.query.util.Options)1