You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by to...@apache.org on 2023/12/12 08:46:58 UTC

(shardingsphere) branch master updated: Refactor AbstractJobConfigurationChangedProcessor (#29376)

This is an automated email from the ASF dual-hosted git repository.

totalo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new a48d652cb7c Refactor AbstractJobConfigurationChangedProcessor (#29376)
a48d652cb7c is described below

commit a48d652cb7cbbbef182882544f4742d664215161
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Tue Dec 12 16:46:52 2023 +0800

    Refactor AbstractJobConfigurationChangedProcessor (#29376)
    
    * Refactor AbstractJobConfigurationChangedProcessor
    
    * Refactor AbstractJobConfigurationChangedProcessor
---
 .../AbstractJobConfigurationChangedProcessor.java     | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)

diff --git a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/metadata/node/config/processor/impl/AbstractJobConfigurationChangedProcessor.java b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/metadata/node/config/processor/impl/AbstractJobConfigurationChangedProcessor.java
index 1a8ced96cd2..cd9746b2d65 100644
--- a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/metadata/node/config/processor/impl/AbstractJobConfigurationChangedProcessor.java
+++ b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/metadata/node/config/processor/impl/AbstractJobConfigurationChangedProcessor.java
@@ -38,17 +38,10 @@ public abstract class AbstractJobConfigurationChangedProcessor implements JobCon
     
     @Override
     public final void process(final Type eventType, final JobConfiguration jobConfig) {
-        boolean deleted = Type.DELETED == eventType;
-        if (deleted) {
-            onDeleted(jobConfig);
-        }
-        boolean disabled = jobConfig.isDisabled();
         String jobId = jobConfig.getJobName();
-        if (disabled || deleted) {
+        if (jobConfig.isDisabled()) {
             PipelineJobRegistry.stop(jobId);
-            if (disabled) {
-                onDisabled(jobId);
-            }
+            onDisabled(jobId);
             return;
         }
         switch (eventType) {
@@ -60,13 +53,15 @@ public abstract class AbstractJobConfigurationChangedProcessor implements JobCon
                     executeJob(jobConfig);
                 }
                 break;
+            case DELETED:
+                PipelineJobRegistry.stop(jobId);
+                onDeleted(jobConfig);
+                break;
             default:
                 break;
         }
     }
     
-    protected abstract void onDeleted(JobConfiguration jobConfig);
-    
     private void onDisabled(final String jobId) {
         PipelineDistributedBarrier distributedBarrier = PipelineDistributedBarrier.getInstance(PipelineJobIdUtils.parseContextKey(jobId));
         for (Integer each : PipelineJobRegistry.getShardingItems(jobId)) {
@@ -85,6 +80,8 @@ public abstract class AbstractJobConfigurationChangedProcessor implements JobCon
     
     protected abstract PipelineJob buildJob();
     
+    protected abstract void onDeleted(JobConfiguration jobConfig);
+    
     protected abstract PipelineJobType getJobType();
     
     @Override