use of org.apache.ignite.internal.jdbc.thin.JdbcThinTcpIo in project ignite by apache.
the class JdbcThinPartitionAwarenessReconnectionAndFailoverSelfTest method testFailoverOnAllNodes.
/**
* Check that all possible sub-connections are used.
*
* <ol>
* <li>Create {@code JdbcThinConnection} to all existing nodes.</li>
* <li>Stop all nodes.</li>
* <li>Submit arbitrary sql query.</li>
* <li>Several retries are expected. Exact number of retries should be equal to the number of originally
* established connections. At the very end, after trying to establish brand new connections {@code SQLException}
* with message: 'Failed to connect to server' should be thrown.</li>
* </ol>
*
* @throws Exception If failed.
*/
@SuppressWarnings("ThrowableNotThrown")
@Test
public void testFailoverOnAllNodes() throws Exception {
try (Connection conn = DriverManager.getConnection("jdbc:ignite:thin://127.0.0.1:10800..10802?partitionAwareness=true")) {
Map<UUID, JdbcThinTcpIo> ios = GridTestUtils.getFieldValue(conn, "ios");
assertConnectionsCount(ios, 3);
stopAllGrids();
logHnd.records.clear();
GridTestUtils.assertThrows(null, new Callable<Object>() {
@Override
public Object call() throws Exception {
conn.createStatement().execute("select 1");
return null;
}
}, SQLException.class, "Failed to connect to server [url=jdbc:ignite:thin://127.0.0.1:10800..10802]");
}
assertEquals("Unexpected log records count.", 3, logHnd.records.size());
for (LogRecord record : logHnd.records) {
assertEquals("Unexpected log record text.", "Exception during sending an sql request.", record.getMessage());
assertEquals("Unexpected log level", Level.FINE, record.getLevel());
}
startGridsMultiThreaded(INITIAL_NODES_CNT);
}
use of org.apache.ignite.internal.jdbc.thin.JdbcThinTcpIo in project ignite by apache.
the class JdbcThinConnectionSelfTest method assertHints.
/**
* Assert hints.
*
* @param conn Connection.
* @param distributedJoins Distributed joins.
* @param enforceJoinOrder Enforce join order.
* @param collocated Co-located.
* @param replicatedOnly Replicated only.
* @param lazy Lazy.
* @param skipReducerOnUpdate Skip reducer on update.
* @throws Exception If failed.
*/
private void assertHints(Connection conn, boolean distributedJoins, boolean enforceJoinOrder, boolean collocated, boolean replicatedOnly, boolean lazy, boolean skipReducerOnUpdate, boolean partitionAwarenessEnabled) throws Exception {
for (JdbcThinTcpIo io : ios(conn)) {
assertEquals(distributedJoins, io.connectionProperties().isDistributedJoins());
assertEquals(enforceJoinOrder, io.connectionProperties().isEnforceJoinOrder());
assertEquals(collocated, io.connectionProperties().isCollocated());
assertEquals(replicatedOnly, io.connectionProperties().isReplicatedOnly());
assertEquals(lazy, io.connectionProperties().isLazy());
assertEquals(skipReducerOnUpdate, io.connectionProperties().isSkipReducerOnUpdate());
assertEquals(partitionAwarenessEnabled, io.connectionProperties().isPartitionAwareness());
}
}
use of org.apache.ignite.internal.jdbc.thin.JdbcThinTcpIo in project ignite by apache.
the class JdbcThinConnectionSelfTest method testAutoCloseServerCursorProperty.
/**
* Test autoCloseServerCursor property handling.
*
* @throws Exception If failed.
*/
@Test
public void testAutoCloseServerCursorProperty() throws Exception {
String url = urlWithPartitionAwarenessProp + "&autoCloseServerCursor";
String err = "Invalid property value. [name=autoCloseServerCursor";
assertInvalid(url + "=0", err);
assertInvalid(url + "=1", err);
assertInvalid(url + "=false1", err);
assertInvalid(url + "=true1", err);
try (Connection conn = DriverManager.getConnection(urlWithPartitionAwarenessProp)) {
for (JdbcThinTcpIo io : ios(conn)) assertFalse(io.connectionProperties().isAutoCloseServerCursor());
}
try (Connection conn = DriverManager.getConnection(url + "=true")) {
for (JdbcThinTcpIo io : ios(conn)) assertTrue(io.connectionProperties().isAutoCloseServerCursor());
}
try (Connection conn = DriverManager.getConnection(url + "=True")) {
for (JdbcThinTcpIo io : ios(conn)) assertTrue(io.connectionProperties().isAutoCloseServerCursor());
}
try (Connection conn = DriverManager.getConnection(url + "=false")) {
for (JdbcThinTcpIo io : ios(conn)) assertFalse(io.connectionProperties().isAutoCloseServerCursor());
}
try (Connection conn = DriverManager.getConnection(url + "=False")) {
for (JdbcThinTcpIo io : ios(conn)) assertFalse(io.connectionProperties().isAutoCloseServerCursor());
}
}
use of org.apache.ignite.internal.jdbc.thin.JdbcThinTcpIo in project ignite by apache.
the class JdbcThinConnectionSelfTest method testTcpNoDelaySemicolon.
/**
* Test TCP no delay property handling with semicolon.
*
* @throws Exception If failed.
*/
@Test
public void testTcpNoDelaySemicolon() throws Exception {
assertInvalid(urlWithPartitionAwarenessPropSemicolon + ";tcpNoDelay=0", "Invalid property value. [name=tcpNoDelay, val=0, choices=[true, false]]");
assertInvalid(urlWithPartitionAwarenessPropSemicolon + ";tcpNoDelay=1", "Invalid property value. [name=tcpNoDelay, val=1, choices=[true, false]]");
assertInvalid(urlWithPartitionAwarenessPropSemicolon + ";tcpNoDelay=false1", "Invalid property value. [name=tcpNoDelay, val=false1, choices=[true, false]]");
assertInvalid(urlWithPartitionAwarenessPropSemicolon + ";tcpNoDelay=true1", "Invalid property value. [name=tcpNoDelay, val=true1, choices=[true, false]]");
try (Connection conn = DriverManager.getConnection(urlWithPartitionAwarenessPropSemicolon + ";tcpNoDelay=true")) {
for (JdbcThinTcpIo io : ios(conn)) assertTrue(io.connectionProperties().isTcpNoDelay());
}
try (Connection conn = DriverManager.getConnection(urlWithPartitionAwarenessPropSemicolon + ";tcpNoDelay=True")) {
for (JdbcThinTcpIo io : ios(conn)) assertTrue(io.connectionProperties().isTcpNoDelay());
}
try (Connection conn = DriverManager.getConnection(urlWithPartitionAwarenessPropSemicolon + ";tcpNoDelay=false")) {
for (JdbcThinTcpIo io : ios(conn)) assertFalse(io.connectionProperties().isTcpNoDelay());
}
try (Connection conn = DriverManager.getConnection(urlWithPartitionAwarenessPropSemicolon + ";tcpNoDelay=False")) {
for (JdbcThinTcpIo io : ios(conn)) assertFalse(io.connectionProperties().isTcpNoDelay());
}
}
use of org.apache.ignite.internal.jdbc.thin.JdbcThinTcpIo in project ignite by apache.
the class JdbcThinDataSourceSelfTest method ios.
/**
* Get client endpoints for connection.
*
* @param conn Connection.
* @return Collection of endpoints.
* @throws Exception If failed.
*/
private static Collection<JdbcThinTcpIo> ios(Connection conn) throws Exception {
JdbcThinConnection conn0 = conn.unwrap(JdbcThinConnection.class);
Collection<JdbcThinTcpIo> ios = partitionAwareness ? ((Map<UUID, JdbcThinTcpIo>) GridTestUtils.getFieldValue(conn0, JdbcThinConnection.class, "ios")).values() : Collections.singleton(GridTestUtils.getFieldValue(conn0, JdbcThinConnection.class, "singleIo"));
assert !ios.isEmpty();
return ios;
}
Aggregations