sandynz commented on code in PR #20849:
URL: https://github.com/apache/shardingsphere/pull/20849#discussion_r964688640


##########
shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/spi/handler/MigrationMetaDataChangedHandler.java:
##########
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.data.pipeline.core.spi.handler;
+
+import lombok.extern.slf4j.Slf4j;
+import 
org.apache.shardingsphere.data.pipeline.api.config.job.MigrationJobConfiguration;
+import 
org.apache.shardingsphere.data.pipeline.api.config.job.yaml.YamlMigrationJobConfigurationSwapper;
+import org.apache.shardingsphere.data.pipeline.core.api.PipelineAPIFactory;
+import org.apache.shardingsphere.data.pipeline.core.context.PipelineContext;
+import org.apache.shardingsphere.data.pipeline.core.job.PipelineJobCenter;
+import 
org.apache.shardingsphere.data.pipeline.core.metadata.node.PipelineMetaDataNode;
+import org.apache.shardingsphere.data.pipeline.scenario.migration.MigrationJob;
+import 
org.apache.shardingsphere.data.pipeline.scenario.migration.MigrationJobPreparer;
+import org.apache.shardingsphere.elasticjob.infra.pojo.JobConfigurationPOJO;
+import 
org.apache.shardingsphere.elasticjob.lite.api.bootstrap.impl.OneOffJobBootstrap;
+import 
org.apache.shardingsphere.mode.repository.cluster.listener.DataChangedEvent;
+
+import java.util.concurrent.CompletableFuture;
+import java.util.regex.Pattern;
+
+/**
+ * Migration pipeline meta data handler.
+ */
+@Slf4j
+public final class MigrationMetaDataChangedHandler implements 
PipelineMetaDataChangedHandler {

Review Comment:
   Class name could be improved, it's not just be used for MIGRATION, e.g. 
JobConfigurationNodeChangedHandler or JobConfigurationChangedHandler
   
   Since the change might be `ADDED, UPDATED, DELETED, IGNORED`, not sure which 
one is better.
   
   



##########
shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/metadata/node/PipelineMetaDataNode.java:
##########
@@ -34,6 +34,11 @@ public final class PipelineMetaDataNode {
     
     public static final Pattern BARRIER_PATTERN = 
Pattern.compile(JOB_PATTERN_PREFIX + "/barrier/(enable|disable)/\\d+");
     
+    private static final String MIGRATION_JOB_PATTERN_PREFIX = 
DataPipelineConstants.DATA_PIPELINE_ROOT + "/jobs/(j01[0-9a-f]+)";
+    
+    public static final Pattern MIGRATION_JOB_CONFIG_PATTERN = 
Pattern.compile(MIGRATION_JOB_PATTERN_PREFIX + "/config");
+    

Review Comment:
   1, It's not just used for MIGRATION, so prefix is not necessary;
   
   2, `/jobs/(j01[0-9a-f]+`, 1) `01` should not be hard-coded, 2) it's better 
to reuse one prefix, the old one could be updated if it's wrong;
   



##########
shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/test/resources/META-INF/services/org.apache.shardingsphere.data.pipeline.core.spi.handler.PipelineMetaDataChangedHandler:
##########
@@ -0,0 +1,19 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+org.apache.shardingsphere.data.pipeline.core.spi.handler.MigrationMetaDataChangedHandler
+org.apache.shardingsphere.data.pipeline.core.spi.handler.BarrierMetaDataChangedHandler

Review Comment:
   Looks it's duplicated with the one in `src/main`



##########
shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/spi/handler/PipelineMetaDataChangedHandlerFactory.java:
##########
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.data.pipeline.core.spi.handler;
+
+import org.apache.shardingsphere.infra.util.spi.ShardingSphereServiceLoader;
+
+import java.util.Collection;
+
+/**
+ * Pipeline meta data listener factory.
+ */
+public final class PipelineMetaDataChangedHandlerFactory {
+    
+    static {
+        
ShardingSphereServiceLoader.register(PipelineMetaDataChangedHandler.class);
+    }
+    
+    /**
+     * Get pipeline meta data listener instance.
+     *
+     * @return pipeline meta data listener
+     */
+    public static Collection<PipelineMetaDataChangedHandler> findAllInstance() 
{
+        return 
ShardingSphereServiceLoader.getServiceInstances(PipelineMetaDataChangedHandler.class);
+    }

Review Comment:
   Method name might be instance`s`?



##########
shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/spi/handler/PipelineMetaDataChangedHandler.java:
##########
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.data.pipeline.core.spi.handler;
+
+import org.apache.shardingsphere.elasticjob.infra.pojo.JobConfigurationPOJO;
+import org.apache.shardingsphere.infra.util.spi.annotation.SingletonSPI;
+import 
org.apache.shardingsphere.mode.repository.cluster.listener.DataChangedEvent;
+
+import java.util.regex.Pattern;
+
+/**
+ * Pipeline meta data changed handler.
+ */
+@SingletonSPI
+public interface PipelineMetaDataChangedHandler {
+    
+    /**
+     * Get key pattern.
+     *
+     * @return key pattern
+     */
+    Pattern getKeyPattern();
+    
+    /**
+     * Event changed handler.
+     *
+     * @param event changed event
+     * @param jobConfigPOJO job config pojo
+     */
+    void handle(DataChangedEvent event, JobConfigurationPOJO jobConfigPOJO);

Review Comment:
   Since it's not just used for job, so `JobConfigurationPOJO jobConfigPOJO` 
param is not suitable to put here
   



##########
shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/execute/PipelineJobExecutor.java:
##########
@@ -81,9 +63,18 @@ private static void dispatchEvent(final DataChangedEvent 
event) {
                     log.error("analyze job config pojo failed.", ex);
                     return;
                 }
-                entry.getValue().handler(event, jobConfigPOJO);
+                entry.getValue().handle(event, jobConfigPOJO);
                 return;
             }
         }
     }
+    
+    /**
+     * Get pipeline job executor instance.
+     *
+     * @return pipeline job executor
+     */
+    public static PipelineJobExecutor getInstance() {
+        return INSTANCE;
+    }

Review Comment:
   Could be put after `INSTANCE`



-- 
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]

Reply via email to