You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by GitBox <gi...@apache.org> on 2023/01/14 09:15:44 UTC

[GitHub] [incubator-seatunnel] liugddx opened a new pull request, #3946: [Feature][Zeta] Add Zeta Client ShutdownHook To Cancel Job

liugddx opened a new pull request, #3946:
URL: https://github.com/apache/incubator-seatunnel/pull/3946

   <!--
   
   Thank you for contributing to SeaTunnel! Please make sure that your code changes
   are covered with tests. And in case of new features or big changes
   remember to adjust the documentation.
   
   Feel free to ping committers for the review!
   
   ## Contribution Checklist
   
     - Make sure that the pull request corresponds to a [GITHUB issue](https://github.com/apache/incubator-seatunnel/issues).
   
     - Name the pull request in the form "[Feature] [component] Title of the pull request", where *Feature* can be replaced by `Hotfix`, `Bug`, etc.
   
     - Minor fixes should be named following this pattern: `[hotfix] [docs] Fix typo in README.md doc`.
   
   -->
   
   ## Purpose of this pull request
   
   <!-- Describe the purpose of this pull request. For example: This pull request adds checkstyle plugin.-->
   
   ## Check list
   
   * [ ] Code changed are covered with tests, or it does not need tests for reason:
   * [ ] If any new Jar binary package adding in your PR, please add License Notice according
     [New License Guide](https://github.com/apache/incubator-seatunnel/blob/dev/docs/en/contribution/new-license.md)
   * [ ] If necessary, please update the documentation to describe the new feature. https://github.com/apache/incubator-seatunnel/tree/dev/docs
   * [ ] If you are contributing the connector code, please check that the following files are updated:
     1. Update change log that in connector document. For more details you can refer to [connector-v2](https://github.com/apache/incubator-seatunnel/tree/dev/docs/en/connector-v2)
     2. Update [plugin-mapping.properties](https://github.com/apache/incubator-seatunnel/blob/dev/plugin-mapping.properties) and add new connector information in it
     3. Update the pom file of [seatunnel-dist](https://github.com/apache/incubator-seatunnel/blob/dev/seatunnel-dist/pom.xml)
   * [ ] Update the [`release-note`](https://github.com/apache/incubator-seatunnel/blob/dev/release-note.md).


-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-seatunnel] Hisoka-X commented on a diff in pull request #3946: [Feature][Zeta] Add Zeta Client ShutdownHook To Cancel Job

Posted by GitBox <gi...@apache.org>.
Hisoka-X commented on code in PR #3946:
URL: https://github.com/apache/incubator-seatunnel/pull/3946#discussion_r1071771488


##########
seatunnel-core/seatunnel-starter/src/main/java/org/apache/seatunnel/core/starter/seatunnel/command/ClientExecuteCommand.java:
##########
@@ -112,14 +116,24 @@ public void execute() throws CommandExecuteException {
                 startTime = LocalDateTime.now();
                 // create job proxy
                 ClientJobProxy clientJobProxy = jobExecutionEnv.execute();
+                // register cancelJob hook
+                if (clientCommandArgs.isCloseJob()) {
+                    Runtime.getRuntime().addShutdownHook(new Thread(() -> {
+                        try {
+                            shutdownHook(clientJobProxy);
+                        } catch (Exception e) {
+                            throw new SeaTunnelEngineException(String.format("Cancel job exception and error is %s", ExceptionUtils.getMessage(e)));

Review Comment:
   need add log.error in here. Throw exception useless.



-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-seatunnel] Hisoka-X commented on a diff in pull request #3946: [Feature][Zeta] Add Zeta Client ShutdownHook To Cancel Job

Posted by GitBox <gi...@apache.org>.
Hisoka-X commented on code in PR #3946:
URL: https://github.com/apache/incubator-seatunnel/pull/3946#discussion_r1070752770


##########
seatunnel-core/seatunnel-starter/src/main/java/org/apache/seatunnel/core/starter/seatunnel/command/ClientExecuteCommand.java:
##########
@@ -176,4 +179,9 @@ private String creatRandomClusterName(String namePrefix) {
         return namePrefix + "-" + random.nextInt(1000000);
     }
 
+    private void shutdownHook(ClientJobProxy clientJobProxy) {
+        log.warn("Task will be closed due to client shutdown.");

Review Comment:
   If job already return status to client, mean job already done, seem like we shouldn't execute cancel job.



-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-seatunnel] Hisoka-X commented on a diff in pull request #3946: [Feature][Zeta] Add Zeta Client ShutdownHook To Cancel Job

Posted by GitBox <gi...@apache.org>.
Hisoka-X commented on code in PR #3946:
URL: https://github.com/apache/incubator-seatunnel/pull/3946#discussion_r1071677578


##########
seatunnel-core/seatunnel-starter/src/main/java/org/apache/seatunnel/core/starter/seatunnel/command/ClientExecuteCommand.java:
##########
@@ -112,14 +114,18 @@ public void execute() throws CommandExecuteException {
                 startTime = LocalDateTime.now();
                 // create job proxy
                 ClientJobProxy clientJobProxy = jobExecutionEnv.execute();
+                // register cancelJob hook
+                if (clientCommandArgs.isCloseJob()) {
+                    Runtime.getRuntime().addShutdownHook(new Thread(() -> shutdownHook(clientJobProxy)));

Review Comment:
   I'm not sure if shutdownHook throw some exception, the console can show it? If not, please use try catch then log it.



-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-seatunnel] EricJoy2048 closed pull request #3946: [Feature][Zeta] Add Zeta Client ShutdownHook To Cancel Job

Posted by GitBox <gi...@apache.org>.
EricJoy2048 closed pull request #3946: [Feature][Zeta] Add Zeta Client ShutdownHook To Cancel Job
URL: https://github.com/apache/incubator-seatunnel/pull/3946


-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-seatunnel] liugddx commented on a diff in pull request #3946: [Feature][Zeta] Add Zeta Client ShutdownHook To Cancel Job

Posted by GitBox <gi...@apache.org>.
liugddx commented on code in PR #3946:
URL: https://github.com/apache/incubator-seatunnel/pull/3946#discussion_r1071780439


##########
seatunnel-core/seatunnel-starter/src/main/java/org/apache/seatunnel/core/starter/seatunnel/command/ClientExecuteCommand.java:
##########
@@ -112,14 +116,24 @@ public void execute() throws CommandExecuteException {
                 startTime = LocalDateTime.now();
                 // create job proxy
                 ClientJobProxy clientJobProxy = jobExecutionEnv.execute();
+                // register cancelJob hook
+                if (clientCommandArgs.isCloseJob()) {
+                    Runtime.getRuntime().addShutdownHook(new Thread(() -> {
+                        try {
+                            shutdownHook(clientJobProxy);
+                        } catch (Exception e) {
+                            throw new SeaTunnelEngineException(String.format("Cancel job exception and error is %s", ExceptionUtils.getMessage(e)));

Review Comment:
   > need add log.error in here. Throw exception useless.
   
   I see.



-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-seatunnel] Hisoka-X commented on a diff in pull request #3946: [Feature][Zeta] Add Zeta Client ShutdownHook To Cancel Job

Posted by GitBox <gi...@apache.org>.
Hisoka-X commented on code in PR #3946:
URL: https://github.com/apache/incubator-seatunnel/pull/3946#discussion_r1070805902


##########
seatunnel-core/seatunnel-starter/src/main/java/org/apache/seatunnel/core/starter/seatunnel/args/ClientCommandArgs.java:
##########
@@ -65,6 +69,10 @@ public class ClientCommandArgs extends AbstractCommandArgs {
         description = "list job status")
     private boolean listJob = false;
 
+    @Parameter(names = {"-cj", "--close-job"},
+        description = "Close client the task will also be closed")
+    private boolean closeJob = false;

Review Comment:
   Just my opinon, I think user use shut down command to cancel job is intuitive operation. If they want to continue running task after client closed, they can use `-cj`



-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-seatunnel] Hisoka-X commented on a diff in pull request #3946: [Feature][Zeta] Add Zeta Client ShutdownHook To Cancel Job

Posted by GitBox <gi...@apache.org>.
Hisoka-X commented on code in PR #3946:
URL: https://github.com/apache/incubator-seatunnel/pull/3946#discussion_r1070790445


##########
seatunnel-core/seatunnel-starter/src/main/java/org/apache/seatunnel/core/starter/seatunnel/args/ClientCommandArgs.java:
##########
@@ -65,6 +69,10 @@ public class ClientCommandArgs extends AbstractCommandArgs {
         description = "list job status")
     private boolean listJob = false;
 
+    @Parameter(names = {"-cj", "--close-job"},
+        description = "Close client the task will also be closed")
+    private boolean closeJob = false;

Review Comment:
   ```suggestion
       private boolean closeJob = true;
   ```



-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-seatunnel] liugddx commented on pull request #3946: [Feature][Zeta] Add Zeta Client ShutdownHook To Cancel Job

Posted by GitBox <gi...@apache.org>.
liugddx commented on PR #3946:
URL: https://github.com/apache/incubator-seatunnel/pull/3946#issuecomment-1382746496

   This is client process.
   ![image](https://user-images.githubusercontent.com/48236177/212475527-5877691d-0a83-4017-92f3-35f93d0d1ce5.png)
   
   This is server process.
   ![image](https://user-images.githubusercontent.com/48236177/212475577-32fb37c5-5708-4c2d-aedf-b8c2e57f1ae9.png)
   


-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-seatunnel] liugddx commented on pull request #3946: [Feature][Zeta] Add Zeta Client ShutdownHook To Cancel Job

Posted by GitBox <gi...@apache.org>.
liugddx commented on PR #3946:
URL: https://github.com/apache/incubator-seatunnel/pull/3946#issuecomment-1384875634

   @EricJoy2048 @Hisoka-X PTAL .


-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-seatunnel] liugddx commented on pull request #3946: [Feature][Zeta] Add Zeta Client ShutdownHook To Cancel Job

Posted by GitBox <gi...@apache.org>.
liugddx commented on PR #3946:
URL: https://github.com/apache/incubator-seatunnel/pull/3946#issuecomment-1384162958

   > Please add change log to `release note`
   
   Done.


-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-seatunnel] EricJoy2048 merged pull request #3946: [Feature][Zeta] Add Zeta Client ShutdownHook To Cancel Job

Posted by GitBox <gi...@apache.org>.
EricJoy2048 merged PR #3946:
URL: https://github.com/apache/incubator-seatunnel/pull/3946


-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-seatunnel] liugddx commented on a diff in pull request #3946: [Feature][Zeta] Add Zeta Client ShutdownHook To Cancel Job

Posted by GitBox <gi...@apache.org>.
liugddx commented on code in PR #3946:
URL: https://github.com/apache/incubator-seatunnel/pull/3946#discussion_r1070792014


##########
seatunnel-core/seatunnel-starter/src/main/java/org/apache/seatunnel/core/starter/seatunnel/args/ClientCommandArgs.java:
##########
@@ -65,6 +69,10 @@ public class ClientCommandArgs extends AbstractCommandArgs {
         description = "list job status")
     private boolean listJob = false;
 
+    @Parameter(names = {"-cj", "--close-job"},
+        description = "Close client the task will also be closed")
+    private boolean closeJob = false;

Review Comment:
   Default is true? Since the client is blocking, maybe the user wants the task to continue?



-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org