use of org.quartz.JobExecutionContext in project candlepin by candlepin.
the class RegenEntitlementCertsJobTest method execute.
@Test
public void execute() throws Exception {
// prep
CandlepinPoolManager pm = mock(CandlepinPoolManager.class);
JobExecutionContext jec = mock(JobExecutionContext.class);
OwnerCurator oc = mock(OwnerCurator.class);
JobDetail detail = mock(JobDetail.class);
JobDataMap jdm = mock(JobDataMap.class);
String ownerId = "foo_owner";
String prodId = "bar_prod";
boolean lazyRegen = true;
Owner owner = new Owner(ownerId);
CandlepinQuery cqmock = mock(CandlepinQuery.class);
when(cqmock.list()).thenReturn(Arrays.asList(owner));
when(oc.listAll()).thenReturn(cqmock);
when(jdm.getString(eq(RegenProductEntitlementCertsJob.PROD_ID))).thenReturn(prodId);
when(jdm.getBoolean(eq(RegenProductEntitlementCertsJob.LAZY_REGEN))).thenReturn(lazyRegen);
when(detail.getJobDataMap()).thenReturn(jdm);
when(jec.getJobDetail()).thenReturn(detail);
// test
RegenProductEntitlementCertsJob recj = new RegenProductEntitlementCertsJob(pm, oc);
injector.injectMembers(recj);
recj.execute(jec);
// verification
verify(pm).regenerateCertificatesOf(eq(owner), eq(prodId), eq(lazyRegen));
}
use of org.quartz.JobExecutionContext in project BRFS by zhangnianli.
the class DefaultBaseSchedulers method pauseAllTask.
@Override
public boolean pauseAllTask() {
try {
// 不在正常运行时,不进行任何操作
if (!isNormal()) {
return false;
}
Scheduler scheduler = this.ssf.getScheduler(this.instanceName);
if (!scheduler.isShutdown()) {
// 1.停止触发器
scheduler.pauseAll();
JobKey currentJob;
// 2.中断所有执行的任务
for (JobExecutionContext jobExecut : scheduler.getCurrentlyExecutingJobs()) {
currentJob = jobExecut.getJobDetail().getKey();
scheduler.interrupt(currentJob);
}
}
return true;
} catch (UnableToInterruptJobException e) {
LOG.error("{}", e);
} catch (SchedulerException e) {
LOG.error("{}", e);
}
return false;
}
use of org.quartz.JobExecutionContext in project searchcode-server by boyter.
the class EnqueueFileRepositoryJob method execute.
public void execute(JobExecutionContext context) {
if (this.indexService.shouldPause(IIndexService.JobType.REPO_ADDER)) {
return;
}
try {
Thread.currentThread().setPriority(Thread.MIN_PRIORITY);
UniqueRepoQueue repoQueue = Singleton.getUniqueFileRepoQueue();
// Filter out those queued to be deleted and not file repositories
List<RepoResult> repoResultList = this.helpers.filterRunningAndDeletedRepoJobs(Singleton.getRepo().getAllRepo()).stream().filter(x -> x.getScm().equals(Values.FILE)).collect(Collectors.toList());
this.logger.info(String.format("4f37a297::adding %d file repositories to be indexed", repoResultList.size()));
for (RepoResult rr : repoResultList) {
if (Singleton.getEnqueueFileRepositoryJobFirstRun()) {
rr.getData().jobRunTime = Instant.parse("1800-01-01T00:00:00.000Z");
this.repo.saveRepo(rr);
this.logger.info(String.format("40cd7595::resetting job run time due to firstRun %b repoName %s", Singleton.getEnqueueFileRepositoryJobFirstRun(), rr.getName()));
}
switch(rr.getScm().toLowerCase()) {
case Values.FILE:
this.logger.info(String.format("18310da9::adding to file queue reponame %s", rr.getName()));
repoQueue.add(rr);
break;
default:
break;
}
}
Singleton.setEnqueueFileRepositoryJob(false);
} catch (Exception ex) {
this.logger.severe(String.format("056c9f75::error in class %s exception %s", ex.getClass(), ex.getMessage()));
Singleton.setEnqueueFileRepositoryJob(false);
}
}
use of org.quartz.JobExecutionContext in project searchcode-server by boyter.
the class IndexDocumentsJobTest method testExecute.
public void testExecute() throws JobExecutionException {
JobExecutionContext jobExecutionContext = mock(JobExecutionContext.class);
IndexService indexService = mock(IndexService.class);
StatsService statsService = mock(StatsService.class);
LoggerWrapper loggerWrapper = mock(LoggerWrapper.class);
// IndexDocumentsJob indexDocumentsJob = new IndexDocumentsJob(indexService, statsService, loggerWrapper);
//
// indexDocumentsJob.execute(jobExecutionContext);
}
use of org.quartz.JobExecutionContext in project CzechIdMng by bcvsolutions.
the class DefaultSchedulerManagerUnitTest method testNotRunTaskWithExecuteDate.
@Test
public void testNotRunTaskWithExecuteDate() throws JobExecutionException {
TestSchedulableTask mockTask = new TestSchedulableTask();
JobExecutionContext context = new JobExecutionContext() {
@Override
public void setResult(Object result) {
}
@Override
public void put(Object key, Object value) {
}
@Override
public boolean isRecovering() {
return false;
}
@Override
public Trigger getTrigger() {
return null;
}
@Override
public Scheduler getScheduler() {
return null;
}
@Override
public Date getScheduledFireTime() {
return null;
}
@Override
public Object getResult() {
return null;
}
@Override
public int getRefireCount() {
return 0;
}
@Override
public TriggerKey getRecoveringTriggerKey() throws IllegalStateException {
return null;
}
@Override
public Date getPreviousFireTime() {
return null;
}
@Override
public Date getNextFireTime() {
return null;
}
@Override
public JobDataMap getMergedJobDataMap() {
JobDataMap map = new JobDataMap();
map.put(EntityEvent.EVENT_PROPERTY_EXECUTE_DATE, ZonedDateTime.now().plusHours(1).toString());
//
return map;
}
@Override
public long getJobRunTime() {
return 0;
}
@Override
public Job getJobInstance() {
return null;
}
@Override
public JobDetail getJobDetail() {
return null;
}
@Override
public Date getFireTime() {
return null;
}
@Override
public String getFireInstanceId() {
return null;
}
@Override
public Calendar getCalendar() {
return null;
}
@Override
public Object get(Object key) {
return null;
}
};
// mock task ends silently - execute time is in future
// exception - failure
mockTask.execute(context);
}
Aggregations