use of org.teiid.transport.SocketConfiguration in project teiid by teiid.
the class TestEmbeddedServer method testRemoteODBCTrasport.
@Test
public void testRemoteODBCTrasport() throws Exception {
SocketConfiguration s = new SocketConfiguration();
InetSocketAddress addr = new InetSocketAddress(0);
s.setBindAddress(addr.getHostName());
s.setPortNumber(addr.getPort());
s.setProtocol(WireProtocol.pg);
EmbeddedConfiguration config = new EmbeddedConfiguration();
config.addTransport(s);
es.start(config);
es.deployVDB(new ByteArrayInputStream("<vdb name=\"test\" version=\"1\"><model name=\"test\" type=\"VIRTUAL\"><metadata type=\"DDL\"><![CDATA[CREATE VIEW helloworld as SELECT 'HELLO WORLD';]]> </metadata></model></vdb>".getBytes()));
Connection conn = null;
try {
Driver d = new Driver();
Properties p = new Properties();
p.setProperty("user", "testuser");
p.setProperty("password", "testpassword");
conn = d.connect("jdbc:postgresql://" + addr.getHostName() + ":" + es.transports.get(0).getPort() + "/test", p);
ResultSet rs = conn.createStatement().executeQuery("select * from helloworld");
rs.next();
assertEquals("HELLO WORLD", rs.getString(1));
} finally {
if (conn != null) {
conn.close();
}
}
}
use of org.teiid.transport.SocketConfiguration in project teiid by teiid.
the class TestEmbeddedServer method testRemoteJDBCTrasport.
@Test
public void testRemoteJDBCTrasport() throws Exception {
SocketConfiguration s = new SocketConfiguration();
InetSocketAddress addr = new InetSocketAddress(0);
s.setBindAddress(addr.getHostName());
s.setPortNumber(addr.getPort());
s.setProtocol(WireProtocol.teiid);
EmbeddedConfiguration config = new EmbeddedConfiguration();
config.addTransport(s);
es.start(config);
es.deployVDB(new ByteArrayInputStream("<vdb name=\"test\" version=\"1\"><model name=\"test\" type=\"VIRTUAL\"><metadata type=\"DDL\"><![CDATA[CREATE VIEW helloworld as SELECT 'HELLO WORLD';]]> </metadata></model></vdb>".getBytes()));
Connection conn = null;
try {
TeiidDriver driver = new TeiidDriver();
conn = driver.connect("jdbc:teiid:test@mm://" + addr.getHostName() + ":" + es.transports.get(0).getPort(), null);
// trigger alternative serialization for byte count
conn.createStatement().execute("set showplan on");
ResultSet rs = conn.createStatement().executeQuery("select * from helloworld");
rs.next();
assertEquals("HELLO WORLD", rs.getString(1));
} finally {
if (conn != null) {
conn.close();
}
}
}
use of org.teiid.transport.SocketConfiguration 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.SocketConfiguration in project teiid by teiid.
the class TransportAdd method buildSocketConfiguration.
private SocketConfiguration buildSocketConfiguration(final OperationContext context, ModelNode node) throws OperationFailedException {
SocketConfiguration socket = new SocketConfiguration();
if (isDefined(TRANSPORT_PROTOCOL_ATTRIBUTE, node, context)) {
socket.setProtocol(asString(TRANSPORT_PROTOCOL_ATTRIBUTE, node, context));
} else {
// $NON-NLS-1$
socket.setProtocol("teiid");
}
if (isDefined(TRANSPORT_MAX_SOCKET_THREADS_ATTRIBUTE, node, context)) {
socket.setMaxSocketThreads(asInt(TRANSPORT_MAX_SOCKET_THREADS_ATTRIBUTE, node, context));
}
if (isDefined(TRANSPORT_IN_BUFFER_SIZE_ATTRIBUTE, node, context)) {
socket.setInputBufferSize(asInt(TRANSPORT_IN_BUFFER_SIZE_ATTRIBUTE, node, context));
}
if (isDefined(TRANSPORT_OUT_BUFFER_SIZE_ATTRIBUTE, node, context)) {
socket.setOutputBufferSize(asInt(TRANSPORT_OUT_BUFFER_SIZE_ATTRIBUTE, node, context));
}
SSLConfiguration ssl = new SSLConfiguration();
if (isDefined(SSL_MODE_ATTRIBUTE, node, context)) {
ssl.setMode(asString(SSL_MODE_ATTRIBUTE, node, context));
}
if (isDefined(SSL_SSL_PROTOCOL_ATTRIBUTE, node, context)) {
ssl.setSslProtocol(asString(SSL_SSL_PROTOCOL_ATTRIBUTE, node, context));
}
if (isDefined(SSL_KEY_MANAGEMENT_ALG_ATTRIBUTE, node, context)) {
ssl.setKeymanagementAlgorithm(asString(SSL_KEY_MANAGEMENT_ALG_ATTRIBUTE, node, context));
}
if (isDefined(SSL_AUTH_MODE_ATTRIBUTE, node, context)) {
ssl.setAuthenticationMode(asString(SSL_AUTH_MODE_ATTRIBUTE, node, context));
}
if (isDefined(SSL_KETSTORE_NAME_ATTRIBUTE, node, context)) {
ssl.setKeystoreFilename(asString(SSL_KETSTORE_NAME_ATTRIBUTE, node, context));
}
if (isDefined(SSL_KETSTORE_ALIAS_ATTRIBUTE, node, context)) {
ssl.setKeystoreKeyAlias(asString(SSL_KETSTORE_ALIAS_ATTRIBUTE, node, context));
}
if (isDefined(SSL_KETSTORE_KEY_PASSWORD_ATTRIBUTE, node, context)) {
ssl.setKeystoreKeyPassword(asString(SSL_KETSTORE_KEY_PASSWORD_ATTRIBUTE, node, context));
}
if (isDefined(SSL_ENABLED_CIPHER_SUITES_ATTRIBUTE, node, context)) {
ssl.setEnabledCipherSuites(asString(SSL_ENABLED_CIPHER_SUITES_ATTRIBUTE, node, context));
}
if (isDefined(SSL_KETSTORE_PASSWORD_ATTRIBUTE, node, context)) {
ssl.setKeystorePassword(asString(SSL_KETSTORE_PASSWORD_ATTRIBUTE, node, context));
}
if (isDefined(SSL_KETSTORE_TYPE_ATTRIBUTE, node, context)) {
ssl.setKeystoreType(asString(SSL_KETSTORE_TYPE_ATTRIBUTE, node, context));
}
if (isDefined(SSL_TRUSTSTORE_NAME_ATTRIBUTE, node, context)) {
ssl.setTruststoreFilename(asString(SSL_TRUSTSTORE_NAME_ATTRIBUTE, node, context));
}
if (isDefined(SSL_TRUSTSTORE_PASSWORD_ATTRIBUTE, node, context)) {
ssl.setTruststorePassword(asString(SSL_TRUSTSTORE_PASSWORD_ATTRIBUTE, node, context));
}
if (isDefined(SSL_TRUSTSTORE_CHECK_EXPIRED_ATTRIBUTE, node, context)) {
ssl.setTruststoreCheckExpired(asBoolean(SSL_TRUSTSTORE_CHECK_EXPIRED_ATTRIBUTE, node, context));
}
socket.setSSLConfiguration(ssl);
return socket;
}
use of org.teiid.transport.SocketConfiguration in project teiid by teiid.
the class TestEmbeddedServer method testRemoteTrasportSSLFail.
@Test(expected = TeiidRuntimeException.class)
public void testRemoteTrasportSSLFail() throws Exception {
SocketConfiguration s = new SocketConfiguration();
InetSocketAddress addr = new InetSocketAddress(0);
s.setBindAddress(addr.getHostName());
s.setPortNumber(addr.getPort());
s.setProtocol(WireProtocol.teiid);
SSLConfiguration sslConfiguration = new SSLConfiguration();
sslConfiguration.setSslProtocol("x");
sslConfiguration.setMode("enabled");
s.setSSLConfiguration(sslConfiguration);
EmbeddedConfiguration config = new EmbeddedConfiguration();
config.addTransport(s);
es.start(config);
}
Aggregations