use of com.google.cloud.scheduler.v1.Job in project pentaho-platform by pentaho.
the class PentahoBlockoutManager method willBlockSchedules.
@Override
public List<IJobTrigger> willBlockSchedules(IJobTrigger testBlockOutJobTrigger) {
List<IJobTrigger> blockedSchedules = new ArrayList<IJobTrigger>();
List<Job> scheduledJobs = new ArrayList<Job>();
try {
scheduledJobs = this.scheduler.getJobs(new IJobFilter() {
@Override
public boolean accept(Job job) {
return !BLOCK_OUT_JOB_NAME.equals(job.getJobName());
}
});
} catch (SchedulerException e) {
throw new RuntimeException(e);
}
// Loop over trigger group names
for (Job scheduledJob : scheduledJobs) {
// Add schedule to list if block out conflicts at all
if (BlockoutManagerUtil.willBlockSchedule(scheduledJob.getJobTrigger(), testBlockOutJobTrigger, this.scheduler)) {
blockedSchedules.add(scheduledJob.getJobTrigger());
}
}
return blockedSchedules;
}
use of com.google.cloud.scheduler.v1.Job in project pentaho-platform by pentaho.
the class PentahoPlatformExporter method exportSchedules.
protected void exportSchedules() {
log.debug("export schedules");
try {
List<Job> jobs = getScheduler().getJobs(null);
for (Job job : jobs) {
if (job.getJobName().equals(EmbeddedVersionCheckSystemListener.VERSION_CHECK_JOBNAME)) {
// if it doesn't exist and fails if you try to import it due to a null ActionClass
continue;
}
try {
JobScheduleRequest scheduleRequest = ScheduleExportUtil.createJobScheduleRequest(job);
getExportManifest().addSchedule(scheduleRequest);
} catch (IllegalArgumentException e) {
log.warn(e.getMessage(), e);
}
}
} catch (SchedulerException e) {
log.error(Messages.getInstance().getString("PentahoPlatformExporter.ERROR_EXPORTING_JOBS"), e);
}
}
use of com.google.cloud.scheduler.v1.Job in project pentaho-platform by pentaho.
the class QuartzScheduler method getJob.
/**
* {@inheritDoc}
*/
@SuppressWarnings("unchecked")
public Job getJob(String jobId) throws SchedulerException {
try {
Scheduler scheduler = getQuartzScheduler();
QuartzJobKey jobKey = QuartzJobKey.parse(jobId);
String groupName = jobKey.getUserName();
for (Trigger trigger : scheduler.getTriggersOfJob(jobId, groupName)) {
Job job = new Job();
JobDetail jobDetail = scheduler.getJobDetail(jobId, groupName);
if (jobDetail != null) {
JobDataMap jobDataMap = jobDetail.getJobDataMap();
if (jobDataMap != null) {
Map<String, Serializable> wrappedMap = jobDataMap.getWrappedMap();
job.setJobParams(wrappedMap);
}
}
job.setJobId(jobId);
setJobTrigger(scheduler, job, trigger);
job.setUserName(jobDetail.getGroup());
return job;
}
} catch (org.quartz.SchedulerException e) {
throw new SchedulerException(Messages.getInstance().getString("QuartzScheduler.ERROR_0007_FAILED_TO_GET_JOB", jobId), // $NON-NLS-1$
e);
}
return null;
}
use of com.google.cloud.scheduler.v1.Job in project pentaho-platform by pentaho.
the class QuartzScheduler method createJob.
/**
* {@inheritDoc}
*/
public Job createJob(String jobName, Class<? extends IAction> action, Map<String, Serializable> jobParams, IJobTrigger trigger, IBackgroundExecutionStreamProvider outputStreamProvider) throws SchedulerException {
if (action == null) {
// $NON-NLS-1$
throw new SchedulerException(Messages.getInstance().getString("QuartzScheduler.ERROR_0003_ACTION_IS_NULL"));
}
if (jobParams == null) {
jobParams = new HashMap<String, Serializable>();
}
jobParams.put(RESERVEDMAPKEY_ACTIONCLASS, action.getName());
Job ret = createJob(jobName, jobParams, trigger, outputStreamProvider);
ret.setSchedulableClass(action.getName());
return ret;
}
use of com.google.cloud.scheduler.v1.Job in project pentaho-platform by pentaho.
the class QuartzScheduler method getJobs.
/**
* {@inheritDoc}
*/
@SuppressWarnings("unchecked")
public List<Job> getJobs(IJobFilter filter) throws SchedulerException {
ArrayList<Job> jobs = new ArrayList<Job>();
try {
Scheduler scheduler = getQuartzScheduler();
for (String groupName : scheduler.getJobGroupNames()) {
for (String jobId : scheduler.getJobNames(groupName)) {
for (Trigger trigger : scheduler.getTriggersOfJob(jobId, groupName)) {
if ("MANUAL_TRIGGER".equals(trigger.getGroup())) {
continue;
}
Job job = new Job();
job.setGroupName(groupName);
JobDetail jobDetail = scheduler.getJobDetail(jobId, groupName);
if (jobDetail != null) {
job.setUserName(jobDetail.getGroup());
JobDataMap jobDataMap = jobDetail.getJobDataMap();
if (jobDataMap != null) {
Map<String, Serializable> wrappedMap = jobDataMap.getWrappedMap();
job.setJobParams(wrappedMap);
}
}
job.setJobId(jobId);
setJobTrigger(scheduler, job, trigger);
job.setJobName(QuartzJobKey.parse(jobId).getJobName());
setJobNextRun(job, trigger);
job.setLastRun(trigger.getPreviousFireTime());
if ((filter == null) || filter.accept(job)) {
jobs.add(job);
}
}
}
}
} catch (org.quartz.SchedulerException e) {
throw new SchedulerException(Messages.getInstance().getString("QuartzScheduler.ERROR_0004_FAILED_TO_LIST_JOBS"), // $NON-NLS-1$
e);
}
return jobs;
}
Aggregations