diff --git a/strike-server/src/main/java/strike/service/election/FastBullyElectionManagementService.java b/strike-server/src/main/java/strike/service/election/FastBullyElectionManagementService.java index df96881..36f83f2 100644 --- a/strike-server/src/main/java/strike/service/election/FastBullyElectionManagementService.java +++ b/strike-server/src/main/java/strike/service/election/FastBullyElectionManagementService.java @@ -46,11 +46,35 @@ public void setAnswerReceivedFlag() { public void resetWaitingForCoordinatorMessageTimer(JobExecutionContext context, TriggerKey triggerKey, Long timeout) { try { - Trigger simpleTrigger = TriggerBuilder.newTrigger() - .withIdentity("election_trigger", "group_fast_bully") - .startAt(DateBuilder.futureDate(Math.toIntExact(timeout), DateBuilder.IntervalUnit.SECOND)) - .build(); - context.getScheduler().rescheduleJob(triggerKey, simpleTrigger); + JobDetail jobDetail = context.getJobDetail(); + if (scheduler.checkExists(jobDetail.getKey())) { + + logger.debug(String.format("Job get trigger again [%s]", jobDetail.getKey().getName())); + scheduler.triggerJob(jobDetail.getKey()); + + } else { + + Trigger simpleTrigger = TriggerBuilder.newTrigger() + .withIdentity("election_trigger", "group_fast_bully") + .startAt(DateBuilder.futureDate(Math.toIntExact(timeout), DateBuilder.IntervalUnit.SECOND)) + .build(); + context.getScheduler().rescheduleJob(triggerKey, simpleTrigger); + } + + } catch (ObjectAlreadyExistsException oe) { + logger.debug(oe.getLocalizedMessage()); + + try { + + JobDetail jobDetail = context.getJobDetail(); + logger.debug(String.format("Job get trigger again [%s]", jobDetail.getKey().getName())); + + scheduler.triggerJob(jobDetail.getKey()); + + } catch (SchedulerException e) { + e.printStackTrace(); + } + } catch (SchedulerException e) { e.printStackTrace(); }