Skip to content

Commit

Permalink
0000781: Restart of jobs can cause embedded derby database connection…
Browse files Browse the repository at this point in the history
…s to fail
  • Loading branch information
chenson42 committed Aug 22, 2012
1 parent c0c0790 commit c45d4a8
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 32 deletions.
Expand Up @@ -145,44 +145,49 @@ public boolean invoke(boolean force) {
if (engine == null) {
log.info("Could not find a reference to the SymmetricEngine from {}", jobName);
} else {
MDC.put("engineName", engine.getEngineName());
if (engine.isStarted()) {
if (!paused || force) {
if (!running) {
running = true;
synchronized (this) {
ran = true;
long startTime = System.currentTimeMillis();
try {
if (!requiresRegistration
|| (requiresRegistration && engine
.getRegistrationService()
.isRegisteredWithServer())) {
hasNotRegisteredMessageBeenLogged = false;
doJob(force);
} else {
if (!hasNotRegisteredMessageBeenLogged) {
log.warn(
"Did not run the {} job because the engine is not registered.",
getName());
hasNotRegisteredMessageBeenLogged = true;
if (!Thread.interrupted()) {
MDC.put("engineName", engine.getEngineName());
if (engine.isStarted()) {
if (!paused || force) {
if (!running) {
running = true;
synchronized (this) {
ran = true;
long startTime = System.currentTimeMillis();
try {
if (!requiresRegistration
|| (requiresRegistration && engine
.getRegistrationService()
.isRegisteredWithServer())) {
hasNotRegisteredMessageBeenLogged = false;
doJob(force);
} else {
if (!hasNotRegisteredMessageBeenLogged) {
log.warn(
"Did not run the {} job because the engine is not registered.",
getName());
hasNotRegisteredMessageBeenLogged = true;
}
}
} finally {
lastFinishTime = new Date();
long endTime = System.currentTimeMillis();
lastExecutionTimeInMs = endTime - startTime;
totalExecutionTimeInMs += lastExecutionTimeInMs;
if (lastExecutionTimeInMs > Constants.LONG_OPERATION_THRESHOLD) {
engine.getStatisticManager().addJobStats(jobName,
startTime, endTime, 0);
}
numberOfRuns++;
running = false;
}
} finally {
lastFinishTime = new Date();
long endTime = System.currentTimeMillis();
lastExecutionTimeInMs = endTime - startTime;
totalExecutionTimeInMs += lastExecutionTimeInMs;
if (lastExecutionTimeInMs > Constants.LONG_OPERATION_THRESHOLD) {
engine.getStatisticManager().addJobStats(jobName,
startTime, endTime, 0);
}
numberOfRuns++;
running = false;
}
}
}
} else {
log.warn("This thread was interrupted. Not executing the job until the interrupted status has cleared");
}

} else {
log.info("The engine is not currently started.");
}
Expand Down
Expand Up @@ -87,6 +87,7 @@ public synchronized void stopJobs() {
for (IJob job : jobs) {
job.stop();
}
Thread.interrupted();
}

public synchronized void destroy () {
Expand Down

0 comments on commit c45d4a8

Please sign in to comment.