You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2020/10/30 11:17:38 UTC
[shardingsphere-elasticjob] branch master updated: Adjust
JobScheduler init sequence to avoid job can not load from reg center
(#1685)
This is an automated email from the ASF dual-hosted git repository.
zhangliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere-elasticjob.git
The following commit(s) were added to refs/heads/master by this push:
new 12070e7 Adjust JobScheduler init sequence to avoid job can not load from reg center (#1685)
12070e7 is described below
commit 12070e79edbbbc296b3d04eb2f4efaadafb1faf1
Author: Liang Zhang <te...@163.com>
AuthorDate: Fri Oct 30 19:17:30 2020 +0800
Adjust JobScheduler init sequence to avoid job can not load from reg center (#1685)
---
.../lite/internal/schedule/JobScheduler.java | 32 +++++++++++-----------
1 file changed, 16 insertions(+), 16 deletions(-)
diff --git a/elasticjob-lite/elasticjob-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/internal/schedule/JobScheduler.java b/elasticjob-lite/elasticjob-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/internal/schedule/JobScheduler.java
index 918ca77..7e19ebe 100644
--- a/elasticjob-lite/elasticjob-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/internal/schedule/JobScheduler.java
+++ b/elasticjob-lite/elasticjob-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/internal/schedule/JobScheduler.java
@@ -7,7 +7,7 @@
* 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.
@@ -80,12 +80,12 @@ public final class JobScheduler {
this.regCenter = regCenter;
Collection<ElasticJobListener> jobListeners = getElasticJobListeners(jobConfig);
setUpFacade = new SetUpFacade(regCenter, jobConfig.getJobName(), jobListeners);
- schedulerFacade = new SchedulerFacade(regCenter, jobConfig.getJobName());
- jobFacade = new LiteJobFacade(regCenter, jobConfig.getJobName(), jobListeners, findTracingConfiguration(jobConfig).orElse(null));
- validateJobProperties(jobConfig);
- jobExecutor = new ElasticJobExecutor(elasticJob, jobConfig, jobFacade);
String jobClassName = JobClassNameProviderFactory.getProvider().getJobClassName(elasticJob);
this.jobConfig = setUpFacade.setUpJobConfiguration(jobClassName, jobConfig);
+ schedulerFacade = new SchedulerFacade(regCenter, jobConfig.getJobName());
+ jobFacade = new LiteJobFacade(regCenter, jobConfig.getJobName(), jobListeners, findTracingConfiguration().orElse(null));
+ validateJobProperties();
+ jobExecutor = new ElasticJobExecutor(elasticJob, this.jobConfig, jobFacade);
setGuaranteeServiceForElasticJobListeners(regCenter, jobListeners);
jobScheduleController = createJobScheduleController();
}
@@ -95,11 +95,11 @@ public final class JobScheduler {
this.regCenter = regCenter;
Collection<ElasticJobListener> jobListeners = getElasticJobListeners(jobConfig);
setUpFacade = new SetUpFacade(regCenter, jobConfig.getJobName(), jobListeners);
- schedulerFacade = new SchedulerFacade(regCenter, jobConfig.getJobName());
- jobFacade = new LiteJobFacade(regCenter, jobConfig.getJobName(), jobListeners, findTracingConfiguration(jobConfig).orElse(null));
- validateJobProperties(jobConfig);
- jobExecutor = new ElasticJobExecutor(elasticJobType, jobConfig, jobFacade);
this.jobConfig = setUpFacade.setUpJobConfiguration(elasticJobType, jobConfig);
+ schedulerFacade = new SchedulerFacade(regCenter, jobConfig.getJobName());
+ jobFacade = new LiteJobFacade(regCenter, jobConfig.getJobName(), jobListeners, findTracingConfiguration().orElse(null));
+ validateJobProperties();
+ jobExecutor = new ElasticJobExecutor(elasticJobType, this.jobConfig, jobFacade);
setGuaranteeServiceForElasticJobListeners(regCenter, jobListeners);
jobScheduleController = createJobScheduleController();
}
@@ -110,15 +110,15 @@ public final class JobScheduler {
.collect(Collectors.toList());
}
- private Optional<TracingConfiguration<?>> findTracingConfiguration(final JobConfiguration jobConfig) {
+ private Optional<TracingConfiguration<?>> findTracingConfiguration() {
return jobConfig.getExtraConfigurations().stream().filter(each -> each instanceof TracingConfiguration).findFirst().map(extraConfig -> (TracingConfiguration<?>) extraConfig);
}
- private void validateJobProperties(final JobConfiguration jobConfig) {
- validateJobErrorHandlerProperties(jobConfig);
+ private void validateJobProperties() {
+ validateJobErrorHandlerProperties();
}
- private void validateJobErrorHandlerProperties(final JobConfiguration jobConfig) {
+ private void validateJobErrorHandlerProperties() {
if (null != jobConfig.getJobErrorHandlerType()) {
ElasticJobServiceLoader.newTypedServiceInstance(JobErrorHandlerPropertiesValidator.class, jobConfig.getJobErrorHandlerType(), jobConfig.getProps())
.ifPresent(validator -> validator.validate(jobConfig.getProps()));
@@ -178,9 +178,9 @@ public final class JobScheduler {
setUpFacade.registerStartUpInfo(!jobConfig.isDisabled());
}
- /**
- * Shutdown job.
- */
+ /**
+ * Shutdown job.
+ */
public void shutdown() {
schedulerFacade.shutdownInstance();
jobExecutor.shutdown();