-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
184 additions
and
353 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
...core/src/main/java/com/dangdang/ddframe/job/lite/internal/reconcile/ReconcileService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* Copyright 1999-2015 dangdang.com. | ||
* <p> | ||
* Licensed 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. | ||
* </p> | ||
*/ | ||
|
||
package com.dangdang.ddframe.job.lite.internal.reconcile; | ||
|
||
import com.dangdang.ddframe.job.lite.config.LiteJobConfiguration; | ||
import com.dangdang.ddframe.job.lite.internal.config.ConfigurationService; | ||
import com.dangdang.ddframe.job.lite.internal.election.LeaderElectionService; | ||
import com.dangdang.ddframe.job.lite.internal.sharding.ShardingService; | ||
import com.dangdang.ddframe.job.reg.base.CoordinatorRegistryCenter; | ||
import com.google.common.util.concurrent.AbstractScheduledService; | ||
import lombok.extern.slf4j.Slf4j; | ||
|
||
import java.util.concurrent.TimeUnit; | ||
|
||
/** | ||
* 修复作业服务器不一致状态服务. | ||
* | ||
* @author caohao | ||
* | ||
*/ | ||
@Slf4j | ||
public class ReconcileService extends AbstractScheduledService { | ||
|
||
private long lastReconcileTime; | ||
|
||
private final ConfigurationService configService; | ||
|
||
private final ShardingService shardingService; | ||
|
||
private final LeaderElectionService leaderElectionService; | ||
|
||
public ReconcileService(final CoordinatorRegistryCenter regCenter, final String jobName) { | ||
lastReconcileTime = System.currentTimeMillis(); | ||
configService = new ConfigurationService(regCenter, jobName); | ||
shardingService = new ShardingService(regCenter, jobName); | ||
leaderElectionService = new LeaderElectionService(regCenter, jobName); | ||
} | ||
|
||
@Override | ||
protected void runOneIteration() throws Exception { | ||
LiteJobConfiguration config = configService.load(true); | ||
int reconcileIntervalMinutes = null == config || config.getReconcileIntervalMinutes() <= 0 ? -1 : config.getReconcileIntervalMinutes(); | ||
if (reconcileIntervalMinutes > 0 && (System.currentTimeMillis() - lastReconcileTime >= reconcileIntervalMinutes * 60 * 1000)) { | ||
lastReconcileTime = System.currentTimeMillis(); | ||
if (leaderElectionService.isLeader() && !shardingService.isNeedSharding() | ||
&& shardingService.hasNotRunningShardingNode()) { | ||
log.warn("Elastic Job: job status node has inconsistent value,start reconciling..."); | ||
shardingService.setReshardingFlag(); | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
protected Scheduler scheduler() { | ||
return Scheduler.newFixedDelaySchedule(0, 1, TimeUnit.MINUTES); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 0 additions & 11 deletions
11
...lite-core/src/main/java/com/dangdang/ddframe/job/lite/internal/worker/AbstractWorker.java
This file was deleted.
Oops, something went wrong.
28 changes: 0 additions & 28 deletions
28
...lite-core/src/main/java/com/dangdang/ddframe/job/lite/internal/worker/WorkersManager.java
This file was deleted.
Oops, something went wrong.
42 changes: 0 additions & 42 deletions
42
...ava/com/dangdang/ddframe/job/lite/internal/worker/reconcile/ReconcileListenerManager.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.