bowenliang123 commented on code in PR #5111:
URL: https://github.com/apache/kyuubi/pull/5111#discussion_r1280008718
##########
kyuubi-hive-jdbc/src/main/java/org/apache/kyuubi/jdbc/hive/KyuubiConnection.java:
##########
@@ -981,6 +986,43 @@ public void close() throws SQLException {
}
}
+ /**
+ * close the connection within timeout forcibly
+ *
+ * @param closeTimeout timeout for closing connection in seconds
+ * @throws SQLException
+ */
+ public void close(int closeTimeout) throws SQLException {
+ checkArgument(closeTimeout > 0, "closeTimeout must be greater than 0");
+ ExecutorService executor = Executors.newSingleThreadExecutor();
+ try {
+ SimpleTimeLimiter.create(executor)
+ .runWithTimeout(
+ () -> {
+ if (!isClosed) {
+ TCloseSessionReq closeReq = new TCloseSessionReq(sessHandle);
+ try {
+ client.CloseSession(closeReq);
+ } catch (TException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ },
+ closeTimeout,
+ TimeUnit.SECONDS);
+ } catch (Exception e) {
+ LOG.error("Error while closing connection with in timeout", e);
+ } finally {
+ executor.shutdownNow();
Review Comment:
Once we abandoned a jammed JDBC connection, we want to release and destroy
the connection and the member instances inside the connection, like the
transport and the client. How to achieve that? And what's `cancel` for a JDBC
connection?
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]