abhishekmjain commented on code in PR #4045:
URL: https://github.com/apache/gobblin/pull/4045#discussion_r1743621573
##########
gobblin-temporal/src/main/java/org/apache/gobblin/temporal/joblauncher/GobblinTemporalJobLauncher.java:
##########
@@ -113,7 +121,37 @@ protected void handleLaunchFinalization() {
@Override
protected void executeCancellation() {
- log.info("Cancel temporal workflow");
+ if (this.workflowId == null) {
+ log.info("Cancellation of temporal workflow attempted without submitting
it");
+ return;
+ }
+
+ log.info("Cancelling temporal workflow {}", this.workflowId);
+ try {
+ WorkflowStub workflowStub =
this.client.newUntypedWorkflowStub(this.workflowId);
+
+ // Describe the workflow execution to get its status
+ DescribeWorkflowExecutionRequest request =
DescribeWorkflowExecutionRequest.newBuilder()
+ .setNamespace(this.namespace)
+ .setExecution(workflowStub.getExecution())
+ .build();
+ DescribeWorkflowExecutionResponse response =
workflowServiceStubs.blockingStub().describeWorkflowExecution(request);
+
+ // Check if the workflow is not finished
+ WorkflowExecutionStatus status =
response.getWorkflowExecutionInfo().getStatus();
+ if (status !=
WorkflowExecutionStatus.WORKFLOW_EXECUTION_STATUS_COMPLETED &&
+ status != WorkflowExecutionStatus.WORKFLOW_EXECUTION_STATUS_FAILED &&
+ status != WorkflowExecutionStatus.WORKFLOW_EXECUTION_STATUS_CANCELED
&&
+ status !=
WorkflowExecutionStatus.WORKFLOW_EXECUTION_STATUS_TERMINATED) {
Review Comment:
Since it is one time check I think it is okay we can keep it here. If this
gets reused further, we can extract it to a function.
--
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]