Search in sources :

Example 1 with BufferService

use of org.teiid.dqp.service.BufferService in project teiid by teiid.

the class EmbeddedServer method start.

public synchronized void start(@SuppressWarnings("hiding") EmbeddedConfiguration config) {
    if (running != null) {
        throw new IllegalStateException();
    }
    this.dqp.setLocalProfile(this.embeddedProfile);
    this.shutdownListener.setBootInProgress(true);
    this.config = config;
    System.setProperty("jboss.node.name", config.getNodeName() == null ? "localhost" : config.getNodeName());
    this.cmr.setProvider(this);
    this.eventDistributorFactoryService = new EmbeddedEventDistributorFactoryService();
    this.eventDistributorFactoryService.start();
    this.dqp.setEventDistributor(this.eventDistributorFactoryService.getReplicatedEventDistributor());
    // $NON-NLS-1$
    this.scheduler = Executors.newScheduledThreadPool(config.getMaxAsyncThreads(), new NamedThreadFactory("Asynch Worker"));
    this.replicator = config.getObjectReplicator();
    if (this.replicator == null && config.getJgroupsConfigFile() != null) {
        channelFactory = new SimpleChannelFactory(config);
        this.replicator = new JGroupsObjectReplicator(channelFactory, this.scheduler);
        try {
            this.nodeTracker = new NodeTracker(channelFactory.createChannel("teiid-node-tracker"), config.getNodeName()) {

                @Override
                public ScheduledExecutorService getScheduledExecutorService() {
                    return scheduler;
                }
            };
        } catch (Exception e) {
            LogManager.logError(LogConstants.CTX_RUNTIME, e, RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40089));
        }
    }
    this.eventDistributorFactoryService = new EmbeddedEventDistributorFactoryService();
    // must be called after the replicator is set
    this.eventDistributorFactoryService.start();
    this.dqp.setEventDistributor(this.eventDistributorFactoryService.getReplicatedEventDistributor());
    if (config.getTransactionManager() == null) {
        LogManager.logInfo(LogConstants.CTX_RUNTIME, RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40089));
        this.transactionService.setTransactionManager((TransactionManager) Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class<?>[] { TransactionManager.class }, new InvocationHandler() {

            @Override
            public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
                throw new UnsupportedOperationException(RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40089));
            }
        }));
    } else {
        this.transactionService.setDetectTransactions(true);
        this.transactionService.setTransactionManager(config.getTransactionManager());
    }
    if (config.getSecurityHelper() != null) {
        this.sessionService.setSecurityHelper(config.getSecurityHelper());
    } else {
        this.sessionService.setSecurityHelper(new DoNothingSecurityHelper());
    }
    if (config.getSecurityDomain() != null) {
        this.sessionService.setSecurityDomain(config.getSecurityDomain());
    } else {
        // $NON-NLS-1$
        this.sessionService.setSecurityDomain("teiid-security");
    }
    this.sessionService.setVDBRepository(repo);
    setBufferManagerProperties(config);
    BufferService bs = getBufferService();
    this.dqp.setBufferManager(bs.getBufferManager());
    startVDBRepository();
    // $NON-NLS-1$
    rs = new SessionAwareCache<CachedResults>("resultset", config.getCacheFactory(), SessionAwareCache.Type.RESULTSET, config.getMaxResultSetCacheStaleness());
    // $NON-NLS-1$
    ppc = new SessionAwareCache<PreparedPlan>("preparedplan", config.getCacheFactory(), SessionAwareCache.Type.PREPAREDPLAN, 0);
    rs.setTupleBufferCache(bs.getTupleBufferCache());
    this.dqp.setResultsetCache(rs);
    ppc.setTupleBufferCache(bs.getTupleBufferCache());
    this.dqp.setPreparedPlanCache(ppc);
    this.dqp.setTransactionService((TransactionService) LogManager.createLoggingProxy(LogConstants.CTX_TXN_LOG, this.transactionService, new Class[] { TransactionService.class }, MessageLevel.DETAIL, Thread.currentThread().getContextClassLoader()));
    this.dqp.start(config);
    this.sessionService.setDqp(this.dqp);
    this.services.setSecurityHelper(this.sessionService.getSecurityHelper());
    if (this.config.getAuthenticationType() != null) {
        this.services.setAuthenticationType(this.config.getAuthenticationType());
        this.sessionService.setAuthenticationType(this.config.getAuthenticationType());
    }
    this.sessionService.start();
    this.services.setVDBRepository(this.repo);
    this.materializationMgr = getMaterializationManager();
    this.repo.addListener(this.materializationMgr);
    this.repo.setAllowEnvFunction(this.config.isAllowEnvFunction());
    if (this.nodeTracker != null) {
        this.nodeTracker.addNodeListener(this.materializationMgr);
    }
    this.logon = new LogonImpl(sessionService, null);
    services.registerClientService(ILogon.class, logon, LogConstants.CTX_SECURITY);
    DQP dqpProxy = DQP.class.cast(Proxy.newProxyInstance(this.getClass().getClassLoader(), new Class[] { DQP.class }, new SessionCheckingProxy(dqp, LogConstants.CTX_DQP, MessageLevel.TRACE)));
    services.registerClientService(DQP.class, dqpProxy, LogConstants.CTX_DQP);
    initDriver();
    List<SocketConfiguration> transports = config.getTransports();
    if (transports != null && !transports.isEmpty()) {
        for (SocketConfiguration socketConfig : transports) {
            SocketListener socketConnection = startTransport(socketConfig, bs.getBufferManager(), config.getMaxODBCLobSizeAllowed());
            if (socketConfig.getSSLConfiguration() != null) {
                try {
                    socketConfig.getSSLConfiguration().getServerSSLEngine();
                } catch (Exception e) {
                    throw new TeiidRuntimeException(e);
                }
            }
            this.transports.add(socketConnection);
        }
    }
    this.shutdownListener.setBootInProgress(false);
    this.shutdownListener.started();
    running = true;
}
Also used : TeiidRuntimeException(org.teiid.core.TeiidRuntimeException) JGroupsObjectReplicator(org.teiid.replication.jgroups.JGroupsObjectReplicator) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) DQP(org.teiid.client.DQP) NamedThreadFactory(org.teiid.core.util.NamedThreadFactory) BufferService(org.teiid.dqp.service.BufferService) Method(java.lang.reflect.Method) InvocationHandler(java.lang.reflect.InvocationHandler) ConnectorManagerException(org.teiid.dqp.internal.datamgr.ConnectorManagerRepository.ConnectorManagerException) InvalidSessionException(org.teiid.client.security.InvalidSessionException) XMLStreamException(javax.xml.stream.XMLStreamException) TeiidSQLException(org.teiid.jdbc.TeiidSQLException) ConnectionException(org.teiid.net.ConnectionException) SQLException(java.sql.SQLException) TranslatorException(org.teiid.translator.TranslatorException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException) URISyntaxException(java.net.URISyntaxException) TeiidException(org.teiid.core.TeiidException) SAXException(org.xml.sax.SAXException) VirtualDatabaseException(org.teiid.deployers.VirtualDatabaseException) TeiidRuntimeException(org.teiid.core.TeiidRuntimeException) CachedResults(org.teiid.dqp.internal.process.CachedResults) PreparedPlan(org.teiid.dqp.internal.process.PreparedPlan)

Aggregations

IOException (java.io.IOException)1 InvocationHandler (java.lang.reflect.InvocationHandler)1 Method (java.lang.reflect.Method)1 URISyntaxException (java.net.URISyntaxException)1 UnknownHostException (java.net.UnknownHostException)1 SQLException (java.sql.SQLException)1 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)1 XMLStreamException (javax.xml.stream.XMLStreamException)1 DQP (org.teiid.client.DQP)1 InvalidSessionException (org.teiid.client.security.InvalidSessionException)1 TeiidException (org.teiid.core.TeiidException)1 TeiidRuntimeException (org.teiid.core.TeiidRuntimeException)1 NamedThreadFactory (org.teiid.core.util.NamedThreadFactory)1 VirtualDatabaseException (org.teiid.deployers.VirtualDatabaseException)1 ConnectorManagerException (org.teiid.dqp.internal.datamgr.ConnectorManagerRepository.ConnectorManagerException)1 CachedResults (org.teiid.dqp.internal.process.CachedResults)1 PreparedPlan (org.teiid.dqp.internal.process.PreparedPlan)1 BufferService (org.teiid.dqp.service.BufferService)1 TeiidSQLException (org.teiid.jdbc.TeiidSQLException)1 ConnectionException (org.teiid.net.ConnectionException)1