use of org.teiid.net.socket.SocketServerConnectionFactory in project teiid by teiid.
the class TestCommSockets method helpEstablishConnection.
private SocketServerConnection helpEstablishConnection(boolean clientSecure, SSLConfiguration config, Properties socketConfig) throws CommunicationException, ConnectionException {
if (listener == null) {
ClientServiceRegistryImpl server = new ClientServiceRegistryImpl() {
@Override
public ClassLoader getCallerClassloader() {
return getClass().getClassLoader();
}
};
service = new SessionServiceImpl();
server.registerClientService(ILogon.class, new LogonImpl(service, "fakeCluster"), null);
server.registerClientService(FakeService.class, new TestSocketRemoting.FakeServiceImpl(), null);
storageManager = new MemoryStorageManager();
listener = new SocketListener(addr, 0, 0, 2, config, server, storageManager);
SocketListenerStats stats = listener.getStats();
assertEquals(0, stats.maxSockets);
assertEquals(0, stats.objectsRead);
assertEquals(0, stats.objectsWritten);
assertEquals(0, stats.sockets);
}
Properties p = new Properties(socketConfig);
String url = new TeiidURL(addr.getHostName(), listener.getPort(), clientSecure).getAppServerURL();
p.setProperty(TeiidURL.CONNECTION.SERVER_URL, url);
p.setProperty(TeiidURL.CONNECTION.APP_NAME, "test");
p.setProperty(TeiidURL.CONNECTION.DISCOVERY_STRATEGY, UrlServerDiscovery.class.getName());
if (sscf == null) {
sscf = new SocketServerConnectionFactory();
sscf.initialize(socketConfig);
}
return sscf.getConnection(p);
}
use of org.teiid.net.socket.SocketServerConnectionFactory in project teiid by teiid.
the class TestFailover method helpEstablishConnection.
private SocketServerConnection helpEstablishConnection(boolean clientSecure, SSLConfiguration config, Properties socketConfig) throws CommunicationException, ConnectionException {
listener = createListener(addr, config);
listener1 = createListener(addr, config);
listener1.stop();
Properties p = new Properties();
TeiidURL teiidUrl = new TeiidURL(addr.getHostName(), listener.getPort(), clientSecure);
teiidUrl.getHostInfo().add(new HostInfo(addr.getHostName(), listener1.getPort()));
String url = teiidUrl.getAppServerURL();
p.setProperty(TeiidURL.CONNECTION.SERVER_URL, url);
p.setProperty(TeiidURL.CONNECTION.DISCOVERY_STRATEGY, UrlServerDiscovery.class.getName());
p.setProperty(TeiidURL.CONNECTION.AUTO_FAILOVER, Boolean.TRUE.toString());
if (sscf == null) {
sscf = new SocketServerConnectionFactory();
sscf.initialize(socketConfig);
}
return sscf.getConnection(p);
}
use of org.teiid.net.socket.SocketServerConnectionFactory in project teiid by teiid.
the class TestJDBCSocketTransport method testSyncTimeout.
/**
* Tests to ensure that a SynchronousTtl/synchTimeout does
* not cause a cancel.
* TODO: had to increase the values since the test would fail on slow machine runs
* @throws Exception
*/
@Test
public void testSyncTimeout() throws Exception {
TeiidDriver td = new TeiidDriver();
td.setSocketProfile(new ConnectionProfile() {
@Override
public ConnectionImpl connect(String url, Properties info) throws TeiidSQLException {
SocketServerConnectionFactory sscf = new SocketServerConnectionFactory();
sscf.initialize(info);
try {
return new ConnectionImpl(sscf.getConnection(info), info, url);
} catch (CommunicationException e) {
throw TeiidSQLException.create(e);
} catch (ConnectionException e) {
throw TeiidSQLException.create(e);
}
}
});
Properties p = new Properties();
p.setProperty("user", "testuser");
p.setProperty("password", "testpassword");
ConnectorManagerRepository cmr = server.getConnectorManagerRepository();
AutoGenDataService agds = new AutoGenDataService() {
@Override
public Object getConnectionFactory() throws TranslatorException {
return null;
}
};
// wait longer than the synch ttl/soTimeout, we should still succeed
agds.setSleep(2000);
cmr.addConnectorManager("source", agds);
try {
conn = td.connect("jdbc:teiid:parts@mm://" + addr.getHostName() + ":" + jdbcTransport.getPort(), p);
Statement s = conn.createStatement();
assertTrue(s.execute("select * from parts"));
} finally {
server.setConnectorManagerRepository(cmr);
}
}
Aggregations