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;
}
Aggregations