ignite-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexander Lapin <lapin1...@gmail.com>
Subject JDBC thin driver: support connection timeout
Date Fri, 30 Nov 2018 13:28:41 GMT
Hi Igniters,

Within context of connection timeout [
https://issues.apache.org/jira/browse/IGNITE-5234] it's not obvious whether
it's required to use setNetworkTimeout's executor or not.

According to the javadoc of java.sql.Connection#setNetworkTimeout(Executor
executor, int milliseconds), executor is "The <code>Executor</code>
implementation which will be used by <code>setNetworkTimeout</code>."
Seems that executor supposed to take care of connection closing/aborting in
case of timeout, based on submitted Runnable implementation. On the other
hand it's possible to ignore executor and implement
timeout-detection/cancellation logic with Timer. Something like following

ConnectionTimeoutTimerTask connectionTimeoutTimerTask = new
timer.schedule(connectionTimeoutTimerTask, 0, REQUEST_TIMEOUT_PERIOD);
JdbcResponse res = cliIo.sendRequest(req);

private class ConnectionTimeoutTimerTask extends TimerTask {
    @Override public void run() {
        if (remainingConnectionTimeout <= 0)
            close(); //connection.close();

        remainingConnectionTimeout -= REQUEST_TIMEOUT_PERIOD;

It worth to mention that MSSQL Jdbc driver doesn't use executor and
PostgreSQL doesn't implement setNetworkTimeout() at all.

>From my point of view it might be better to ignore executor, is it suitable?

Any ideas?

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message