ruanwenjun commented on code in PR #17719:
URL:
https://github.com/apache/dolphinscheduler/pull/17719#discussion_r2591174330
##########
dolphinscheduler-task-plugin/dolphinscheduler-task-emr/src/main/java/org/apache/dolphinscheduler/plugin/task/emr/EmrJobFlowTask.java:
##########
@@ -180,11 +180,23 @@ private ClusterStatus getClusterStatus() {
@Override
public void cancelApplication() throws TaskException {
- log.info("trying terminate job flow, taskId:{}, clusterId:{}",
this.taskExecutionContext.getTaskInstanceId(),
- clusterId);
- TerminateJobFlowsRequest terminateJobFlowsRequest = new
TerminateJobFlowsRequest().withJobFlowIds(clusterId);
- TerminateJobFlowsResult terminateJobFlowsResult =
emrClient.terminateJobFlows(terminateJobFlowsRequest);
- log.info("the result of terminate job flow is:{}",
terminateJobFlowsResult);
+ try {
+ log.info("trying terminate job flow, taskId:{}, clusterId:{}",
+ this.taskExecutionContext.getTaskInstanceId(),
+ clusterId);
+ TerminateJobFlowsRequest terminateJobFlowsRequest =
+ new TerminateJobFlowsRequest().withJobFlowIds(clusterId);
+ TerminateJobFlowsResult terminateJobFlowsResult =
emrClient.terminateJobFlows(terminateJobFlowsRequest);
+ log.info("the result of terminate job flow is:{}",
terminateJobFlowsResult);
+ } catch (Exception e) {
+ log.error("emr job flow task cancel error: {}", e.getMessage(), e);
+ throw new TaskException("emr job flow task cancel error: " +
e.getMessage(), e);
+ } finally {
+ // shutdown emrclient
+ if (emrClient != null) {
+ emrClient.shutdown();
+ }
+ }
Review Comment:
Revert this change.
##########
dolphinscheduler-task-plugin/dolphinscheduler-task-emr/src/main/java/org/apache/dolphinscheduler/plugin/task/emr/EmrAddStepsTask.java:
##########
@@ -187,26 +187,37 @@ private StepStatus getStepStatus() {
@Override
public void cancelApplication() throws TaskException {
- log.info("trying cancel emr step, taskId:{}, clusterId:{}, stepId:{}",
- this.taskExecutionContext.getTaskInstanceId(), clusterId,
stepId);
- CancelStepsRequest cancelStepsRequest = new
CancelStepsRequest().withClusterId(clusterId).withStepIds(stepId);
- CancelStepsResult cancelStepsResult =
emrClient.cancelSteps(cancelStepsRequest);
+ try {
+ log.info("trying cancel emr step, taskId:{}, clusterId:{},
stepId:{}",
+ this.taskExecutionContext.getTaskInstanceId(), clusterId,
stepId);
+ CancelStepsRequest cancelStepsRequest =
+ new
CancelStepsRequest().withClusterId(clusterId).withStepIds(stepId);
+ CancelStepsResult cancelStepsResult =
emrClient.cancelSteps(cancelStepsRequest);
+
+ if (cancelStepsResult == null) {
+ throw new EmrTaskException("cancel emr step failed");
+ }
- if (cancelStepsResult == null) {
- throw new EmrTaskException("cancel emr step failed");
- }
+ CancelStepsInfo cancelEmrStepInfo =
cancelStepsResult.getCancelStepsInfoList()
+ .stream()
+ .filter(cancelStepsInfo ->
cancelStepsInfo.getStepId().equals(stepId))
+ .findFirst()
+ .orElseThrow(() -> new EmrTaskException("cancel emr step
failed"));
- CancelStepsInfo cancelEmrStepInfo =
cancelStepsResult.getCancelStepsInfoList()
- .stream()
- .filter(cancelStepsInfo ->
cancelStepsInfo.getStepId().equals(stepId))
- .findFirst()
- .orElseThrow(() -> new EmrTaskException("cancel emr step
failed"));
+ if
(CancelStepsRequestStatus.FAILED.toString().equals(cancelEmrStepInfo.getStatus()))
{
+ throw new EmrTaskException("cancel emr step failed, message:"
+ cancelEmrStepInfo.getReason());
+ }
- if
(CancelStepsRequestStatus.FAILED.toString().equals(cancelEmrStepInfo.getStatus()))
{
- throw new EmrTaskException("cancel emr step failed, message:" +
cancelEmrStepInfo.getReason());
+ log.info("the result of cancel emr step is:{}", cancelStepsResult);
+ } catch (EmrTaskException | SdkBaseException e) {
+ log.error("cancel emr step failed", e);
+ throw new TaskException("cancel emr step failed", e);
+ } finally {
+ // shutdown emrclient
+ if (emrClient != null) {
+ emrClient.shutdown();
+ }
Review Comment:
Revert this change. The client should be closed at handle method.
--
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]