You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2022/01/28 06:29:57 UTC

[GitHub] [shardingsphere] ReyYang commented on a change in pull request #15136: For #14722: Refactor the issue that cannot have multiple jobs under the same Schema name

ReyYang commented on a change in pull request #15136:
URL: https://github.com/apache/shardingsphere/pull/15136#discussion_r794233756



##########
File path: shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/scenario/rulealtered/RuleAlteredJobWorker.java
##########
@@ -265,4 +270,38 @@ private void disableSSLForMySQL(final Map<String, Map<String, Object>> yamlDataS
             entry.getValue().put(jdbcUrlKey, new JdbcUrlAppender().appendQueryProperties((String) entry.getValue().get(jdbcUrlKey), queryProps));
         }
     }
+    
+    private void isUncompletedJobOfSameSchemaInJobList(final String schema) {
+        boolean isUncompletedJobOfSameSchema = false;
+        for (JobInfo each : PipelineJobAPIFactory.getRuleAlteredJobAPI().list()) {
+            JobConfiguration jobConfiguration = YamlEngine.unmarshal(each.getJobParameter(), JobConfiguration.class, true);
+            if (isUncompletedJobOfSameSchema(jobConfiguration, each.getJobId(), schema)) {
+                isUncompletedJobOfSameSchema = true;
+                break;
+            }
+        }
+        if (isUncompletedJobOfSameSchema) {
+            log.warn("There is an outstanding job with the same schema name");
+        }
+    }
+    
+    private boolean isUncompletedJobOfSameSchema(final JobConfiguration jobConfig, final String jobId, final String currentSchema) {
+        HandleConfiguration handleConfig = jobConfig.getHandleConfig();
+        WorkflowConfiguration workflowConfig;
+        if (null == handleConfig || null == (workflowConfig = jobConfig.getWorkflowConfig())) {
+            log.warn("handleConfig or workflowConfig null, jobId={}", jobId);
+            return false;
+        }
+        return currentSchema.equals(workflowConfig.getSchemaName());
+    }
+    
+    /**
+     * scaling release schema name lock.
+     *
+     * @param event scaling release schema name lock event
+     */
+    @Subscribe
+    public void scalingReleaseSchemaNameLock(final ScalingReleaseSchemaNameLockEvent event) {
+        ZookeeperDistributeLock.releaseLock(event.getSchemaName());
+    }

Review comment:
       `ScalingSchemaNameDistributeLock` cannot be referenced in the `ScalingRegistrySubscriber` class due to the isolation relationship of the package




-- 
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: notifications-unsubscribe@shardingsphere.apache.org

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