Skip to content

Commit 5ef32ec

Browse files
committed
fix bug
1 parent 1725b60 commit 5ef32ec

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

job-core/src/main/java/com/lts/job/core/cluster/MasterElector.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public class MasterElector {
2222

2323
private Application application;
2424
private List<MasterNodeChangeListener> masterNodeChangeListenerList;
25-
private Node master;
25+
private volatile Node master;
2626

2727
public MasterElector(Application application) {
2828
this.application = application;

job-example/src/main/java/com/lts/job/example/api/JobClientTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@
22

33
import com.lts.job.client.JobClient;
44
import com.lts.job.client.RetryJobClient;
5+
import com.lts.job.client.domain.Response;
6+
import com.lts.job.core.domain.Job;
57
import com.lts.job.example.support.BaseJobClientTest;
68
import com.lts.job.example.support.JobFinishedHandlerImpl;
79
import com.lts.job.example.support.MasterNodeChangeListenerImpl;
810

911
import java.io.IOException;
12+
import java.util.UUID;
1013

1114
/**
1215
* @author Robert HG ([email protected]) on 8/13/14.

job-tracker/src/main/java/com/lts/job/tracker/support/DeadJobChecker.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,16 @@ public DeadJobChecker(Application application) {
5757
this.commandWrapper = application.getCommandWrapper();
5858
}
5959

60+
private volatile boolean start;
61+
private ScheduledFuture<?> scheduledFuture;
62+
6063
public void start() {
61-
ScheduledFuture<?> scheduledFuture = FIXED_EXECUTOR_SERVICE.scheduleWithFixedDelay(new Runnable() {
64+
if (start) {
65+
return;
66+
}
67+
start = true;
68+
69+
scheduledFuture = FIXED_EXECUTOR_SERVICE.scheduleWithFixedDelay(new Runnable() {
6270
@Override
6371
public void run() {
6472
try {
@@ -158,7 +166,11 @@ private JobMongoRepository getJobRepository() {
158166
}
159167

160168
public void stop() {
161-
FIXED_EXECUTOR_SERVICE.shutdown();
169+
if (start) {
170+
start = false;
171+
scheduledFuture.cancel(true);
172+
FIXED_EXECUTOR_SERVICE.shutdown();
173+
}
162174
}
163175

164176
}

0 commit comments

Comments
 (0)