Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
qq254963746 committed Mar 20, 2015
1 parent 1725b60 commit 5ef32ec
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class MasterElector {

private Application application;
private List<MasterNodeChangeListener> masterNodeChangeListenerList;
private Node master;
private volatile Node master;

public MasterElector(Application application) {
this.application = application;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@

import com.lts.job.client.JobClient;
import com.lts.job.client.RetryJobClient;
import com.lts.job.client.domain.Response;
import com.lts.job.core.domain.Job;
import com.lts.job.example.support.BaseJobClientTest;
import com.lts.job.example.support.JobFinishedHandlerImpl;
import com.lts.job.example.support.MasterNodeChangeListenerImpl;

import java.io.IOException;
import java.util.UUID;

/**
* @author Robert HG ([email protected]) on 8/13/14.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,16 @@ public DeadJobChecker(Application application) {
this.commandWrapper = application.getCommandWrapper();
}

private volatile boolean start;
private ScheduledFuture<?> scheduledFuture;

public void start() {
ScheduledFuture<?> scheduledFuture = FIXED_EXECUTOR_SERVICE.scheduleWithFixedDelay(new Runnable() {
if (start) {
return;
}
start = true;

scheduledFuture = FIXED_EXECUTOR_SERVICE.scheduleWithFixedDelay(new Runnable() {
@Override
public void run() {
try {
Expand Down Expand Up @@ -158,7 +166,11 @@ private JobMongoRepository getJobRepository() {
}

public void stop() {
FIXED_EXECUTOR_SERVICE.shutdown();
if (start) {
start = false;
scheduledFuture.cancel(true);
FIXED_EXECUTOR_SERVICE.shutdown();
}
}

}

0 comments on commit 5ef32ec

Please sign in to comment.