本文整理了Java中com.atlassian.scheduler.config.JobConfig
类的一些代码示例,展示了JobConfig
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JobConfig
类的具体详情如下:
包路径:com.atlassian.scheduler.config.JobConfig
类名称:JobConfig
[英]Configuration options available when scheduling a job to be run. This is similar to JobDetails, but provides only the information that is relevant to configuring the job or for the job to reference when it is actually running.
[中]安排要运行的作业时可用的配置选项。这与JobDetails类似,但仅提供与配置作业相关的信息,或作业实际运行时要引用的信息。
代码示例来源:origin: com.atlassian.support/stp
private void scheduleLogScanJob(Schedule schedule)
{
try
{
schedulerService.scheduleJob(JOB_ID, JobConfig.forJobRunnerKey(JOB_RUNNER_KEY)
.withRunMode(RunMode.RUN_ONCE_PER_CLUSTER)
.withSchedule(schedule));
}
catch (SchedulerServiceException e)
{
log.error("Failed to schedule log scan job", e);
}
}
}
代码示例来源:origin: com.atlassian.support/stp
@Nonnull
@Override
public Map
{
return config.getParameters();
}
代码示例来源:origin: com.atlassian.support/stp
@Nonnull
@Override
public RunMode getRunMode()
{
return config.getRunMode();
}
代码示例来源:origin: com.atlassian.jira/jira-core
private static JobConfig getJobConfig(final Long subscriptionId, final Schedule schedule)
{
return JobConfig.forJobRunnerKey(JobRunnerKey.of(JOB_RUNNER_KEY))
.withSchedule(schedule)
.withParameters(ImmutableMap.
}
代码示例来源:origin: com.atlassian.jira/jira-core
@Override
public void triggerPoll(final long directoryID, final SynchronisationMode synchronisationMode)
{
JobConfig cOnfig= JobConfig.forJobRunnerKey(JOB_RUNNER_KEY)
.withRunMode(RUN_ONCE_PER_CLUSTER)
.withSchedule(Schedule.runOnce(null))
.withParameters(ImmutableMap.
try
{
schedulerService.scheduleJobWithGeneratedId(config);
}
catch (SchedulerServiceException e)
{
throw new RuntimeException(e);
}
}
代码示例来源:origin: com.atlassian.applinks/applinks-plugin
@Override
public void onStart() {
scheduler.registerJobRunner(JOB_RUNNER_KEY, this);
try {
scheduler.scheduleJob(JOB_ID, JobConfig.forJobRunnerKey(JOB_RUNNER_KEY)
.withSchedule(getSchedule()));
} catch (final SchedulerServiceException e) {
log.error("Unable to schedule analytics job", e);
}
}
代码示例来源:origin: com.atlassian.scheduler/atlassian-scheduler-quartz1
public Trigger buildTrigger(final JobId jobId, final JobConfig jobConfig)
throws SchedulerServiceException {
final byte[] parameters = parameterMapSerializer.serializeParameters(jobConfig.getParameters());
final Trigger trigger = buildTrigger(jobConfig.getSchedule());
trigger.setGroup(QUARTZ_TRIGGER_GROUP);
trigger.setName(jobId.toString());
trigger.getJobDataMap().put(QUARTZ_PARAMETERS_KEY, parameters);
return trigger;
}
代码示例来源:origin: com.atlassian.scheduler/atlassian-scheduler-quartz1
@Override
public void scheduleJob(final JobId jobId, final JobConfig jobConfig)
throws SchedulerServiceException {
try {
requireNonNull(jobConfig, "jobConfig");
LOG.debug("scheduleJob: {}: {}", jobId, jobConfig);
localJobs.unscheduleJob(jobId);
clusteredJobs.unscheduleJob(jobId);
final Quartz1SchedulerFacade facade = getFacade(jobConfig.getRunMode());
final JobRunnerKey jobRunnerKey = jobConfig.getJobRunnerKey();
final Trigger trigger = triggerFactory.buildTrigger(jobId, jobConfig);
facade.scheduleJob(jobRunnerKey, trigger);
} catch (SchedulerRuntimeException sre) {
throw checked(sre);
}
}
代码示例来源:origin: com.atlassian.scheduler/atlassian-scheduler-core
@Nullable
private JobRunnerResponse validateJobConfig() {
try {
jobCOnfig= JobConfig.forJobRunnerKey(jobDetails.getJobRunnerKey())
.withRunMode(jobDetails.getRunMode())
.withSchedule(jobDetails.getSchedule())
.withParameters(jobDetails.getParameters());
return null;
} catch (SchedulerRuntimeException sre) {
return aborted(jobDetails.toString());
}
}
代码示例来源:origin: com.atlassian.jira/jira-core
@Override
@Nonnull
public Status scheduleDelayedUpgrades(final int delayMins, final boolean isAllowReindex)
{
final Schedule schedule = Schedule.runOnce(DateTime.now().plusMinutes(delayMins).toDate());
JobConfig jobCOnfig= JobConfig.forJobRunnerKey(JOB_RUNNER_KEY)
.withSchedule(schedule)
.withParameters(ImmutableMap.
try
{
schedulerService.scheduleJob(JOB_ID, jobConfig);
}
catch (SchedulerServiceException e)
{
log.error(
"Unable to schedule upgrade tasks for future execution :" + e, e);
final Collection
"Unable to schedule upgrade tasks for future execution: " + e.getMessage() + '\n' + ExceptionUtils.getStackTrace(e));
return new Status(errors);
}
return Status.OK;
}
代码示例来源:origin: com.atlassian.jira/jira-core
/**
* Request a full replication of files in the home directories that are configured for replication.
*/
public void replicateJiraHome() throws SchedulerServiceException
{
JobConfig jobCOnfig= JobConfig.forJobRunnerKey(FULL_REPLICATION_KEY)
.withRunMode(RunMode.RUN_ONCE_PER_CLUSTER)
.withSchedule(Schedule.runOnce(null));
schedulerService.scheduleJob(FULL_REPLICATION_ID, jobConfig);
}
代码示例来源:origin: com.atlassian.jira/jira-core
@Override
public void runNow(final long serviceId) throws Exception
{
JiraServiceContainer jiraServiceCOntainer= getServiceWithId(serviceId);
if (jiraServiceCOntainer== null)
{
throw new ServiceException("Service with id '" + serviceId + "' was not found");
}
JobConfig cOnfig= JobConfig.forJobRunnerKey(SERVICE_JOB_KEY)
.withSchedule(Schedule.runOnce(null))
.withRunMode(RunMode.RUN_ONCE_PER_CLUSTER)
.withParameters(ImmutableMap.
JobId jobId = schedulerService.scheduleJobWithGeneratedId(config);
LOG.debug("JIRA Service '" + jiraServiceContainer.getName() + "' scheduled for immediate execution with job id '" + jobId + '\'');
}
代码示例来源:origin: com.atlassian.jira/jira-core
private boolean isReindexAllowed(final JobRunnerRequest jobRunnerRequest)
{
Boolean isReindexAllowed = (Boolean) jobRunnerRequest.getJobConfig().getParameters().get(REINDEX_ALLOWED_PROPERTY);
// If no parameter is found we assume reindex is allowed.
return isReindexAllowed == null ? true : isReindexAllowed;
}
代码示例来源:origin: com.atlassian.refapp/atlassian-refapp-scheduler-demo-plugin
private StreamsEntryRequest createStreamsEntryRequest(JobRunnerRequest request) {
final DateTime startTime = new DateTime(request.getStartTime());
final SimpleDateFormat dateFormatter = new SimpleDateFormat(DATE_PATTERN);
return new StreamsEntryRequest()
.id(startTime.hashCode())
.title("triggered as per " + request.getJobConfig().getRunMode() + " job, at " + dateFormatter.format(request.getStartTime()))
.postedDate(startTime.plusMinutes(2))
.type(ActivityObjectTypes.article())
.verb(ActivityVerbs.post())
.user("Scheduler");
}
}
代码示例来源:origin: com.atlassian.bitbucket.server.plugin/source-annotation-support
@Override
public void afterPropertiesSet() throws Exception {
schedulerService.registerJobRunner(CLEANUP_JOB_RUNNER_KEY, newCleanupTask());
// schedule the cleanup job once a day starting in a day
schedulerService.scheduleJob(CLEANUP_JOB_ID, JobConfig.forJobRunnerKey(CLEANUP_JOB_RUNNER_KEY)
.withSchedule(Schedule.forInterval(TimeUnit.DAYS.toMillis(1), DateTime.now().plusDays(1).toDate()))
.withRunMode(RunMode.RUN_LOCALLY)); // cache dir is local to every application node
}
代码示例来源:origin: com.atlassian.jira/jira-core
private void scheduleCronJob(final JiraServiceContainer jiraServiceContainer) throws SchedulerServiceException
{
final boolean localService = jiraServiceContainer.isLocalService();
JobConfig cOnfig= JobConfig.forJobRunnerKey(SERVICE_JOB_KEY)
.withSchedule(Schedule.forCronExpression(jiraServiceContainer.getCronExpression()))
.withRunMode(localService ? RunMode.RUN_LOCALLY : RunMode.RUN_ONCE_PER_CLUSTER)
.withParameters(ImmutableMap.
schedulerService.scheduleJob(toJobId(jiraServiceContainer.getId()), config);
}
代码示例来源:origin: com.atlassian.jira/jira-core
@Nullable
@Override
public JobRunnerResponse runJob(final JobRunnerRequest jobRunnerRequest)
{
// Get the job class to actually run
final Map
final Long serviceId = (Long) parameters.get(ServiceManager.SERVICE_ID_KEY);
if (serviceId == null)
{
return JobRunnerResponse.failed("Service entry with job ID '" + jobRunnerRequest.getJobId() + "' has no job config parameters");
}
return runServiceId(serviceId);
}
代码示例来源:origin: com.atlassian.jira/jira-core
private void queueDelayedEvent(final JiraHomeChangeEvent event)
{
delayedFileReplicationQueue.add(event);
JobConfig jobCOnfig= JobConfig.forJobRunnerKey(DELAYED_REPLICATION_KEY)
.withRunMode(RunMode.RUN_LOCALLY)
.withSchedule(Schedule.runOnce(DateTime.now().plusSeconds(IDLE_SECONDS).toDate()));
try
{
schedulerService.scheduleJob(DELAYED_REPLICATION_ID, jobConfig);
}
catch (SchedulerServiceException e)
{
log.error("Failed to schedule delayed replication", e);
}
}
代码示例来源:origin: com.atlassian.jira/jira-core
@Override
public void addPoller(final DirectoryPoller poller) throws DirectoryMonitorRegistrationException
{
final Date OneMinuteFromNow= new DateTime().plusMinutes(1).toDate();
final JobConfig cOnfig= JobConfig.forJobRunnerKey(JOB_RUNNER_KEY)
.withRunMode(RUN_ONCE_PER_CLUSTER)
.withSchedule(Schedule.forInterval(poller.getPollingInterval() * 1000, oneMinuteFromNow))
.withParameters(ImmutableMap.
try
{
schedulerService.scheduleJob(getJobId(poller), config);
}
catch (SchedulerServiceException e)
{
throw new DirectoryMonitorRegistrationException(e);
}
}
代码示例来源:origin: com.atlassian.plugin.automation/jira-automation-spi
@SuppressWarnings("unchecked")
@Nullable
@Override
public JobRunnerResponse runJob(final JobRunnerRequest request)
{
final Map
try
{
final Class extends PluginJob> jobClass = (Class extends PluginJob>) classLoader.loadClass((String) params.get(JOB_CLASS_CANONICAL_NAME));
jobClass.newInstance().execute(jobDataMap);
return JobRunnerResponse.success();
}
catch (Exception e)
{
log.error(String.format("Unable to execute the job [id:%s]", request.getJobId().toString()), e);
return JobRunnerResponse.failed(e);
}
}
}