use of org.apache.ignite.internal.jdbc.thin.JdbcThinTcpIo in project ignite by apache.
the class JdbcThinDataSourceSelfTest method testSqlHints.
/**
* @throws Exception If failed.
*/
@Test
public void testSqlHints() throws Exception {
IgniteJdbcThinDataSource ids = new IgniteJdbcThinDataSource();
ids.setUrl("jdbc:ignite:thin://127.0.0.1");
try (Connection conn = ids.getConnection()) {
for (JdbcThinTcpIo io : ios(conn)) {
assertFalse(io.connectionProperties().isAutoCloseServerCursor());
assertFalse(io.connectionProperties().isCollocated());
assertFalse(io.connectionProperties().isEnforceJoinOrder());
assertFalse(io.connectionProperties().isLazy());
assertFalse(io.connectionProperties().isDistributedJoins());
assertFalse(io.connectionProperties().isReplicatedOnly());
}
}
ids.setAutoCloseServerCursor(true);
ids.setCollocated(true);
ids.setEnforceJoinOrder(true);
ids.setLazy(true);
ids.setDistributedJoins(true);
ids.setReplicatedOnly(true);
try (Connection conn = ids.getConnection()) {
for (JdbcThinTcpIo io : ios(conn)) {
assertTrue(io.connectionProperties().isAutoCloseServerCursor());
assertTrue(io.connectionProperties().isCollocated());
assertTrue(io.connectionProperties().isEnforceJoinOrder());
assertTrue(io.connectionProperties().isLazy());
assertTrue(io.connectionProperties().isDistributedJoins());
assertTrue(io.connectionProperties().isReplicatedOnly());
}
}
}
use of org.apache.ignite.internal.jdbc.thin.JdbcThinTcpIo in project ignite by apache.
the class JdbcThinDataSourceSelfTest method testSocketBuffers.
/**
* @throws Exception If failed.
*/
@Test
public void testSocketBuffers() throws Exception {
final IgniteJdbcThinDataSource ids = new IgniteJdbcThinDataSource();
ids.setUrl("jdbc:ignite:thin://127.0.0.1");
ids.setSocketReceiveBuffer(111);
ids.setSocketSendBuffer(111);
try (Connection conn = ids.getConnection()) {
for (JdbcThinTcpIo io : ios(conn)) {
assertEquals(111, io.connectionProperties().getSocketReceiveBuffer());
assertEquals(111, io.connectionProperties().getSocketSendBuffer());
}
}
GridTestUtils.assertThrows(log, new Callable<Object>() {
@Override
public Object call() throws Exception {
ids.setSocketReceiveBuffer(-1);
ids.getConnection();
return null;
}
}, SQLException.class, "Property cannot be lower than 0 [name=socketReceiveBuffer, value=-1]");
GridTestUtils.assertThrows(log, new Callable<Object>() {
@Override
public Object call() throws Exception {
ids.setSocketReceiveBuffer(1024);
ids.setSocketSendBuffer(-1);
ids.getConnection();
return null;
}
}, SQLException.class, "Property cannot be lower than 0 [name=socketSendBuffer, value=-1]");
}
use of org.apache.ignite.internal.jdbc.thin.JdbcThinTcpIo in project ignite by apache.
the class JdbcThinTcpIoTest method testHostWithValidAddress.
/**
* Test connection to host with accessible address.
*
* @throws Exception If failed.
*/
@Test
public void testHostWithValidAddress() throws Exception {
startGrids(1);
JdbcThinTcpIo jdbcThinTcpIo = null;
try {
jdbcThinTcpIo = new JdbcThinTcpIo(new ConnectionPropertiesImpl(), new InetSocketAddress("127.0.0.1", 10800), null, 500);
} finally {
if (jdbcThinTcpIo != null)
jdbcThinTcpIo.close();
}
stopGrid(0);
}
use of org.apache.ignite.internal.jdbc.thin.JdbcThinTcpIo in project ignite by apache.
the class JdbcThinConnectionMultipleAddressesTest method stop.
/**
* @param conn Connection.
* @param all If {@code true} all nodes will be stopped.
*/
private void stop(Connection conn, boolean all) {
if (all)
stopAllGrids();
else {
JdbcThinTcpIo io = GridTestUtils.getFieldValue(conn, "cliIo");
int idx = GridTestUtils.getFieldValue(io, "srvIdx");
stopGrid(idx);
}
}
use of org.apache.ignite.internal.jdbc.thin.JdbcThinTcpIo in project ignite by apache.
the class JdbcThinTcpIoTest method testHostWithManyAddresses.
/**
* Test connection to host which has inaccessible A-records.
*
* @throws SQLException On connection error or reject.
* @throws IOException On IO error in handshake.
*/
public void testHostWithManyAddresses() throws SQLException, IOException, InterruptedException {
CountDownLatch connectionAccepted = new CountDownLatch(1);
try (ServerSocket sock = createServerSocket(connectionAccepted)) {
String[] addrs = { INACCESSIBLE_ADDRESSES[0], "127.0.0.1", INACCESSIBLE_ADDRESSES[1] };
JdbcThinTcpIo jdbcThinTcpIo = createTcpIo(addrs, sock.getLocalPort());
try {
jdbcThinTcpIo.start(500);
// Check connection
assertTrue(connectionAccepted.await(1000, TimeUnit.MILLISECONDS));
} finally {
jdbcThinTcpIo.close();
}
}
}
Aggregations