use of org.teiid.transport.SocketListener in project teiid by teiid.
the class TestJDBCSocketPerformance method oneTimeSetup.
@BeforeClass
public static void oneTimeSetup() throws Exception {
SocketConfiguration config = new SocketConfiguration();
config.setSSLConfiguration(new SSLConfiguration());
addr = new InetSocketAddress(0);
config.setBindAddress(addr.getHostName());
config.setPortNumber(0);
EmbeddedConfiguration dqpConfig = new EmbeddedConfiguration();
dqpConfig.setMaxActivePlans(2);
server = new FakeServer(false);
server.start(dqpConfig);
ModelMetaData mmd = new ModelMetaData();
mmd.setName("x");
mmd.setModelType(Type.PHYSICAL);
mmd.addSourceMapping("x", "hc", null);
mmd.setSchemaSourceType("ddl");
StringBuffer ddl = new StringBuffer("create foreign table x (col0 string");
for (int i = 1; i < 10; i++) {
ddl.append(",").append(" col").append(i).append(" string");
}
ddl.append(");");
mmd.setSchemaText(ddl.toString());
server.addTranslator("hc", new HardCodedExecutionFactory() {
@Override
protected List<? extends List<?>> getData(QueryExpression command) {
List<List<String>> result = new ArrayList<List<String>>();
int size = command.getProjectedQuery().getDerivedColumns().size();
for (int i = 0; i < 64; i++) {
List<String> row = new ArrayList<String>(size);
for (int j = 0; j < size; j++) {
row.add("abcdefghi" + j);
}
result.add(row);
}
return result;
}
});
server.deployVDB("x", mmd);
jdbcTransport = new SocketListener(addr, config, server.getClientServiceRegistry(), BufferManagerFactory.getStandaloneBufferManager());
}
use of org.teiid.transport.SocketListener 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)));
}
}
Aggregations