Search in sources :

Example 1 with LocalServerConnection

use of org.teiid.transport.LocalServerConnection in project teiid by teiid.

the class LocalClient method getVDBInternal.

private VDBMetaData getVDBInternal() throws SQLException, TeiidProcessingException {
    if (this.vdb == null) {
        LocalServerConnection lsc = (LocalServerConnection) getConnection().getServerConnection();
        vdb = lsc.getWorkContext().getVDB();
        if (vdb == null) {
            throw new TeiidRuntimeException(ODataPlugin.Util.gs(ODataPlugin.Event.TEIID16001, this.vdbName, this.vdbVersion));
        }
        this.vdb = vdb;
    }
    if (vdb.getStatus() != Status.ACTIVE) {
        throw new TeiidProcessingException(QueryPlugin.Event.TEIID31099, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31099, vdb, vdb.getStatus()));
    }
    return this.vdb;
}
Also used : TeiidRuntimeException(org.teiid.core.TeiidRuntimeException) LocalServerConnection(org.teiid.transport.LocalServerConnection) TeiidProcessingException(org.teiid.core.TeiidProcessingException)

Example 2 with LocalServerConnection

use of org.teiid.transport.LocalServerConnection in project teiid by teiid.

the class ODataFilter method registerVDBListener.

protected void registerVDBListener(Client client, Connection conn) {
    if (!this.listenerRegistered) {
        synchronized (this) {
            if (!this.listenerRegistered) {
                if (client instanceof LocalClient) {
                    try {
                        ConnectionImpl connection = (ConnectionImpl) conn;
                        LocalServerConnection lsc = (LocalServerConnection) connection.getServerConnection();
                        lsc.addListener(this);
                        this.listenerRegistered = true;
                    } catch (SQLException e) {
                        LogManager.logWarning(LogConstants.CTX_ODATA, ODataPlugin.Util.gs(ODataPlugin.Event.TEIID16014));
                    }
                }
            }
        }
    }
}
Also used : SQLException(java.sql.SQLException) LocalClient(org.teiid.olingo.service.LocalClient) ConnectionImpl(org.teiid.jdbc.ConnectionImpl) LocalServerConnection(org.teiid.transport.LocalServerConnection)

Example 3 with LocalServerConnection

use of org.teiid.transport.LocalServerConnection in project teiid by teiid.

the class TransportService method start.

@Override
public void start(StartContext context) throws StartException {
    this.setVDBRepository(this.getVdbRepository());
    SessionService ss = sessionServiceInjector.getValue();
    this.setSecurityHelper(ss.getSecurityHelper());
    // create the necessary services
    // $NON-NLS-1$
    this.logon = new LogonImpl(ss, "teiid-cluster");
    DQP dqpProxy = proxyService(DQP.class, getDQP(), LogConstants.CTX_DQP);
    this.registerClientService(ILogon.class, logon, LogConstants.CTX_SECURITY);
    this.registerClientService(DQP.class, dqpProxy, LogConstants.CTX_DQP);
    this.setAuthenticationType(ss.getDefaultAuthenticationType());
    if (this.socketConfig != null) {
        /*
    		try {
				// this is to show the bound socket port in the JMX console
				SocketBinding socketBinding = getSocketBindingInjector().getValue();
				ManagedServerSocketBinding ss = (ManagedServerSocketBinding)socketBinding.getSocketBindings().getServerSocketFactory().createServerSocket(socketBinding.getName());
				socketBinding.getSocketBindings().getNamedRegistry().registerBinding(ss);
			}  catch (IOException e) {
				throw new StartException(IntegrationPlugin.Util.gs(IntegrationPlugin.Event.TEIID50013));
			}
    		*/
        this.address = getSocketBindingInjector().getValue().getSocketAddress();
        this.socketConfig.setBindAddress(this.address.getHostName());
        this.socketConfig.setPortNumber(this.address.getPort());
        boolean sslEnabled = false;
        if (this.socketConfig.getSSLConfiguration() != null) {
            sslEnabled = this.socketConfig.getSSLConfiguration().isSslEnabled();
        }
        if (socketConfig.getProtocol() == WireProtocol.teiid) {
            this.socketListener = new SocketListener(address, this.socketConfig, this, getBufferManagerInjector().getValue());
            // $NON-NLS-1$ //$NON-NLS-2$
            LogManager.logInfo(LogConstants.CTX_RUNTIME, IntegrationPlugin.Util.gs(IntegrationPlugin.Event.TEIID50012, this.transportName, address.getHostName(), String.valueOf(address.getPort()), (sslEnabled ? "ON" : "OFF")));
        } else if (socketConfig.getProtocol() == WireProtocol.pg) {
            TeiidDriver driver = new TeiidDriver();
            driver.setLocalProfile(new ConnectionProfile() {

                @Override
                public ConnectionImpl connect(String url, Properties info) throws TeiidSQLException {
                    try {
                        LocalServerConnection sc = new LocalServerConnection(info, true) {

                            @Override
                            protected ClientServiceRegistry getClientServiceRegistry(String name) {
                                return TransportService.this;
                            }
                        };
                        return new ConnectionImpl(sc, info, url);
                    } catch (CommunicationException e) {
                        throw TeiidSQLException.create(e);
                    } catch (ConnectionException e) {
                        throw TeiidSQLException.create(e);
                    }
                }
            });
            ODBCSocketListener odbc = new ODBCSocketListener(address, this.socketConfig, this, getBufferManagerInjector().getValue(), getMaxODBCLobSizeAllowed(), this.logon, driver);
            this.socketListener = odbc;
            // $NON-NLS-1$ //$NON-NLS-2$
            LogManager.logInfo(LogConstants.CTX_RUNTIME, IntegrationPlugin.Util.gs(IntegrationPlugin.Event.TEIID50037, this.transportName, address.getHostName(), String.valueOf(address.getPort()), (sslEnabled ? "ON" : "OFF")));
        } else {
            throw new StartException(IntegrationPlugin.Util.gs(IntegrationPlugin.Event.TEIID50013));
        }
    } else {
        LogManager.logInfo(LogConstants.CTX_RUNTIME, IntegrationPlugin.Util.gs(IntegrationPlugin.Event.TEIID50038, LocalServerConnection.jndiNameForRuntime(transportName)));
    }
}
Also used : DQP(org.teiid.client.DQP) CommunicationException(org.teiid.net.CommunicationException) ConnectionProfile(org.teiid.jdbc.ConnectionProfile) ConnectionImpl(org.teiid.jdbc.ConnectionImpl) Properties(java.util.Properties) SessionService(org.teiid.dqp.service.SessionService) LogonImpl(org.teiid.transport.LogonImpl) SocketListener(org.teiid.transport.SocketListener) ODBCSocketListener(org.teiid.transport.ODBCSocketListener) TeiidDriver(org.teiid.jdbc.TeiidDriver) StartException(org.jboss.msc.service.StartException) LocalServerConnection(org.teiid.transport.LocalServerConnection) ODBCSocketListener(org.teiid.transport.ODBCSocketListener) ConnectionException(org.teiid.net.ConnectionException)

Aggregations

LocalServerConnection (org.teiid.transport.LocalServerConnection)3 ConnectionImpl (org.teiid.jdbc.ConnectionImpl)2 SQLException (java.sql.SQLException)1 Properties (java.util.Properties)1 StartException (org.jboss.msc.service.StartException)1 DQP (org.teiid.client.DQP)1 TeiidProcessingException (org.teiid.core.TeiidProcessingException)1 TeiidRuntimeException (org.teiid.core.TeiidRuntimeException)1 SessionService (org.teiid.dqp.service.SessionService)1 ConnectionProfile (org.teiid.jdbc.ConnectionProfile)1 TeiidDriver (org.teiid.jdbc.TeiidDriver)1 CommunicationException (org.teiid.net.CommunicationException)1 ConnectionException (org.teiid.net.ConnectionException)1 LocalClient (org.teiid.olingo.service.LocalClient)1 LogonImpl (org.teiid.transport.LogonImpl)1 ODBCSocketListener (org.teiid.transport.ODBCSocketListener)1 SocketListener (org.teiid.transport.SocketListener)1