File tree Expand file tree Collapse file tree 3 files changed +18
-3
lines changed
job-core/src/main/java/com/lts/job/core/cluster
job-example/src/main/java/com/lts/job/example/api
job-tracker/src/main/java/com/lts/job/tracker/support Expand file tree Collapse file tree 3 files changed +18
-3
lines changed Original file line number Diff line number Diff 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 ;
Original file line number Diff line number Diff line change 22
33import com .lts .job .client .JobClient ;
44import com .lts .job .client .RetryJobClient ;
5+ import com .lts .job .client .domain .Response ;
6+ import com .lts .job .core .domain .Job ;
57import com .lts .job .example .support .BaseJobClientTest ;
68import com .lts .job .example .support .JobFinishedHandlerImpl ;
79import com .lts .job .example .support .MasterNodeChangeListenerImpl ;
810
911import java .io .IOException ;
12+ import java .util .UUID ;
1013
1114/**
1215 * @author Robert HG ([email protected] ) on 8/13/14.
Original file line number Diff line number Diff 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}
You can’t perform that action at this time.
0 commit comments