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
(pseudo-code):
ConnectionTimeoutTimerTask connectionTimeoutTimerTask = new
ConnectionTimeoutTimerTask(timeout);
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?