Copilot commented on code in PR #7081:
URL: https://github.com/apache/ignite-3/pull/7081#discussion_r2565056568
##########
docs/_docs/developers-guide/clients/jdbc-driver.adoc:
##########
@@ -67,8 +67,8 @@
jdbc:ignite:thin://host[:port][,host[:port][/schema][[?parameter1=value1][;param
** `connectionTimeZone` - Client connection time-zone ID. This property can be
used by the client to change the time zone of the session on the server.
Affects the interpretation of dates in queries that do not specify the time
zone explicitly. If not set, system default on client timezone will be used.
** `queryTimeout` - Number of seconds the driver will wait for a `Statement`
object to execute. 0 means there is no limit. Default value: `0`.
** `connectionTimeout` - Number of milliseconds JDBC client will wait for
server to respond. 0 means there is no limit. Default value: `0`.
-** `reconnectThrottlingPeriod` - Reconnect throttling period, in milliseconds.
0 means there is no limit. Default value: `30_000`.
-** `reconnectThrottlingRetries` - Reconnect throttling retries. 0 means there
is no limit. Default value: `3`.
+** `reconnectInterval` - Background reconnect interval, in milliseconds. `0`
means that background reconnect is disabled. Default value: `30_000`.
+** `reconnectRetriesLimit` - Maximum number of retry attempts to establish
connection. `0` means that no retries will be made. `-1` `-1` means that the
number of retries is not limited. Default value: `16`.
Review Comment:
Duplicate text "-1" appears twice. It should be a single occurrence: `'-1'
means that the number of retries is not limited.`
```suggestion
** `reconnectRetriesLimit` - Maximum number of retry attempts to establish
connection. `0` means that no retries will be made. `-1` means that the number
of retries is not limited. Default value: `16`.
```
##########
modules/jdbc/src/integrationTest/java/org/apache/ignite/jdbc/ItJdbcConnectionSelfTest.java:
##########
@@ -1013,4 +1024,71 @@ void ensureClientConnectedToMultipleEndpoints() {
Awaitility.await().until(() -> ((JdbcConnection)
conn).channelsCount(), is(initialNodes()));
}
+
+ @Test
+ public void testChangeBackgroundReconnectInterval() throws SQLException {
+ String propertyName = "reconnectInterval";
+ String urlPrefix = URL + "?" + propertyName;
+
+ SqlThrowingFunction<String, Number> valueGetter = url -> {
+ try (JdbcConnection conn = (JdbcConnection)
DriverManager.getConnection(url)) {
+ return conn.properties().getReconnectInterval();
+ }
+ };
+
+ assertThat(valueGetter.apply(URL),
is(IgniteClientConfiguration.DFLT_BACKGROUND_RECONNECT_INTERVAL));
+ assertThat(valueGetter.apply(urlPrefix + "=9223372036854775807"),
is(Long.MAX_VALUE));
+ assertThat(valueGetter.apply(urlPrefix + "=0"), is(0L));
+
+ assertInvalid(urlPrefix + "=A",
+ format("Failed to parse int property [name={}, value=A]",
propertyName));
+
+ assertInvalid(urlPrefix + "=-1",
+ format("Property cannot be lower than 0 [name={}, value=-1]",
propertyName));
+
+ assertInvalid(urlPrefix + "=9223372036854775808",
+ format("Failed to parse int property [name={},
value=9223372036854775808]", propertyName));
+ }
+
+ @Test
+ public void testChangeReconnectRetriesLimit() throws SQLException {
+ String propertyName = "reconnectRetriesLimit";
+ String urlPrefix = URL + "?" + propertyName;
+
+ SqlThrowingFunction<String, Number> valueGetter = url -> {
+ try (JdbcConnection conn = (JdbcConnection)
DriverManager.getConnection(url)) {
+ return conn.properties().getReconnectRetriesLimit();
+ }
+ };
+
+ assertThat(valueGetter.apply(URL),
is(RetryLimitPolicy.DFLT_RETRY_LIMIT));
+ assertThat(valueGetter.apply(urlPrefix + "=2147483647"),
is(Integer.MAX_VALUE));
+ assertThat(valueGetter.apply(urlPrefix + "=0"), is(0));
+ // -1 is a valid value, meaning an unlimited number of attempts.
+ assertThat(valueGetter.apply(urlPrefix + "=-1"), is(-1));
+
+ assertInvalid(urlPrefix + "=A",
+ format("Failed to parse int property [name={}, value=A]",
propertyName));
+
+ assertInvalid(urlPrefix + "=-2",
+ format("Property cannot be lower than -1 [name={}, value=-2]",
propertyName));
+
+ assertInvalid(urlPrefix + "=2147483648",
+ format("Failed to parse int property [name={},
value=2147483648]", propertyName));
+ }
+
+ /**
+ * Function that can throw an {@link SQLException}.
+ */
+ @FunctionalInterface
+ private interface SqlThrowingFunction<T, R> {
+ /**
+ * Applies the function the a given argument.
Review Comment:
Typo in documentation: "Applies the function the a given argument" should be
"Applies the function to a given argument".
```suggestion
* Applies the function to a given argument.
```
##########
modules/jdbc/src/integrationTest/java/org/apache/ignite/jdbc/ItJdbcConnectionFailoverTest.java:
##########
@@ -82,6 +123,50 @@ void testConnectionFailover() throws SQLException {
}
}
+ /**
+ * Ensures that the connection to a previously stopped node will be
restored after the specified time interval.
+ *
+ * <p>Note: this test relies on the internal implementation to ensure that
the
+ * JDBC connection property is correctly applied to the
underlying client.
+ */
+ @Test
+ @Disabled("https://issues.apache.org/jira/browse/IGNITE-27188")
+ void testConnectionRestoredAfterBackgroundReconnectInterval() throws
Exception {
+ int nodesCount = 3;
+ cluster.startAndInit(nodesCount, new int[]{2});
+ int reconnectInterval = 300;
+ int timeout = reconnectInterval * 2;
+
+ try (Connection connection = getConnection(nodesCount,
"backgroundReconnectInterval=" + reconnectInterval)) {
Review Comment:
The property name used here should be "reconnectInterval", not
"backgroundReconnectInterval". The ConnectionPropertiesImpl defines the
property as "reconnectInterval" (line 75 in ConnectionPropertiesImpl.java).
##########
modules/jdbc/src/integrationTest/java/org/apache/ignite/jdbc/ItJdbcConnectionFailoverTest.java:
##########
@@ -82,6 +123,50 @@ void testConnectionFailover() throws SQLException {
}
}
+ /**
+ * Ensures that the connection to a previously stopped node will be
restored after the specified time interval.
+ *
+ * <p>Note: this test relies on the internal implementation to ensure that
the
+ * JDBC connection property is correctly applied to the
underlying client.
+ */
+ @Test
+ @Disabled("https://issues.apache.org/jira/browse/IGNITE-27188")
+ void testConnectionRestoredAfterBackgroundReconnectInterval() throws
Exception {
+ int nodesCount = 3;
+ cluster.startAndInit(nodesCount, new int[]{2});
+ int reconnectInterval = 300;
+ int timeout = reconnectInterval * 2;
+
+ try (Connection connection = getConnection(nodesCount,
"backgroundReconnectInterval=" + reconnectInterval)) {
+ Awaitility.await().until(() -> channelsCount(connection),
is(nodesCount));
+
+ cluster.stopNode(0);
+
+ assertThat(channelsCount(connection), is(nodesCount - 1));
+
+ cluster.startNode(0);
+
+ Thread.sleep(timeout);
+
+ assertThat(channelsCount(connection), is(nodesCount));
+ }
+
+ // No background reconnection is expected.
+ try (Connection connection = getConnection(nodesCount,
"backgroundReconnectInterval=0")) {
Review Comment:
The property name used here should be "reconnectInterval", not
"backgroundReconnectInterval". The ConnectionPropertiesImpl defines the
property as "reconnectInterval" (line 75 in ConnectionPropertiesImpl.java).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]