bowenliang123 commented on code in PR #5111:
URL: https://github.com/apache/kyuubi/pull/5111#discussion_r1280132333
##########
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:
Or let's add a dedicated method for closing `transport` inside the
`KyuubiConnection` , in my case for forcibly destroying the instance of
TTransport and TCLIService inside?
--
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]