org.rhq.enterprise.server.scheduler.jobs
Class RepoSyncJob

java.lang.Object
  extended by org.rhq.enterprise.server.scheduler.jobs.RepoSyncJob
All Implemented Interfaces:
org.quartz.InterruptableJob, org.quartz.Job, org.quartz.StatefulJob

public class RepoSyncJob
extends Object
implements org.quartz.StatefulJob, org.quartz.InterruptableJob

Quartz schedule job that handles synchronizing contents of a repo, including:

Many of the calls out to the plugin are ultimately made from the ContentProviderManager. The methods in this job do not call that directly, but rather go through EJB methods to get there.

This implements StatefulJob (as opposed to Job) because we do not need nor want this job triggered concurrently. That is, we don't need multiple instances of this job running at the same time.

Much of the functionality in this class was migrated from ContentProviderSyncJob.

Author:
Jason Dobies

Field Summary
static String KEY_REPO_NAME
           
 
Constructor Summary
RepoSyncJob()
           
 
Method Summary
static org.quartz.JobDataMap createJobDataMap(org.quartz.JobDetail details, org.rhq.core.domain.content.Repo repo)
          Creates (if necessary) and populates a job details map to contain the necessary data to perform a repo sync.
static String createJobName(org.rhq.core.domain.content.Repo repo)
          Creates a name to use when scheduling a repo sync job.
static String createUniqueJobName(org.rhq.core.domain.content.Repo repo)
          Performs similar to {#createJobName} except adds uniqueness to the name regardless of the parameters.
 void execute(org.quartz.JobExecutionContext context)
          
 void interrupt()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

KEY_REPO_NAME

public static final String KEY_REPO_NAME
See Also:
Constant Field Values
Constructor Detail

RepoSyncJob

public RepoSyncJob()
Method Detail

execute

public void execute(org.quartz.JobExecutionContext context)
             throws org.quartz.JobExecutionException

Specified by:
execute in interface org.quartz.Job
Throws:
org.quartz.JobExecutionException

createJobDataMap

public static org.quartz.JobDataMap createJobDataMap(org.quartz.JobDetail details,
                                                     org.rhq.core.domain.content.Repo repo)
Creates (if necessary) and populates a job details map to contain the necessary data to perform a repo sync. If there is an existing details map in the provided details object, it will be reused, leaving existing data intact.

Parameters:
details - may not be null
repo - may not be null
Returns:
populated map used to drive a repo sync job; this will be the same map as what exists in the JobDetail.getJobDataMap() call of the details object if that call does not return null

createJobName

public static String createJobName(org.rhq.core.domain.content.Repo repo)
Creates a name to use when scheduling a repo sync job. Calling this method multiple times on the same parameters will always produce the same name.

Parameters:
repo - may not be null
Returns:
name to use to schedule the job; will not be null

createUniqueJobName

public static String createUniqueJobName(org.rhq.core.domain.content.Repo repo)
Performs similar to {#createJobName} except adds uniqueness to the name regardless of the parameters. In other words, calling this method multiple times on the same parameters will always (almost, it's based on system time) produce a unique name.

Parameters:
repo - may not be null
Returns:
name to use to schedule the job; will not be null

interrupt

public void interrupt()
               throws org.quartz.UnableToInterruptJobException
Specified by:
interrupt in interface org.quartz.InterruptableJob
Throws:
org.quartz.UnableToInterruptJobException


Copyright © 2008-2012 Red Hat, Inc.. All Rights Reserved.