Skip to content

Commit

Permalink
[KYUUBI #5725] Handle the session exception for all kyuubi operations…
Browse files Browse the repository at this point in the history
… during running

# 🔍 Description

Now only the `LaunchEngine` and `BatchJobSubmission` handle the kyuubi session exception.

We shall handle the session exception for all kyuubi operations, so that the user can get the correct KyuubiSessionEvent with RESTful API.

## Issue References 🔗

This pull request fixes #

## Describe Your Solution 🔧

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

## Types of changes 🔖

- [x] Bugfix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)

## Test Plan 🧪

#### Behavior Without This Pull Request ⚰️

#### Behavior With This Pull Request 🎉

#### Related Unit Tests

---

# Checklists
## 📝 Author Self Checklist

- [x] My code follows the [style guidelines](https://kyuubi.readthedocs.io/en/master/contributing/code/style.html) of this project
- [ ] I have performed a self-review
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
- [x] This patch was not authored or co-authored using [Generative Tooling](https://www.apache.org/legal/generative-tooling.html)

## 📝 Committer Pre-Merge Checklist

- [x] Pull request title is okay.
- [ ] No license issues.
- [ ] Milestone correctly set?
- [ ] Test coverage is ok
- [ ] Assignees are selected.
- [ ] Minimum number of approvals
- [ ] No changes are requested

**Be nice. Be informative.**

Closes #5725 from turboFei/handle_session_exception_rest.

Closes #5725

dd514f3 [fwang12] remove
1614951 [fwang12] handle
cee9171 [fwang12] Revert "handle session exception for all kyuubi operations"
4a0c192 [fwang12] Revert "comment"
7ce89f8 [fwang12] comment
5d9d4dc [fwang12] handle session exception for all kyuubi operations

Authored-by: fwang12 <fwang12@ebay.com>
Signed-off-by: Cheng Pan <chengpan@apache.org>
  • Loading branch information
turboFei authored and pan3793 committed Nov 20, 2023
1 parent 25bb7e5 commit 39f39a1
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ class BatchJobSubmission(
OperationLog.removeCurrentOperationLog()
}

override protected def runInternal(): Unit = session.handleSessionException {
override protected def runInternal(): Unit = {
val asyncOperation: Runnable = () => {
try {
metadata match {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class ExecutedCommandExec(
OperationLog.removeCurrentOperationLog()
}

override protected def runInternal(): Unit = session.handleSessionException {
override protected def runInternal(): Unit = {
val asyncOperation: Runnable = () => {
setState(OperationState.RUNNING)
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import org.apache.kyuubi.metrics.MetricsConstants.{OPERATION_FAIL, OPERATION_OPE
import org.apache.kyuubi.metrics.MetricsSystem
import org.apache.kyuubi.operation.FetchOrientation.FetchOrientation
import org.apache.kyuubi.operation.OperationState.OperationState
import org.apache.kyuubi.session.{KyuubiSessionImpl, KyuubiSessionManager, Session}
import org.apache.kyuubi.session.{KyuubiSession, KyuubiSessionImpl, KyuubiSessionManager, Session}
import org.apache.kyuubi.util.ThriftUtils

abstract class KyuubiOperation(session: Session) extends AbstractOperation(session) {
Expand Down Expand Up @@ -100,6 +100,17 @@ abstract class KyuubiOperation(session: Session) extends AbstractOperation(sessi
}
}

override def run(): Unit = {
beforeRun()
try {
session.asInstanceOf[KyuubiSession].handleSessionException {
runInternal()
}
} finally {
afterRun()
}
}

override protected def beforeRun(): Unit = {
setHasResultSet(true)
setState(OperationState.RUNNING)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class LaunchEngine(session: KyuubiSessionImpl, override val shouldRunAsync: Bool
OperationLog.removeCurrentOperationLog()
}

override protected def runInternal(): Unit = session.handleSessionException {
override protected def runInternal(): Unit = {
val asyncOperation: Runnable = () => {
setState(OperationState.RUNNING)
try {
Expand Down

0 comments on commit 39f39a1

Please sign in to comment.