Skip to content

Commit

Permalink
0003679: Registration sometimes throws java.lang.InterruptedException
Browse files Browse the repository at this point in the history
  • Loading branch information
chenson42 committed Aug 16, 2018
1 parent 4b15eeb commit 9653a35
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 32 deletions.
Expand Up @@ -372,10 +372,11 @@ public String getDeprecatedStartParameter() {
}

@Override
public void startJobsAfterConfigChange() {
// No action on Android
public void restartJobs() {
this.stopJobs();
this.startJobs();
}

@Override
public void init() {
// No action on Android
Expand Down
Expand Up @@ -72,13 +72,7 @@ protected Map<String, String> createSqlReplacementTokens() {

@Override
public void init() {
if (this.jobs != null && !this.jobs.isEmpty()) {
for (IJob job : jobs) {
if (job.isStarted()) {
job.stop();
}
}
}
this.stopJobs();
List<JobDefinition> jobDefitions = loadJobs(engine);

BuiltInJobs builtInJobs = new BuiltInJobs();
Expand Down Expand Up @@ -138,17 +132,7 @@ public boolean isJobApplicableToNodeGroup(IJob job) {
return engine.getParameterService().getNodeGroupId().equals(nodeGroupId);
}

@Override
public synchronized void startJobsAfterConfigChange() {
if (jobs != null) {
for (IJob job : jobs) {
if (isAutoStartConfigured(job) && !job.isStarted()) {
job.start();
}
}
}
}


protected boolean isAutoStartConfigured(IJob job) {
String autoStartValue = null;

Expand Down Expand Up @@ -210,6 +194,12 @@ public int compare(IJob job1, IJob job2) {
}
return jobsSorted;
}

@Override
public void restartJobs() {
this.init();
this.startJobs();
}

@Override
public void saveJob(JobDefinition job) {
Expand All @@ -220,8 +210,7 @@ public void saveJob(JobDefinition job) {
if (sqlTemplate.update(getSql("updateJobSql"), args) <= 0) {
sqlTemplate.update(getSql("insertJobSql"), args);
}
init();
startJobsAfterConfigChange();
restartJobs();
}

@Override
Expand All @@ -233,7 +222,6 @@ public void removeJob(String name) {
} else {
throw new SymmetricException("Failed to remove job " + name + ". Note that BUILT_IN jobs cannot be removed.");
}
init();
startJobsAfterConfigChange();
restartJobs();
}
}
Expand Up @@ -1022,7 +1022,7 @@ public void clearCaches() {
getNodeService().flushNodeAuthorizedCache();
getNodeService().flushNodeCache();
getNodeService().flushNodeGroupCache();
getJobManager().startJobsAfterConfigChange();
getJobManager().restartJobs();
getLoadFilterService().clearCache();
getMonitorService().flushMonitorCache();
getMonitorService().flushNotificationCache();
Expand Down
Expand Up @@ -36,8 +36,6 @@ public interface IJobManager {

public void stopJobs();

public void startJobsAfterConfigChange();

public void destroy();

public List<IJob> getJobs();
Expand All @@ -52,4 +50,6 @@ public interface IJobManager {

public boolean isJobApplicableToNodeGroup(IJob job);

public void restartJobs();

}
Expand Up @@ -315,8 +315,7 @@ public void syncEnded(DataContext context, List<IncomingBatch> batchesProcessed,
IJobManager jobManager = engine.getJobManager();
if (jobManager != null && jobManager.isStarted()) {
log.info("About to restart jobs because new configuration came through the data loader");
jobManager.init();
jobManager.startJobsAfterConfigChange();
jobManager.restartJobs();
}
context.remove(CTX_KEY_RESTART_JOBMANAGER_NEEDED);
}
Expand Down
Expand Up @@ -634,8 +634,7 @@ public void contextCommitted(SimpleRouterContext routingContext) {
IJobManager jobManager = engine.getJobManager();
if (jobManager != null) {
log.info("About to restart jobs because new configuration come through the data router");
jobManager.init();
jobManager.startJobsAfterConfigChange();
jobManager.restartJobs();
}
}

Expand Down

0 comments on commit 9653a35

Please sign in to comment.